00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "canio.h"
00022 #include "canio_kvaser.h"
00023 #include "player.h"
00024 #include "device.h"
00025 #include "configfile.h"
00026
00027
00028
00029 class rmp_frame_t;
00030
00031
00032
00033 class SegwayRMP : public Driver
00034 {
00035 public:
00036
00037 SegwayRMP(ConfigFile* cf, int section);
00038 ~SegwayRMP();
00039
00040
00041 virtual int Setup();
00042 virtual int Shutdown();
00043
00044 protected:
00045
00046
00047 player_device_id_t position_id;
00048 player_position_data_t position_data;
00049
00050 player_device_id_t position3d_id;
00051 player_position3d_data_t position3d_data;
00052
00053 player_device_id_t power_id;
00054 player_power_data_t power_data;
00055
00056 private:
00057
00058 const char* portname;
00059 const char* caniotype;
00060
00061 int timeout_counter;
00062
00063 int max_xspeed, max_yawspeed;
00064
00065 bool firstread;
00066
00067 DualCANIO *canio;
00068
00069 int16_t last_xspeed, last_yawspeed;
00070
00071
00072
00073 bool motor_allow_enable;
00074
00075
00076 bool motor_enabled;
00077
00078
00079 uint32_t last_raw_yaw, last_raw_left, last_raw_right, last_raw_foreaft;
00080
00081
00082 double odom_x, odom_y, odom_yaw;
00083
00084
00085 int HandlePositionConfig(void* client, unsigned char* buffer, size_t len);
00086
00087
00088 int HandlePosition3DConfig(void* client, unsigned char* buffer, size_t len);
00089
00090
00091 int Read();
00092
00093
00094
00095 int Diff(uint32_t from, uint32_t to, bool first);
00096
00097
00098 int Write(CanPacket& pkt);
00099
00100
00101 virtual void Main();
00102
00103
00104 void MakeStatusCommand(CanPacket* pkt, uint16_t cmd, uint16_t val);
00105
00106
00107 void MakeVelocityCommand(CanPacket* pkt, int32_t xspeed, int32_t yawspeed);
00108
00109 void MakeShutdownCommand(CanPacket* pkt);
00110
00111 void UpdateData(rmp_frame_t *);
00112 };
00113
00114