Skip to content

Commit

Permalink
Update end trajectory test to be timer-based
Browse files Browse the repository at this point in the history
This switches how the joint trajectory action detects the end of a
trajectory. Previously, we would wait for the robot to be in-motion
then exit being in-motion. However, this caused stalling issues for
short trajectories. Now, we wait until the time expected to complete
the trajectory has passed and the robot is not in motion.
  • Loading branch information
nardavin committed Mar 29, 2022
1 parent 01146c8 commit d1cd81a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ class JointTrajectoryAction
ros::Timer watchdog_timer_;

/**
* \brief Indicates whether a motion has been started
* \brief The time that the active trajectory is expected to end execution.
* Used to determine when to begin checking for goal completion.
*/
bool motion_started_;
ros::Time expected_traj_end_;

/**
* \brief Indicates action has an active goal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ JointTrajectoryAction::JointTrajectoryAction() :
boost::bind(&JointTrajectoryAction::watchdog, this, _1));

has_active_goal_ = false;
motion_started_ = false;

action_server_.start();
}
Expand All @@ -102,7 +101,6 @@ void JointTrajectoryAction::robotStatusCB(
const industrial_msgs::RobotStatusConstPtr &msg)
{
last_robot_status_ = msg; // caching robot status for later use.
motion_started_ |= (msg->in_motion.val != industrial_msgs::TriState::FALSE);
}

void JointTrajectoryAction::watchdog(const ros::TimerEvent &e)
Expand Down Expand Up @@ -309,8 +307,9 @@ void JointTrajectoryAction::goalCB(JointTractoryActionServer::GoalHandle gh)
// Publishing the joint names for the 4 groups
dyn_traj.joint_names = all_joint_names_;

motion_started_ = false;
this->pub_trajectory_command_.publish(dyn_traj);

expected_traj_end_ = ros::Time::now() + gh.getGoal()->trajectory.points.back().time_from_start;
}
else
{
Expand Down Expand Up @@ -400,9 +399,9 @@ void JointTrajectoryAction::controllerStateCB(
return;
}

if (!motion_started_)
if (ros::Time::now() < expected_traj_end_)
{
ROS_DEBUG("Motion has not started, ignoring feedback");
ROS_DEBUG("Motion has not ended, ignoring feedback");
return;
}

Expand Down

0 comments on commit d1cd81a

Please sign in to comment.