Provides an interface to an AX-12A servo. Requires the Dynamixel bus protocol library/
Fork of AX-12A by
Diff: AX12.cpp
- Revision:
- 0:1a48094c99d1
- Child:
- 1:d7642b2e155d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AX12.cpp Thu Dec 10 21:45:59 2015 +0000 @@ -0,0 +1,60 @@ +/* mbed AX-12+ Servo Library - External hardware version */ + +#include "AX12.h" +#include "mbed.h" + +AX12::AX12( DynamixelBus* pbus, ServoId ID) +{ + _pbus = pbus; + _ID = ID; +} + +/*****/ + +StatusCode AX12::Ping() +{ + return _pbus->Ping(_ID); +} + +/*****/ + +StatusCode AX12::SetGoal(float degrees) +{ + short goal = (short)((1023.0f * degrees) / 300.0f); + + CommBuffer data; + data.push_back( goal & 0xff ); + data.push_back( goal >> 8 ); + + // write the packet, return the error code + int offset = GoalPositionL; + return _pbus->Write(_ID, offset, data); +} + +/*****/ + +bool IsMoving(void) +{ + return false; +} + +/*****/ + +float GetPosition() +{ + return 0; +} + +/*****/ + +float GetTemperature(void) +{ + return 0; +} + +/*****/ + +float GetSupplyVoltage(void) +{ + return 0; +}