Skip to content
Open
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 @@ -1312,8 +1312,10 @@ 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;
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;
if (search_monotonically_increasing)
{
last_sample_idx_ = i;
Expand Down
22 changes: 22 additions & 0 deletions joint_trajectory_controller/test/test_trajectory_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,28 @@ TEST_P(TrajectoryControllerTestParameterized, state_topic_consistency_command_jo
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