Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <cereal_port/CerealPort.h>
00039
00040 #define MSG_LENGTH 64
00041
00042 #define MINIQ_RATE 3.0
00043
00044 class miniQ
00045 {
00046 public:
00047
00049 typedef enum _miniQaction {
00050
00051
00052 MQ_ACTION_GET_VERSION = 1,
00053
00054 MQ_ACTION_DRIVE = 2,
00055 MQ_ACTION_DRIVE_DIRECT = 3,
00056
00057 MQ_ACTION_GET_ODOMETRY = 4,
00058 MQ_ACTION_GET_ENCODER_PULSES = 5,
00059 MQ_ACTION_GET_WHEEL_VELOCITIES = 6,
00060 MQ_ACTION_GET_GAS_SENSOR = 7,
00061 MQ_ACTION_GET_IR_BUMPER = 8,
00062 MQ_ACTION_GET_LINE_SENSOR = 9,
00063 MQ_ACTION_GET_BATTERY = 10,
00064
00065 MQ_ACTION_GET_DEBUG = 11,
00066 MQ_ACTION_SET_DEBUG = 12,
00067
00068 MQ_ACTION_SET_PID_GAINS = 13,
00069 MQ_ACTION_GET_PID_GAINS = 14,
00070 MQ_ACTION_SET_ODOMETRY_CALIBRATION = 15,
00071 MQ_ACTION_GET_ODOMETRY_CALIBRATION = 16,
00072 MQ_ACTION_SET_ID = 17,
00073 MQ_ACTION_GET_ID = 18,
00074 MQ_ACTION_SET_MODE = 19,
00075 MQ_ACTION_GET_MODE = 20,
00076 MQ_ACTION_SET_GAS_CALIBRATION = 21,
00077 MQ_ACTION_GET_GAS_CALIBRATION = 22,
00078 MQ_ACTION_SET_BATTERY_TYPE = 23,
00079 MQ_ACTION_GET_BATTERY_TYPE = 24,
00080 MQ_ACTION_SET_TIMEOUT = 25,
00081 MQ_ACTION_GET_TIMEOUT = 26,
00082
00083
00084 MQ_ACTION_GET_GROUP_1 = 27,
00085
00086 MQ_ACTION_GET_GROUP_2 = 28,
00087 MQ_ACTION_COUNT = 29
00088
00089 } miniQaction;
00090
00091 typedef enum _miniQPID
00092 {
00093 LeftStartingPID = 0,
00094 LeftRunningPID = 1,
00095 RightStartingPID = 2,
00096 RightRunningPID = 3
00097
00098 } miniQPID;
00099
00100 miniQ();
00101 ~miniQ();
00102
00112 static bool openPort(char * port, int baudrate);
00113
00121 bool checkVersion();
00122
00131 void setVelocities(double linear_velocity, double angular_velocity);
00132
00140 bool update();
00141
00149 bool updateVelocities();
00150
00158 double getX(){ return x_; }
00166 double getY(){ return y_; }
00174 double getYaw(){ return yaw_; }
00182 double getLinearVelocity(){ return linear_velocity_; }
00190 double getAngularVelocity(){ return angular_velocity_; }
00198 double getLeftWheelVelocity(){ return left_wheel_velocity_; }
00206 double getRightWheelVelocity(){ return right_wheel_velocity_; }
00214 double getGas(){ return gas_; }
00222 double getRawGas(){ return gas_raw_; }
00223
00224 static int scanForId(int id);
00225
00226 void setId(int id);
00227 int getID(){ return id_; };
00228
00229 bool setMode(int mode);
00230 bool setBatteryType(int battery_type);
00231 bool setPIDGains(int kp, int ki, int kd, miniQPID pid);
00232 bool setOdometryCallibration(double odometry_d, double odometry_yaw);
00233 bool setGasSensorCallibration(double a, double b);
00234 bool setTimeout(double timeout);
00235
00236 void setPWM(int left_pwm, int left_dir, int right_pwm, int right_dir);
00237
00238 bool updateWheelVelocities();
00239
00240 private:
00241
00242
00244 double x_;
00246 double y_;
00248 double yaw_;
00250 double linear_velocity_;
00252 double angular_velocity_;
00254 double left_wheel_velocity_;
00256 double right_wheel_velocity_;
00257
00259 double gas_;
00261 double gas_raw_;
00262
00264 int id_;
00265
00266 static cereal::CerealPort serial_port;
00267 };
00268
00269