erratic/motorpacket.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 (ErraticMotorPackets)
28  */
29 #ifndef _ErraticMotorPacket_H
30 #define _ErraticMotorPacket_H
31 
32 #include <limits.h>
33 
34 #include "erratic.h"
35 
36 
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 ErraticMotorPacket
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  ErraticMotorPacket(int idx)
58  {
59  param_idx = idx;
60 
61  xpos = INT_MAX;
62  ypos = INT_MAX;
63  }
64 };
65 
66 #endif
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.
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
Encapsulates a device (i.e., a driver bound to an interface)
Definition: device.h:75
virtual void Main(void)=0
Main method for driver thread.
int ReadInt(int section, const char *name, int value)
Read an integer value.
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
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
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
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:197
A device address.
Definition: player.h:146
An autopointer for the message queue.
Definition: message.h:74
#define PLAYER_ERROR(msg)
Error message macros.
Definition: error.h:81
void Print()
Copyright (C) 2010 Ana Teresa Hernández Malagón anat.hernandezm@gmail.com Movirobotics athernandez@mo...
Definition: mbase/motorpacket.cc:45
Base class for drivers which oeprate with a thread.
Definition: driver.h:553
bool Parse(unsigned char *buffer, int length)
Parse -Parses and absorbs a standard packet from the robot.
Definition: mbase/motorpacket.cc:58
uint32_t size
Size in bytes of the payload to follow.
Definition: player.h:174
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
Base class for all drivers.
Definition: driver.h:109
void Fill(player_mbasedriver_data_t *data)
Fill.
Definition: mbase/motorpacket.cc:111
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76
Definition: erratic/motorpacket.h:38