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

Public Member Functions

 P2OS (ConfigFile *cf, int section)
 
virtual int Subscribe (player_devaddr_t id)
 Subscribe to this driver. More...
 
virtual int Unsubscribe (player_devaddr_t id)
 Unsubscribe from this driver. More...
 
virtual void Main ()
 Main method for driver thread. More...
 
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...
 
void CMUcamReset (bool doLock=true)
 
void CMUcamTrack (int rmin=0, int rmax=0, int gmin=0, int gmax=0, int bmin=0, int bmax=0)
 
void CMUcamStartTracking (bool doLock=true)
 
void CMUcamStopTracking (bool doLock=true)
 
- 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 (QueuePointer &, player_devaddr_t)
 Subscribe to 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...
 

Private Member Functions

int SendReceive (P2OSPacket *pkt, bool publish_data=true)
 
void ResetRawPositions ()
 
void ToggleSonarPower (unsigned char val)
 
void ToggleMotorPower (unsigned char val)
 
int HandleConfig (QueuePointer &resp_queue, player_msghdr *hdr, void *data)
 
int HandleCommand (player_msghdr *hdr, void *data)
 
void StandardSIPPutData (double timestampStandardSIP)
 
void GyroPutData (double timestampGyro)
 
void BlobfinderPutData (double timestampSERAUX)
 
void ActarrayPutData (double timestampArm)
 
void HandlePositionCommand (player_position2d_cmd_vel_t position_cmd)
 
int HandleGripperCommand (player_msghdr *hdr, void *data)
 
int HandleLiftCommand (player_msghdr *hdr, void *data)
 
int HandleArmGripperCommand (player_msghdr *hdr, void *data)
 
void HandleAudioCommand (player_audio_sample_item_t audio_cmd)
 
void get_ptz_packet (int s1, int s2=0)
 
int SetupPtz ()
 
void OpenGripper (void)
 
void CloseGripper (void)
 
void StopGripper (void)
 
void OpenArmGripper (void)
 
void CloseArmGripper (void)
 
void StopArmGripper (void)
 
double TicksToDegrees (int joint, unsigned char ticks)
 
unsigned char DegreesToTicks (int joint, double degrees)
 
double TicksToRadians (int joint, unsigned char ticks)
 
unsigned char RadiansToTicks (int joint, double rads)
 
double RadsPerSectoSecsPerTick (int joint, double speed)
 
double SecsPerTicktoRadsPerSec (int joint, double secs)
 
void ToggleActArrayPower (unsigned char val, bool lock=true)
 
void SetActArrayJointSpeed (int joint, double speed)
 
void HandleActArrayPosCmd (player_actarray_position_cmd_t cmd)
 
void HandleActArrayHomeCmd (player_actarray_home_cmd_t cmd)
 
int HandleActArrayCommand (player_msghdr *hdr, void *data)
 
void HandleLimbHomeCmd (void)
 
void HandleLimbStopCmd (void)
 
void HandleLimbSetPoseCmd (player_limb_setpose_cmd_t cmd)
 
void HandleLimbSetPositionCmd (player_limb_setposition_cmd_t cmd)
 
void HandleLimbVecMoveCmd (player_limb_vecmove_cmd_t cmd)
 
int HandleLimbCommand (player_msghdr *hdr, void *data)
 
int SendCommand (unsigned char *str, int len)
 
int SendRequest (unsigned char *str, int len, unsigned char *reply, uint8_t camera=1)
 
void PrintPacket (char *str, unsigned char *cmd, int len)
 
int SendAbsPanTilt (int pan, int tilt)
 
int setDefaultTiltRange ()
 
int GetAbsPanTilt (int *pan, int *tilt)
 
int GetAbsZoom (int *zoom)
 
int SendAbsZoom (int zoom)
 
int read_ptz (unsigned char *reply, int size)
 
int ReceiveCommandAnswer (int asize)
 
int ReceiveRequestAnswer (unsigned char *data, int s1, int s2)
 
int setControlMode ()
 
int setNotifyCommand ()
 
int setPower (int on)
 
int setOnScreenOff ()
 
int CheckHostControlMode ()
 
int sendInit ()
 
int GetMaxZoom (int *maxzoom)
 
void SendPulse (void)
 

Private Attributes

player_p2os_data_t p2os_data
 
player_devaddr_t position_id
 
player_devaddr_t sonar_id
 
player_devaddr_t aio_id
 
player_devaddr_t dio_id
 
player_devaddr_t gripper_id
 
player_devaddr_t lift_id
 
player_devaddr_t bumper_id
 
player_devaddr_t power_id
 
player_devaddr_t compass_id
 
player_devaddr_t gyro_id
 
player_devaddr_t blobfinder_id
 
player_devaddr_t audio_id
 
player_devaddr_t actarray_id
 
player_devaddr_t limb_id
 
player_devaddr_t ptz_id
 
player_devaddr_t armgripper_id
 
bool sentGripperCmd
 
uint8_t lastGripperCmd
 
uint8_t lastLiftCmd
 
player_actarray_position_cmd_t lastLiftPosCmd
 
bool sentArmGripperCmd
 
uint8_t lastArmGripperCmd
 
uint8_t lastActArrayCmd
 
player_actarray_position_cmd_t lastActArrayPosCmd
 
player_actarray_home_cmd_t lastActArrayHomeCmd
 
bool sent_audio_cmd
 
player_audio_sample_item_t last_audio_cmd
 
int rot_kp
 
int rot_kv
 
int rot_ki
 
int trans_kp
 
int trans_kv
 
int trans_ki
 
int position_subscriptions
 
int sonar_subscriptions
 
int actarray_subscriptions
 
int ptz_subscriptions
 
SIPsippacket
 
player_pose3d_t gripperPose
 
player_bbox3d_t gripperOuterSize
 
player_bbox3d_t gripperInnerSize
 
player_bbox3d_t armGripperOuterSize
 
player_bbox3d_t armGripperInnerSize
 
double aaLengths [6]
 
double aaOrients [18]
 
double aaAxes [18]
 
player_point_3d_t aaBasePos
 
player_orientation_3d_t aaBaseOrient
 
KineCalckineCalc
 
float armOffsetX
 
float armOffsetY
 
float armOffsetZ
 
player_limb_data_t limb_data
 
int param_idx
 
int direct_wheel_vel_control
 
int psos_fd
 
const char * psos_serial_port
 
bool psos_use_tcp
 
const char * psos_tcp_host
 
int psos_tcp_port
 
struct timeval lastblob_tv
 
int motor_max_speed
 
int motor_max_turnspeed
 
bool use_vel_band
 
short motor_max_trans_accel
 
short motor_max_trans_decel
 
short motor_max_rot_accel
 
short motor_max_rot_decel
 
int radio_modemp
 
int joystickp
 
int bumpstall
 
bool ignore_checksum
 
player_ptz_data_t ptz_data
 
int maxfov
 
int minfov
 
int maxzoom
 
int pandemand
 
int tiltdemand
 
int zoomdemand
 
circbuf cb
 
float pulse
 
double lastPulseTime
 

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 P2OS::Main ( )
virtual

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.

Implements ThreadedDriver.

References PlayerCc::min(), PLAYER_LIMB_STATE_COLL, PLAYER_LIMB_STATE_IDLE, PLAYER_LIMB_STATE_MOVING, and PLAYER_LIMB_STATE_OOR.

Here is the call graph for this function:

◆ MainQuit()

void P2OS::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.

◆ ProcessMessage()

int P2OS::ProcessMessage ( QueuePointer resp_queue,
player_msghdr hdr,
void *  data 
)
virtual

Message handler.

This function is called once for each message in the incoming queue. Reimplement it to provide message handling. Return 0 if you handled the message and -1 otherwise

Parameters
resp_queueThe queue to which any response should go.
hdrThe message header
dataThe message body

Reimplemented from Driver.

References player_actarray_geom::actuators, player_actarray_geom::actuators_count, player_limb_setpose_cmd::approach, player_blobfinder_imager_config::autogain, player_actarray_actuatorgeom::axis, player_actarray_geom::base_orientation, player_actarray_geom::base_pos, player_limb_geom_req::basePos, player_blobfinder_color_config::bmax, player_blobfinder_color_config::bmin, player_blobfinder_imager_config::brightness, player_bumper_geom::bumper_def, player_bumper_geom::bumper_def_count, player_gripper_geom::capacity, player_actarray_actuatorgeom::centre, player_blobfinder_imager_config::colormode, player_ptz_req_generic::config, player_ptz_req_generic::config_count, player_actarray_actuatorgeom::config_speed, player_blobfinder_imager_config::contrast, player_limb_vecmove_cmd::direction, player_blobfinder_color_config::gmax, player_blobfinder_color_config::gmin, player_actarray_actuatorgeom::hasbrakes, player_actarray_actuatorgeom::home, player_audio_sample_item::index, player_gripper_geom::inner_size, player_actarray_position_cmd::joint, player_actarray_home_cmd::joint, player_bumper_define::length, player_actarray_actuatorgeom::length, player_limb_vecmove_cmd::length, Message::MatchMessage(), player_actarray_actuatorgeom::max, player_actarray_actuatorgeom::min, player_gripper_geom::num_beams, player_actarray_actuatorgeom::orientation, player_limb_setpose_cmd::orientation, player_gripper_geom::outer_size, player_pose2d::pa, PLAYER_ACTARRAY_CMD_HOME, PLAYER_ACTARRAY_CMD_MULTI_POS, PLAYER_ACTARRAY_CMD_POS, PLAYER_ACTARRAY_REQ_GET_GEOM, PLAYER_ACTARRAY_REQ_POWER, PLAYER_ACTARRAY_REQ_SPEED, PLAYER_ACTARRAY_TYPE_LINEAR, PLAYER_ACTARRAY_TYPE_ROTARY, PLAYER_AUDIO_CMD_SAMPLE_PLAY, PLAYER_BLOBFINDER_REQ_SET_COLOR, PLAYER_BLOBFINDER_REQ_SET_IMAGER_PARAMS, PLAYER_BUMPER_REQ_GET_GEOM, PLAYER_CAPABILITIES_REQ, PLAYER_ERROR, PLAYER_GRIPPER_CMD_CLOSE, PLAYER_GRIPPER_CMD_OPEN, PLAYER_GRIPPER_CMD_STOP, PLAYER_GRIPPER_REQ_GET_GEOM, PLAYER_LIMB_CMD_HOME, PLAYER_LIMB_CMD_SETPOSE, PLAYER_LIMB_CMD_STOP, PLAYER_LIMB_REQ_BRAKES, PLAYER_LIMB_REQ_GEOM, PLAYER_LIMB_REQ_POWER, PLAYER_LIMB_REQ_SPEED, PLAYER_LIMB_STATE_MOVING, PLAYER_LIMB_STATE_OOR, PLAYER_MSGTYPE_CMD, PLAYER_MSGTYPE_REQ, PLAYER_MSGTYPE_RESP_ACK, PLAYER_MSGTYPE_RESP_NACK, PLAYER_POSITION2D_CMD_VEL, PLAYER_POSITION2D_REQ_GET_GEOM, PLAYER_POSITION2D_REQ_MOTOR_POWER, PLAYER_POSITION2D_REQ_RESET_ODOM, PLAYER_POSITION2D_REQ_SET_ODOM, PLAYER_POSITION2D_REQ_VELOCITY_MODE, PLAYER_PTZ_REQ_GENERIC, PLAYER_SONAR_REQ_GET_GEOM, PLAYER_SONAR_REQ_POWER, PLAYER_WARN, player_gripper_geom::pose, player_position2d_geom::pose, player_position2d_set_odom_req::pose, player_bumper_define::pose, player_sonar_geom::poses, player_sonar_geom::poses_count, player_actarray_position_cmd::position, player_limb_setpose_cmd::position, player_limb_setposition_cmd::position, player_actarray_multi_position_cmd::positions, player_actarray_multi_position_cmd::positions_count, player_orientation_3d::ppitch, player_orientation_3d::proll, player_point_3d::px, player_pose2d::px, player_pose3d::px, player_point_3d::py, player_pose2d::py, player_pose3d::py, player_orientation_3d::pyaw, player_pose3d::pyaw, player_point_3d::pz, player_bumper_define::radius, player_blobfinder_color_config::rmax, player_blobfinder_color_config::rmin, player_msghdr::size, player_position2d_geom::size, player_bbox3d::sl, player_position2d_power_config::state, player_sonar_power_config::state, player_msghdr::subtype, player_bbox3d::sw, player_msghdr::type, player_actarray_actuatorgeom::type, player_position2d_velocity_mode_config::value, and player_position2d_cmd_vel::vel.

Here is the call graph for this function:

◆ Subscribe()

int P2OS::Subscribe ( player_devaddr_t  addr)
virtual

Subscribe to this driver.

The Subscribe() and Unsubscribe() methods are used to control subscriptions to the driver; a driver MAY override them, but usually won't.

Parameters
addrAddress of the device to subscribe to (the driver may have more than one interface).
Returns
Returns 0 on success.

Reimplemented from Driver.

References Device::MatchDeviceAddress(), and Driver::Subscribe().

Here is the call graph for this function:

◆ Unsubscribe()

int P2OS::Unsubscribe ( player_devaddr_t  addr)
virtual

Unsubscribe from this driver.

The Subscribe() and Unsubscribe() methods are used to control subscriptions to the driver; a driver MAY override them, but usually won't.

Parameters
addrAddress of the device to unsubscribe from (the driver may have more than one interface).
Returns
Returns 0 on success.

Reimplemented from Driver.

References Device::MatchDeviceAddress(), PLAYER_ACTARRAY_DATA_STATE, PLAYER_AIO_DATA_STATE, PLAYER_BLOBFINDER_DATA_BLOBS, PLAYER_BUMPER_DATA_STATE, PLAYER_DIO_DATA_VALUES, PLAYER_GRIPPER_DATA_STATE, PLAYER_LIMB_DATA_STATE, PLAYER_MSGTYPE_DATA, PLAYER_POSITION2D_DATA_STATE, PLAYER_POWER_DATA_STATE, PLAYER_PTZ_DATA_STATE, PLAYER_SONAR_DATA_RANGES, and Driver::Unsubscribe().

Here is the call graph for this function:

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