error in simple plugin for an AUV
Hi, I am new to gazebo. I had written a Matlab code for nonlinear dynamics of an AUV , now I need to connect my simulink code to gazebo. I am not using the physics of gazebo as the physics is going to be controlled from simulink.
I create a model of the AUV in gazebo and setup the joints for the propeller, rudder and elevator.
However, I am having difficulty understanding the plugin tutorials.
I copy and modified the code from herelink text
I am trying to compile the plugin but I am having error:
[ 50%] Building CXX object CMakeFiles/remusbody.dir/remusbody.cc.o /home/wilmer/catkin_ws/src/plugins/remusbody.cc:5:33: fatal error: geometry_msgs/Twist.h: No such file or directory compilation terminated. CMakeFiles/remusbody.dir/build.make:62: recipe for target 'CMakeFiles/remusbody.dir/remusbody.cc.o' failed make[2]: * [CMakeFiles/remusbody.dir/remusbody.cc.o] Error 1 CMakeFiles/Makefile2:355: recipe for target 'CMakeFiles/remusbody.dir/all' failed make[1]: [CMakeFiles/remusbody.dir/all] Error 2 Makefile:138: recipe for target 'all' failed make: ** [all] Error 2
what I am doing wrong?
I attach this line to package.xml
<build_depend>geometry_msgs</build_depend>
My cmakelist is this
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
find_package(gazebo REQUIRED)
find_package(catkin REQUIRED COMPONENTS roscpp geometry_msgs)
add_library(remusbody SHARED remusbody.cc)
target_link_libraries(remusbody ${GAZEBO_LIBRARIES})
include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")
My plugin code is attached down.
any help is welcome...
#include <stdio.h>
#include <geometry_msgs/Twist.h>
#include "geometry_msgs/PoseStamped.h"
#include "gazebo/gazebo.hh"
#include "gazebo/physics/physics.hh"
#include "gazebo/common/common.hh"
#include "math/Vector3.hh"
#include <math/gzmath.hh>
static float Vlin=0.0, Vang=0.0; // set as global
namespace gazebo
{
class ROSModelPlugin : public ModelPlugin
{
public: ROSModelPlugin()
{
// Start up ROS
std::string name1 = "gz"; // this is what appears in the rostopics
int argc = 0;
ros::init(argc, NULL, name1);
}
public: ~ROSModelPlugin()
{
delete this->nh;
}
public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
{
// Store the pointer to the model
this->model = _parent;
// ROS Nodehandle
this->nh = new ros::NodeHandle("~");
// ROS Subscriber
this->subvel = this->nh->subscribe<geometry_msgs::Twist>("cmd_vel", 1000, &ROSModelPlugin::ROSCallback_Vel, this );
this->nh = new ros::NodeHandle("~");
this->pubpose = this->nh->advertise<geometry_msgs::PoseStamped>("pose",1000);
//***********************************************
// Listen to the update event. This event is broadcast every
// simulation iteration.
// for gazebo 1.4 or lower it should be ConnectWorldUpdateStart
this->updateConnection = event::Events::ConnectWorldUpdateBegin(
boost::bind(&ROSModelPlugin::OnUpdate, this));
}
// Called by the world update start event
public: void OnUpdate()
{
std::vector<double> rangesgz;
static double qw,qx,qy,qz, Rrad, Prad, Yrad;
// ************* QUATERNION / POSE DATA ******************
math::Vector3 p = model->GetWorldPose().pos;
math::Quaternion r = model->GetWorldPose().rot;
//from quaternion to Roll Pitch Yaw, in radianos
qw=r.w; qx=r.x; qy=r.y; qz=r.z;
Rrad=atan2( 2*(qw*qx+qy*qz), 1-2*(qx*qx+qy*qy) ); //Roll
Prad=asin(2*(qw*qy-qz*qx)); //Pitch
Yrad=atan2( 2*(qw*qz+qx*qy), 1-2*(qy*qy+qz*qz) ); //Yaw
// ***************************************************
ros::Time current_time ...