36 namespace joint_trajectory_action
45 controller_alive_(false), has_moved_once_(false)
52 ROS_ERROR(
"Failed to initialize joint_names.");
80 ROS_WARN(
"Aborting goal because motion possible status is FALSE.");
91 ROS_DEBUG(
"Waiting for subscription to joint trajectory state");
104 ROS_WARN(
"Aborting goal because we have never heard a controller state message.");
109 "Aborting goal because we haven't heard from the controller in " <<
WATCHDOG_PERIOD_ <<
" seconds");
123 ROS_ERROR(
"Joint trajectory action rejected: waiting for (initial) feedback from controller");
124 control_msgs::FollowJointTrajectoryResult rslt;
125 rslt.error_code = control_msgs::FollowJointTrajectoryResult::INVALID_GOAL;
126 gh.
setRejected(rslt,
"Waiting for (initial) feedback from controller");
132 if (!gh.
getGoal()->trajectory.points.empty())
140 ROS_WARN(
"Received new goal, canceling current goal");
158 ROS_WARN(
"Cancel publishing trajectory because of current position is goal");
163 ROS_ERROR(
"Joint trajectory action failing on invalid joints");
164 control_msgs::FollowJointTrajectoryResult rslt;
165 rslt.error_code = control_msgs::FollowJointTrajectoryResult::INVALID_JOINTS;
171 ROS_ERROR(
"Joint trajectory action failed on empty trajectory");
172 control_msgs::FollowJointTrajectoryResult rslt;
173 rslt.error_code = control_msgs::FollowJointTrajectoryResult::INVALID_GOAL;
178 if (gh.
getGoal()->goal_time_tolerance.toSec() > 0.0)
180 ROS_WARN_STREAM(
"Ignoring goal time tolerance in action goal, may be supported in the future");
182 if (!gh.
getGoal()->goal_tolerance.empty())
185 "Ignoring goal tolerance in action, using paramater tolerance of " <<
goal_threshold_ <<
" instead");
187 if (!gh.
getGoal()->path_tolerance.empty())
189 ROS_WARN_STREAM(
"Ignoring goal path tolerance, option not supported by ROS-Industrial drivers");
195 ROS_DEBUG(
"Received action cancel request");
199 trajectory_msgs::JointTrajectory empty;
209 ROS_WARN(
"Active goal and goal cancel do not match, ignoring cancel request");
215 ROS_DEBUG(
"Checking controller state feedback");
229 ROS_DEBUG(
"Current trajectory is empty, ignoring feedback");
235 ROS_ERROR(
"Joint names from the controller don't match our joint names.");
241 ROS_DEBUG(
"Waiting to check for goal completion until halfway through trajectory");
259 ROS_INFO(
"Inside goal constraints, stopped moving, return success for action");
265 ROS_INFO(
"Inside goal constraints, return success for action");
266 ROS_WARN(
"Robot status in motion unknown, the robot driver node and controller code should be updated");
272 ROS_DEBUG(
"Within goal constraints but robot is still moving");
277 ROS_INFO(
"Inside goal constraints, return success for action");
278 ROS_WARN(
"Robot status is not being published the robot driver node and controller code should be updated");
290 trajectory_msgs::JointTrajectory empty;
303 trajectory_msgs::JointTrajectory empty;
312 const trajectory_msgs::JointTrajectory & traj)
315 if (traj.points.empty())
317 ROS_WARN(
"Empty joint trajectory passed to check goal constraints, return false");
322 int last_point = traj.points.size() - 1;
ros::Publisher pub_trajectory_command_
Publishes desired trajectory (typically to the robot driver)
bool getJointNames(const std::string joint_list_param, const std::string urdf_param, std::vector< std::string > &joint_names)
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle node_
Internal ROS node handle.
bool withinGoalConstraints(const control_msgs::FollowJointTrajectoryFeedbackConstPtr &msg, const trajectory_msgs::JointTrajectory &traj)
Controller status callback (executed when robot status message received)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void setRejected(const Result &result=Result(), const std::string &text=std::string(""))
bool has_moved_once_
Indicates that the robot has been in a moving state at least once since starting the current active t...
boost::shared_ptr< const Goal > getGoal() const
industrial_msgs::RobotStatusConstPtr last_robot_status_
Cache of the last subscribed status message.
bool controller_alive_
Controller was alive during the last watchdog interval.
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool cancelMotionCB(std_srvs::EmptyRequest &req, std_srvs::EmptyResponse &res)
Cancel motion callback (executed when cancel_motion service is called)
ros::ServiceServer srv_cancel_motion_
Service to stop robot motion.
void setCanceled(const Result &result=Result(), const std::string &text=std::string(""))
void abortGoal()
Aborts the current action goal and sends a stop command (empty message) to the robot driver...
void goalCB(JointTractoryActionServer::GoalHandle gh)
Action server goal callback method.
void setAccepted(const std::string &text=std::string(""))
static const double WATCHDOG_PERIOD_
The watchdog period (seconds)
JointTractoryActionServer action_server_
Internal action server.
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
control_msgs::FollowJointTrajectoryFeedbackConstPtr last_trajectory_state_
Cache of the last subscribed feedback message.
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
~FSRoboRJointTrajectoryAction()
Destructor.
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
void robotStatusCB(const industrial_msgs::RobotStatusConstPtr &msg)
Controller status callback (executed when robot status message received)
double goal_threshold_
The goal joint threshold used for determining if a robot is near it final destination. A single value is used for all joints.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::Subscriber sub_robot_status_
Subscribes to the robot status (typically published by the robot driver).
bool isSimilar(std::vector< std::string > lhs, std::vector< std::string > rhs)
void controllerStateCB(const control_msgs::FollowJointTrajectoryFeedbackConstPtr &msg)
Controller state callback (executed when feedback message received)
bool has_active_goal_
Indicates action has an active goal.
#define ROS_WARN_STREAM(args)
FSRoboRJointTrajectoryAction()
Constructor.
std::vector< std::string > joint_names_
The joint names associated with the robot the action is interfacing with. The joint names must be the...
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
trajectory_msgs::JointTrajectory current_traj_
Cache of the current active trajectory.
#define ROS_INFO_STREAM(args)
ros::Time time_to_check_
Time at which to start checking for completion of current goal, if one is active. ...
ros::Timer watchdog_timer_
Watchdog time used to fail the action request if the robot driver is not responding.
void watchdog(const ros::TimerEvent &e)
Watch dog callback, used to detect robot driver failures.
bool isWithinRange(const std::vector< double > &lhs, const std::vector< double > &rhs, double full_range)
void cancelCB(JointTractoryActionServer::GoalHandle gh)
Action server cancel callback method.
static const double DEFAULT_GOAL_THRESHOLD_
The default goal joint threshold see(goal_threshold). Unit are joint specific (i.e. radians or meters).
JointTractoryActionServer::GoalHandle active_goal_
Cache of the current active goal.
ros::Subscriber sub_trajectory_state_
Subscribes to trajectory feedback (typically published by the robot driver).