当我在catkin_ws目录中运行catkin_make命令时会出现此错误。我认为off_node.ccp文件中存在问题,因为第一个错误出现与cpp文件有关并导致更多错误消息,我无法调试。我在错误信息下面添加了off_node.ccp程序。
Base path: /home/yograj/catkin_ws
Source space: /home/yograj/catkin_ws/src
Build space: /home/yograj/catkin_ws/build
Devel space: /home/yograj/catkin_ws/devel
Install space: /home/yograj/catkin_ws/install
Error(s) in /home/yograj/catkin_ws/src/px4_mavros/package.xml:
- The manifest (with format version 2) must not contain the following tags: run_depend
yograj@yograj-Inspiron-5537:~/catkin_ws$ catkin_make
Base path: /home/yograj/catkin_ws
Source space: /home/yograj/catkin_ws/src
Build space: /home/yograj/catkin_ws/build
Devel space: /home/yograj/catkin_ws/devel
Install space: /home/yograj/catkin_ws/install
Error(s) in /home/yograj/catkin_ws/src/px4_mavros/package.xml:
- The manifest (with format version 2) must not contain the following tags: run_depend
yograj@yograj-Inspiron-5537:~/catkin_ws$ catkin_make
Base path: /home/yograj/catkin_ws
Source space: /home/yograj/catkin_ws/src
Build space: /home/yograj/catkin_ws/build
Devel space: /home/yograj/catkin_ws/devel
Install space: /home/yograj/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/yograj/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/yograj/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/yograj/catkin_ws/devel;/opt/ros/kinetic
-- This workspace overlays: /home/yograj/catkin_ws/devel;/opt/ros/kinetic
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/yograj/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.8
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 1 packages in topological order:
-- ~~ - px4_mavros
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'px4_mavros'
-- ==> add_subdirectory(px4_mavros)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/yograj/catkin_ws/build
####
#### Running command: "make -j4 -l4" in "/home/yograj/catkin_ws/build"
####
[ 50%] Building CXX object px4_mavros/CMakeFiles/offb_node.dir/src/offb_node.cpp.o
/home/yograj/catkin_ws/src/px4_mavros/src/offb_node.cpp: In function ‘int main(int, char**)’:
/home/yograj/catkin_ws/src/px4_mavros/src/offb_node.cpp:53:40: error: ‘mavros_msgs::SetMode::Response {aka struct mavros_msgs::SetModeResponse_<std::allocator<void> >}’ has no member named ‘success’
offb_set_mode.response.success){
^
px4_mavros/CMakeFiles/offb_node.dir/build.make:62: recipe for target 'px4_mavros/CMakeFiles/offb_node.dir/src/offb_node.cpp.o' failed
make[2]: *** [px4_mavros/CMakeFiles/offb_node.dir/src/offb_node.cpp.o] Error 1
CMakeFiles/Makefile2:823: recipe for target 'px4_mavros/CMakeFiles/offb_node.dir/all' failed
make[1]: *** [px4_mavros/CMakeFiles/offb_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
这是off_node.cpp文件的程序
#include <ros/ros.h>
#include <geometry_msgs/PoseStamped.h>
#include <mavros_msgs/CommandBool.h>
#include <mavros_msgs/SetMode.h>
#include <mavros_msgs/State.h>
mavros_msgs::State current_state;
void state_cb(const mavros_msgs::State::ConstPtr& msg){
current_state = *msg;
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "offb_node");
ros::NodeHandle nh;
ros::Subscriber state_sub = nh.subscribe<mavros_msgs::State>
("mavros/state", 10, state_cb);
ros::Publisher local_pos_pub = nh.advertise<geometry_msgs::PoseStamped>
("mavros/setpoint_position/local", 10);
ros::ServiceClient arming_client = nh.serviceClient<mavros_msgs::CommandBool>
("mavros/cmd/arming");
ros::ServiceClient set_mode_client = nh.serviceClient<mavros_msgs::SetMode>
("mavros/set_mode");
//the setpoint publishing rate MUST be faster than 2Hz
ros::Rate rate(20.0);
// wait for FCU connection
while(ros::ok() && current_state.connected){
ros::spinOnce();
rate.sleep();
}
geometry_msgs::PoseStamped pose;
pose.pose.position.x = 0;
pose.pose.position.y = 0;
pose.pose.position.z = 2;
//send a few setpoints before starting
for(int i = 100; ros::ok() && i > 0; --i){
local_pos_pub.publish(pose);
ros::spinOnce();
rate.sleep();
}
mavros_msgs::SetMode offb_set_mode;
offb_set_mode.request.custom_mode = "OFFBOARD";
mavros_msgs::CommandBool arm_cmd;
arm_cmd.request.value = true;
ros::Time last_request = ros::Time::now();
while(ros::ok()){
if( current_state.mode != "OFFBOARD" &&
(ros::Time::now() - last_request > ros::Duration(5.0))){
if( set_mode_client.call(offb_set_mode) &&
offb_set_mode.response.success){
ROS_INFO("Offboard enabled");
}
last_request = ros::Time::now();
} else {
if( !current_state.armed &&
(ros::Time::now() - last_request > ros::Duration(5.0))){
if( arming_client.call(arm_cmd) &&
arm_cmd.response.success){
ROS_INFO("Vehicle armed");
}
last_request = ros::Time::now();
}
}
local_pos_pub.publish(pose);
ros::spinOnce();
rate.sleep();
}
return 0;
}
答案 0 :(得分:0)
您可能正在查看错误的文档 原因kinetic doc:
mavros_msgs::SetMode
没有成功回应而是mode_sent
答案 1 :(得分:-1)
查看mavros_msgs / SetMode的文档,您尝试访问的字段似乎直接包含在SetMode服务中。 尝试更改以下内容:
offb_set_mode.success
到
for(i = 0; i < ht->size; i++){
bucket_t before_head = { .next = ht->buckets[i] }; // Only next member used.
bucket_t *previous = &before_head;
while (previous->next && strcmp(previous->next->key,key) != 0) {
previous = previous->next;
}
if (previous->next) { // match was found
// delete previous->next and its members allocations
bucket_t *node_after_match = previous->next->next;
free(previous->next->key);
free(previous->next->val);
free(previous->next);
// link previous to node after deletion.
previous->next = node_after_match;
// assign a potential new head of the list
ht->buckets[i] = before_head.next;
break; // exit for loop
}
}
(http://docs.ros.org/jade/api/mavros_msgs/html/srv/SetMode.html)