Gazebo | Ignition | Community
Ask Your Question
0

cube rotates with linear velocity

asked 2014-03-01 23:21:58 -0500

Akm gravatar image

updated 2014-03-02 12:26:04 -0500

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 GZREGISTERMODEL_PLUGIN(ModelPush) }

edit retag flag offensive close merge delete

Comments

could you post your plugin?

AndreiHaidu gravatar imageAndreiHaidu ( 2014-03-02 07:03:50 -0500 )edit

is the model colliding with anything? or just floating around the world (with gravity disabled?)

AndreiHaidu gravatar imageAndreiHaidu ( 2014-03-02 16:12:02 -0500 )edit

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.

Akm gravatar imageAkm ( 2014-03-02 17:14:58 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-03-03 18:26:04 -0500

scpeters gravatar image

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?

edit flag offensive delete link more

Comments

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?

Akm gravatar imageAkm ( 2014-03-03 21:09:38 -0500 )edit

Question Tools

Stats

Asked: 2014-03-01 23:21:58 -0500

Seen: 558 times

Last updated: Mar 03 '14