Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tutorial_ros_pub_sub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CeTI
ROS
CeTI Summer School
tutorial_ros_pub_sub
Commits
3b720a26
Commit
3b720a26
authored
4 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
add some comments
parent
39b114c6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/listener.cpp
+8
-2
8 additions, 2 deletions
src/listener.cpp
src/talker.cpp
+12
-0
12 additions, 0 deletions
src/talker.cpp
with
20 additions
and
2 deletions
src/listener.cpp
+
8
−
2
View file @
3b720a26
...
...
@@ -4,6 +4,11 @@
/**
* This tutorial demonstrates simple receipt of messages over the ROS system.
*/
/**
* This callback function is called when a message on the topic "chatter" is received
* @param msg The received message
*/
void
chatterCallback
(
const
std_msgs
::
String
::
ConstPtr
&
msg
)
{
ROS_INFO
(
"I heard: [%s]"
,
msg
->
data
.
c_str
());
...
...
@@ -26,7 +31,8 @@ int main(int argc, char **argv)
/**
* NodeHandle is the main access point to communications with the ROS system.
* The first NodeHandle constructed will fully initialize this node, and the last
* NodeHandle destructed will close down the node.
* NodeHandle destructed will close down the node. The NodeHandle can be initialized
* with a namespace, which is relevant for the parameter server.
*/
ros
::
NodeHandle
n
;
...
...
@@ -50,7 +56,7 @@ int main(int argc, char **argv)
/**
* ros::spin() will enter a loop, pumping callbacks. With this version, all
* callbacks will be called from within this thread (the main one). ros::spin()
* will exit when Ctrl-C is pressed, or the node is shutdown by the master.
* will exit when Ctrl-C is pressed, or the node is shut
down by the master.
*/
ros
::
spin
();
...
...
This diff is collapsed.
Click to expand it.
src/talker.cpp
+
12
−
0
View file @
3b720a26
...
...
@@ -53,6 +53,10 @@ int main(int argc, char **argv)
* a unique string for each message.
*/
int
count
=
0
;
/**
* The main loop runs until the ros core is shutting down.
*/
while
(
ros
::
ok
())
{
/**
...
...
@@ -74,9 +78,17 @@ int main(int argc, char **argv)
*/
chatter_pub
.
publish
(
msg
);
/**
* The spinOnce() method processes callbacks.
*/
ros
::
spinOnce
();
/**
* To prevent too many messages being sent and busy waiting, we sleep for some time here (the rate is 10hz,
* so we sleep for 100ms).
*/
loop_rate
.
sleep
();
++
count
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment