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
51#define ECHO_MAX_SERVO_LIMITS 65
52#define ECHO_MIN_SERVO_LIMITS 66
53#define ECHO_CEN_SERVO_LIMITS 67
55#define ECHO_ENCODER_COUNTS 112
56#define ECHO_ENCODER_COUNTS_TS 113
60#define SET_SLEEP_MODE 144
61#define ECHO_SLEEP_MODE 145
63#define SLEEP_MODE_ON 1
64#define SLEEP_MODE_OFF 0
66#define SERVO_CHANNELS 8
74#define CLODBUSTER_CONFIG_BUFFER_SIZE 256
76#define DEFAULT_CLODBUSTER_PORT "/dev/ttyUSB0"
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);};
131 player_position2d_data_t position_data;
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);
Definition clodbuster.h:129
virtual void Main()
Main method for driver thread.
Definition clodbuster.cc:352
virtual int MainSetup()
Sets up the resources needed by the driver thread.
Definition clodbuster.cc:144
int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
Definition clodbuster.cc:243
virtual void MainQuit()
Cleanup method for driver thread (called when main exits)
Definition clodbuster.cc:227
Class for loading configuration file information.
Definition configfile.h:197
Definition clodbuster.h:85
An autopointer for the message queue.
Definition message.h:74
Base class for drivers which oeprate with a thread.
Definition driver.h:553
Messages between wsn and a robot.
Definition er.h:87
Definition clodbuster.h:79
Generic message header.
Definition player.h:162