1

I have read the FAQ on how to get velocities from nodes. Yet, of the methods described, none feature a way to get the velocity from a passive servo motor (motor sensing).

I'm trying to use a motor, set to torque 0, which makes it 'loose', as a velocity sensor for an attached inversed pendulum.

The standard motor node has the .getVelocity() method which should allow to receive velocity applied to the motor. In real servos, these would even provide data in passive mode. However in webots, the API describes:

Note that if the velocity is not explicitly set using the wb_motor_set_velocity function, then the wb_motor_get_velocity and wb_motor_get_max_velocity functions return the same value.

Why is that so, and is there any way to use a passive motor/servo for velocity measurment, like one would do with a real servo?

Aerodynamic
  • 782
  • 5
  • 19

1 Answers1

2

To get the velocity you should not rely on the Motor API, but rather use a position sensor: https://www.cyberbotics.com/doc/reference/positionsensor

The position sensor allows you to get the current position of a joint (e.g. its angle for a rotational joint). Then, from the position, you can easily compute the speed of the joint (simply take the difference between current position and position at previous step and divide it by the time difference (i.e. the time step fo the controller)).

David Mansolino
  • 1,713
  • 7
  • 13
  • Ok, I guessed that to be an option as well. Though I would be interested in the reasoning why the API exposes the getVelocity field, yet populates it only if the motor provides it's own torque. Wouldn't a real motor still output measurement if it's driven externly ? – Aerodynamic Feb 26 '20 at 16:51
  • 1
    The Motor is only returning the target velocity usinf the 'getVelocity' function, but not the actual one. – David Mansolino Feb 27 '20 at 06:21
  • 1
    Ok, I added an [issue](https://github.com/cyberbotics/webots/issues/1416) regarding a possible renaming to clear up the function's returned value. – Aerodynamic Feb 27 '20 at 18:18