Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Setting initial velocity in plugin

I am trying to have a model rotate along a Lissajous curve. I am using torques to set the angular acceleration to be able to simulate this movement.

For this to work, I have to set the initial angular velocity.

I tried this by adding a parameter which checks if the update method has run before, and then set the angular velocity the first time the Update method of the plugin is called.

if (!this->dataPtr->runOnce){
    this->dataPtr->link->SetAngularVel({0,50,0});
    this->dataPtr->runOnce = true;
}

However, if I print out the

this->dataPtr->link->WorldAngularVel()

I can see that it is set, but the next time the Update method is called, it is already set to a value close to zero.

Just to be sure I added a delay before setting the torques, but they don't have any influence on the initial value, so they must be reset somewhere else...

Any idea what I am doing wrong?

Setting initial velocity in plugin

I am trying to have a model rotate along a Lissajous curve. I am using torques to set the angular acceleration to be able to simulate this movement.

For this to work, I have to set the initial angular velocity.

I tried this by adding a parameter which checks if the update method has run before, and then set the angular velocity the first time the Update method of the plugin is called.

if (!this->dataPtr->runOnce){
    this->dataPtr->link->SetAngularVel({0,50,0});
    this->dataPtr->runOnce = true;
}

However, if I print out the

this->dataPtr->link->WorldAngularVel()

I can see that it is set, but the next time the Update method is called, it is already set to a value close to zero.

Just to be sure I added a delay before setting the torques, but they don't have any influence on the initial value, so they must be reset somewhere else...

Any idea what I am doing wrong?

EDIT 1 Based on the comments some additional information:

Each timestep I set the forces/torques working on the model. If I do not set an initial velocity, I can see that my velocity changes each timestep according to the formula v = v0 + a*dT, with a = F/m. I set the mass of the model to 1 for easy calculation of the required force.

However, if I do set the initial velocity (using the instantaneous method) I can see that in t=0, the velocity is set to the requested value, but that in the next timestep, the velocity is calculated as in the formula above, but with v0 = 0 instead of v0 = "the requested value"

I want to have my model move according to a set pattern, and for this to work I need to be able to set an initial velocity.