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

read

Read the current settings from a servo.
The return value is 0 if the command executed correctly and the data in the servos 'info' structure has been updated. A non-zero value indicates an error and is made up of a number of error bits ORed together:-
#define AX12_RECV_LEN 0x1000     /* we received an invalid length */
#define AX12_RECV_ID 0x800       /* we received an invalid servo id */
#define AX12_RECV_HEADER 0x400   /* we received an invalid header */
#define AX12_RECV_CHECKSUM 0x200 /* we received an invalid checksum */
#define AX12_RECV_TIMEOUT 0x100  /* we timed out when receiving */
#define AX12_ERROR_INSTRUCTION 0x40 /* undefined instruction */
#define AX12_ERROR_OVERLOAD 0x20 /* the maximum torque cannot drive the load */
#define AX12_ERROR_CHECKSUM 0x10 /* we sent the wrong checksum to the AX12 */
#define AX12_ERROR_RANGE 0x8     /* the instruction range was invalid */
#define AX12_ERROR_OVERHEAT 0x4  /* the servo is overheating */
#define AX12_ERROR_ANGLE 0x2     /* the angle is out of range */
#define AX12_ERROR_VOLTAGE 0x1   /* the voltage is out of range */
If the call is successful then the info structure is updated with the current position, speed, load, voltage, temperature and whether or not the servo is moving. These settings can be accessed using the other 'getActual' functions.
Syntax
DynamixelAX12. read()
Where DynamixelAX12 is the name you have given to the device in Project Designer.
Parameters
None
Returns
uint16_t
Example
Assuming your servo is called 'myServo' in Project Designer:
// Read info from the servo
uint16_t status = myServo.read();
if( status == 0){
    // Success
}else{
    if(status & AX12_RECV_TIMEOUT){
        cerr << "Timed out reading servo\n";
    }
}
See Also
getActualIsMoving
getActualLoad
getActualRPM
getActualSpeed
getActualTemperature
getActualVolts

 

 

Valid XHTML 1.0 Transitional