Reputation: 35
When I am debugging my webots controller in Pycharm, I noticed that a motor will have two constants: LINEAR and ROTATIONAL.
The proto for the NAO lists "RShoulderPitch" as a rotational motor (for a Hinge2Joint), but in PyCharm, the motor returned by the following code
r_shoulder_pitch = getMotor("RShoulderPitch")
has the constants as follows: LINEAR=1 and ROTATIONAL=0.
Maybe I am misunderstanding these constants, but should it not be the reverse (i.e. ROTATIONAL=1 and LINEAR=0)?
Note: A position sensor returned by
r_shoulder_pitch.getPositionSensor()
also has the following constants in PyCharm: ANGULAR=0, LINEAR=1, ROTATIONAL=0.
Upvotes: 1
Views: 136
Reputation: 1834
This is not very "pythonic", but Motor.LINEAR
and Motor.ROTATIONAL
are constants to compare the return values of the Motor.getType()
function.
These constants do not contain the type of the current motor.
A typical usage is:
my_motor = my_robot.getMotor('RShoulderPitch')
if my_motor.getType() == Motor.ROTATIONAL:
print('my motor is rotational')
else:
print('my motor is linear')
I also have 2 advices:
Hinge2Joint
. This allows to deal with 2 joints with the performance of one. But this is an optimization. The API only sees the device level (the Motors in this case). So there is no need to know that it's an Hinge2Joint to use it.Upvotes: 1