Please enable JavaScript.
Coggle requires JavaScript to display documents.
ROS Tutorials 1.11~ (1.12 Writing a Simple Publisher and Subscriber…
ROS Tutorials
1.11~
1.11
Writing a Simple Publisher and Subscriber (C++)
1.11.1
Writing the Publisher Node
1.11.1.1
The Code
$mkdir -p src
creat 「 talker.cpp 」 files in /src
Copy node code:
https://raw.githubusercontent.com/ros/ros_tutorials/kinetic-devel/roscpp_tutorials/talker/talker.cpp
1.12
Writing a Simple Publisher and Subscriber (python)
1.12.1
Writing the Publisher Node
$ roscd beginner_tutorials
1.12.1.1
$ mkdir scripts
$ cd scripts
$ wget
https://raw.github.com/ros/ros_tutorials/kinetic-devel/rospy_tutorials/001_talker_listener/talker.py
$ chmod +x talker.py
1.12.1.2
The Code Explained
~ #!/usr/bin/env python
Every Python ROS Node will have this declaration at the top. The first line makes sure your script is executed as a Python script.
rospy.Publisher('topic_name', std_msgs.msg.String, queue_size)
網址:
http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers
rospy.init_node('my_node_name', anonymous=True)
網址:
http://wiki.ros.org/rospy/Overview/Initialization%20and%20Shutdown
anonymous?
http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%29
1.12.2
Writing the Subscriber Node
1.12.2.1
The Code
$ roscd beginner_tutorials/scripts/
$ wget
https://raw.github.com/ros/ros_tutorials/kinetic-devel/rospy_tutorials/001_talker_listener/listener.py
$ chmod +x listener.py
1.12.2.2
The code explaine
1.12.3
Building your nodes
$ cd ~/catkin_ws
$ catkin_make
1.13
Examining the Simple Publisher and Subscriber
http://wiki.ros.org/ROS/Tutorials/ExaminingPublisherSubscriber
1.13.1
Running the Publisher
$ roscore
$ cd ~/catkin_ws
$ source ./devel/setup.bash
$ rosrun beginner_tutorials talker (C++)
$ rosrun beginner_tutorials talker.py (Python)
1.13.2
Running the Subscriber
$ rosrun beginner_tutorials listener (C++)
$ rosrun beginner_tutorials listener.py (Python)