Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class JointTrajectoryController : public controller_interface::ControllerInterfa
Params params_;

trajectory_msgs::msg::JointTrajectoryPoint last_commanded_state_;
rclcpp::Time last_commanded_time_;
/// Specify interpolation method. Default to splines.
interpolation_methods::InterpolationMethod interpolation_method_{
interpolation_methods::DEFAULT_INTERPOLATION};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,12 @@ controller_interface::return_type JointTrajectoryController::update(
first_sample = true;
if (params_.open_loop_control)
{
if (last_commanded_time_.seconds() == 0.0)
{
last_commanded_time_ = time;
}
traj_external_point_ptr_->set_point_before_trajectory_msg(
time, last_commanded_state_, joints_angle_wraparound_);
last_commanded_time_, last_commanded_state_, joints_angle_wraparound_);
}
else
{
Expand Down Expand Up @@ -310,6 +314,7 @@ controller_interface::return_type JointTrajectoryController::update(

// store the previous command. Used in open-loop control mode
last_commanded_state_ = state_desired_;
last_commanded_time_ = time;
}

if (active_goal)
Expand Down Expand Up @@ -937,6 +942,7 @@ controller_interface::CallbackReturn JointTrajectoryController::on_activate(
read_state_from_state_interfaces(state_current_);
read_state_from_state_interfaces(last_commanded_state_);
}
last_commanded_time_ = rclcpp::Time();

// The controller should start by holding position at the beginning of active state
add_new_trajectory_msg(set_hold_position());
Expand Down