23 #include <boost/shared_ptr.hpp> 27 const double PI = 3.14159265358979323846;
32 if((x==0.0) && (y==0.0))
return 0;
37 double getWeightedDelta(
double current_position,
double old_target,
double new_target){
50 return 0.6*fabs(dtempDeltaPhi1RAD) + 0.4*fabs(dtempDeltaPhiCmd1RAD);
57 m_dExWheelXPosMM = geom_.dWheelXPosMM + geom_.dDistSteerAxisToDriveWheelMM * sin(state_.dAngGearSteerRad);
58 m_dExWheelYPosMM = geom_.dWheelYPosMM - geom_.dDistSteerAxisToDriveWheelMM * cos(state_.dAngGearSteerRad);
61 m_dExWheelDistMM = sqrt( (m_dExWheelXPosMM * m_dExWheelXPosMM) + (m_dExWheelYPosMM * m_dExWheelYPosMM) );
66 m_dVelWheelMMS = geom_.dRadiusWheelMM * (state_.dVelGearDriveRadS - dFactorVel* state_.dVelGearSteerRadS);
74 double dtempRelDistWheelsMM = sqrt( dtempDiffXMM*dtempDiffXMM + dtempDiffYMM*dtempDiffYMM );
85 return m_dVelWheelMMS*cos(state_.dAngGearSteerRad);
88 return m_dVelWheelMMS*sin(state_.dAngGearSteerRad);
91 for(std::vector<WheelParams>::const_iterator it = params.begin(); it != params.end(); ++it){
92 wheels_.push_back(boost::make_shared<WheelData>(it->geom));
108 m_dVelGearDriveTargetRadS = 0.0;
109 m_dAngGearSteerTargetRad = state_.dAngGearSteerRad;
116 double dtempAxVelYRobMMS = plt_state.
dVelLatMMS;
118 dtempAxVelXRobMMS += plt_state.
dRotRobRadS * m_dExWheelDistMM * -sin(m_dExWheelAngRad);
119 dtempAxVelYRobMMS += plt_state.
dRotRobRadS * m_dExWheelDistMM * cos(m_dExWheelAngRad);
123 double dAngGearSteerTarget1Rad =
MathSup::atan4quad(dtempAxVelYRobMMS, dtempAxVelXRobMMS);
125 double dAngGearSteerTarget2Rad = dAngGearSteerTarget1Rad +
MathSup::PI;
129 double dVelGearDriveTarget1RadS = sqrt( (dtempAxVelXRobMMS * dtempAxVelXRobMMS) +
130 (dtempAxVelYRobMMS * dtempAxVelYRobMMS) ) / geom_.dRadiusWheelMM;
132 double dVelGearDriveTarget2RadS = -dVelGearDriveTarget1RadS;
135 if(
getWeightedDelta(state_.dAngGearSteerRad, m_dAngGearSteerTargetRad, dAngGearSteerTarget1Rad)
136 <=
getWeightedDelta(state_.dAngGearSteerRad, m_dAngGearSteerTargetRad, dAngGearSteerTarget2Rad))
139 m_dVelGearDriveTargetRadS = dVelGearDriveTarget1RadS;
140 m_dAngGearSteerTargetRad = dAngGearSteerTarget1Rad;
145 m_dVelGearDriveTargetRadS = dVelGearDriveTarget2RadS;
146 m_dAngGearSteerTargetRad = dAngGearSteerTarget2Rad;
155 }
else if (value < -limit) {
177 command.
dVelGearDriveRadS =
limitValue(m_dVelGearDriveTargetRadS + m_dAngGearSteerTargetRad * dFactorVel, params_.dMaxDriveRateRadpS);
189 double dForceDamp = - pos_params_.dDamp *m_dCtrlVelCmdInt;
192 double dAccCmd = (dForceDamp + dForceProp) / pos_params_.dVirtM;
193 dAccCmd =
limitValue(dAccCmd, pos_params_.dDDPhiMax);
195 double dVelCmdInt =m_dCtrlVelCmdInt + dCmdRateS * dAccCmd;
196 dVelCmdInt =
limitValue(dVelCmdInt, pos_params_.dDPhiMax);
199 m_dCtrlVelCmdInt = dVelCmdInt;
208 m_dCtrlVelCmdInt = 0.0;
212 assert(wheels_.size() == pos_ctrls.size());
213 for(
size_t i = 0; i < wheels_.size(); ++i){
214 wheels_[i]->pos_params_ = pos_ctrls[i];
double limitValue(double value, double limit)
double atan4quad(double y, double x)
static double mergeRotRobRadS(const WheelData &wheel1, const WheelData &wheel2)
void setTarget(const PlatformState &state)
void configure(const std::vector< PosCtrlParams > &pos_ctrl)
virtual void calcControlStep(WheelCommand &command, double dCmdRateS, bool reset)
void updateState(const WheelState &state)
double getWeightedDelta(double current_position, double old_target, double new_target)
UndercarriageGeom(const std::vector< WheelParams > ¶ms)
def normalize_angle(angle)
void normalizePi(double &val)
virtual void calcDirect(PlatformState &state) const
virtual void updateWheelStates(const std::vector< WheelState > &states)=0
double dAngGearSteerRadDelta
virtual void calcControlStep(WheelCommand &command, double dCmdRateS, bool reset)
virtual void calcDirect(PlatformState &state) const =0
virtual void updateWheelStates(const std::vector< WheelState > &states)