ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

joint_trajectory_action question

asked 2013-06-02 06:00:32 -0500

AdrianPeng gravatar image

I am reading the joint_trajectory_action.cpp file in joint_trajectory_action ros package.

I have a question about following callback function.

void goalCB(GoalHandle gh)
  // Ensures that the joints in the goal match the joints we are commanding.
  if (!setsEqual(joint_names_, gh.getGoal()->trajectory.joint_names))
    ROS_ERROR("Joints on incoming goal don't match our joints");

  // Cancels the currently active goal.
  if (has_active_goal_)
    // Stops the controller.
    trajectory_msgs::JointTrajectory empty;
    empty.joint_names = joint_names_;

    // Marks the current goal as canceled.
    has_active_goal_ = false;

  active_goal_ = gh;
  has_active_goal_ = true;

  // Sends the trajectory along to the controller
  current_traj_ = active_goal_.getGoal()->trajectory;

I don't understand why it needs to cancel the currently active goal.

Thanks for any help in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-06-02 21:49:16 -0500

Adolfo Rodriguez T gravatar image

This action server implements a goal policy in which only one goal is active and new goals preempt previous goals, ie. it always executes the latest received goal.

In this context, "Cancels the currently active goal" means canceling the trajectory that was being executed prior to the goal that woke up the goalCB callback. Note that the currently active goal is not the goal that that woke up the goalCB callback.

Since what remains of the currently active goal won't be executed, it makes sense to cancel it, providing clients with feedback that allows them to take proper action, if needed.

edit flag offensive delete link more


Very clear! Thanks!

AdrianPeng gravatar image AdrianPeng  ( 2013-06-03 05:13:24 -0500 )edit

Question Tools


Asked: 2013-06-02 06:00:32 -0500

Seen: 1,285 times

Last updated: Jun 02 '13