KorebotROS.h
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
00032
00033 #ifndef __KOREBOT_ROS_H_
00034 #define __KOREBOT_ROS_H_
00035
00036 #include <stdlib.h>
00037 #include <stdio.h>
00038 #include <string.h>
00039 #include <math.h>
00040 #include <iostream>
00041 #include <fstream>
00042
00043 #include <baselib.h>
00044 #include "MotionModule.h"
00045 #include <includeROS.h>
00046
00047 namespace MipResources{
00049
00050
00051
00056 class KorebotROSPar : public DiffDrivePar{
00057 private:
00058
00059 string _korebotName;
00060
00061
00062 Decimal _maxWheelTurnRate;
00063
00064
00065 Decimal _leftDiam;
00066
00067
00068 Decimal _rightDiam;
00069
00070
00071 Decimal _axelTrack;
00072
00073
00074 Decimal _encoderResol;
00075
00076
00077 GAZEBO_JOINT_PTR _leftJoint;
00078
00079
00080 GAZEBO_JOINT_PTR _rightJoint;
00081
00082
00083 Decimal _leftRatio;
00084
00085
00086 Decimal _rightRatio;
00087
00088
00089 string _intOdoMeth;
00090
00091 public:
00093 KorebotROSPar();
00094
00096 KorebotROSPar(const string &kn, const Decimal &mwtr, const Decimal &ld, const Decimal &rd, const Decimal &at, const Decimal &er, GAZEBO_JOINT_PTR lj, GAZEBO_JOINT_PTR rj, const string &intOdoMeth);
00097
00099 KorebotROSPar(GAZEBO_JOINT_PTR lj, GAZEBO_JOINT_PTR rj, const string &intOdoMeth);
00100
00102 KorebotROSPar(const string &kn, const Decimal &mwtr, const Decimal &ld, const Decimal &rd, const Decimal &at, const Decimal &er, const string &intOdoMeth);
00103
00105 ~KorebotROSPar(){
00106 }
00107
00110 string _providedName();
00111
00114 Decimal _providedMaxWheelTurnRate(void);
00115
00118 Decimal _providedLeftDiam(void);
00119
00122 Decimal _providedRightDiam(void);
00123
00126 Decimal _providedAxelTrack(void);
00127
00130 Decimal _providedEncoderResol(void);
00131
00134 GAZEBO_JOINT_PTR getLeftJoint();
00135
00138 GAZEBO_JOINT_PTR getRightJoint();
00139
00142 Decimal getLeftRatio() const;
00143
00146 Decimal getRightRatio() const;
00147
00150 string getIntOdoMeth() const;
00151
00154 string print();
00155 };
00156
00163 class KorebotROSVar : public DiffDriveVar{
00164 private:
00165
00166 public:
00168 KorebotROSVar();
00169
00172 virtual string getName(void){
00173 return "MotionKorebotROS";
00174 }
00175 };
00176
00177
00184 class KorebotROS : protected DiffDrive{
00185 private:
00186 static const ResourcePlate _plate = MM_KORROS_RES;
00187
00188
00189 GAZEBO_COMMON_NAMESPACE::Time* _lastTime;
00190 Decimal _odomPose[3];
00191 Decimal _odomVel[3];
00192
00193
00194 long int _lastLeftPulses;
00195 long int _lastRightPulses;
00196
00197
00198 Decimal _actLeftWheelSpeed;
00199 Decimal _actRightWheelSpeed;
00200
00201
00202 Decimal _prevLeftWheelSpeed;
00203 Decimal _prevRightWheelSpeed;
00204
00205
00206 Decimal _linearSpeed;
00207 Decimal _angularSpeed;
00208
00209
00210 bool _firstStep;
00211
00212 GAZEBO_COMMON_NAMESPACE::Time _actIntTime;
00213 GAZEBO_COMMON_NAMESPACE::Time _lastIntTime;
00214 Decimal _elapsedTimeROS;
00215
00216
00217 void _updateIntTime();
00218 protected:
00219
00220
00221
00222
00223
00224 KorebotROSPar *_korePar;
00225 KorebotROSVar *_koreVar;
00227
00228 long int _leftPulses;
00229 long int _rightPulses;
00230
00231 public:
00235 KorebotROS(int argc, const char* argv[],KorebotROSPar* krp);
00236
00238 ~KorebotROS();
00239
00241 ResourcePlate getPlate() const {
00242 return _plate;
00243 }
00244
00248 void setWheelCommands(Decimal leftAngVel, Decimal rightAngVel);
00249
00254 DiffDriveEncoderReading getEncoders();
00255
00257 void resetEncoders();
00258
00267 bool setStateKorebotROS(MotionModuleState correctedState, bool setPastTimeStamp=false, Time pastTimeStamp=Time());
00268
00270 void _localizationStepKorebotROS();
00271
00273 MotionModuleTState _providedLocStepKorebotROS();
00274
00276 void _initOdometerKorebotROS();
00277
00280 void _computeVelocities(DiffDriveEncoderReading &currReading);
00281
00283 void _intVelocities();
00284
00286 void _setWheelCommandsKorebotROS();
00287
00288 void _providedLocSetKorebotROS(MotionModuleState state);
00289
00292 MotionModuleTState getStateKorebotROS();
00293
00297 MotionModuleTState getState(Time ts);
00298
00308 bool setStateKorebotROS(MotionModuleState correctedState, MotionModuleState &finalState, bool setPastTimeStamp=false, Time pastTimeStamp=Time());
00309
00315 void setCommandsKorebotROS(const Decimal &drive, const Decimal &turnrate, bool scaled=true);
00316
00323 void setCommandsKorebotROS(const Decimal &drive, const Decimal &turnrate, MotionModuleTState &finalTState, bool scaled=true);
00324
00335 void setCommandsAndTStateKorebotROS(MotionModuleState correctedState, const Decimal &drive, const Decimal &turnrate, MotionModuleTState &finalTState, bool scaled=true, bool setPastTimeStamp=false, Time pastTimeStamp=Time());
00336
00340 void _providedSetCommandsKorebotROS(const Decimal &drive, const Decimal &turnrate);
00341
00342 };
00343
00344
00345
00346
00347 };
00348
00349 #endif
00350
00351
00352
00353
00354