Implement Publisher
1. code part
(1) python
1 | #!/usr/bin/env python3 |
(2) C++
1 | /*********************************************************************** |
2. set up env
(1) python
- create a folder under your
<package>named scripts, it is because distinguish between python and c++ - go to the terminal
1 | roscore |
1 | rosrun turtlesim turtlesim_node # another terminal |
1 | rosrun learning_topic velocity_publisher.py |
we can see the turtle move
(2) C++
put the c code in the
<package>/srcfoldergo to the
CMakeLists.txtfile, add these two command here1
2add_executable(velocity_publisher src/velocity_publisher.cpp)
target_link_libraries(velocity_publisher ${catkin_LIBRARIES})
go to the workspace root folder and open terminal here
compile the c++ file
1
catkin_make
if can see
0%to100%means successthen go to the terminal
1
roscore
1
rosrun turtlesim turtlesim_node # another terminal
1
rosrun learning_topic velocity_publisher