A simple tutorial for the standard ROS cpp publisher and subscriber setup
- Create a catkin workspace
- Clone the repository using
git clone https://github.com/Abhishek-Nalawade/beginner_tutorials
- Go in catkin workspace directory and type
catkin_make clean && catkin_make
source devel/setup.bash
roslaunch roslaunch beginner_tutorials tutorial.launch arg1:=1
- Or for default argument use
roslaunch roslaunch beginner_tutorials tutorial.launch
- You can also run the publisher and subcriber nodes separately using two terminals
a)rosrun beginner_tutorials publisher
b)rosrun beginner_tutorials subscriber
To change the output string that is being published
Open a new terminal and navigate to catkin_ws
source devel/setup.bash
rosservice call /change_base_output_string "New string "
cd catkin_ws
source devel/setup.bash
rosrun tf tf_echo /world /talk
rosrun tf view_frames
evince frames.pdf
rosrun rqt_tf_tree rqt_tf_tree
To run the tests
cd catkin_ws
source devel/setup.bash
catkin_make run_tests_beginner_tutorials
The rosbag recording is disabled by default.
To generate a new rosbag file type
roslaunch beginner_tutorials tutorial.launch rosbagEnable:=true
A bag file will be saved in Results directory. To play the ROS bag file, terminate the talker and listener nodes, and type the following in a new terminal.
rosrun beginner_tutorials subscriber
Open new terminal, and navigate to Results directory.
cd cakin_ws/src/beginner_tutorials/Results rosbag play bag.bag
Inspecting the bag
To inspect a recorded bag file: cd into the resutls directory where rosbags are stored and type
rosbag info bag.bag
- Ubuntu 18.04
- ROS Melodic
- roscpp
- std_msgs
- message_generation