50 #if defined (PLAYER_STATIC)
51 #define PLAYERCORE_EXPORT
52 #elif defined (playercore_EXPORTS)
53 #define PLAYERCORE_EXPORT __declspec (dllexport)
55 #define PLAYERCORE_EXPORT __declspec (dllimport)
58 #define PLAYERCORE_EXPORT
63 #include <libplayerinterface/player.h>
96 bool operator == (
void * pointer);
100 bool operator != (
void * pointer);
164 return(((type < 0) || (hdr->
type == (uint8_t)type)) &&
165 ((subtype < 0) || (hdr->
subtype == (uint8_t)subtype)) &&
181 return(((type < 0) || (hdr->
type == (uint8_t)type)) &&
182 ((subtype < 0) || (hdr->
subtype == (uint8_t)subtype)));
248 int host, robot, interf, index;
253 int _type,
int _subtype,
int _replace) :
254 host(_host), robot(_robot), interf(_interf), index(_index),
255 type(_type), subtype(_subtype), replace(_replace), next(NULL) {}
259 return(((this->host < 0) ||
260 ((uint32_t)this->host == hdr->
addr.
host)) &&
261 ((this->robot < 0) ||
262 ((uint32_t)this->robot == hdr->
addr.
robot)) &&
263 ((this->interf < 0) ||
264 ((uint16_t)this->interf == hdr->
addr.
interf)) &&
265 ((this->index < 0) ||
266 ((uint16_t)this->index == hdr->
addr.
index)) &&
268 ((uint8_t)this->type == hdr->
type)) &&
269 ((this->subtype < 0) ||
270 ((uint8_t)this->subtype == hdr->
subtype)));
273 bool Equivalent (
int _host,
int _robot,
int _interf,
int _index,
int _type,
int _subtype)
275 return (host == _host && robot == _robot && interf ==_interf && index == _index &&
276 type == _type && subtype == _subtype);
345 bool Empty() {
return(this->head == NULL); }
354 void PushFront(
Message & msg,
bool haveLock);
360 void PushBack(
Message & msg,
bool haveLock);
369 void SetReplace(
bool _Replace) { this->Replace = _Replace; };
376 void AddReplaceRule(
int _host,
int _robot,
int _interf,
int _index,
377 int _type,
int _subtype,
int _replace);
384 int _type,
int _subtype,
int _replace);
394 bool Wait(
double TimeOut=0.0);
397 void DataAvailable(
void);
401 void ClearFilter(
void);
403 void SetFilter(
int host,
int robot,
int interf,
int index,
404 int type,
int subtype);
406 void SetPull (
bool _pull) { this->pull = _pull; }
409 size_t GetLength(
void);
412 void SetDataRequested(
bool d,
bool haveLock);
416 void Lock() {pthread_mutex_lock(&lock);};
418 void Unlock() {pthread_mutex_unlock(&lock);};
445 int filter_host, filter_robot, filter_interf,
446 filter_index, filter_type, filter_subtype;
#define PLAYER_WARN1(msg, a)
Error message macros.
Definition: error.h:90
position 2d velocity command
Definition: player_interfaces.h:617
unsigned int * RefCount
Reference count.
Definition: message.h:110
unsigned int * RefCount
Reference count.
Definition: message.h:200
player_pose2d_t vel
translational velocities [m/s,m/s,rad/s] (x, y, yaw)
Definition: player_interfaces.h:620
uint32_t host
The "host" on which the device resides.
Definition: player.h:148
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
QueuePointer Queue
queue to which any response to this message should be directed
Definition: message.h:197
uint8_t * Data
Pointer to the message data.
Definition: message.h:210
double ReadFloat(int section, const char *name, double value)
Read a floating point (double) value.
MessageQueue * Queue
The queue we are pointing to.
Definition: message.h:107
A pose in the plane.
Definition: player.h:217
#define PLAYER_LASER_DATA_SCANPOSE
Data subtype: pose-stamped scan.
Definition: player_interfaces.h:848
Generic message header.
Definition: player.h:161
unsigned int GetDataSize()
Size of message data.
Definition: message.h:190
bool drop_count
Count of the number of messages discarded due to queue overflow.
Definition: message.h:456
float max_angle
Start and end angles for the laser scan [rad].
Definition: player_interfaces.h:888
MessageQueueElement * head
Head of the queue.
Definition: message.h:423
virtual int MainSetup(void)
Sets up the resources needed by the driver thread.
Definition: driver.h:658
pthread_mutex_t * Lock
Used to lock access to refcount.
Definition: message.h:113
pthread_mutex_t * Lock
Used to lock access to Data.
Definition: message.h:212
player_msghdr_t Header
message header
Definition: message.h:208
virtual void MainQuit(void)
Cleanup method for driver thread (called when main exits)
Definition: driver.h:664
MessageQueueElement * next
Pointer to next queue element.
Definition: message.h:232
pthread_cond_t cond
A condition variable that can be used to signal, via DataAvailable(), other threads that are Wait()in...
Definition: message.h:440
uint8_t type
Message type; must be one of PLAYER_MSGTYPE_*.
Definition: player.h:166
Encapsulates a device (i.e., a driver bound to an interface)
Definition: device.h:74
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
double px
X [m].
Definition: player.h:220
MessageQueueElement * tail
Tail of the queue.
Definition: message.h:425
bool filter_on
Current filter values.
Definition: message.h:444
We keep a singly-linked list of (addr,type,subtype,replace) tuples.
Definition: message.h:243
#define PLAYER_POSITION2D_CMD_VEL
Command: velocity (PLAYER_POSITION2D_CMD_VEL)
Definition: player_interfaces.h:581
uint8_t subtype
Message subtype; interface specific.
Definition: player.h:168
uint32_t robot
The "robot" or device collection in which the device resides.
Definition: player.h:151
virtual void Main(void)=0
Main method for driver thread.
const char * ReadTupleString(int section, const char *name, int index, const char *value)
Read a string from a tuple field.
int ReadInt(int section, const char *name, int value)
Read an integer value.
void * GetPayload()
Get pointer to payload.
Definition: message.h:188
player_pose2d_t pose
The global pose of the laser at the time the scan was acquired.
Definition: player_interfaces.h:914
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
double py
Y [m].
Definition: player.h:222
bool pull
Flag for if in pull mode.
Definition: message.h:449
void SetReplace(bool _Replace)
Set the Replace flag, which governs whether data and command messages of the same subtype from the sa...
Definition: message.h:369
player_laser_data_t scan
The scan data.
Definition: player_interfaces.h:912
void Unlock()
Unlock the mutex associated with this queue.
Definition: message.h:418
uint32_t id
A unique, increasing, ID for the scan.
Definition: player_interfaces.h:902
float * ranges
Range readings [m].
Definition: player_interfaces.h:896
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
bool Replace
When a (data or command) message doesn't match a rule in replaceRules, should we replace it?
Definition: message.h:434
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
Class for loading configuration file information.
Definition: configfile.h:196
A device address.
Definition: player.h:145
An autopointer for the message queue.
Definition: message.h:73
size_t Length
Current length of queue, in elements.
Definition: message.h:436
pthread_mutex_t lock
Mutex to control access to the queue, via Lock() and Unlock().
Definition: message.h:427
Message * msg
The message stored in this queue element.
Definition: message.h:227
pthread_mutex_t condMutex
Mutex to go with condition variable cond.
Definition: message.h:442
MessageReplaceRule * replaceRules
Singly-linked list of replacement rules.
Definition: message.h:431
position2d data
Definition: player_interfaces.h:606
bool Empty()
Check whether a queue is empty.
Definition: message.h:345
A doubly-linked queue of messages.
Definition: message.h:337
This class is a helper for maintaining doubly-linked queues of Messages.
Definition: message.h:218
#define PLAYER_ERROR(msg)
Error message macros.
Definition: error.h:81
float min_angle
Start and end angles for the laser scan [rad].
Definition: player_interfaces.h:886
Base class for drivers which oeprate with a thread.
Definition: driver.h:552
#define PLAYER_POSITION2D_DATA_STATE
Data: state (PLAYER_POSITION2D_DATA_STATE)
Definition: player_interfaces.h:568
float max_range
Maximum range [m].
Definition: player_interfaces.h:892
double timestamp
Time associated with message contents (seconds since epoch)
Definition: player.h:170
void SetPull(bool _pull)
Set the pull flag.
Definition: message.h:406
player_pose2d_t pos
position [m,m,rad] (x, y, yaw)
Definition: player_interfaces.h:609
uint32_t size
Size in bytes of the payload to follow.
Definition: player.h:174
bool data_delivered
Flag that data was sent (in PULL mode)
Definition: message.h:454
Reference-counted message objects.
Definition: message.h:132
size_t Maxlen
Maximum length of queue in elements.
Definition: message.h:429
void Lock()
Lock the mutex associated with this queue.
Definition: message.h:416
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
MessageQueueElement * prev
Pointer to previous queue element.
Definition: message.h:230
double pa
yaw [rad]
Definition: player.h:224
Base class for all drivers.
Definition: driver.h:108
bool data_requested
Flag for data was requested (in PULL mode), but none has yet been delivered.
Definition: message.h:452
uint32_t intensity_count
Number of intensity readings.
Definition: player_interfaces.h:898
#define PLAYER_POSITION2D_DATA_GEOM
Data: geometry.
Definition: player_interfaces.h:574
Data: pose-stamped scan (PLAYER_LASER_DATA_SCANPOSE)
Definition: player_interfaces.h:909
float resolution
Angular resolution [rad].
Definition: player_interfaces.h:890
uint32_t ranges_count
Number of range readings.
Definition: player_interfaces.h:894
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype)
Helper for message processing.
Definition: message.h:177
Data: scan (PLAYER_LASER_DATA_SCAN)
Definition: player_interfaces.h:883
player_msghdr_t * GetHeader()
Get pointer to header.
Definition: message.h:186
uint16_t index
Which device of that interface.
Definition: player.h:155
player_devaddr_t addr
Device to which this message pertains.
Definition: player.h:164
uint16_t interf
The interface provided by the device; must be one of PLAYER_*_CODE.
Definition: player.h:153
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76
position2d position command
Definition: player_interfaces.h:626
uint8_t * intensity
Intensity readings.
Definition: player_interfaces.h:900