Skip to content

Commit fefc38d

Browse files
Implement effort feedforward
1 parent a80e6f7 commit fefc38d

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

joint_trajectory_controller/src/joint_trajectory_controller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,6 @@ controller_interface::return_type JointTrajectoryController::update(
328328
{
329329
if (traj_contr_)
330330
{
331-
// TODO(christophfroehlich) add has_effort_command_interface_ ?
332-
// command_next_.effort[index_cmd_joint] : 0.0)
333331
traj_contr_->compute_commands(
334332
tmp_command_, state_current_, state_error_, command_next_,
335333
time - current_trajectory_->time_from_start(), period);
@@ -1837,6 +1835,7 @@ void JointTrajectoryController::add_new_trajectory_msg_nonRT(
18371835
RCLCPP_ERROR(get_node()->get_logger(), "Failed to compute gains for trajectory.");
18381836
}
18391837
}
1838+
RCLCPP_INFO(get_node()->get_logger(), "Called add_new_trajectory_msg_nonRT.");
18401839
}
18411840

18421841
void JointTrajectoryController::add_new_trajectory_msg_RT(
@@ -1856,6 +1855,7 @@ void JointTrajectoryController::add_new_trajectory_msg_RT(
18561855
RCLCPP_ERROR(get_node()->get_logger(), "Failed to compute gains for trajectory.");
18571856
}
18581857
}
1858+
RCLCPP_INFO(get_node()->get_logger(), "Called add_new_trajectory_msg_RT.");
18591859
}
18601860

18611861
void JointTrajectoryController::preempt_active_goal()

joint_trajectory_controller/test/test_trajectory_controller_utils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ class TrajectoryControllerTest : public ::testing::Test
698698
EXPECT_EQ(effort.at(2), joint_eff_[2]);
699699
}
700700
}
701-
else // traj_controller_->use_closed_loop_pid_adapter() == true
701+
else // traj_controller_->use_external_control_law() == true
702702
{
703703
// velocity or effort PID?
704704
// --> set kp > 0.0 in test

joint_trajectory_controller_plugins/src/pid_trajectory_plugin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,14 @@ void PidTrajectoryPlugin::compute_commands(
128128
const trajectory_msgs::msg::JointTrajectoryPoint desired,
129129
const rclcpp::Duration & /*duration_since_start*/, const rclcpp::Duration & period)
130130
{
131+
// if effort field is present, otherwise it would have been rejected
132+
auto has_effort_command_interface = !desired.effort.empty();
131133
// Update PIDs
132134
for (auto i = 0ul; i < num_cmd_joints_; ++i)
133135
{
134136
tmp_command[map_cmd_to_joints_[i]] =
135137
(desired.velocities[map_cmd_to_joints_[i]] * ff_velocity_scale_[i]) +
138+
(has_effort_command_interface ? desired.effort[i] : 0.0) +
136139
pids_[i]->compute_command(
137140
error.positions[map_cmd_to_joints_[i]], error.velocities[map_cmd_to_joints_[i]], period);
138141
}

0 commit comments

Comments
 (0)