51 #if defined (PLAYER_STATIC)
52 #define PLAYERCORE_EXPORT
53 #elif defined (playercore_EXPORTS)
54 #define PLAYERCORE_EXPORT __declspec (dllexport)
56 #define PLAYERCORE_EXPORT __declspec (dllimport)
59 #define PLAYERCORE_EXPORT
64 #include <libplayercommon/playercommon.h>
65 #include <libplayercore/message.h>
66 #include <libplayerinterface/player.h>
67 #include <libplayercore/property.h>
86 #define HANDLE_CAPABILITY_REQUEST(device_addr, queue, hdr, data, cap_type, cap_subtype) \
87 if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ, PLAYER_CAPABILITIES_REQ, device_addr)) \
89 player_capabilities_req_t & cap_req = * reinterpret_cast<player_capabilities_req_t *> (data);\
90 if (cap_req.type == cap_type && cap_req.subtype == cap_subtype) \
92 Publish(device_addr, queue, PLAYER_MSGTYPE_RESP_ACK, PLAYER_CAPABILITIES_REQ); \
108 class PLAYERCORE_EXPORT
Driver
120 bool HasSubscriptions();
145 void SetError(
int code) {this->error = code;}
156 virtual bool Wait(
double TimeOut=0.0);
159 int AddFileWatch(
int fd,
bool ReadWatch =
true,
bool WriteWatch =
false,
bool ExceptWatch =
true);
162 int RemoveFileWatch(
int fd,
bool ReadWatch =
true,
bool WriteWatch =
false,
bool ExceptWatch =
true);
168 pthread_mutex_t accessMutex;
170 pthread_mutex_t subscriptionMutex;
174 virtual void Lock(
void);
176 virtual void Unlock(
void);
179 virtual void SubscriptionLock(
void);
181 virtual void SubscriptionUnlock(
void);
186 virtual void TestCancel() {};
217 double* timestamp=NULL,
238 double* timestamp=NULL,
309 bool overwrite_cmds =
true,
317 int GetError() {
return(this->error); }
377 virtual int Terminate();
386 virtual int Setup() {
return 0;};
393 virtual int Shutdown() {
return 0;};
402 void ProcessMessages(
int maxmsgs);
408 void ProcessMessages(
void);
423 virtual void Update()
425 this->ProcessMessages();
435 virtual int ProcessInternalMessages(
QueuePointer& resp_queue,
446 virtual bool RegisterProperty(
const char *key,
458 virtual bool RegisterProperty(
Property *property,
463 typedef enum player_thread_state
465 PLAYER_THREAD_STATE_STOPPED,
466 PLAYER_THREAD_STATE_RUNNING,
467 PLAYER_THREAD_STATE_STOPPING,
468 PLAYER_THREAD_STATE_RESTARTING
469 } player_thread_state_t;
476 pthread_mutex_init(&barrierMutex,NULL);
477 pthread_cond_init(&barrierCond,NULL);
482 pthread_mutex_destroy(&barrierMutex);
483 pthread_cond_destroy(&barrierCond);
486 int SetValue(
int Value)
488 return barrierValue = Value;
493 pthread_mutex_lock(&barrierMutex);
494 assert(barrierValue);
496 pthread_cond_wait(&barrierCond,&barrierMutex);
498 pthread_cond_broadcast(&barrierCond);
499 pthread_mutex_unlock(&barrierMutex);
505 pthread_mutex_t barrierMutex;
509 pthread_cond_t barrierCond;
560 virtual void StartThread(
void);
566 virtual void StopThread(
void);
570 static void* DummyMain(
void *driver);
574 static void DummyMainQuit(
void *driver);
580 pthread_t driverthread;
584 player_thread_state_t ThreadState;
585 bool SetupSuccessful;
620 bool overwrite_cmds =
true,
655 virtual void Main(
void) = 0;
658 virtual int MainSetup(
void) {
return 0;};
664 virtual void MainQuit(
void) {};
675 bool Wait(
double TimeOut=0.0);
virtual bool Wait(double TimeOut=0.0)
Wait for new data to arrive on the driver's queue.
#define PLAYER_MSG5(level, msg, a, b, c, d, e)
Error message macros.
Definition: error.h:109
#define PLAYER_WARN1(msg, a)
Error message macros.
Definition: error.h:89
position 2d velocity command
Definition: player_interfaces.h:617
player_pose2d_t vel
translational velocities [m/s,m/s,rad/s] (x, y, yaw)
Definition: player_interfaces.h:620
Command: state (PLAYER_POSITION1D_CMD_VEL)
Definition: player_interfaces.h:3570
uint32_t host
The "host" on which the device resides.
Definition: player.h:147
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:158
#define PLAYER_POSITION1D_DATA_STATE
Data subtype: state.
Definition: player_interfaces.h:3512
Data: state (PLAYER_POSITION1D_DATA_STATE)
Definition: player_interfaces.h:3542
double px
X [m].
Definition: player.h:230
A pose in the plane.
Definition: player.h:216
Generic message header.
Definition: player.h:160
#define PLAYER_POSITION1D_CMD_VEL
Command subtype: velocity command.
Definition: player_interfaces.h:3518
float vel
velocity [m/s] or [rad/s]
Definition: player_interfaces.h:3573
uint8_t type
Message type; must be one of PLAYER_MSGTYPE_*.
Definition: player.h:165
Encapsulates a device (i.e., a driver bound to an interface)
Definition: device.h:73
#define PLAYER_POSITION2D_REQ_MOTOR_POWER
Request/reply: Motor power.
Definition: player_interfaces.h:496
double px
X [m].
Definition: player.h:219
#define PLAYER_POSITION2D_REQ_POSITION_PID
Request/reply: Set position PID parameters.
Definition: player_interfaces.h:556
#define PLAYER_POSITION2D_CMD_VEL
Command: velocity (PLAYER_POSITION2D_CMD_VEL)
Definition: player_interfaces.h:581
Property base class.
Definition: property.h:58
double pyaw
yaw [rad]
Definition: player.h:240
uint8_t subtype
Message subtype; interface specific.
Definition: player.h:167
uint32_t robot
The "robot" or device collection in which the device resides.
Definition: player.h:150
#define PLAYER_POSITION1D_REQ_RESET_ODOM
Request/reply subtype: reset odometry.
Definition: player_interfaces.h:3500
Definition: position/differential/chronos.hh:27
#define PLAYER_MSG4(level, msg, a, b, c, d)
Error message macros.
Definition: error.h:108
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:94
double py
Y [m].
Definition: player.h:221
virtual void Update()
Update non-threaded drivers.
Definition: driver.h:422
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:111
player_pose3d_t pose
Pose of the robot base, in the robot cs (m, rad).
Definition: player_interfaces.h:658
Property bag class: stores registered properties.
Definition: property.h:206
#define PLAYER_POSITION2D_REQ_GET_GEOM
Request/reply: geometry.
Definition: player_interfaces.h:483
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:105
#define PLAYER_POSITION2D_REQ_SPEED_PROF
Request/reply: Set linear speed profile parameters.
Definition: player_interfaces.h:562
virtual void TestCancel()
enable thread cancellation and test for cancellation
Definition: driver.h:185
Request/reply: Set linear speed profile parameters.
Definition: player_interfaces.h:3703
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
speed prof req
Definition: player_interfaces.h:715
Class for loading configuration file information.
Definition: configfile.h:195
double sw
Width [m].
Definition: player.h:256
virtual int Setup()
Initialize the driver.
Definition: driver.h:385
float acc
max acceleration [m/s^2]
Definition: player_interfaces.h:720
A device address.
Definition: player.h:144
#define PLAYER_POSITION2D_REQ_RESET_ODOM
Request/reply: Reset odometry.
Definition: player_interfaces.h:541
An autopointer for the message queue.
Definition: message.h:72
double py
Y [m].
Definition: player.h:232
#define PLAYER_POSITION2D_REQ_POSITION_MODE
Request/reply: Change control mode.
Definition: player_interfaces.h:529
#define PLAYER_POSITION1D_REQ_SPEED_PROF
Request/reply subtype: set speed profile params.
Definition: player_interfaces.h:3509
position2d data
Definition: player_interfaces.h:606
#define PLAYER_ERROR1(msg, a)
Error message macros.
Definition: error.h:81
position2d geom
Definition: player_interfaces.h:655
uint32_t seq
For keeping track of associated messages.
Definition: player.h:171
Base class for drivers which oeprate with a thread.
Definition: driver.h:551
#define PLAYER_POSITION2D_DATA_STATE
Data: state (PLAYER_POSITION2D_DATA_STATE)
Definition: player_interfaces.h:568
virtual int Terminate()
Terminate the driver.
#define PLAYER_POSITION2D_CMD_POS
Command: position (PLAYER_POSITION2D_CMD_POS)
Definition: player_interfaces.h:588
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:88
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:98
virtual int Shutdown()
Finalize the driver.
Definition: driver.h:392
#define PLAYER_POSITION2D_REQ_SPEED_PID
Request/reply: Set velocity PID parameters.
Definition: player_interfaces.h:548
double pa
yaw [rad]
Definition: player.h:223
Base class for all drivers.
Definition: driver.h:107
#define PLAYER_WARN4(msg, a, b, c, d)
Error message macros.
Definition: error.h:92
float speed
max speed [m/s]
Definition: player_interfaces.h:718
player_bbox3d_t size
Dimensions of the base (m).
Definition: player_interfaces.h:660
uint16_t index
Which device of that interface.
Definition: player.h:154
player_devaddr_t addr
Device to which this message pertains.
Definition: player.h:163
uint16_t interf
The interface provided by the device; must be one of PLAYER_*_CODE.
Definition: player.h:152
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:75
#define PLAYER_POSITION2D_REQ_SET_ODOM
Request/reply: Set odometry.
Definition: player_interfaces.h:535