Home | Tutorials | Wiki | Issues
Ask Your Question
0

gzerr couldn't be resolved (mobile_base plugin)

asked 2013-04-18 08:36:31 -0500

Christoph gravatar image

updated 2013-04-19 04:13:22 -0500

Hey guys,

I just wanted to control my mobile platform by adapting the code from the [http://gazebosim.org/wiki/Tutorials/1...robot/mobilebase] tutorial. I am using the newest gazebo version.

I compiled the plugin using the CMakeLists.txt and after that imported the project in Eclipse.

When I wanted to rebuild the project, Eclipse threw some error messages regarding the gzerr macro saying the function Instance and the method ColorErr could not be resolved. I also tried to call the function directly with the same results. The only thing I changed is the class name.

Here is the plugin code so far:

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


namespace gazebo
{   
  class PlattformControlPlugin : public ModelPlugin
  {
    public: void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf) 
    {

      // Store the pointer to the model
      this->model = _parent;

      // Load parameters for this plugin
      if (this->LoadParams(_sdf))
      {
        // Listen to the update event. This event is broadcast every
        // simulation iteration.
        this->updateConnection = event::Events::ConnectWorldUpdateStart(
            boost::bind(&PlattformControlPlugin::OnUpdate, this));
      }
    }

    public: bool LoadParams(sdf::ElementPtr _sdf) 
    {
      if (this->FindJointByParam(_sdf, this->left_wheel_joint_,
                             "left_wheel_hinge") &&
          this->FindJointByParam(_sdf, this->right_wheel_joint_,
                             "right_wheel_hinge"))
        return true;
      else
        return false;
    }

    public: bool FindJointByParam(sdf::ElementPtr _sdf,
                                  physics::JointPtr &_joint,
                                  std::string _param)
    {
      if (!_sdf->HasElement(_param))
      {
        // original plugin code
        gzerr << "param [" << _param << "] not found\n";

        // My call without using the macro
        //common::Console::Instance()->ColorErr("Error", __FILE__, __LINE__, 31)
        //      << "param [" << _param << "] not found\n";
        return false;
      }
      else
      {
        _joint = this->model->GetJoint(
          _sdf->GetElement(_param)->GetValueString());

        if (!_joint)
        {
          gzerr << "joint by name ["
                << _sdf->GetElement(_param)->GetValueString()
                << "] not found in model\n";
          return false;
        }
      }
      return true;
    }

    // Called by the world update start event
    public: void OnUpdate()
    {
      this->left_wheel_joint_->SetForce(0, 0.2);
      this->right_wheel_joint_->SetForce(0, -0.2);
    }

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

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

    private: physics::JointPtr left_wheel_joint_;
    private: physics::JointPtr right_wheel_joint_;
  };

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

I tested the plugin using std::cerr for the moment. And I didn't get my platform moving, because the plugin couldn't find my joints. I tried using the names with and without the namespace of my sdf-file. And in Gazebo I can see those names.

The plugin doesn't get further than to this point:

if (!_sdf->HasElement(_param))
          {
            // original plugin code
            gzerr << "param [" << _param << "] not found\n";

            // My call without using the macro
            //common::Console::Instance()->ColorErr("Error", __FILE__, __LINE__, 31)
            //      << "param [" << _param << "] not found\n";
            return false;
          }

Tia, Christoph

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-05-13 08:17:23 -0500

Christoph gravatar image

updated 2013-05-13 08:26:30 -0500

The error resulted from wrong or insufficient settings (linked libraries, includes) in my development environment. I can't tell you exactly what I did wrong. Because I needed some ROS code I built a ROS package with GAZEBO path includes. After this the error didn't show up again. The mobile_base plugin and the tutorial are working fine.

It would be nice if someone could accept my answer or close this question as I can't do that by myself.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-04-18 08:36:31 -0500

Seen: 331 times

Last updated: May 13 '13