ROS Publisher c++ 与 Python 实现

ROS Publisher c++ 与 Python 实现

C++

创建完工作空间后
在这里插入图片描述
在这里插入图片描述功能包根据需要什么创建(rospy geometry_msgs )
把C++文件放到src
catkin_make

创建包/src/包名/Cmakelist.txt

add_executable(velocity_publisher src/velocity_publisher.cpp)//文件velocity_publisher 为rosrun 后的指令
target_link_libraries(velocity_publisher ${catkin_LIBRARIES})//依赖
#######
#install#
#######
回到catkin_ws catkin_make
最后 source devel/setup.bash
运行 rosrun 包名 velocity_publisher(cpp名)

Python

在源文件(catkin_ws)内创建scripts,把 .py 文件放到里面
直接在终端里打开scripts 运行 python --.py(py文件)

发布了35 篇原创文章 · 获赞 2 · 访问量 925

猜你喜欢

转载自blog.csdn.net/hk2121/article/details/102669079