Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef COB_TWIST_CONTROLLER_CONSTRAINTS_CONSTRAINT_IMPL_H
00019 #define COB_TWIST_CONTROLLER_CONSTRAINTS_CONSTRAINT_IMPL_H
00020
00021 #include <sstream>
00022 #include <set>
00023 #include <vector>
00024 #include <string>
00025 #include <ros/ros.h>
00026
00027 #include <boost/shared_ptr.hpp>
00028 #include <boost/pointer_cast.hpp>
00029
00030 #include <kdl/chainjnttojacsolver.hpp>
00031
00032 #include "cob_twist_controller/constraints/constraint.h"
00033 #include "cob_twist_controller/constraints/constraint_params.h"
00034
00035
00039 template <typename PRIO>
00040 std::set<ConstraintBase_t> ConstraintsBuilder<PRIO>::createConstraints(const TwistControllerParams& tc_params,
00041 const LimiterParams& limiter_params,
00042 KDL::ChainJntToJacSolver& jnt_to_jac,
00043 KDL::ChainFkSolverVel_recursive& fk_solver_vel,
00044 CallbackDataMediator& data_mediator)
00045 {
00046 std::set<ConstraintBase_t> constraints;
00047
00048 if (JLA_ON == tc_params.constraint_jla)
00049 {
00050 typedef JointLimitAvoidance<ConstraintParamsJLA, PRIO> Jla_t;
00051
00052 ConstraintParamsJLA params = ConstraintParamsJLA(tc_params.constraint_params.at(JLA), limiter_params);
00053 uint32_t startPrio = params.params_.priority;
00054 for (uint32_t i = 0; i < tc_params.joints.size(); ++i)
00055 {
00056
00057 params.joint_ = tc_params.joints[i];
00058 params.joint_idx_ = static_cast<int32_t>(i);
00059 boost::shared_ptr<Jla_t > jla(new Jla_t(startPrio++, params, data_mediator));
00060 constraints.insert(boost::static_pointer_cast<PriorityBase<PRIO> >(jla));
00061 }
00062 }
00063 else if (JLA_MID_ON == tc_params.constraint_jla)
00064 {
00065 typedef JointLimitAvoidanceMid<ConstraintParamsJLA, PRIO> JlaMid_t;
00066
00067 ConstraintParamsJLA params = ConstraintParamsJLA(tc_params.constraint_params.at(JLA), limiter_params);
00068
00069 boost::shared_ptr<JlaMid_t > jla(new JlaMid_t(params.params_.priority, params, data_mediator));
00070 constraints.insert(boost::static_pointer_cast<PriorityBase<PRIO> >(jla));
00071 }
00072 else if (JLA_INEQ_ON == tc_params.constraint_jla)
00073 {
00074 typedef JointLimitAvoidanceIneq<ConstraintParamsJLA, PRIO> Jla_t;
00075
00076 ConstraintParamsJLA params = ConstraintParamsJLA(tc_params.constraint_params.at(JLA), limiter_params);
00077 uint32_t startPrio = params.params_.priority;
00078 for (uint32_t i = 0; i < tc_params.joints.size(); ++i)
00079 {
00080
00081 params.joint_ = tc_params.joints[i];
00082 params.joint_idx_ = static_cast<int32_t>(i);
00083 boost::shared_ptr<Jla_t > jla(new Jla_t(startPrio++, params, data_mediator));
00084 constraints.insert(boost::static_pointer_cast<PriorityBase<PRIO> >(jla));
00085 }
00086 }
00087 else
00088 {
00089
00090 }
00091
00092
00093 if (CA_ON == tc_params.constraint_ca)
00094 {
00095 typedef CollisionAvoidance<ConstraintParamsCA, PRIO> CollisionAvoidance_t;
00096 uint32_t startPrio = tc_params.constraint_params.at(CA).priority;
00097
00098 for (std::vector<std::string>::const_iterator it = tc_params.collision_check_links.begin();
00099 it != tc_params.collision_check_links.end(); it++)
00100 {
00101 ConstraintParamsCA params = ConstraintParamsCA(tc_params.constraint_params.at(CA),tc_params.frame_names, *it);
00102 data_mediator.fill(params);
00103
00104 boost::shared_ptr<CollisionAvoidance_t > ca(new CollisionAvoidance_t(startPrio--, params, data_mediator, jnt_to_jac, fk_solver_vel));
00105 constraints.insert(boost::static_pointer_cast<PriorityBase<PRIO> >(ca));
00106 }
00107 }
00108 else
00109 {
00110
00111 }
00112
00113 return constraints;
00114 }
00115
00116
00117
00118 #include "cob_twist_controller/constraints/constraint_ca_impl.h"
00119
00120
00121 #include "cob_twist_controller/constraints/constraint_jla_impl.h"
00122
00123 #endif // COB_TWIST_CONTROLLER_CONSTRAINTS_CONSTRAINT_IMPL_H