ROS中编译自定义消息出现如下错误
Following error occured when compiling custom message in ROS
我正在学习有关如何创建 ROS 自定义消息的 "WS Newman's" 教程。编译时出现如下错误"The dependencies of the message/service 'example_msg/Num' have changed. Please rerun cmake"
Num.msg 有
Header header
int32 demo_int
float64 demo_double
Cmakelists.txt
project(example_msg)
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
message_generation
)
add_message_files(
FILES
Num.msg
# Message2.msg
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package(
CATKIN_DEPENDS message_runtime
)
include_directories(
include ${catkin_INCLUDE_DIRS}
# include
${catkin_INCLUDE_DIRS}
)
add_executable(example_ros_message_publisher
src/example_ros_message_publisher.cpp
)
add_dependencies(example_ros_message_publisher ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(example_ros_message_publisher
${catkin_LIBRARIES}
)
package.xml
<package format="2">
<name>example_msg</name>
<version>0.0.0</version>
<description>The example_msg package</description>
<maintainer email="asiri@todo.todo">asiri</maintainer>
<license>TODO</license>
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>std_msgs</exec_depend>
<export>
</export>
</package>
example_ros_message_publisher.cpp
#include <ros/ros.h>
#include <example_msg/Num.h>
#include <math.h>
int main(int argc, char **argv) {
ros::init(argc, argv, "example_ros_message_publisher"); // name of this node
ros::NodeHandle n; // two lines to create a publisher object that can talk to ROS
ros::Publisher my_publisher_object = n.advertise<example_msg::Num>("example_topic", 1);
//"example_topic" is the name of the topic to which we will publish
// the "1" argument says to use a buffer size of 1; could make larger, if expect network backups
example_msg::Num my_new_message;
//create a variable of type "example_msg",
// as defined in this package
ros::Rate naptime(1.0); //create a ros object from the ros “Rate” class;
//set the sleep timer for 1Hz repetition rate (arg is in units of Hz)
// put some data in the header. Do: rosmsg show std_msgs/Header
// to see the definition of "Header" in std_msgs
my_new_message.header.stamp = ros::Time::now(); //set the time stamp in the header;
my_new_message.header.seq=0; // call this sequence number zero
my_new_message.header.frame_id = "base_frame"; // would want to put true reference frame name here, if needed for coord transforms
my_new_message.demo_int= 1;
my_new_message.demo_double=100.0;
double sqrt_arg;
// do work here in infinite loop (desired for this example), but terminate if detect ROS has faulted
while (ros::ok())
{
my_new_message.header.seq++; //increment the sequence counter
my_new_message.header.stamp = ros::Time::now(); //update the time stamp
my_new_message.demo_int*=2.0; //double the integer in this field
sqrt_arg = my_new_message.demo_double;
my_new_message.demo_double = sqrt(sqrt_arg);
my_publisher_object.publish(my_new_message); // publish the data in new message format on topic "example_topic"
//the next line will cause the loop to sleep for the balance of the desired period
// to achieve the specified loop frequency
naptime.sleep();
}
}
当我运行 catkin_make 安装出现以下错误。
"The dependencies of the message/service 'example_msg/Num' have changed. Please rerun cmake."
柳絮中的错误。
要触发更深层次的重建,您可以触摸包含 example_msg/Num
.
的软件包的 CMakeLists.txt
文件
我正在学习有关如何创建 ROS 自定义消息的 "WS Newman's" 教程。编译时出现如下错误"The dependencies of the message/service 'example_msg/Num' have changed. Please rerun cmake"
Num.msg 有
Header header
int32 demo_int
float64 demo_double
Cmakelists.txt
project(example_msg)
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
message_generation
)
add_message_files(
FILES
Num.msg
# Message2.msg
)
generate_messages(
DEPENDENCIES
std_msgs
)
catkin_package(
CATKIN_DEPENDS message_runtime
)
include_directories(
include ${catkin_INCLUDE_DIRS}
# include
${catkin_INCLUDE_DIRS}
)
add_executable(example_ros_message_publisher
src/example_ros_message_publisher.cpp
)
add_dependencies(example_ros_message_publisher ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(example_ros_message_publisher
${catkin_LIBRARIES}
)
package.xml
<package format="2">
<name>example_msg</name>
<version>0.0.0</version>
<description>The example_msg package</description>
<maintainer email="asiri@todo.todo">asiri</maintainer>
<license>TODO</license>
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>std_msgs</exec_depend>
<export>
</export>
</package>
example_ros_message_publisher.cpp
#include <ros/ros.h>
#include <example_msg/Num.h>
#include <math.h>
int main(int argc, char **argv) {
ros::init(argc, argv, "example_ros_message_publisher"); // name of this node
ros::NodeHandle n; // two lines to create a publisher object that can talk to ROS
ros::Publisher my_publisher_object = n.advertise<example_msg::Num>("example_topic", 1);
//"example_topic" is the name of the topic to which we will publish
// the "1" argument says to use a buffer size of 1; could make larger, if expect network backups
example_msg::Num my_new_message;
//create a variable of type "example_msg",
// as defined in this package
ros::Rate naptime(1.0); //create a ros object from the ros “Rate” class;
//set the sleep timer for 1Hz repetition rate (arg is in units of Hz)
// put some data in the header. Do: rosmsg show std_msgs/Header
// to see the definition of "Header" in std_msgs
my_new_message.header.stamp = ros::Time::now(); //set the time stamp in the header;
my_new_message.header.seq=0; // call this sequence number zero
my_new_message.header.frame_id = "base_frame"; // would want to put true reference frame name here, if needed for coord transforms
my_new_message.demo_int= 1;
my_new_message.demo_double=100.0;
double sqrt_arg;
// do work here in infinite loop (desired for this example), but terminate if detect ROS has faulted
while (ros::ok())
{
my_new_message.header.seq++; //increment the sequence counter
my_new_message.header.stamp = ros::Time::now(); //update the time stamp
my_new_message.demo_int*=2.0; //double the integer in this field
sqrt_arg = my_new_message.demo_double;
my_new_message.demo_double = sqrt(sqrt_arg);
my_publisher_object.publish(my_new_message); // publish the data in new message format on topic "example_topic"
//the next line will cause the loop to sleep for the balance of the desired period
// to achieve the specified loop frequency
naptime.sleep();
}
}
当我运行 catkin_make 安装出现以下错误。 "The dependencies of the message/service 'example_msg/Num' have changed. Please rerun cmake."
柳絮中的错误。
要触发更深层次的重建,您可以触摸包含 example_msg/Num
.
CMakeLists.txt
文件