0
$\begingroup$

Gazebo Answers logo

Hi, I am new to Gazebo and trying out the tutorials. When I run the second tutorial, in which a cube is created and a linear velocity is given to it, the cube translates for a while and then starts to topple about its edge. This toppling behavior continues from there on. If I increase the velocity I dont see this behavior. Can anyone explain that why is the linear velocity causing rotational motion.

Thanks.

The Plugin Code

#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) }


Originally posted by Akm on Gazebo Answers with karma: 1 on 2014-03-02

Post score: 0


Original comments

Comment by AndreiHaidu on 2014-03-02:
could you post your plugin?

Comment by AndreiHaidu on 2014-03-02:
is the model colliding with anything? or just floating around the world (with gravity disabled?)

Comment by Akm on 2014-03-02:
No its not colliding with anything, I am using the exact same thing as given in this link --- http://gazebosim.org/wiki/Tutorials/2.2/plugins/ModelPush I guess the gravity is disabled, because its not specifically being set anywhere.

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

I see the same thing when I run the tutorial. Gravity is enabled, and the box is colliding with the ground plane, and friction causes the rotation. If you add a positive vertical component to the velocity the box will rise and not rotate. For example, try the following patch:


diff -r b35228888b2d examples/plugins/model_push/model_push.cc
--- a/examples/plugins/model_push/model_push.cc Mon Mar 03 14:47:50 2014 -0800
+++ b/examples/plugins/model_push/model_push.cc Mon Mar 03 16:23:13 2014 -0800
@@ -39,7 +39,7 @@
     public: void OnUpdate(const common::UpdateInfo & /*_info*/)
     {
       // Apply a small linear velocity to the model.
-      this->model->SetLinearVel(math::Vector3(.03, 0, 0));
+      this->model->SetLinearVel(math::Vector3(.03, 0, 0.03));
     }
 
     // Pointer to the model

We appreciate feedback on the tutorials. Should there be a better explanation of the expected behavior?


Originally posted by scpeters with karma: 2861 on 2014-03-03

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Akm on 2014-03-03:
thanks for the answer. It would be great if the expected output could be explained a little better in the tutorials. If I may ask, how did you figure out that the box is colliding with the ground plane? Also, if the gravity is enabled, then as soon as the center of mass shifts beyond the normal then the cube should immediately topple, but the rotational motion looks uniform (constant angular velocity). Am I missing something?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.