obot_constants.h
1 /*
2  * Player - One Hell of a Robot Server
3  * Copyright (C) 2000-2003
4  * Brian Gerkey
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  * Relevant constants for the so-called "Trogdor" robots, by Botrics.
27  * These values are taken from the 'cerebellum' module of CARMEN; thanks to
28  * the authors of that module.
29  */
30 
31 #include <math.h>
32 
33 #define OBOT_DEFAULT_PORT "/dev/usb/ttyUSB1"
34 
35 // might need to define a longer delay to wait for acks
36 #define OBOT_DELAY_US 50000
37 
38 // time between consecutive publishes
39 #define OBOT_PUBLISH_INTERVAL 0.1
40 
41 /************************************************************************/
42 /* Physical constants, in meters, radians, seconds (unless otherwise noted) */
43 #define OBOT_AXLE_LENGTH 0.317
44 #define OBOT_WHEEL_DIAM 0.10795 /* 4.25 inches */
45 #define OBOT_WHEEL_CIRCUM (OBOT_WHEEL_DIAM * M_PI)
46 #define OBOT_TICKS_PER_REV 11600.0
47 #define OBOT_M_PER_TICK (OBOT_WHEEL_CIRCUM / OBOT_TICKS_PER_REV)
48 /* the new internal PID loop runs every 1.9375ms (we think) */
49 #define OBOT_PID_FREQUENCY (1/1.9375e-3)
50 #define OBOT_MAGIC_TIMING_CONSTANT 1.0
51 #define OBOT_MPS_PER_TICK (OBOT_M_PER_TICK * OBOT_PID_FREQUENCY / \
52  OBOT_MAGIC_TIMING_CONSTANT)
53 #define OBOT_WIDTH 0.45
54 #define OBOT_LENGTH 0.45
55 #define OBOT_POSE_X 0.0
56 #define OBOT_POSE_Y 0.0
57 #define OBOT_POSE_A 0.0
58 #define OBOT_NOMINAL_VOLTAGE 48.0
59 
60 /* assuming that the counts can use the full space of a signed 32-bit int */
61 #define OBOT_MAX_TICS 2147483648U
62 
63 /* for safety */
64 //#define OBOT_MAX_WHEELSPEED 1.0
65 #define OBOT_MAX_WHEELSPEED 5.0
66 
67 /* to account for our bad low-level PID motor controller */
68 #define OBOT_MIN_WHEELSPEED_TICKS 5
69 
70 /************************************************************************/
71 /* Comm protocol values */
72 #define OBOT_ACK 6 // if command acknowledged
73 #define OBOT_NACK 21 // if garbled message
74 
75 #define OBOT_INIT1 253 // The init commands are used in sequence(1,2,3)
76 #define OBOT_INIT2 252 // to initialize a link to a cerebellum.
77 #define OBOT_INIT3 251 // It will then blink green and start accepting other
78  // commands.
79 
80 #define OBOT_DEINIT 250
81 
82 #define OBOT_SET_VELOCITIES 118 // 'v'(left_vel, right_vel) as 16-bit signed ints
83 #define OBOT_SET_ACCELERATIONS 97 // 'a'(left_accel, right_accel) as 16-bit unsigned ints
84 #define OBOT_ENABLE_VEL_CONTROL 101 // 'e'()
85 #define OBOT_DISABLE_VEL_CONTROL 100 // 'd'()
86 #define OBOT_GET_ODOM 111 // 'o'()->(left_count, right_count, left_vel, right_vel)
87 #define OBOT_GET_VOLTAGE 98 // 'b'()->(batt_voltage)
88 #define OBOT_STOP 115 // 's'() [shortcut for set_velocities(0,0)]
89 #define OBOT_KILL 107 // 'k'() [shortcut for disable_velocity_control]
90 #define OBOT_HEARTBEAT 104 // 'h'() sends keepalive
91 /************************************************************************/
92 
93 
uint8_t state
FALSE for off, TRUE for on.
Definition: player_interfaces.h:667
#define PLAYER_WARN1(msg, a)
Error message macros.
Definition: error.h:90
position 2d velocity command
Definition: player_interfaces.h:617
double velocity
forward velocity (m/s)
Definition: player_interfaces.h:640
player_pose2d_t vel
translational velocities [m/s,m/s,rad/s] (x, y, yaw)
Definition: player_interfaces.h:620
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:159
A rectangular bounding box, used to define the size of an object.
Definition: player.h:254
double ReadFloat(int section, const char *name, double value)
Read a floating point (double) value.
uint32_t valid
Status bits.
Definition: player_interfaces.h:296
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:161
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
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
#define PLAYER_POSITION2D_REQ_MOTOR_POWER
Request/reply: Motor power.
Definition: player_interfaces.h:496
position2d power config
Definition: player_interfaces.h:664
double px
X [m].
Definition: player.h:220
#define PLAYER_POWER_DATA_STATE
Data subtype: voltage.
Definition: player_interfaces.h:274
#define PLAYER_POWER_MASK_VOLTS
bit masks for the player_power_data_t mask field
Definition: player_interfaces.h:282
#define PLAYER_POSITION2D_CMD_VEL
Command: velocity (PLAYER_POSITION2D_CMD_VEL)
Definition: player_interfaces.h:581
virtual void Main(void)=0
Main method for driver thread.
double ReadAngle(int section, const char *name, double value)
Read an angle (includes unit conversion).
int ReadInt(int section, const char *name, int value)
Read an integer value.
double angle
relative turning angle (rad)
Definition: player_interfaces.h:642
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
double py
Y [m].
Definition: player.h:222
#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_POSITION2D_REQ_GET_GEOM
Request/reply: geometry.
Definition: player_interfaces.h:483
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
Data: voltage (PLAYER_POWER_DATA_STATE)
Definition: player_interfaces.h:291
double ReadTupleAngle(int section, const char *name, int index, double value)
Read an angle form a tuple (includes units conversion)
position2d command setting velocity and steering angle
Definition: player_interfaces.h:637
int ReadDeviceAddr(player_devaddr_t *addr, int section, const char *name, int code, int index, const char *key)
Read a device id.
player_pose2d_t pose
(x, y, yaw) [m, m, rad]
Definition: player_interfaces.h:689
Class for loading configuration file information.
Definition: configfile.h:196
A device address.
Definition: player.h:145
#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
player_pose2d_t vel
translational velocities [m/s,m/s,rad/s] (x, y, yaw)
Definition: player_interfaces.h:611
position2d data
Definition: player_interfaces.h:606
#define PLAYER_ERROR1(msg, a)
Error message macros.
Definition: error.h:82
position2d geom
Definition: player_interfaces.h:655
A pose in space.
Definition: player.h:228
#define PLAYER_ERROR(msg)
Error message macros.
Definition: error.h:81
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 percent
Percent of full charge [%].
Definition: player_interfaces.h:301
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
float volts
Battery voltage [V].
Definition: player_interfaces.h:299
#define PLAYER_WARN(msg)
Warning message macros.
Definition: error.h:89
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
double pa
yaw [rad]
Definition: player.h:224
Base class for all drivers.
Definition: driver.h:108
#define PLAYER_POWER_MASK_PERCENT
Data subtype: voltage.
Definition: player_interfaces.h:285
uint8_t stall
Are the motors stalled?
Definition: player_interfaces.h:613
player_bbox3d_t size
Dimensions of the base (m).
Definition: player_interfaces.h:660
set odometry
Definition: player_interfaces.h:686
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:76
#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