31 #ifndef _CLODBUSTERDEVICE_H
32 #define _CLODBUSTERDEVICE_H
37 #include <libplayercore/playercore.h>
40 #define CLODBUSTER_CYCLETIME_USEC 50000
45 #define SET_SERVO_THROTTLE 0
46 #define SET_SERVO_FRONTSTEER 1
47 #define SET_SERVO_BACKSTEER 2
48 #define SET_SERVO_PAN 3
50 #define ECHO_SERVO_VALUES 64 // 0x40
51 #define ECHO_MAX_SERVO_LIMITS 65 //0x41
52 #define ECHO_MIN_SERVO_LIMITS 66 //0x42
53 #define ECHO_CEN_SERVO_LIMITS 67 //0x43
55 #define ECHO_ENCODER_COUNTS 112 // 0x70
56 #define ECHO_ENCODER_COUNTS_TS 113 // 0x71
57 #define ECHO_ADC 128 //0x80
60 #define SET_SLEEP_MODE 144 // 0x90
61 #define ECHO_SLEEP_MODE 145 // 0x91
63 #define SLEEP_MODE_ON 1
64 #define SLEEP_MODE_OFF 0
66 #define SERVO_CHANNELS 8
70 #define ARGINT 0x3B // Positive int (LSB, MSB)
71 #define ARGNINT 0x1B // Negative int (LSB, MSB)
72 #define ARGSTR 0x2B // String (Note: 1st byte is length!!)
74 #define CLODBUSTER_CONFIG_BUFFER_SIZE 256
76 #define DEFAULT_CLODBUSTER_PORT "/dev/ttyUSB0" // This has to be USB - serial port.
87 float kp, ki, kd, freq, k1, k2, k3;
91 k1 = kp + .5*T*ki + kd/T;
92 k2 = -kp - 2.0*kd/T + .5*ki*T;
94 printf(
"Gain constants set to K1 = %f, K2 = %f, K3 = %f\n",k1,k2,k3);
97 PIDGains(
float kp_,
float ki_,
float kd_,
float freq_)
98 :kp(kp_), ki(ki_), kd(kd_),freq(freq_)
118 void SetFreq(
float f)
123 float K1(){
return(k1);};
124 float K2(){
return(k2);};
125 float K3(){
return(k3);};
132 void ResetRawPositions();
133 clodbuster_encoder_data_t ReadEncoders();
138 char clodbuster_serial_port[MAX_FILENAME_SIZE];
144 clodbuster_encoder_data_t encoder_offset;
145 clodbuster_encoder_data_t encoder_measurement;
146 clodbuster_encoder_data_t old_encoder_measurement;
147 float EncV, EncOmega, EncVleft, EncVright;
149 bool direct_command_control;
150 unsigned char max_limits[SERVO_CHANNELS],center_limits[SERVO_CHANNELS],min_limits[SERVO_CHANNELS];
151 void GetGraspBoardParams();
156 float WheelSeparation;
157 unsigned int CountsPerRev;
164 void IntegrateEncoders();
165 void DifferenceEncoders();
171 int motor_max_turnspeed;
176 short speedDemand, turnRateDemand;
177 bool newmotorspeed, newmotorturn;
193 unsigned char SetServo(
unsigned char chan,
int value);
194 void SetServo(
unsigned char chan,
unsigned char cmd);
uint8_t state
FALSE for off, TRUE for on.
Definition: player_interfaces.h:667
position 2d velocity command
Definition: player_interfaces.h:617
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
double px
X [m].
Definition: player.h:231
position2d velocity mode config
Definition: player_interfaces.h:671
Generic message header.
Definition: player.h:161
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_POSITION2D_CMD_VEL
Command: velocity (PLAYER_POSITION2D_CMD_VEL)
Definition: player_interfaces.h:581
double pyaw
yaw [rad]
Definition: player.h:241
Definition: clodbuster.h:78
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:95
Definition: clodbuster.h:84
#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
virtual void MainQuit()
Cleanup method for driver thread (called when main exits)
Definition: clodbuster.cc:227
float ki
PID parameters.
Definition: player_interfaces.h:698
#define PLAYER_POSITION2D_REQ_GET_GEOM
Request/reply: geometry.
Definition: player_interfaces.h:483
uint32_t value
driver-specific
Definition: player_interfaces.h:674
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:106
double sl
Length [m].
Definition: player.h:259
float kp
PID parameters.
Definition: player_interfaces.h:696
player_pose2d_t pose
(x, y, yaw) [m, m, rad]
Definition: player_interfaces.h:689
virtual int MainSetup()
Sets up the resources needed by the driver thread.
Definition: clodbuster.cc:144
Class for loading configuration file information.
Definition: configfile.h:196
double sw
Width [m].
Definition: player.h:257
#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
int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
Definition: clodbuster.cc:243
position2d data
Definition: player_interfaces.h:606
position2d geom
Definition: player_interfaces.h:655
virtual void Main()
Main method for driver thread.
Definition: clodbuster.cc:352
Definition: clodbuster/packet.h:37
Base class for drivers which oeprate with a thread.
Definition: driver.h:552
float kd
PID parameters.
Definition: player_interfaces.h:700
Messages between wsn and a robot.
Definition: er.h:86
#define PLAYER_POSITION2D_DATA_STATE
Data: state (PLAYER_POSITION2D_DATA_STATE)
Definition: player_interfaces.h:568
uint32_t size
Size in bytes of the payload to follow.
Definition: player.h:174
Definition: clodbuster.h:128
position2d speed PID req
Definition: player_interfaces.h:693
#define PLAYER_POSITION2D_REQ_VELOCITY_MODE
Request/reply: Change velocity control.
Definition: player_interfaces.h:522
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:99
#define PLAYER_POSITION2D_REQ_SPEED_PID
Request/reply: Set velocity PID parameters.
Definition: player_interfaces.h:548
Base class for all drivers.
Definition: driver.h:108
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