48 if (step_plan.steps.empty())
52 msgs::ErrorStatus status = isConsistent(step_plan);
55 ROS_ERROR(
"[StepQueue] updateStepPlan: Consistency check failed!");
60 unsigned int step_plan_start_index = std::max(min_step_index, step_plan.steps.front().step_index);
67 if (step_plan_start_index != 0)
69 ROS_ERROR(
"[StepQueue] updateStepPlan: Current step queue is empty. Expected step plan starting with index 0!");
79 if (!this->
step_plan_.getStep(old_step, step_plan_start_index))
81 ROS_ERROR(
"[StepQueue] updateStepPlan: Can't merge plan due to non-overlapping step indices of current step plan (max queued index: %i, needed index: %u)!", this->
step_plan_.getLastStepIndex(), step_plan_start_index);
85 else if (!StepPlan::getStep(new_step, step_plan, step_plan_start_index))
87 ROS_ERROR(
"[StepQueue] updateStepPlan: Can't merge plan due to non-overlapping step indices of new step plan (max index: %u, needed index: %u)!", step_plan.steps.back().step_index, step_plan_start_index);
91 else if (old_step.foot.foot_index != new_step.foot.foot_index)
93 ROS_ERROR(
"[StepQueue] updateStepPlan: Step %u has wrong foot index!", step_plan_start_index);
99 geometry_msgs::Pose p_old = old_step.foot.pose;
100 geometry_msgs::Pose p_new = new_step.foot.pose;
101 if (p_old.position.x != p_new.position.x || p_old.position.y != p_new.position.y || p_old.position.z != p_new.position.z)
103 ROS_WARN(
"[StepQueue] updateStepPlan: Overlapping step differs in position! Delta: %f/%f/%f", p_new.position.x-p_old.position.x, p_new.position.y-p_old.position.y, p_new.position.z-p_old.position.z);
105 if (p_old.orientation.x != p_new.orientation.x || p_old.orientation.y != p_new.orientation.y || p_old.orientation.z != p_new.orientation.z || p_old.orientation.w != p_new.orientation.w)
107 ROS_WARN(
"[StepQueue] updateStepPlan: Overlapping step differs in orientation! Delta: %f/%f/%f/%f", p_new.orientation.x-p_old.orientation.x, p_new.orientation.y-p_old.orientation.y, p_new.orientation.z-p_old.orientation.z, p_new.orientation.w-p_old.orientation.w);
113 status += this->
step_plan_.stitchStepPlan(step_plan, step_plan_start_index);
114 this->
step_plan_.removeSteps(step_plan.steps.rbegin()->step_index+1);
137 std::vector<msgs::Step> steps;
139 for (
unsigned int i = start_index; i <= end_index; i++)
143 steps.push_back(step);
159 step_plan_.removeSteps(from_step_index, to_step_index);
183 return step.step_index;
194 return step.step_index;
void removeStep(unsigned int step_index)
Remove steps with specific index from queue.
int lastStepIndex() const
Returns last step index enqueued for execution.
std::string toString(const StepControllerState &state)
bool getStepAt(msgs::Step &step, unsigned int position=0u)
Retrieves step of execution queue.
bool empty() const
Checks if there are steps in queue.
void removeSteps(unsigned int from_step_index, int to_step_index=-1)
Remove steps in the given range [from_step_index, to_step_index].
bool isDirty() const
Returns if step queue has been changed.
int firstStepIndex() const
Returns next step index enqueued for execution.
boost::unique_lock< Mutex > UniqueLock
void clearDirtyFlag()
Resets dirty flag.
bool updateStepPlan(const msgs::StepPlan &step_plan, int min_step_index=0)
Merges given step plan to the current execution queue of steps. Hereby, two cases have to considered:...
std::vector< msgs::Step > getSteps(unsigned int start_index, unsigned int end_index) const
getSteps Retrieves all steps with index in range of [start_index; end_index]
boost::shared_lock< Mutex > SharedLock
size_t size() const
Returns size of step queue.
bool getStep(msgs::Step &step, unsigned int step_index=0u)
Retrieves step of execution queue.