expand_state_job.cpp
Go to the documentation of this file.
00001 #include <vigir_footstep_planning_default_plugins/state_generator/expand_state_job.h>
00002 
00003 #include <vigir_footstep_planning_plugins/plugin_aggregators/robot_model.h>
00004 #include <vigir_footstep_planning_plugins/plugin_aggregators/world_model.h>
00005 #include <vigir_footstep_planning_plugins/plugin_aggregators/step_cost_estimator.h>
00006 #include <vigir_footstep_planning_plugins/plugin_aggregators/post_processor.h>
00007 
00008 
00009 
00010 namespace vigir_footstep_planning
00011 {
00012 namespace threading
00013 {
00014 ExpandStateJob::ExpandStateJob(const Footstep& footstep, const PlanningState& state)
00015   : successful(false)
00016   , footstep_(footstep)
00017   , state_(state)
00018 {
00019 }
00020 
00021 ExpandStateJob::~ExpandStateJob()
00022 {
00023 }
00024 
00025 void ExpandStateJob::run()
00026 {
00027   successful = false;
00028 
00030   if (state_.getPredState() == nullptr)
00031     return;
00032 
00033   next.reset(new PlanningState(footstep_.performMeOnThisState(state_)));
00034   State& new_state = next->getState();
00035 
00036   if (*(state_.getPredState()) == *next)
00037     return;  
00038 
00039   const State& left_foot = state_.getLeg() == LEFT ? state_.getState() : state_.getPredState()->getState();
00040   const State& right_foot = state_.getLeg() == RIGHT ? state_.getState() : state_.getPredState()->getState();
00041 
00042   // update 3D pose based on world data
00043   WorldModel::instance().update3DData(new_state);
00044 
00045   // apply post processing steps
00046   PostProcessor::instance().postProcessForward(left_foot, right_foot, new_state);
00047   //PostProcessor::instance().postProcessBackward(left_foot, right_foot, next_state);
00048 
00049   // check reachability due to discretization
00050   if (!RobotModel::instance().isReachable(left_foot, right_foot, new_state))
00051     return;
00052 
00053   // collision check
00054   if (!WorldModel::instance().isAccessible(new_state, state_.getState()))
00055     return;
00056 
00057   // lookup costs
00058   double cost, risk;
00059   if (!StepCostEstimator::instance().getCost(left_foot, right_foot, new_state, cost, risk))
00060     return;
00061 
00062   cost += footstep_.getStepCost();
00063 
00064   new_state.setCost(cost);
00065   new_state.setRisk(risk);
00066   successful = true;
00067 }
00068 }
00069 }


vigir_footstep_planning_default_plugins
Author(s): Alexander Stumpf
autogenerated on Fri Apr 7 2017 02:59:40