Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ void JointTrajectoryController::publish_state(
state_publisher_legacy_->msg_.desired.velocities = desired_state.velocities;
state_publisher_legacy_->msg_.desired.accelerations = desired_state.accelerations;
state_publisher_legacy_->msg_.actual.positions = current_state.positions;
state_publisher_legacy_->msg_.actual.time_from_start = current_state.time_from_start;
state_publisher_legacy_->msg_.error.positions = state_error.positions;
if (has_velocity_state_interface_)
{
Expand Down Expand Up @@ -1175,6 +1176,7 @@ void JointTrajectoryController::publish_state(
state_publisher_->msg_.reference.positions = desired_state.positions;
state_publisher_->msg_.reference.velocities = desired_state.velocities;
state_publisher_->msg_.reference.accelerations = desired_state.accelerations;
state_publisher_->msg_.reference.time_from_start = desired_state.time_from_start;
state_publisher_->msg_.feedback.positions = current_state.positions;
// DESIRED and ACTUAL are deprecated in the message but we are still
// reporting on them
Expand All @@ -1183,6 +1185,7 @@ void JointTrajectoryController::publish_state(
state_publisher_legacy_->msg_.desired.accelerations = desired_state.accelerations;
state_publisher_legacy_->msg_.actual.positions = current_state.positions;
state_publisher_->msg_.error.positions = state_error.positions;
state_publisher_->msg_.feedback.time_from_start = desired_state.time_from_start;
if (has_velocity_state_interface_)
{
state_publisher_->msg_.feedback.velocities = current_state.velocities;
Expand Down
1 change: 1 addition & 0 deletions joint_trajectory_controller/src/trajectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ bool Trajectory::sample(
}
start_segment_itr = begin() + static_cast<TrajectoryPointConstIter::difference_type>(i);
end_segment_itr = begin() + static_cast<TrajectoryPointConstIter::difference_type>(i + 1);
output_state.time_from_start = next_point.time_from_start;
last_sample_idx_ = i;
return true;
}
Expand Down
21 changes: 21 additions & 0 deletions joint_trajectory_controller/test/test_trajectory_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,27 @@ TEST_P(TrajectoryControllerTestParameterized, state_topic_consistency)
EXPECT_EQ(n_joints, state->output.effort.size());
}
}
TEST_F(TrajectoryControllerTest, time_from_start_populated)
{
rclcpp::executors::SingleThreadedExecutor executor;
SetUpAndActivateTrajectoryController(executor, {});
subscribeToState(executor);

// schedule a single waypoint at 100ms:
builtin_interfaces::msg::Duration tfs; tfs.sec = 0; tfs.nanosec = 100000000;
publish(tfs, {INITIAL_POS_JOINTS}, rclcpp::Time(0));
traj_controller_->wait_for_trajectory(executor);

updateController();
// give the publish timer one more spin
executor.spin_some();

auto state = getState();
ASSERT_TRUE(state);
EXPECT_EQ(state->feedback.time_from_start.sec, 0u);
EXPECT_EQ(state->feedback.time_from_start.nanosec, 100000000u);
}


/**
* @brief check if dynamic parameters are updated
Expand Down
Loading