Skip to content
Snippets Groups Projects
Commit 5783733a authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Added support to read the fallen status from the firmware.

parent e026b57f
No related branches found
No related tags found
No related merge requests found
......@@ -590,6 +590,40 @@ bool CDarwinRobot::mm_is_power_enabled(void)
throw CDarwinRobotException(_HERE_,"Invalid robot device");
}
bool CDarwinRobot::mm_has_fallen(void)
{
unsigned char value;
if(this->robot_device!=NULL)
{
this->robot_device->read_byte_register(DARWIN_MM_CNTRL,&value);
if(value&(MANAGER_FWD_FALL | MANAGER_BWD_FALL))
return true;
else
return false;
}
else
throw CDarwinRobotException(_HERE_,"Invalid robot device");
}
fall_t CDarwinRobot::mm_get_fallen_position(void)
{
unsigned char value;
if(this->robot_device!=NULL)
{
this->robot_device->read_byte_register(DARWIN_MM_CNTRL,&value);
if(value&MANAGER_FWD_FALL)
return MM_FWD_FALL;
else if(value&MANAGER_BWD_FALL)
return MM_BWD_FALL;
else
return MM_STANDING;
}
else
throw CDarwinRobotException(_HERE_,"Invalid robot device");
}
void CDarwinRobot::mm_enable_servo(unsigned char servo_id)
{
unsigned char value;
......
......@@ -50,6 +50,8 @@ typedef struct
}TChargerData;
#pragma pack (pop)
typedef enum {MM_FWD_FALL=0,MM_BWD_FALL=1,MM_STANDING=2} fall_t;
class CDarwinRobot
{
private:
......@@ -109,6 +111,8 @@ class CDarwinRobot
void mm_enable_power(void);
void mm_disable_power(void);
bool mm_is_power_enabled(void);
bool mm_has_fallen(void);
fall_t mm_get_fallen_position(void);
void mm_enable_servo(unsigned char servo_id);
void mm_disable_servo(unsigned char servo_id);
bool mm_is_servo_enabled(unsigned char servo_id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment