一 python 通过ros调用C++
1.python 中
rospy.init_node('realsense_data_publish', anonymous=True) # 节点初始化 ,节点名称
pub = rospy.Publisher('realsense_data', String, queue_size=1) # 创建publisher,subscriber需订阅的名称,发布的数据类型
hello_str = "hello world,hello lyy"
pub.publish(hello_str) # 发布节点信息
2.关于C++
1)在catkin_ws工作空间中创建功能包
catkin_create_pkg my_pcl_tutorial pcl_conversions pcl_ros roscpp sensor_msgs
2)修改 package.xml 添加
<build_depend>libpcl-all-dev</build_depend>
<exec_depend>libpcl-all</exec_depend>
3)在src中创建.cpp并编写代码,比如订阅python中发布的话题的程序如下:
#include <ros/ros.h>
// PCL specific includes
#include <sensor_msgs/PointCloud2.h>
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_