epuckDriver.hpp
Go to the documentation of this file.
1 /* Copyright 2008 Renato Florentino Garcia <fgar.renato@gmail.com>
2  *
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2, as
5  * published by the Free Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 #ifndef EPUCK_DRIVER2_1_HPP
17 #define EPUCK_DRIVER2_1_HPP
18 
19 #include <libplayercore/playercore.h>
20 #include <string>
21 #include <memory>
22 #include "serialPort.hpp"
23 #include "epuckPosition2d.hpp"
24 #include "epuckIR.hpp"
25 #include "epuckCamera.hpp"
26 #include "epuckLEDs.hpp"
27 
42 {
43 public:
44 
45  EpuckDriver(ConfigFile* cf, int section);
46 
47  ~EpuckDriver();
48 
49  virtual int MainSetup();
50 
51  virtual void MainQuit();
52 
53  virtual int ProcessMessage(QueuePointer &resp_queue,
54  player_msghdr* hdr, void* data);
55 
56  virtual int Subscribe(player_devaddr_t addr);
57 
58  virtual int Unsubscribe(player_devaddr_t addr);
59 
60  static Driver* EpuckDriver_Init(ConfigFile* cf, int section);
61 
62 private:
63 
64  const unsigned EXPECTED_EPUCK_SIDE_VERSION;
65 
66  virtual void Main();
67 
68  player_devaddr_t position2dAddr;
70  std::auto_ptr<EpuckPosition2d> epuckPosition2d;
71 
72  player_devaddr_t irAddr;
73  player_ir_data_t irData;
74  std::auto_ptr<EpuckIR> epuckIR;
75 
76  player_devaddr_t cameraAddr;
77  player_camera_data_t cameraData;
78  std::auto_ptr<EpuckCamera> epuckCamera;
79 
82  player_devaddr_t frontLEDAddr;
83  player_blinkenlight_data_t frontLEDData;
84  player_devaddr_t bodyLEDAddr;
85  player_blinkenlight_data_t bodyLEDData;
86  std::auto_ptr<EpuckLEDs> epuckLEDs;
87 
88  SerialPort* serialPort;
89 };
90 
91 #endif
position 2d velocity command
Definition: player_interfaces.h:617
This class controls the turn on and turn off of e-puck LEDs.
Definition: epuckLEDs.hpp:31
#define PLAYER_MSG1(level, msg, a)
Error message macros.
Definition: error.h:106
virtual int Subscribe(player_devaddr_t addr)
Subscribe to this driver.
double velocity
forward velocity (m/s)
Definition: player_interfaces.h:640
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.
player_pose2d_t vel
translational velocities [m/s,m/s,rad/s] (x, y, yaw)
Definition: player_interfaces.h:620
uint8_t enable
FALSE: off, TRUE: on.
Definition: player_interfaces.h:2863
#define PLAYER_IR_DATA_RANGES
Data subtype: ranges.
Definition: player_interfaces.h:2108
Data: state (PLAYER_BLINKENLIGHT_DATA_STATE) The blinkenlight data provides the current state of the ...
Definition: player_interfaces.h:2826
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
#define PLAYER_CAMERA_FORMAT_RGB565
Image format : 16-bit color (5 bits R, 6 bits G, 5 bits B).
Definition: player_interfaces.h:2940
float x
x component.
Definition: epuckInterface.hpp:40
double px
X [m].
Definition: player.h:231
uint32_t poses_count
the number of ir samples returned by this robot
Definition: player_interfaces.h:2133
Struct which represents the pose and velocity of e-puck.
Definition: epuckPosition2d.hpp:45
Generic message header.
Definition: player.h:161
virtual int MainSetup()
Sets up the resources needed by the driver thread.
Definition: epuckDriver.cpp:222
uint32_t compression
Image compression; PLAYER_CAMERA_COMPRESS_RAW indicates no compression.
Definition: player_interfaces.h:2966
uint32_t width
Image dimensions [pixels].
Definition: player_interfaces.h:2953
#define PLAYER_IR_REQ_POSE
Request/reply subtype: get pose.
Definition: player_interfaces.h:2102
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
double px
X [m].
Definition: player.h:220
Request/reply: get pose.
Definition: player_interfaces.h:2130
@ RGB_565_MODE
RGB color mode, with 16 bits per pixel.
Definition: epuckCamera.hpp:83
virtual void Main()
Main method for driver thread.
Definition: epuckDriver.cpp:456
#define PLAYER_POSITION2D_CMD_VEL
Command: velocity (PLAYER_POSITION2D_CMD_VEL)
Definition: player_interfaces.h:581
uint32_t fdiv
Some images (such as disparity maps) use scaled pixel values; for these images, fdiv specifies the sc...
Definition: player_interfaces.h:2963
float height
Height of e-puck body.
Definition: epuckPosition2d.hpp:41
double pyaw
yaw [rad]
Definition: player.h:241
EpuckCamera(const SerialPort *const serialPort, unsigned sensor_x1, unsigned sensor_y1, unsigned sensor_width, unsigned sensor_height, unsigned zoom_fact_width, unsigned zoom_fact_height, ColorModes color_mode)
The EpuckCamera class constructor.
Definition: epuckCamera.cpp:43
ColorModes
Possible color modes for e-puck camera.
Definition: epuckCamera.hpp:80
uint32_t image_count
Size of image data as stored in image buffer (bytes)
Definition: player_interfaces.h:2968
int ReadInt(int section, const char *name, int value)
Read an integer value.
double angle
relative turning angle (rad)
Definition: player_interfaces.h:642
void ProcessMessages(void)
Process pending messages.
player_pose3d_t * poses
the pose of each IR detector on this robot
Definition: player_interfaces.h:2135
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
QueuePointer InQueue
Queue for all incoming messages for this driver.
Definition: driver.h:285
double py
Y [m].
Definition: player.h:222
#define PLAYER_CAMERA_FORMAT_MONO16
Image format : 16-bit monochrome (network byte order).
Definition: player_interfaces.h:2938
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:112
player_pose3d_t pose
Pose of the robot base, in the robot cs (m, rad).
Definition: player_interfaces.h:658
#define PLAYER_CAMERA_DATA_STATE
Data subtype: state.
Definition: player_interfaces.h:2922
float * ranges
ranges [m]
Definition: player_interfaces.h:2124
Plug-in driver for the e-puck robot, in conformity with Player version 2.1.
Definition: epuckDriver.hpp:41
unsigned recvUnsigned() const
Receive an unsigned interger from e-puck.
Definition: serialPort.cpp:115
uint8_t * image
Compressed image data (byte-aligned, row major order).
Definition: player_interfaces.h:2972
std::vector< float > voltages
The raw IR readings.
Definition: epuckIR.hpp:41
#define PLAYER_POSITION2D_REQ_GET_GEOM
Request/reply: geometry.
Definition: player_interfaces.h:483
Struct which represents the geometry of e-puck body.
Definition: epuckPosition2d.hpp:38
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
Triple velocity
E-puck velocity in a 2D surface.
Definition: epuckPosition2d.hpp:48
double sl
Length [m].
Definition: player.h:259
void sendInt(int message) const
Send an integer to e-puck.
Definition: serialPort.cpp:172
Send and receive messages from e-puck.
Definition: serialPort.hpp:40
position2d command setting velocity and steering angle
Definition: player_interfaces.h:637
const SerialPort *const serialPort
A SerialPort class instance shared among the device interfaces.
Definition: epuckInterface.hpp:59
static const unsigned RING_LEDS_NUM
The quantity of LEDs in e-puck ring LEDs.
Definition: epuckLEDs.hpp:36
Class for to get data from e-puck IR sensors.
Definition: epuckIR.hpp:31
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
Data: state (PLAYER_CAMERA_DATA_STATE)
Definition: player_interfaces.h:2950
player_pose2d_t pose
(x, y, yaw) [m, m, rad]
Definition: player_interfaces.h:689
std::vector< float > ranges
The equivalent obstacle distance.
Definition: epuckIR.hpp:42
float y
y component.
Definition: epuckInterface.hpp:41
Class for loading configuration file information.
Definition: configfile.h:196
double sw
Width [m].
Definition: player.h:257
A device address.
Definition: player.h:145
@ GREY_SCALE_MODE
Grey color mode, with 8 bits per pixel.
Definition: epuckCamera.hpp:82
#define PLAYER_POSITION2D_REQ_RESET_ODOM
Request/reply: Reset odometry.
Definition: player_interfaces.h:541
An autopointer for the message queue.
Definition: message.h:73
double py
Y [m].
Definition: player.h:233
uint32_t format
Image format (must be compatible with depth).
Definition: player_interfaces.h:2959
player_pose2d_t vel
translational velocities [m/s,m/s,rad/s] (x, y, yaw)
Definition: player_interfaces.h:611
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
Definition: epuckDriver.cpp:290
int initialize()
Open the serial port device and set the configurations for it.
Definition: serialPort.cpp:39
position2d data
Definition: player_interfaces.h:606
Command: power (PLAYER_BLINKENLIGHT_CMD_POWER) This blinkenlight command turns the light on or off.
Definition: player_interfaces.h:2858
#define PLAYER_ERROR1(msg, a)
Error message macros.
Definition: error.h:82
position2d geom
Definition: player_interfaces.h:655
bool Empty()
Check whether a queue is empty.
Definition: message.h:345
A pose in space.
Definition: player.h:228
#define PLAYER_CAMERA_COMPRESS_RAW
Compression method: raw.
Definition: player_interfaces.h:2945
#define PLAYER_ERROR(msg)
Error message macros.
Definition: error.h:81
Base class for drivers which oeprate with a thread.
Definition: driver.h:552
uint32_t voltages_count
number of samples
Definition: player_interfaces.h:2118
virtual void MainQuit()
Cleanup method for driver thread (called when main exits)
Definition: epuckDriver.cpp:257
float width
Width of e-puck body.
Definition: epuckPosition2d.hpp:40
uint32_t ranges_count
number of samples
Definition: player_interfaces.h:2122
virtual int Unsubscribe(player_devaddr_t addr)
Unsubscribe from this driver.
Definition: epuckDriver.cpp:274
#define PLAYER_CAMERA_FORMAT_MONO8
Image format : 8-bit monochrome.
Definition: player_interfaces.h:2936
#define PLAYER_POSITION2D_DATA_STATE
Data: state (PLAYER_POSITION2D_DATA_STATE)
Definition: player_interfaces.h:568
player_pose2d_t pos
position [m,m,rad] (x, y, yaw)
Definition: player_interfaces.h:609
virtual int Subscribe(player_devaddr_t addr)
Subscribe to this driver.
Definition: epuckDriver.cpp:263
std::string getError() const
Return the last error.
Definition: serialPort.hpp:60
Data: ranges (PLAYER_IR_DATA_RANGES)
Definition: player_interfaces.h:2115
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
@ YUV_MODE
YUV color mode, with 16 bits per pixel.
Definition: epuckCamera.hpp:84
double pa
yaw [rad]
Definition: player.h:224
Base class for all drivers.
Definition: driver.h:108
Struct which represents a triple (x,y,theta).
Definition: epuckInterface.hpp:38
It controls the e-puck velocity and odometry.
Definition: epuckPosition2d.hpp:33
float theta
theta component.
Definition: epuckInterface.hpp:42
Represents the data got from e-puck IR sensors.
Definition: epuckIR.hpp:39
player_bbox3d_t size
Dimensions of the base (m).
Definition: player_interfaces.h:660
#define PLAYER_BLINKENLIGHT_CMD_POWER
Data: state (PLAYER_BLINKENLIGHT_DATA_STATE) The blinkenlight data provides the current state of the ...
Definition: player_interfaces.h:2814
uint32_t height
Image dimensions [pixels].
Definition: player_interfaces.h:2955
Triple pose
E-puck pose in a 2D surface.
Definition: epuckPosition2d.hpp:47
set odometry
Definition: player_interfaces.h:686
virtual int Unsubscribe(player_devaddr_t addr)
Unsubscribe from this driver.
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
float * voltages
voltages [V]
Definition: player_interfaces.h:2120
#define PLAYER_POSITION2D_REQ_SET_ODOM
Request/reply: Set odometry.
Definition: player_interfaces.h:535
#define PLAYER_POSITION2D_CMD_CAR
Command: carlike (PLAYER_POSITION2D_CMD_CAR)
Definition: player_interfaces.h:594
uint32_t bpp
Image bits-per-pixel (8, 16, 24, 32).
Definition: player_interfaces.h:2957