garcia_mixed.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000 Brian Gerkey et al.
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  *
20  */
21 
22 #include <stdint.h>
23 
24 #include <libplayercore/playercore.h>
25 
26 #include "acpGarcia.h"
27 
29 // The class for the driver
31 {
32  public:
33 
34  // Constructor; need that
35  GarciaDriver(ConfigFile* cf, int section);
36 
37  virtual ~GarciaDriver();
38 
39  // Must implement the following methods.
40  int MainSetup();
41  void MainQuit();
42  // Main function for device thread.
43  virtual void Main();
44 
45  // This method will be invoked on each incoming message
46  virtual int ProcessMessage(QueuePointer & resp_queue,
47  player_msghdr * hdr,
48  void * data);
49  //void ProcessConfig();
50  void ProcessPos2dPosCmd(player_msghdr_t* hdr, player_position2d_cmd_pos_t &data);
51  void ProcessPos2dVelCmd(player_msghdr_t* hdr, player_position2d_cmd_vel_t &data);
52  void ProcessSpeechCommand(player_msghdr_t* hdr, player_speech_cmd_t &data);
53  void ProcessDioCommand(player_msghdr_t* hdr, player_dio_cmd_t &data);
54 
55  void ProcessPos2dGeomReq(player_msghdr_t* hdr);
56  void ProcessIrPoseReq(player_msghdr_t* hdr);
57 
58  void RefreshData();
59 
60  private:
61 
62  // position2d interface
63  player_devaddr_t mPos2dAddr;
64  player_position2d_data_t mPos2dData;
65  player_position2d_cmd_pos_t mPos2dPosCmd;
66  player_position2d_cmd_vel_t mPos2dVelCmd;
67 
68  // ir interface
69  player_devaddr_t mIrAddr;
70  player_ir_data_t mIrData;
71 
72  // speech interface
73  player_devaddr_t mSpeechAddr;
74  player_speech_cmd_t mSpeechCmd;
75 
76  // dio interface
77  player_devaddr_t mDioAddr;
78  player_dio_data_t mDioData;
79  player_dio_cmd_t mDioCmd;
80 
81  // power interface
82  player_devaddr_t mPowerAddr;
83  player_power_data_t mPowerData;
84 
85  int32_t mSleep;
86 
87  double mLength;
88  double mWidth;
89  double mWheelBase;
90  double mWheelRadius;
91 
92  acpValue mSpeed;
93  acpValue mPitch;
94  acpValue mVolume;
95 
96  acpGarcia* mGarcia;
97 };
int MainSetup()
Sets up the resources needed by the driver thread.
Definition: garcia_mixed.cc:280
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.
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
uint8_t type
Message type; must be one of PLAYER_MSGTYPE_*.
Definition: player.h:166
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.
void ProcessMessages(void)
Process pending messages.
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:112
#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_ERROR1(msg, a)
Error message macros.
Definition: error.h:82
A pose in space.
Definition: player.h:229
#define PLAYER_ERROR(msg)
Error message macros.
Definition: error.h:81
virtual void Main()
Main method for driver thread.
Definition: garcia_mixed.cc:320
Base class for drivers which oeprate with a thread.
Definition: driver.h:553
void MainQuit()
Cleanup method for driver thread (called when main exits)
Definition: garcia_mixed.cc:308
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
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
Definition: garcia_mixed.cc:344
Definition: garcia_mixed.h:31