/opt/ros/kinetic/include/ros/message_traits.h:255:102: required from ‘const char* ros::message_traits::md5sum(const M&) [with M = float]’
/opt/ros/kinetic/include/ros/publisher.h:112:7: required from ‘void ros::Publisher::publish(const M&) const [with M = float]’
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:292:53: required from here
/opt/ros/kinetic/include/ros/message_traits.h:126:34: error: request for member ‘__getMD5Sum’ in ‘m’, which is of non-class type ‘const float’
return m.__getMD5Sum().c_str();
^
/opt/ros/kinetic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::DataType<M>::value(const M&) [with M = float]’:
/opt/ros/kinetic/include/ros/message_traits.h:264:104: required from ‘const char* ros::message_traits::datatype(const M&) [with M = float]’
/opt/ros/kinetic/include/ros/publisher.h:112:7: required from ‘void ros::Publisher::publish(const M&) const [with M = float]’
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:292:53: required from here
/opt/ros/kinetic/include/ros/message_traits.h:143:36: error: request for member ‘__getDataType’ in ‘m’, which is of non-class type ‘const float’
return m.__getDataType().c_str();
^
Navigation-master/CMakeFiles/DW_local_planner.dir/build.make:62: recipe for target 'Navigation-master/CMakeFiles/DW_local_planner.dir/src/DW_local_planner.cpp.o' failed
make[2]: *** [Navigation-master/CMakeFiles/DW_local_planner.dir/src/DW_local_planner.cpp.o] Error 1
CMakeFiles/Makefile2:5028: recipe for target 'Navigation-master/CMakeFiles/DW_local_planner.dir/all' failed
make[1]: *** [Navigation-master/CMakeFiles/DW_local_planner.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
/opt/ros/kinetic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::MD5Sum<M>::value(const M&) [with M = float]’:
/opt/ros/kinetic/include/ros/message_traits.h:255:102: required from ‘const char* ros::message_traits::md5sum(const M&) [with M = float]’
/opt/ros/kinetic/include/ros/publisher.h:112:7: required from ‘void ros::Publisher::publish(const M&) const [with M = float]’
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:293:53: required from here
/opt/ros/kinetic/include/ros/message_traits.h:126:34: error: request for member ‘__getMD5Sum’ in ‘m’, which is of non-class type ‘const float’
return m.__getMD5Sum().c_str();
^
/opt/ros/kinetic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::DataType<M>::value(const M&) [with M = float]’:
/opt/ros/kinetic/include/ros/message_traits.h:264:104: required from ‘const char* ros::message_traits::datatype(const M&) [with M = float]’
/opt/ros/kinetic/include/ros/publisher.h:112:7: required from ‘void ros::Publisher::publish(const M&) const [with M = float]’
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:293:53: required from here
/opt/ros/kinetic/include/ros/message_traits.h:143:36: error: request for member ‘__getDataType’ in ‘m’, which is of non-class type ‘const float’
return m.__getDataType().c_str();
^
Navigation-master/CMakeFiles/DW_local_planner.dir/build.make:62: recipe for target 'Navigation-master/CMakeFiles/DW_local_planner.dir/src/DW_local_planner.cpp.o' failed
make[2]: *** [Navigation-master/CMakeFiles/DW_local_planner.dir/src/DW_local_planner.cpp.o] Error 1
CMakeFiles/Makefile2:5028: recipe for target 'Navigation-master/CMakeFiles/DW_local_planner.dir/all' failed
make[1]: *** [Navigation-master/CMakeFiles/DW_local_planner.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp: In member function ‘virtual void DW_local_planner::DWaPlannerROS::initialize(std::__cxx11::string, tf::TransformListener*, costmap_2d::Costmap2DROS*)’:
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:55:35: error: ‘Float64’ is not a member of ‘std_msgs’
onepath_distance=nh.advertise<std_msgs::Float64>("onepath_dist", 10)
^
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:55:35: error: ‘Float64’ is not a member of ‘std_msgs’
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:55:72: error: no matching function for call to ‘ros::NodeHandle::advertise(const char [13], int)’
onepath_distance=nh.advertise<std_msgs::Float64>("onepath_dist", 10);
^
In file included from /opt/ros/kinetic/include/ros/ros.h:45:0,
from /home/zhy/nav_test/src/Navigation-master/include/DW_local_planner/DW_local_planner.h:10,
from /home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:1:
/opt/ros/kinetic/include/ros/node_handle.h:249:15: note: candidate: template<class M> ros::Publisher ros::NodeHandle::advertise(const string&, uint32_t, bool)
Publisher advertise(const std::string& topic, uint32_t queue_size, b
^
/opt/ros/kinetic/include/ros/node_handle.h:249:15: note: template argument deduction/substitution failed:
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:55:72: error: template argument 1 is invalid
onepath_distance=nh.advertise<std_msgs::Float64>("onepath_dist", 10);
^
In file included from /opt/ros/kinetic/include/ros/ros.h:45:0,
from /home/zhy/nav_test/src/Navigation-master/include/DW_local_planner/DW_local_planner.h:10,
from /home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:1:
/opt/ros/kinetic/include/ros/node_handle.h:315:13: note: candidate: template<class M> ros::Publisher ros::NodeHandle::advertise(const string&, uint32_t, const SubscriberStatusCallback&, const SubscriberStatusCallback&, const VoidConstPtr&, bool)
Publisher advertise(const std::string& topic, uint32_t queue_size,
^
/opt/ros/kinetic/include/ros/node_handle.h:315:13: note: template argument deduction/substitution failed:
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:55:72: error: template argument 1 is invalid
onepath_distance=nh.advertise<std_msgs::Float64>("onepath_dist", 10);
^
In file included from /opt/ros/kinetic/include/ros/serialization.h:37:0,
from /opt/ros/kinetic/include/ros/publisher.h:34,
from /opt/ros/kinetic/include/ros/node_handle.h:32,
from /opt/ros/kinetic/include/ros/ros.h:45,
from /home/zhy/nav_test/src/Navigation-master/include/DW_local_planner/DW_local_planner.h:10,
from /home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:1:
/opt/ros/kinetic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::MD5Sum<M>::value(const M&) [with M = float]’:
/opt/ros/kinetic/include/ros/message_traits.h:255:102: required from ‘const char* ros::message_traits::md5sum(const M&) [with M = float]’
/opt/ros/kinetic/include/ros/publisher.h:112:7: required from ‘void ros::Publisher::publish(const M&) const [with M = float]’
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:297:52: required from here
/opt/ros/kinetic/include/ros/message_traits.h:126:34: error: request for member ‘__getMD5Sum’ in ‘m’, which is of non-class type ‘const float’
return m.__getMD5Sum().c_str();
^
/opt/ros/kinetic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::DataType<M>::value(const M&) [with M = float]’:
/opt/ros/kinetic/include/ros/message_traits.h:264:104: required from ‘const char* ros::message_traits::datatype(const M&) [with M = float]’
/opt/ros/kinetic/include/ros/publisher.h:112:7: required from ‘void ros::Publisher::publish(const M&) const [with M = float]’
/home/zhy/nav_test/src/Navigation-master/src/DW_local_planner.cpp:297:52: required from here
/opt/ros/kinetic/include/ros/message_traits.h:143:36: error: request for member ‘__getDataType’ in ‘m’, which is of non-class type ‘const float’
return m.__getDataType().c_str();
^
Navigation-master/CMakeFiles/DW_local_planner.dir/build.make:62: recipe for target 'Navigation-master/CMakeFiles/DW_local_planner.dir/src/DW_local_planner.cpp.o' failed
make[2]: *** [Navigation-master/CMakeFiles/DW_local_planner.dir/src/DW_local_planner.cpp.o] Error 1
CMakeFiles/Makefile2:5028: recipe for target 'Navigation-master/CMakeFiles/DW_local_planner.dir/all' failed
make[1]: *** [Navigation-master/CMakeFiles/DW_local_planner.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
报错说是ros/message_traits.h:里面报错,就是消息的发送与接受那一部分有问题。
- 先检查是否缺少话题所需要的头文件。缺少头文件也会报这样的错误。
- 检查在初始化阶段的话题名称与程序里写的发布/接受的名称是否一致
- 检查数据类型是否正确,我的就是里面的数据不对,我把c++的消息类型与ros的数据类型写混了。
解决方法:
(1)在程序里直接就用ros的数据类型,不用c++的数据类型。
(2)在发布话题的数据a之前,把程序里面的c++数据类型转换成ros里面的数据类型。
example(1):
std_msgs::Float64 a,b;
a=1.1111;
b=2.2222;
c=a+b;
std_msgs::Float64 c;
c.data=a;
pub.publish(c);
example(2):
float a,b,d;
a=1.1111;
b=2.2222;
d=a+b;
std_msgs::Float64 c;
c.data=d;
pub.publish(c);
基本上就是类似的查找错误步骤。下面两个错误是我修改上面的错误的过程中的一些报错。主要还是数据不匹配的问题,不是啥大问题,有思路查找起来应该不是很麻烦。找出来发现小丑竟是我自己~………………