WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation


Contains constants, datatypes, and common commands for actuators eg: servos and motors.
This library tries to standardise on how we deal with these devices.
For example we introduce the concept of 'drive speed' so that we can use the same code to drive motors and modified servos. Theoretically this means we can swap between any actuator without changing the code. A drive speed of 0 means 'stop' regardless of whether you are using a motor or a modified servo. DRIVE_SPEED_MIN means go full speed in reverse and DRIVE_SPEED_MAX means go full speed forwards. Obviously the actual speed the robot moves at will depend on the abilities of the actual motor/servo as well as the wheel diameter.
For unmodified servos then DRIVE_SPEED_MIN and DRIVE_SPEED_MAX are the maximum movements of the servo and DRIVE_SPEED_CENTER is the center position.
Actuators can also be 'disconnected' ie they are no longer sent any commands until they are 'reconnected'. Disconnecting will mean that the motors will free wheel to a stop. If the robot is on a slope then it may well start accelerating down the slope. NB This is different from setting the drive speed to 0 (or using the constant DRIVE_SPEED_BRAKE) which will cause the motor to brake - which will then stop the robot from rolling down the slope. Obviously if the motors are unable to hold the robot then it may skid down the slope.
We also try to address the common problem of differential drive robots. Since the motors are on the sides of the robot then setting them both to turn clockwise at full speed will just cause the robot to spin on the spot. You need to make one turn clockwise and the other turn counter clockwise in order to go in a straight line. This often makes the code rather less obvious. We address this issue by having an 'inverted' state for each motor. That way we can set one motor as inverted and we can then just tell the motors to go full speed ahead and the library takes care of the rest.




act_setSpeed(__ACTUATOR_COMMON* act, DRIVE_SPEED speed)

Set the required speed to a value between DRIVE_SPEED_MIN and DRIVE_SPEED_MAX.
If the actuator has been disconnected then nothing will happen until it is reconnected.

DRIVE_SPEED act_getSpeed(const __ACTUATOR_COMMON* act)

Returns the last value from 'act_setSpeed'.
NB This is not the actual speed that the actuator is moving at - we have no way of knowing that without an encoder!

act_setConnected(__ACTUATOR_COMMON* act,boolean connected)

Connect or disconnect the actuator from the drive system. The second parameter should be TRUE to connect, or FALSE to disconnect.
When an actuator is disconnected it stops receiving commands.

boolean act_isConnected(const __ACTUATOR_COMMON* act)

Test if an actuator is connected. Returns TRUE if it is, and FALSE if it is not.

boolean act_isInverted(const __ACTUATOR_COMMON* act)

Test if an actuator is inverted. Returns TRUE if it is, FALSE if it is not.
You cannot change the inverted state except when creating the actuator.

Valid XHTML 1.0 Transitional