00001 00009 /***************************************************************************** 00010 ** Preprocessor 00011 *****************************************************************************/ 00012 00013 #ifndef KOBUKI_CORE_SENSORS_HPP__ 00014 #define KOBUKI_CORE_SENSORS_HPP__ 00015 00016 /***************************************************************************** 00017 ** Include 00018 *****************************************************************************/ 00019 00020 #include "../packet_handler/payload_base.hpp" 00021 #include <stdint.h> 00022 00023 /***************************************************************************** 00024 ** Namespaces 00025 *****************************************************************************/ 00026 00027 namespace kobuki 00028 { 00029 00030 /***************************************************************************** 00031 ** Interface 00032 *****************************************************************************/ 00033 00034 class CoreSensors : public packet_handler::payloadBase 00035 { 00036 public: 00037 struct Data { 00038 uint16_t time_stamp; 00039 uint8_t bumper; 00040 uint8_t wheel_drop; 00041 uint8_t cliff; 00042 uint16_t left_encoder; 00043 uint16_t right_encoder; 00044 char left_pwm; 00045 char right_pwm; 00046 uint8_t buttons; 00047 uint8_t charger; 00048 uint8_t battery; 00049 uint8_t over_current; 00050 } data; 00051 00052 struct Flags { 00053 // buttons 00054 static const uint8_t Button0 = 0x01; 00055 static const uint8_t Button1 = 0x02; 00056 static const uint8_t Button2 = 0x04; 00057 00058 // bumper 00059 static const uint8_t LeftBumper = 0x04; 00060 static const uint8_t CenterBumper = 0x02; 00061 static const uint8_t RightBumper = 0x01; 00062 00063 // cliff sensor 00064 static const uint8_t LeftCliff = 0x04; 00065 static const uint8_t CenterCliff = 0x02; 00066 static const uint8_t RightCliff = 0x01; 00067 00068 // wheel drop sensor 00069 static const uint8_t LeftWheel = 0x02; 00070 static const uint8_t RightWheel = 0x01; 00071 00072 // Charging source 00073 // - first four bits distinguish between adapter or docking base charging 00074 static const uint8_t AdapterType = 0x10; 00075 // - last 4 bits specified the charging status (see Battery.hpp for details) 00076 static const uint8_t BatteryStateMask = 0x0F; 00077 static const uint8_t Discharging = 0x00; 00078 static const uint8_t Charged = 0x02; 00079 static const uint8_t Charging = 0x06; 00080 00081 // wheel drop sensor 00082 static const uint8_t LeftWheel_OC = 0x01; 00083 static const uint8_t RightWheel_OC = 0x02; 00084 00085 }; 00086 00087 bool serialise(ecl::PushAndPop<unsigned char> & byteStream); 00088 bool deserialise(ecl::PushAndPop<unsigned char> & byteStream); 00089 }; 00090 00091 } // namespace kobuki 00092 00093 #endif /* KOBUKI_CORE_SENSORS_HPP__ */