目录
安装vscode Linux版本
安装vscode插件
配置头文件路径
订阅PX4中imu数据
参考:
ROS基本操作 ROS中订阅节点消息测试 ROS下如何订阅任意话题_步步清风皆是你的博客-CSDN博客
安装vscode Linux版本
https://code.visualstudio.com/
安装vscode插件
配置头文件路径
"/opt/ros/melodic/include/",
"/usr/include/",
"/usr/arm-linux-gnueabihf/include/"
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/opt/ros/melodic/include/",
"/usr/include/",
"/usr/arm-linux-gnueabihf/include/"
],
"defines": [],
"compilerPath": "/opt/gcc-arm-none-eabi-9-2020-q2-update/bin/arm-none-eabi-gcc",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-arm"
}
],
"version": 4
}
订阅PX4中imu数据
rosmsg show sensor_msgs/Imu
#打印
std_msgs/Header header
uint32 seq
time stamp
string frame_id
geometry_msgs/Quaternion orientation
float64 x
float64 y
float64 z
float64 w
float64[9] orientation_covariance
geometry_msgs/Vector3 angular_velocity
float64 x
float64 y
float64 z
float64[9] angular_velocity_covariance
geometry_msgs/Vector3 linear_acceleration
float64 x
float64 y
float64 z
float64[9] linear_acceleration_covariance
可以看到sensor_msgs/Imu下四个组成员:std_msgs/Header、geometry_msgs/Quaternion、geometry_msgs/Vector3、geometry_msgs/Vector3。对其访问方式。
void chatter_imu(const sensor_msgs::ImuConstPtr &msg){
float x,y,z;
/*
两种访问方式*/
//geometry_msgs::Vector3 gv;
//gv = msg->angular_velocity;
x = msg->angular_velocity.x;
y = msg->angular_velocity.y;
z = msg->angular_velocity.z;
// x = gv.x;
// y = gv.y;
// z = gv.z;
ROS_INFO("I heard chatter_imu x:[%f] y:[%f] z:[%f]",x, y, z);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)