SegwayRMP Class Reference
Inheritance diagram for SegwayRMP:
Inheritance graph
Collaboration diagram for SegwayRMP:
Collaboration graph

Public Member Functions

 SegwayRMP (ConfigFile *cf, int section)
 
virtual int MainSetup ()
 Sets up the resources needed by the driver thread.
 
virtual void MainQuit ()
 Cleanup method for driver thread (called when main exits) More...
 
virtual int ProcessMessage (QueuePointer &resp_queue, player_msghdr *hdr, void *data)
 Message handler. More...
 
int CanBusSetup ()
 Sets up the CAN bus for communication.
 
int USBSetup ()
 Sets up the USB bus for communication.
 
- Public Member Functions inherited from ThreadedDriver
 ThreadedDriver (ConfigFile *cf, int section, bool overwrite_cmds, size_t queue_maxlen, int interface_)
 Constructor with implicit interface. More...
 
 ThreadedDriver (ConfigFile *cf, int section, bool overwrite_cmds=true, size_t queue_maxlen=PLAYER_MSGQUEUE_DEFAULT_MAXLEN)
 Constructor for multiple-interface drivers. More...
 
virtual ~ThreadedDriver ()
 Destructor.
 
virtual int Setup ()
 Initialize the driver. More...
 
virtual int Shutdown ()
 Finalize the driver. More...
 
virtual int Terminate ()
 Terminate the driver. More...
 
bool Wait (double TimeOut=0.0)
 Wait for new data to arrive on the driver's queue. More...
 
virtual void Update ()
 Update non-threaded drivers. More...
 
- Public Member Functions inherited from Driver
bool HasSubscriptions ()
 
virtual void Publish (player_devaddr_t addr, QueuePointer &queue, uint8_t type, uint8_t subtype, void *src=NULL, size_t deprecated=0, double *timestamp=NULL, bool copy=true)
 Publish a message via one of this driver's interfaces. More...
 
virtual void Publish (player_devaddr_t addr, uint8_t type, uint8_t subtype, void *src=NULL, size_t deprecated=0, double *timestamp=NULL, bool copy=true)
 Publish a message via one of this driver's interfaces. More...
 
virtual void Publish (QueuePointer &queue, player_msghdr_t *hdr, void *src, bool copy=true)
 Publish a message via one of this driver's interfaces. More...
 
virtual void Publish (player_msghdr_t *hdr, void *src, bool copy=true)
 Publish a message via one of this driver's interfaces. More...
 
 Driver (ConfigFile *cf, int section, bool overwrite_cmds, size_t queue_maxlen, int interf)
 Constructor for single-interface drivers. More...
 
 Driver (ConfigFile *cf, int section, bool overwrite_cmds=true, size_t queue_maxlen=PLAYER_MSGQUEUE_DEFAULT_MAXLEN)
 Constructor for multiple-interface drivers. More...
 
virtual ~Driver ()
 Destructor.
 
int GetError ()
 Get last error value. More...
 
virtual int Subscribe (player_devaddr_t addr)
 Subscribe to this driver. More...
 
virtual int Subscribe (QueuePointer &, player_devaddr_t)
 Subscribe to this driver. More...
 
virtual int Unsubscribe (player_devaddr_t addr)
 Unsubscribe from this driver. More...
 
virtual int Unsubscribe (QueuePointer &, player_devaddr_t)
 Unsubscribe from this driver. More...
 
void ProcessMessages (int maxmsgs)
 Process pending messages. More...
 
void ProcessMessages (void)
 Process pending messages. More...
 
virtual int ProcessInternalMessages (QueuePointer &resp_queue, player_msghdr *hdr, void *data)
 Internal message handler. More...
 
virtual bool RegisterProperty (const char *key, Property *property, ConfigFile *cf, int section)
 Property registration. More...
 
virtual bool RegisterProperty (Property *property, ConfigFile *cf, int section)
 Property registration. More...
 

Protected Attributes

player_devaddr_t position_id
 
player_position2d_data_t position_data
 
player_devaddr_t position3d_id
 
player_position3d_data_t position3d_data
 
player_devaddr_t power_base_id
 
player_power_data_t power_base_data
 
player_devaddr_t power_ui_id
 
player_power_data_t power_ui_data
 

Private Member Functions

int HandlePositionConfig (QueuePointer &resp_queue, uint32_t subtype, void *data, size_t len)
 
int HandlePosition3DConfig (QueuePointer &resp_queue, uint32_t subtype, void *data, size_t len)
 
int Read ()
 
int CanBusRead ()
 
int USBRead ()
 
int Diff (uint32_t from, uint32_t to, bool first)
 
int Write (CanPacket &pkt)
 
virtual void Main ()
 Main method for driver thread. More...
 
void MakeStatusCommand (CanPacket *pkt, uint16_t cmd, uint16_t val)
 
void MakeVelocityCommand (CanPacket *pkt, int32_t xspeed, int32_t yawspeed)
 
void MakeShutdownCommand (CanPacket *pkt)
 
void UpdateData (rmp_frame_t *)
 

Private Attributes

BusType bus_type
 
const char * portname
 
const char * caniotype
 
const char * usb_device
 
int timeout_counter
 
float max_xspeed
 
float max_yawspeed
 
bool firstread
 
DualCANIOcanio
 
USBIOusbio
 
float curr_xspeed
 
float curr_yawspeed
 
float last_xspeed
 
float last_yawspeed
 
bool speed_change
 
bool motor_allow_enable
 
bool motor_enabled
 
uint32_t last_raw_yaw
 
uint32_t last_raw_left
 
uint32_t last_raw_right
 
uint32_t last_raw_foreaft
 
double odom_x
 
double odom_y
 
double odom_yaw
 

Additional Inherited Members

- Public Attributes inherited from Driver
QueuePointer ret_queue
 Last requester's queue. More...
 
player_devaddr_t device_addr
 Default device address (single-interface drivers)
 
int entries
 Total number of entries in the device table using this driver. More...
 
bool alwayson
 Always on flag. More...
 
QueuePointer InQueue
 Queue for all incoming messages for this driver.
 
- Protected Member Functions inherited from ThreadedDriver
virtual void StartThread (void)
 
virtual void StopThread (void)
 Cancel (and wait for termination) of the driver thread. More...
 
void TestCancel ()
 enable thread cancellation and test for cancellation More...
 
- Protected Member Functions inherited from Driver
int AddInterface (player_devaddr_t addr)
 Add an interface. More...
 
int AddInterface (player_devaddr_t *addr, ConfigFile *cf, int section, int code, const char *key=NULL)
 Add an interface. More...
 
void SetError (int code)
 Set/reset error code.
 
int AddFileWatch (int fd, bool ReadWatch=true, bool WriteWatch=false, bool ExceptWatch=true)
 Wake up the driver if the specified event occurs on the file descriptor.
 
int RemoveFileWatch (int fd, bool ReadWatch=true, bool WriteWatch=false, bool ExceptWatch=true)
 Remove a previously added watch, call with the same arguments as when adding the watch.
 
virtual void Lock (void)
 Lock access between the server and driver threads. More...
 
virtual void Unlock (void)
 Unlock access to driver internals. More...
 
virtual void SubscriptionLock (void)
 Lock to protect the subscription count for the driver.
 
virtual void SubscriptionUnlock (void)
 Unlock to protect the subscription count for the driver. More...
 
- Static Protected Member Functions inherited from ThreadedDriver
static void * DummyMain (void *driver)
 Dummy main (just calls real main). More...
 
static void DummyMainQuit (void *driver)
 Dummy main cleanup (just calls real main cleanup). More...
 

Member Function Documentation

◆ Main()

void SegwayRMP::Main ( )
privatevirtual

Main method for driver thread.

drivers have their own thread of execution, created using StartThread(); this is the entry point for the driver thread, and must be overloaded by all threaded drivers.

@ TODO report better timestamps, possibly using time info from the RMP

Todo:
We are getting intermittent timeouts. Does not break functionality, but should be checked.

Implements ThreadedDriver.

References PLAYER_ERROR, PLAYER_MSG0, PLAYER_MSG2, PLAYER_MSGTYPE_DATA, PLAYER_POSITION2D_DATA_STATE, PLAYER_POSITION3D_DATA_STATE, PLAYER_POWER_DATA_STATE, and PLAYER_WARN.

◆ MainQuit()

void SegwayRMP::MainQuit ( void  )
virtual

Cleanup method for driver thread (called when main exits)

Overload this method and to do additional cleanup when the driver thread exits.

Reimplemented from ThreadedDriver.

References PLAYER_MSG0.

◆ ProcessMessage()

◆ UpdateData()

void SegwayRMP::UpdateData ( rmp_frame_t data_frame)
private

TODO left off here

References PlayerCc::max(), PLAYER_POWER_MASK_VOLTS, and PLAYER_WARN2.

Here is the call graph for this function:

The documentation for this class was generated from the following files: