Home | Tutorials | Wiki | Issues
Ask Your Question
0

'math' has not been declared Gazebo 8 Write Plug in Tutorial

asked 2017-06-05 16:32:59 -0500

michael1234 gravatar image

updated 2017-06-06 15:57:55 -0500

I am following this tutorial --> click me <--

I am getting this error:

**error:** 'math' has not been declared
   this->model->SetLinearVel(math::Vector3(.03, 0, 0));
                             ^

Wasn't math imported with some kind of library in the script?

Full script:

#include <boost/bind.hpp>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>
#include <stdio.h>

namespace gazebo
{
  class ModelPush : 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(&ModelPush::OnUpdate, this, _1));
    }

    // 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(.03, 0, 0));
    }

    // 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(ModelPush)
}
edit retag flag offensive close merge delete

Comments

What's your Gazebo version?

chapulina gravatar imagechapulina ( 2017-06-05 19:05:53 -0500 )edit

It is Gazebo 8.

michael1234 gravatar imagemichael1234 ( 2017-06-05 19:24:58 -0500 )edit

You can try adding `#include <gazebo math="" math.hh="">` to the top. I believe the tutorial needs to be updated for Gazebo > 7

chapulina gravatar imagechapulina ( 2017-06-06 15:30:11 -0500 )edit

It didn't work for me.

michael1234 gravatar imagemichael1234 ( 2017-06-06 15:58:12 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-06-06 16:01:07 -0500

michael1234 gravatar image

The Gazebo documentation isn't updated, I had to used the ignition library.

ignition::math::Vector3<double /* var type */ >(0.03f, 0.0f, 0.0f);
edit flag offensive delete link more
0

answered 2017-06-06 15:59:13 -0500

chapulina gravatar image

That tutorial probably needs to be updated for Gazebo 8. It should be changed to use ignition::math instead of Gazebo math.

You can try the following:

  1. Include ignition math vector:

    #include <ignition/math/Vector3.hh>
    
  2. Change math::Vector3 to ignition::math::Vector3d

edit flag offensive delete link more

Comments

1

The include isn't necessary.

michael1234 gravatar imagemichael1234 ( 2017-06-06 16:04:26 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-06-05 16:32:59 -0500

Seen: 2,071 times

Last updated: Jun 06 '17