Klamp't  0.8.1
Public Member Functions | Public Attributes | List of all members
SerialController Class Reference

A controller that writes sensor data to a socket and reads robot commands from a socket. More...

#include <SerialController.h>

Inheritance diagram for SerialController:
RobotController

Public Member Functions

 SerialController (Robot &robot, const string &servAddr="", Real writeRate=10)
 
virtual const char * Type () const
 
virtual void Update (Real dt)
 
virtual void Reset ()
 
virtual map< string, string > Settings () const
 
virtual bool GetSetting (const string &name, string &str) const
 
virtual bool SetSetting (const string &name, const string &str)
 
bool OpenConnection (const string &servaddr)
 
bool CloseConnection ()
 
void PackSensorData (AnyCollection &data)
 
- Public Member Functions inherited from RobotController
 RobotController (Robot &robot)
 
virtual bool ReadState (File &f)
 
virtual bool WriteState (File &f) const
 
virtual vector< string > Commands () const
 
virtual bool SendCommand (const string &name, const string &str)
 
void SetPIDCommand (const Config &qdes)
 
void SetPIDCommand (const Config &qdes, const Config &dqdes)
 
void SetFeedforwardPIDCommand (const Config &qdes, const Config &dqdes, const Vector &torques)
 
void SetTorqueCommand (const Vector &torques)
 
bool GetCommandedConfig (Config &q)
 
bool GetCommandedVelocity (Config &dq)
 
bool GetSensedConfig (Config &q)
 
bool GetSensedVelocity (Config &dq)
 

Public Attributes

string servAddr
 
Real writeRate
 
Real lastWriteTime
 
shared_ptr< SocketPipeWorker > controllerPipe
 
Config vcmd
 
Real endVCmdTime
 
- Public Attributes inherited from RobotController
Robotrobot
 
Real time
 
Real nominalTimeStep
 a "desired" time step, by default 0, which acts as a hint to the simulator. Note that it doesn't have to abide the hint.
 
RobotSensorssensors
 sensor input (filled in by simulator)
 
RobotMotorCommandcommand
 motor command output (output to simulator)
 

Detailed Description

A controller that writes sensor data to a socket and reads robot commands from a socket.

Sensor data is given by string messages, formatted in JSON, prepended by 4 bytes of the string length. Messages are of the form: "{sensor1:[values1[0],...,values1[n1]],...,sensork:[valuesk[0],...valuesk[0]]}"

Command data is formatted the same way in JSON, prepended by 4 bytes of the string length. The commands are of the form: {command1:value1,...commandk:valuek} where command can be

Command data is read opportunistically. Sensor data is written at a given writeRate (in Hz)

Settings include


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