37 #ifndef JOINT_TRAJECTORY_ACTION_CONTROLLER_H__ 38 #define JOINT_TRAJECTORY_ACTION_CONTROLLER_H__ 42 #include <boost/scoped_ptr.hpp> 43 #include <boost/shared_ptr.hpp> 49 #include <filters/filter_chain.hpp> 55 #include <control_msgs/FollowJointTrajectoryAction.h> 56 #include <trajectory_msgs/JointTrajectory.h> 57 #include <pr2_controllers_msgs/QueryTrajectoryState.h> 58 #include <pr2_controllers_msgs/JointTrajectoryControllerState.h> 59 #include <pr2_controllers_msgs/JointTrajectoryAction.h> 64 template <
class Action>
72 #if ((actionlib_VERSION_MAJOR == 1) && (actionlib_VERSION_MINOR < 12)) || (actionlib_VERSION_MAJOR < 1) 89 : req_abort_(false), req_succeed_(false), gh_(gh), preallocated_result_(preallocated_result)
91 if (!preallocated_result_)
92 preallocated_result_.reset(
new Result);
93 if (!preallocated_feedback_)
94 preallocated_feedback_.reset(
new Feedback);
97 void setAborted(ResultConstPtr result = ResultConstPtr((Result*)NULL))
99 if (!req_succeed_ && !req_abort_)
101 req_result_ = result;
106 void setSucceeded(ResultConstPtr result = ResultConstPtr((Result*)NULL))
108 if (!req_succeed_ && !req_abort_)
110 req_result_ = result;
122 using namespace actionlib_msgs;
126 if (req_abort_ && gs.status == GoalStatus::ACTIVE)
133 else if (req_succeed_ && gs.status == GoalStatus::ACTIVE)
147 JointTolerance(
double _position = 0,
double _velocity = 0,
double _acceleration = 0) :
148 position(_position), velocity(_velocity), acceleration(_acceleration)
152 bool violated(
double p_err,
double v_err = 0,
double a_err = 0)
const 155 (position > 0 && fabs(p_err) > position) ||
156 (velocity > 0 && fabs(v_err) > velocity) ||
157 (acceleration > 0 && fabs(a_err) > acceleration);
192 std::vector<pr2_mechanism_model::JointState*>
joints_;
194 std::vector<control_toolbox::Pid>
pids_;
196 std::vector<control_toolbox::LimitedProxy>
proxies_;
212 void commandCB(
const trajectory_msgs::JointTrajectory::ConstPtr &msg);
215 bool queryStateService(pr2_controllers_msgs::QueryTrajectoryState::Request &req,
216 pr2_controllers_msgs::QueryTrajectoryState::Response &resp);
225 void goalCB(GoalHandle gh);
226 void cancelCB(GoalHandle gh);
227 void goalCBFollow(GoalHandleFollow gh);
228 void cancelCBFollow(GoalHandleFollow gh);
236 void commandTrajectory(
const trajectory_msgs::JointTrajectory::ConstPtr &traj,
240 void preemptActiveGoal();
274 std::vector<double> q, qd,
qdd;
279 static void sampleSplineWithTimeBounds(
const std::vector<double>& coefficients,
double duration,
double time,
280 double& position,
double& velocity,
double& acceleration);
ACTION_DEFINITION(Action)
actionlib::ServerGoalHandle< Action > GoalHandle
bool violated(double p_err, double v_err=0, double a_err=0) const
std::vector< Spline > splines
RTServerGoalHandle< pr2_controllers_msgs::JointTrajectoryAction > RTGoalHandle
realtime_tools::RealtimeBox< boost::shared_ptr< const SpecifiedTrajectory > > current_trajectory_box_
boost::shared_ptr< const Goal > getGoal() const
boost::shared_ptr< Feedback > FeedbackPtr
std::vector< bool > proxies_enabled_
RTServerGoalHandle(GoalHandle &gh, const ResultPtr &preallocated_result=ResultPtr((Result *) NULL))
void init(const M_string &remappings)
std::vector< JointTolerance > default_goal_tolerance_
FJTAS::GoalHandle GoalHandleFollow
void setAborted(ResultConstPtr result=ResultConstPtr((Result *) NULL))
JointTolerance(double _position=0, double _velocity=0, double _acceleration=0)
actionlib_msgs::GoalStatus getGoalStatus() const
std::vector< JointTolerance > default_trajectory_tolerance_
std::vector< double > coef
FeedbackPtr preallocated_feedback_
std::vector< control_toolbox::Pid > pids_
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
std::vector< JointTolerance > goal_tolerance
boost::scoped_ptr< realtime_tools::RealtimePublisher< pr2_controllers_msgs::JointTrajectoryControllerState > > controller_state_publisher_
boost::scoped_ptr< FJTAS > action_server_follow_
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
std::vector< double > masses_
void setSucceeded(ResultConstPtr result=ResultConstPtr((Result *) NULL))
ResultConstPtr req_result_
pr2_mechanism_model::RobotState * robot_
ResultPtr preallocated_result_
boost::shared_ptr< RTGoalHandleFollow > rt_active_goal_follow_
actionlib::ActionServer< control_msgs::FollowJointTrajectoryAction > FJTAS
JTAS::GoalHandle GoalHandle
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
boost::shared_ptr< RTGoalHandle > gh
std::vector< Segment > SpecifiedTrajectory
boost::shared_ptr< RTGoalHandle > rt_active_goal_
actionlib::ActionServer< pr2_controllers_msgs::JointTrajectoryAction > JTAS
boost::shared_ptr< RTGoalHandleFollow > gh_follow
RTServerGoalHandle< control_msgs::FollowJointTrajectoryAction > RTGoalHandleFollow
std::vector< double > qdd
boost::shared_ptr< Result > ResultPtr
std::vector< control_toolbox::LimitedProxy > proxies_
ros::Timer goal_handle_timer_
ros::ServiceServer serve_query_state_
std::vector< JointTolerance > trajectory_tolerance
std::vector< boost::shared_ptr< filters::FilterChain< double > > > output_filters_
double default_goal_time_constraint_
boost::scoped_ptr< JTAS > action_server_
double goal_time_tolerance
ros::Subscriber sub_command_
std::vector< pr2_mechanism_model::JointState * > joints_
void runNonRT(const ros::TimerEvent &te)