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