Trouble with using roscpp and mavros api to integrate pixhawk with Jetson

259 views
Skip to first unread message

gurudutt....@gmail.com

unread,
Feb 10, 2015, 4:07:03 PM2/10/15
to drones-...@googlegroups.com
Hi,

I'm trying to Integrate pixhawk with Nvidia Jetson TK1.
I was able to use ROS/Mavros and communicate with pixhawk by ros commands.
Now I'm trying to use roscpp and mavros C++ api to communicate with pixhawk by C++ development on Jetson.
I was able to run hello world program by following this tutorial http://jbohren.com/articles/roscpp-hello-world/

Now, I'm trying to use it and mavros api to send arming commands to pixhawk.
I modified it this way and compiled the program.

// Include the ROS C++ APIs
#include <ros/ros.h>
#include <mavros/mavros.h>
#include <mavros/CommandBool.h>
#include <mavros/mavros_plugin.h>
#include <pluginlib/class_list_macros.h>
#include <iostream>
using namespace mavros;
using namespace mavplugin;

// Standard C++ entry point
int main(int argc, char** argv) {
  // Announce this program to the ROS master as a "node" called "hello_world_node"
  ros::init(argc, argv, "mavros");
  // Start the node resource managers (communication, time, etc)
  ros::start();
  // Broadcast a simple log message
  ROS_INFO_STREAM("Hello, world!");
  //Create Request and Response structures for Arming service
  CommandBool::Request arm_req;//=new CommandBool::Request<std::Allocator<void>>();
  arm_req.value=1;
  CommandBool::Response arm_res;//=new CommandBool::Response();
  //Send arming command to master node
  bool result=mavplugin::CommandPlugin::arming_cb(&arm_req, &arm_res);
  // Process ROS callbacks until receiving a SIGINT (ctrl-c)
  ros::spin();
  // Stop the node's resources
  ros::shutdown();
  // Exit tranquilly
  return 0;
}


I got the following error message after compiling this:

sample.cpp: In function ‘int main(int, char**)’:
sample.cpp:28:26: error: ‘mavplugin::CommandPlugin’ has not been declared
   bool result=mavplugin::CommandPlugin::arming_cb(&arm_req, &arm_res);


Can anyone please suggest me how to proceed?
Thanks.

Glenn Gregory

unread,
Feb 11, 2015, 12:36:09 AM2/11/15
to drones-...@googlegroups.com
It looks like you are trying to access the callback function directly. The CommandPlugin sets up ROS services which you can access from custom ROS packages via the ros::ServiceClient object. 

I suggest running through this simple ROS service tutorial to get familiar:

This is where the service is advertised:

Here is the python example to arm through the service:
Reply all
Reply to author
Forward
0 new messages