18 #ifndef COB_TWIST_CONTROLLER_TASK_STACK_TASK_STACK_CONTROLLER_H 19 #define COB_TWIST_CONTROLLER_TASK_STACK_TASK_STACK_CONTROLLER_H 26 #include <boost/shared_ptr.hpp> 27 #include <Eigen/Dense> 43 Task(
PRIO prio, std::string
id) : prio_(prio), id_(id), is_active_(true)
46 Task(
PRIO prio, std::string
id, Eigen::MatrixXd task_jacobian, Eigen::VectorXd task)
47 : prio_(prio), id_(id), task_jacobian_(task_jacobian), task_(task), is_active_(true)
53 task_jacobian_(task.task_jacobian_),
55 is_active_(task.is_active_),
69 return ( this->prio_ < other.
prio_ );
74 return ( this->prio_ > other.
prio_ );
79 return ( this->prio_ == other.
prio_ );
88 typedef typename std::vector<Task<PRIO> >::iterator
TypedIter_t;
98 this->active_task_iter_ = this->tasks_.begin();
102 void clearAllTasks();
106 void deactivateTask(
typename std::vector<
Task<PRIO> >::iterator it);
107 void deactivateTask(std::string task_id);
108 void activateTask(std::string task_id);
109 void deactivateAllTasks();
111 void activateAllTasks();
112 void activateHighestPrioTask();
114 typename std::vector<Task<PRIO> >::iterator getTasksBegin();
115 typename std::vector<Task<PRIO> >::iterator getTasksEnd();
116 typename std::vector<Task<PRIO> >::iterator nextActiveTask();
117 typename std::vector<Task<PRIO> >::iterator beginTaskIter();
119 int countActiveTasks()
const;
120 ros::Time getLastModificationTime()
const;
123 void updateModificationTime(
bool change);
130 template <
typename PRIO>
134 for (
TypedConstIter_t it = this->tasks_.begin(); it != this->tasks_.end(); it++)
148 template <
typename PRIO>
153 for (
TypedIter_t it = this->tasks_.begin(); it != this->tasks_.end(); it++)
155 if (it->id_ == t.
id_)
165 if (this->tasks_.end() == mem_it)
167 for (
TypedIter_t it = this->tasks_.begin(); it != this->tasks_.end(); it++)
169 if (t.
prio_ < it->prio_)
176 if (this->tasks_.end() == mem_it)
178 this->tasks_.push_back(t);
182 this->tasks_.insert(mem_it, t);
185 this->updateModificationTime(
true);
189 template <
typename PRIO>
193 for (
TypedIter_t it = this->tasks_.begin(); it != this->tasks_.end(); it++)
200 it->is_active_ =
true;
203 this->updateModificationTime(change);
206 template <
typename PRIO>
210 if (this->tasks_.end() != it)
212 this->updateModificationTime(!it->is_active_);
214 ROS_WARN_STREAM(
"Activation of highest prio task in stack: " << it->id_);
215 it->is_active_ =
true;
219 template <
typename PRIO>
222 return this->tasks_.begin();
225 template <
typename PRIO>
228 return this->tasks_.end();
231 template <
typename PRIO>
234 for (
TypedIter_t it = this->tasks_.begin(); it != this->tasks_.end(); it++)
236 if (it->id_ == task_id)
238 this->updateModificationTime(!it->is_active_);
239 it->is_active_ =
true;
245 template <
typename PRIO>
248 if (std::find(this->tasks_.begin(), this->tasks_.end(), it) != this->tasks_.end())
250 this->updateModificationTime(it->is_active_);
251 it->is_active_ =
false;
255 template <
typename PRIO>
258 for (
TypedIter_t it = this->tasks_.begin(); it != this->tasks_.end(); it++)
260 if (it->id_ == task_id)
262 this->updateModificationTime(it->is_active_);
263 it->is_active_ =
false;
269 template <
typename PRIO>
273 for (
TypedIter_t it = this->tasks_.begin(); it != this->tasks_.end(); it++)
280 it->is_active_ =
false;
283 this->updateModificationTime(change);
286 template <
typename PRIO>
291 while (this->tasks_.end() != this->active_task_iter_)
293 if (this->active_task_iter_->is_active_)
295 ret = this->active_task_iter_++;
299 this->active_task_iter_++;
305 template <
typename PRIO>
308 this->active_task_iter_ = this->tasks_.begin();
309 return this->active_task_iter_;
312 template <
typename PRIO>
315 this->tasks_.clear();
316 this->active_task_iter_ = this->tasks_.end();
317 this->updateModificationTime(
true);
320 template <
typename PRIO>
323 return this->modification_time_;
326 template <
typename PRIO>
340 #endif // COB_TWIST_CONTROLLER_TASK_STACK_TASK_STACK_CONTROLLER_H
void setPriority(PRIO prio)
Task(PRIO prio, std::string id)
std::vector< Task< PRIO > >::iterator TypedIter_t
void updateModificationTime(bool change)
std::vector< Task< PRIO > > tasks_
TwistControllerParams tcp_
void addTask(Task< PRIO > t)
geometry_msgs::TransformStamped t
void activateTask(std::string task_id)
std::vector< Task< PRIO > >::iterator getTasksEnd()
int countActiveTasks() const
void deactivateTask(typename std::vector< Task< PRIO > >::iterator it)
bool operator>(const Task &other) const
std::vector< Task< PRIO > >::iterator beginTaskIter()
void activateHighestPrioTask()
bool operator<(const Task &other) const
std::vector< Task< PRIO > >::iterator nextActiveTask()
TaskStackController< uint32_t > TaskStackController_t
Task(PRIO prio, std::string id, Eigen::MatrixXd task_jacobian, Eigen::VectorXd task)
#define ROS_WARN_STREAM(args)
ros::Time modification_time_
Eigen::MatrixXd task_jacobian_
ros::Time getLastModificationTime() const
void deactivateAllTasks()
TypedIter_t active_task_iter_
std::vector< Task< PRIO > >::iterator getTasksBegin()
std::vector< Task< PRIO > >::const_iterator TypedConstIter_t
bool operator==(const Task &other) const
std::vector< Task_t >::iterator TaskSetIter_t