gpt4 book ai didi

ros - 在ROS中编译自定义消息时出现以下错误

转载 作者:行者123 更新时间:2023-12-04 01:42:36 25 4
gpt4 key购买 nike

我正在关注有关如何创建 ROS 自定义消息的“WS Newman”教程。编译时出现以下错误“消息/服务'example_msg/Num'的依赖关系已更改。请重新运行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}
)

包.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 install 时出现以下错误。
“消息/服务'example_msg/Num'的依赖关系已经改变。请重新运行cmake。”

最佳答案

柳絮中的一个错误。
要触发更深层次的重建,您可以触摸 CMakeLists.txt包含您的 example_msg/Num 的包的文件.

关于ros - 在ROS中编译自定义消息时出现以下错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56769404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com