erratic/sip.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000
4  * Brian Gerkey, Kasper Stoy, Richard Vaughan, & Andrew Howard
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  */
22 
23 /*
24  * $Id$
25  *
26  * part of the P2OS parser. methods for filling and parsing server
27  * information packets (SIPs)
28  */
29 #ifndef _SIP_H
30 #define _SIP_H
31 
32 #include <limits.h>
33 
34 #include "erratic.h"
35 
36 
37 class erSIP
38 {
39  private:
40  int PositionChange( unsigned short, unsigned short );
41  int param_idx; // index of our robot's data in the parameter table
42 
43  public:
44  // these values are returned in every standard SIP
45  bool lwstall, rwstall;
46  unsigned char status, battery;
47  unsigned short ptu, timer, rawxpos;
48  unsigned short rawypos;
49  short angle, lvel, rvel, control;
50  int xpos, ypos;
51  int x_offset,y_offset,angle_offset;
52 
53  bool Parse( unsigned char *buffer, int length );
54  void Print();
55  void Fill(player_erratic_data_t* data);
56 
57  erSIP(int idx)
58  {
59  param_idx = idx;
60 
61  xpos = INT_MAX;
62  ypos = INT_MAX;
63  }
64 };
65 
66 #endif
T min(T a, T b)
Return the minimum of a, b.
Definition: utility.h:91
Request to get an integer property.
Definition: player.h:459
#define PLAYER_WARN1(msg, a)
Definition: error.h:90
Definition: nav200.h:82
String Property Class.
Definition: property.h:171
#define PLAYER_MSG1(level, msg, a)
Definition: error.h:106
#define PLAYER_MSG3(level, msg, a, b, c)
Definition: error.h:108
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
double ReadFloat(int section, const char *name, double value)
Read a floating point (double) value.
Definition: nav200.h:89
A pose in the plane.
Definition: player.h:218
Definition: nav200.h:97
#define PLAYER_SET_STRPROP_REQ
String property set request subtype.
Definition: player.h:440
Definition: erratic/sip.h:38
double ReadTupleLength(int section, const char *name, int index, double value)
Read a length from a tuple (includes units conversion)
Generic message header.
Definition: player.h:162
virtual int MainSetup(void)
Sets up the resources needed by the driver thread.
Definition: driver.h:658
virtual void MainQuit(void)
Cleanup method for driver thread (called when main exits)
Definition: driver.h:664
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:75
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
double px
X [m].
Definition: player.h:220
double x1
Endpoints [m].
Definition: player.h:314
uint8_t subtype
Message subtype; interface specific.
Definition: player.h:168
double ReadTupleFloat(int section, const char *name, int index, double value)
Read a float (double) from a tuple field.
virtual void Main(void)=0
Main method for driver thread.
Definition: lms400_cola.h:64
const char * ReadFilename(int section, const char *name, const char *value)
Read a filename.
int ReadInt(int section, const char *name, int value)
Read an integer value.
double ReadLength(int section, const char *name, double value)
Read a length (includes unit conversion, if any).
void * GetPayload()
Get pointer to payload.
Definition: message.h:188
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
double py
Y [m].
Definition: player.h:222
#define PLAYER_ERROR2(msg, a, b)
Definition: error.h:83
int32_t value
The property value.
Definition: player.h:465
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:112
#define PLAYER_WARN2(msg, a, b)
Definition: error.h:91
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
static bool MatchDeviceAddress(player_devaddr_t addr1, player_devaddr_t addr2)
Compare two addresses.
Definition: device.h:201
A rectangular bounding box, used to define the origin and bounds of an object.
Definition: player.h:308
virtual int MainSetup()
Sets up the resources needed by the driver thread.
Definition: imagebase.cc:83
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
virtual void MainQuit()
Cleanup method for driver thread (called when main exits)
Definition: imagebase.cc:104
double x0
Origin x [m].
Definition: player.h:310
#define PLAYER_MSGTYPE_RESP_NACK
A negative response message.
Definition: player.h:125
Integer property class.
Definition: property.h:115
Definition: imagebase.h:62
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
int GetTupleCount(int section, const char *name)
Get the number of values in a tuple.
Class for loading configuration file information.
Definition: configfile.h:197
int ReadTupleInt(int section, const char *name, int index, int value)
Read an integer from a tuple field.
#define PLAYER_CAPABILITIES_REQ
Capability request message type.
Definition: player.h:397
A device address.
Definition: player.h:146
An autopointer for the message queue.
Definition: message.h:74
Double property class.
Definition: property.h:143
Definition: p2os/sip.h:37
char * key
The property key.
Definition: player.h:485
double y0
Origin y [m].
Definition: player.h:312
#define PLAYER_ERROR1(msg, a)
Definition: error.h:82
Definition: rfi341_protocol.h:43
#define PLAYER_ERROR(msg)
Definition: error.h:81
Base class for drivers which oeprate with a thread.
Definition: driver.h:553
uint32_t size
Size in bytes of the payload to follow.
Definition: player.h:174
char * key
The property key.
Definition: player.h:463
Reference-counted message objects.
Definition: message.h:133
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
double y1
Endpoints [m].
Definition: player.h:316
double pa
yaw [rad]
Definition: player.h:224
Base class for all drivers.
Definition: driver.h:109
Request to get a string property.
Definition: player.h:481
Definition: nav200.h:116
#define PLAYER_MSG0(level, msg)
General messages.
Definition: error.h:105
#define PLAYER_MSG2(level, msg, a, b)
Definition: error.h:107
void ParseSERAUX(unsigned char *buffer)
Parse a SERAUX SIP packet.
Definition: p2os/sip.cc:488
#define PLAYER_SET_INTPROP_REQ
Integer property set request subtype.
Definition: player.h:432
player_msghdr_t * GetHeader()
Get pointer to header.
Definition: message.h:186
player_devaddr_t addr
Device to which this message pertains.
Definition: player.h:164
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76
T max(T a, T b)
Return the maximum of a, b.
Definition: utility.h:104