ROS编译出现一系列错误
/home/forklift/catkin_ws/src/car_uav/include/car_uav/test_kalman.h:55:38: error: ‘Imu’ in namespace ‘sensor_msgs’ does not name a type
void imu_callback(const sensor_msgs::Imu::ConstPtr& msg);
^~~
/home/forklift/catkin_ws/src/car_uav/include/car_uav/test_kalman.h:55:51: error: expected unqualified-id before ‘&’ token
void imu_callback(const sensor_msgs::Imu::ConstPtr& msg);
^
/home/forklift/catkin_ws/src/car_uav/include/car_uav/test_kalman.h:55:51: error: expected ‘)’ before ‘&’ token
/home/forklift/catkin_ws/src/car_uav/include/car_uav/test_kalman.h:55:53: error: expected initializer before ‘msg’
void imu_callback(const sensor_msgs::Imu::ConstPtr& msg);
^~~
/home/forklift/catkin_ws/src/car_uav/include/car_uav/test_kalman.h:57:45: error: ‘Vector3’ in namespace ‘geometry_msgs’ does not name a type
void velocity_callback(const geometry_msgs::Vector3::ConstPtr& msg);
^~~~~~~
/home/forklift/catkin_ws/src/car_uav/include/car_uav/test_kalman.h:57:62: error: expected unqualified-id before ‘&’ token
void velocity_callback(const geometry_msgs::Vector3::ConstPtr& msg);
^
/home/forklift/catkin_ws/src/car_uav/include/car_uav/test_kalman.h:57:62: error: expected ‘)’ before ‘&’ token
/home/forklift/catkin_ws/src/car_uav/include/car_uav/test_kalman.h:57:64: error: expected initializer before ‘msg’
void velocity_callback(const geometry_msgs::Vector3::ConstPtr& msg);
错误原因,未包含对应的头文件,此处 sensor_msgs::Imu
和 geometry_msgs::Vector3
有问题,添加头文件
#include <geometry_msgs/Vector3.h>
#include <sensor_msgs/Imu.h>
解决问题