Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I found the error was in package.xml, there was multiple errors.

In theory this plugin should move an object in the enviroment. i had to test the plugin with my robot

thank you for your help chapulina

if someone see an error please write a comment

my plugin at the moment is:

    #include <boost/bind.hpp>
    #include <gazebo/gazebo.hh>
    #include "geometry_msgs/Twist.h"
    #include <gazebo/physics/physics.hh>
    #include <gazebo/common/common.hh>
    #include <stdio.h>
    static float velx=0.0,vely=0.0,velz=0.0,Vangx=0.0,Vangy=0.0, Vangz=0.0; // set as global
    namespace gazebo
    {
      class remusbody : public ModelPlugin
      {
        public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
        {
          // Store the pointer to the model
          this->model = _parent;

          // Listen to the update event. This event is broadcast every
          // simulation iteration.
          this->updateConnection = event::Events::ConnectWorldUpdateBegin(
              boost::bind(&remusbody::OnUpdate, this, _1));
        }
        // callback functions run every time data is published to the topic
        void ROSCallback_Vel(const geometry_msgs::Twist::ConstPtr& msg)
        {
            velx=msg->linear.x;
            vely=msg->linear.y;
            velz=msg->linear.z;
            Vangx=msg->angular.x;
            Vangy=msg->angular.y;
            Vangz=msg->angular.z;
        }

        // Called by the world update start event
        public: void OnUpdate(const common::UpdateInfo & /*_info*/)
        {
          // Apply a small linear velocity to the model.
          this->model->SetLinearVel(math::Vector3(velx, vely, velz));
           this->model->SetAngularVel(math::Vector3(Vangx, Vangy, Vangz));
        }



        // Pointer to the model
        private: physics::ModelPtr model;

        // Pointer to the update event connection
        private: event::ConnectionPtr updateConnection;
      };

      // Register this plugin with the simulator
      GZ_REGISTER_MODEL_PLUGIN(remusbody)
    }

my cmakelist is

    cmake_minimum_required(VERSION 2.8.3)
    project(plugins)

    # Load catkin and all dependencies required for this package
    find_package(catkin REQUIRED COMPONENTS 
      roscpp 
      gazebo_ros
      geometry_msgs 
    )

    # Depend on system install of Gazebo
    set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
    find_package(gazebo REQUIRED)

    link_directories(${GAZEBO_LIBRARY_DIRS})
    include_directories(${Boost_INCLUDE_DIR} ${catkin_INCLUDE_DIRS} ${GAZEBO_INCLUDE_DIRS})

    add_library(plugins SHARED remusbody.cc)
    target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${GAZEBO_LIBRARIES})

    catkin_package(
      DEPENDS 
        roscpp 
        gazebo_ros 
        geometry_msgs
    )

and my package.xml inside my plugin folder is

    <?xml version="1.0"?>
    <package>
      <name>plugins</name>
      <version>0.0.0</version>
      <description>The plugins wilmer_gazebo package</description>

      <maintainer email="wilmer@todo.todo">wilmer</maintainer>



      <license>TODO</license>



      <buildtool_depend>catkin</buildtool_depend>
      <build_depend>roscpp</build_depend>
      <build_depend>rospy</build_depend>
      <build_depend>gazebo_ros</build_depend>
      <build_depend>std_msgs</build_depend>
      <build_depend>geometry_msgs</build_depend>
      <run_depend>roscpp</run_depend>
      <run_depend>rospy</run_depend>
      <run_depend>gazebo_ros</run_depend>
      <run_depend>std_msgs</run_depend>
      <run_depend>geometry_msgs</run_depend>


      <!-- The export tag contains other, unspecified, tags -->
      <export>
        <!-- Other tools can request additional information be placed here -->

      </export>
    </package>