44 #define sign(x) (x>0?+1:x<0?-1:0) 45 #define stringfy(x) #x 46 #define setState(x) {state=x;} 47 #define setStateVel(x,v,w) {setState(x);setVel(v,w);} 100 if (mode ==
"run")
can_run =
true;
101 if (mode ==
"stop")
can_run =
false;
116 ,
const unsigned char &bumper
117 ,
const unsigned char &charger
121 std::vector<unsigned char> signal_filt(signal.size(), 0);
126 if(bumper || charger) {
153 pose_update.x( std::sqrt( dx*dx + dy*dy ) );
154 pose_update.heading( pose.heading() -
pose_priv.heading() );
176 for (
unsigned int i = 0; i <
past_signals.size(); i++) {
179 for (
unsigned int j = 0; j < signal_filt.size(); j++)
201 if(charger && bumper) {
241 std::ostringstream oss;
249 current_state = new_state =
state;
250 switch((
unsigned int)current_state) {
252 idle(new_state, new_vx, new_wz);
255 scan(new_state, new_vx, new_wz, signal_filt, pose_update, debug_str);
258 find_stream(new_state, new_vx, new_wz, signal_filt);
261 get_stream(new_state, new_vx, new_wz, signal_filt);
266 aligned(new_state, new_vx, new_wz, signal_filt, debug_str);
272 oss <<
"Wrong state : " << current_state;
273 debug_str = oss.str();
292 for(i = 0; i < signal_filt.size(); i++)
294 if(signal_filt[i] & state)
void processBumpChargeEvent(const unsigned char &bumper, const unsigned char &charger)
void computePoseUpdate(ecl::LegacyPose2D< double > &pose_update, const ecl::LegacyPose2D< double > &pose)
compute pose update from previouse pose and current pose
unsigned int signal_window
void modeShift(const std::string &mode)
RobotDockingState::State state
Simple module for the docking drive algorithm.
void bumped(RobotDockingState::State &nstate, double &nvx, double &nwz, int &bump_count)
void scan(RobotDockingState::State &state, double &vx, double &wz, const std::vector< unsigned char > &signal_filt, const ecl::LegacyPose2D< double > &pose_update, std::string &debug_str)
void find_stream(RobotDockingState::State &state, double &vx, double &wz, const std::vector< unsigned char > &signal_filt)
void setVel(double v, double w)
void idle(RobotDockingState::State &state, double &vx, double &wz)
#define setStateVel(x, v, w)
std::vector< std::string > ROBOT_STATE_STR
void filterIRSensor(std::vector< unsigned char > &signal_filt, const std::vector< unsigned char > &signal)
void updateVelocity(const std::vector< unsigned char > &signal_filt, const ecl::LegacyPose2D< double > &pose_update, std::string &debug_str)
std::vector< std::vector< unsigned char > > past_signals
bool validateSignal(const std::vector< unsigned char > &signal_filt, const unsigned int state)
void generateDebugMessage(const std::vector< unsigned char > &signal_filt, const unsigned char &bumper, const unsigned char &charger, const ecl::LegacyPose2D< double > &pose_update, const std::string &debug_str)
void get_stream(RobotDockingState::State &state, double &vx, double &wz, const std::vector< unsigned char > &signal_filt)
void aligned(RobotDockingState::State &state, double &vx, double &wz, const std::vector< unsigned char > &signal_filt, std::string &debug_str)
void velocityCommands(const double &vx, const double &wz)
ecl::LegacyPose2D< double > pose_priv
void update(const std::vector< unsigned char > &signal, const unsigned char &bumper, const unsigned char &charger, const ecl::LegacyPose2D< double > &pose)
Updates the odometry from firmware stamps and encoders.