Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you have a few tutorials on older versions. the underscores used to set text to italic are making a few typos, make sure to notice them

1-this tutorial shows how to set the model velocities. http://gazebosim.org/wiki/Tutorials/1.3/intermediate/control_model for the above tutorial you might also find this usefull.

// *** QUATERNION / POSE DATA ***** static double qw,qx,qy,qz, Rrad, Prad, Yrad; math::Vector3 p = model->GetWorldPose().pos; math::Quaternion r = model->GetWorldPose().rot; //from quaternion to Roll Pitch Yaw, in radians qw=r.w; qx=r.x; qy=r.y; qz=r.z; Rrad=atan2( 2(qwqx+qyqz), 1-2(qxqx+qyqy) ); //Roll Prad=asin(2(qwqy-qzqx)); //Pitch Yrad=atan2( 2(qwqz+qxqy), 1-2(qyqy+qzqz) ); //Yaw // ************** //set velocities float velx,vely; velx=Vlincos(Yrad); vely=Vlinsin(Yrad);
this->model->SetLinearVel(math::Vector3(velx, vely, 0)); this->model->SetAngularVel(math::Vector3(0, 0, Vang)); //
**************

2- or you can control the model using aplying joint forces, but this needs a robot with joints as wheels http://gazebosim.org/wiki/Tutorials/1.3/control_robot/mobile_base

hope this helps.

you have a few tutorials on older versions. the underscores used to set text to italic are making a few typos, make sure to notice them

1-this tutorial shows how to set the model velocities. http://gazebosim.org/wiki/Tutorials/1.3/intermediate/control_model for the above tutorial you might also find this usefull.

// *** QUATERNION / POSE DATA ***** **

  static double qw,qx,qy,qz, Rrad, Prad, Yrad;
   math::Vector3 p = model->GetWorldPose().pos;
   math::Quaternion r = model->GetWorldPose().rot;
   //from quaternion to Roll Pitch Yaw, in radians
   qw=r.w;   qx=r.x;     qy=r.y;     qz=r.z;
   Rrad=atan2(  2(qwqx+qyqz),  1-2(qxqx+qyqy) 2*(qw*qx+qy*qz),  1-2*(qx*qx+qy*qy)  );  //Roll
      Prad=asin(2(qwqy-qzqx)); Prad=asin(2*(qw*qy-qz*qx));                           //Pitch
   Yrad=atan2(  2(qwqz+qxqy),  1-2(qyqy+qzqz) 2*(qw*qz+qx*qy),  1-2*(qy*qy+qz*qz)  );  //Yaw

// ************** *

        //set velocities
          float velx,vely;
            velx=Vlincos(Yrad);
            vely=Vlinsin(Yrad); 
velx=Vlin*cos(Yrad); vely=Vlin*sin(Yrad); this->model->SetLinearVel(math::Vector3(velx, vely, 0)); this->model->SetAngularVel(math::Vector3(0, 0, Vang));

// *****************************

2- or you can control the model using aplying joint forces, but this needs a robot with joints as wheels http://gazebosim.org/wiki/Tutorials/1.3/control_robot/mobile_base

hope this helps.