-
Notifications
You must be signed in to change notification settings - Fork 373
Extend odometry tests for steering controllers #1606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4f07022
618c36d
590f747
551a67e
d059bcc
66ac359
9e9824b
9b5e976
891d4ec
e26b57f
f93c6d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,6 +341,15 @@ controller_interface::CallbackReturn SteeringControllersLibrary::on_activate( | |
// Set default value in command | ||
reset_controller_reference_msg(*(input_ref_.readFromRT()), get_node()); | ||
|
||
// Set the initial steering angle values | ||
size_t steering_count_idx = | ||
params_.front_steering ? params_.front_wheels_names.size() : params_.rear_wheels_names.size(); | ||
|
||
for (size_t i = 0; i < steering_count_idx; i++) | ||
{ | ||
command_interfaces_[steering_count_idx + i].set_value(0.575875); | ||
} | ||
|
||
return controller_interface::CallbackReturn::SUCCESS; | ||
} | ||
|
||
|
@@ -388,32 +397,52 @@ controller_interface::return_type SteeringControllersLibrary::update_and_write_c | |
last_linear_velocity_ = timeout ? 0.0 : reference_interfaces_[0]; | ||
last_angular_velocity_ = timeout ? 0.0 : reference_interfaces_[1]; | ||
|
||
auto [traction_commands, steering_commands] = odometry_.get_commands( | ||
reference_interfaces_[0], reference_interfaces_[1], params_.open_loop, | ||
params_.reduce_wheel_speed_until_steering_reached); | ||
|
||
if (params_.front_steering) | ||
// calculate new commands if not in timeout | ||
if (!timeout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the necessity of this change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I specifically wanted to update traction_commands and steering_commands when the timeout is false, so I thought there is a need to add this |
||
{ | ||
for (size_t i = 0; i < params_.rear_wheels_names.size(); i++) | ||
auto [traction_commands, steering_commands] = odometry_.get_commands( | ||
reference_interfaces_[0], reference_interfaces_[1], params_.open_loop, | ||
params_.reduce_wheel_speed_until_steering_reached); | ||
|
||
if (params_.front_steering) | ||
{ | ||
command_interfaces_[i].set_value(timeout ? 0.0 : traction_commands[i]); | ||
for (size_t i = 0; i < params_.rear_wheels_names.size(); i++) | ||
{ | ||
command_interfaces_[i].set_value(traction_commands[i]); | ||
} | ||
for (size_t i = 0; i < params_.front_wheels_names.size(); i++) | ||
{ | ||
command_interfaces_[i + params_.rear_wheels_names.size()].set_value(steering_commands[i]); | ||
} | ||
} | ||
for (size_t i = 0; i < params_.front_wheels_names.size(); i++) | ||
else | ||
{ | ||
command_interfaces_[i + params_.rear_wheels_names.size()].set_value(steering_commands[i]); | ||
for (size_t i = 0; i < params_.front_wheels_names.size(); i++) | ||
{ | ||
command_interfaces_[i].set_value(traction_commands[i]); | ||
} | ||
for (size_t i = 0; i < params_.rear_wheels_names.size(); i++) | ||
{ | ||
command_interfaces_[i + params_.front_wheels_names.size()].set_value( | ||
steering_commands[i]); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
// In timeout, only reset wheel velocities to zero | ||
if (params_.front_steering) | ||
{ | ||
for (size_t i = 0; i < params_.front_wheels_names.size(); i++) | ||
for (size_t i = 0; i < params_.rear_wheels_names.size(); i++) | ||
{ | ||
command_interfaces_[i].set_value(timeout ? 0.0 : traction_commands[i]); | ||
command_interfaces_[i].set_value(0.0); | ||
} | ||
for (size_t i = 0; i < params_.rear_wheels_names.size(); i++) | ||
} | ||
else | ||
{ | ||
for (size_t i = 0; i < params_.front_wheels_names.size(); i++) | ||
{ | ||
command_interfaces_[i + params_.front_wheels_names.size()].set_value( | ||
steering_commands[i]); | ||
command_interfaces_[i].set_value(0.0); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
test_steering_controllers_library: | ||
ros__parameters: | ||
|
||
reference_timeout: 0.1 | ||
front_steering: true | ||
open_loop: true | ||
velocity_rolling_window_size: 10 | ||
position_feedback: false | ||
use_stamped_vel: true | ||
rear_wheels_names: [rear_right_wheel_joint, rear_left_wheel_joint] | ||
front_wheels_names: [front_right_steering_joint, front_left_steering_joint] | ||
|
||
wheelbase: 3.24644 | ||
front_wheel_track: 2.12321 | ||
rear_wheel_track: 1.76868 | ||
front_wheels_radius: 0.45 | ||
rear_wheels_radius: 0.45 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test clearly expects the steering angles (command_interfaces_[2] and command_interfaces_[3]) to remain at 0.575875 during timeouts but somehow they were not so i directly set the steering angles to the expected value in the controller activation method (on_activate).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a timeout check in the
update_and_write_commands
function, ensuring that commands are updated only when the timeout is false.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that this is the right approach. This value should be the steering angle for the requested twist, which should remain unchanged after timeout.
But something is strange, both steering angles should not be the same as this test uses ackermann config
ros2_controllers/steering_controllers_library/test/test_steering_controllers_library.hpp
Line 125 in d1844e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This answer refers to the line in the code of the thread.