18 #ifndef UndercarriageCtrlGeom_INCLUDEDEF_H 19 #define UndercarriageCtrlGeom_INCLUDEDEF_H 24 #include <boost/make_shared.hpp> 31 const double getVelX() {
return dVelLongMMS / 1000.0; }
32 const double getVelY() {
return dVelLatMMS / 1000.0; }
34 void setVelX(
const double val) { dVelLongMMS = val * 1000.0; }
35 void setVelY(
const double val) { dVelLatMMS = val * 1000.0; }
43 WheelState() : dVelGearDriveRadS(0), dVelGearSteerRadS(0), dAngGearSteerRad(0) {}
95 dFactorVel(-geom_.dSteerDriveCoupling + geom_.dDistSteerAxisToDriveWheelMM / geom_.dRadiusWheelMM) {
107 virtual void updateWheelStates(
const std::vector<WheelState> &states) = 0;
112 template<
typename V>
static void updateWheelStates(V& wheels,
const std::vector<WheelState> &states)
114 if(wheels.size() != states.size())
throw std::length_error(
"number of states does not match number of wheels");
116 for(
size_t i = 0; i < wheels.size(); ++i){
117 wheels[i]->updateState(states[i]);
123 double dtempRotRobRADPS = 0;
124 double dtempVelXRobMMS = 0;
125 double dtempVelYRobMMS = 0;
128 for(
int i = 0; i < wheels.size() ; i++)
131 const WheelData &other_wheel = *wheels[(i+1) % wheels.size()];
134 dtempVelXRobMMS += wheel.
getVelX();
135 dtempVelYRobMMS += wheel.
getVelY();
139 state.
dRotRobRadS = dtempRotRobRADPS/wheels.size();
143 state.
dVelLatMMS = dtempVelYRobMMS/wheels.size();
162 virtual void updateWheelStates(
const std::vector<WheelState> &states);
165 std::vector<boost::shared_ptr<WheelData> >
wheels_;
168 double limitValue(
double value,
double limit);
174 for(
typename std::vector<T2>::const_iterator it = params.begin(); it != params.end(); ++it){
175 wheels_.push_back(boost::make_shared<T>(*it));
190 for(
size_t i = 0; i < wheels_.size(); ++i){
191 wheels_[i]->setTarget(state);
196 void calcControlStep(std::vector<WheelCommand> &commands,
double dCmdRateS,
bool reset) {
197 commands.resize(wheels_.size());
199 for(
size_t i = 0; i < wheels_.size(); ++i){
200 wheels_[i]->calcControlStep(commands[i], dCmdRateS, reset);
205 for(
size_t i = 0; i < wheels_.size(); ++i){
235 virtual void calcControlStep(
WheelCommand &command,
double dCmdRateS,
bool reset);
237 virtual void reset();
240 :
WheelData(params.geom), params_(params.ctrl) {
265 double dSpring, dDamp,
dVirtM, dDPhiMax, dDDPhiMax;
282 virtual void calcControlStep(
WheelCommand &command,
double dCmdRateS,
bool reset);
284 virtual void reset();
287 :
CtrlData(params), pos_params_(params.pos_ctrl),m_dCtrlVelCmdInt(0) {
288 state_.dAngGearSteerRad = params_.dWheelNeutralPos;
291 m_dAngGearSteerTargetRad = params_.dWheelNeutralPos;
298 void configure(
const std::vector<PosCtrlParams> &pos_ctrl);
WheelData(const WheelGeom &geom)
CtrlData(const P ¶ms)
double dSteerDriveCoupling
virtual void calcDirect(PlatformState &state) const
void setTarget(const PlatformState &state)
PosCtrlData(const WheelCtrlPosParams ¶ms)
PosCtrlParams pos_params_
virtual void updateWheelStates(const std::vector< WheelState > &states)
static double mergeRotRobRadS(const WheelData &wheel1, const WheelData &wheel2)
WheelCtrlParams WheelParams
std::vector< boost::shared_ptr< T > > wheels_
static void updateWheelStates(V &wheels, const std::vector< WheelState > &states)
WheelCtrlPosParams WheelParams
double dMaxDriveRateRadpS
std::vector< boost::shared_ptr< WheelData > > wheels_
void calcControlStep(std::vector< WheelCommand > &commands, double dCmdRateS, bool reset)
UndercarriageCtrl(const std::vector< WheelParams > ¶ms)
double limitValue(double value, double limit)
double dDistSteerAxisToDriveWheelMM
virtual ~UndercarriageGeomBase()
UndercarriageCtrlBase(const std::vector< T2 > ¶ms)
static void calcDirect(PlatformState &state, const V &wheels)
double m_dVelGearDriveTargetRadS
virtual void updateWheelStates(const std::vector< WheelState > &states)=0
double dMaxSteerRateRadpS
double dAngGearSteerRadDelta
double m_dAngGearSteerTargetRad
virtual void calcDirect(PlatformState &state) const =0
UndercarriageDirectCtrl(const std::vector< WheelParams > ¶ms)