Skip to content

Commit 71800b2

Browse files
committedJun 8, 2024
Remove front_steering from steering library
To Accommodate controllers that are not only steering at front or rear this change remove the `front_steering` variable from steering_controller_library, as a byproduct of that the the notino of front or rear wheel radius is also removed from dependant controllers and the library has know "wheels" and "steers" joints. Signed-off-by: Quique Llorente <ellorent@redhat.com>
1 parent b245155 commit 71800b2

27 files changed

+203
-422
lines changed
 

‎ackermann_steering_controller/src/ackermann_steering_controller.cpp

+3-13
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,11 @@ controller_interface::CallbackReturn AckermannSteeringController::configure_odom
3131
{
3232
ackermann_params_ = ackermann_param_listener_->get_params();
3333

34-
const double front_wheels_radius = ackermann_params_.front_wheels_radius;
35-
const double rear_wheels_radius = ackermann_params_.rear_wheels_radius;
36-
const double front_wheel_track = ackermann_params_.front_wheel_track;
37-
const double rear_wheel_track = ackermann_params_.rear_wheel_track;
34+
const double traction_wheels_radius = ackermann_params_.traction_wheels_radius;
35+
const double traction_wheel_track = ackermann_params_.traction_wheel_track;
3836
const double wheelbase = ackermann_params_.wheelbase;
3937

40-
if (params_.front_steering)
41-
{
42-
odometry_.set_wheel_params(rear_wheels_radius, wheelbase, rear_wheel_track);
43-
}
44-
else
45-
{
46-
odometry_.set_wheel_params(front_wheels_radius, wheelbase, front_wheel_track);
47-
}
48-
38+
odometry_.set_wheel_params(traction_wheels_radius, wheelbase, traction_wheel_track);
4939
odometry_.set_odometry_type(steering_odometry::ACKERMANN_CONFIG);
5040

5141
set_interface_numbers(NR_STATE_ITFS, NR_CMD_ITFS, NR_REF_ITFS);

‎ackermann_steering_controller/src/ackermann_steering_controller.yaml

+4-26
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
ackermann_steering_controller:
2-
front_wheel_track:
2+
traction_wheel_track:
33
{
44
type: double,
55
default_value: 0.0,
6-
description: "Front wheel track length. For details see: https://en.wikipedia.org/wiki/Wheelbase",
7-
read_only: false,
8-
validation: {
9-
gt<>: [0.0]
10-
}
11-
}
12-
13-
rear_wheel_track:
14-
{
15-
type: double,
16-
default_value: 0.0,
17-
description: "Rear wheel track length. For details see: https://en.wikipedia.org/wiki/Wheelbase",
6+
description: "Traction wheel track length. For details see: https://en.wikipedia.org/wiki/Wheelbase",
187
read_only: false,
198
validation: {
209
gt<>: [0.0]
@@ -32,22 +21,11 @@ ackermann_steering_controller:
3221
}
3322
}
3423

35-
front_wheels_radius:
36-
{
37-
type: double,
38-
default_value: 0.0,
39-
description: "Front wheels radius.",
40-
read_only: false,
41-
validation: {
42-
gt<>: [0.0]
43-
}
44-
}
45-
46-
rear_wheels_radius:
24+
traction_wheels_radius:
4725
{
4826
type: double,
4927
default_value: 0.0,
50-
description: "Rear wheels radius.",
28+
description: "Traction wheels radius.",
5129
read_only: false,
5230
validation: {
5331
gt<>: [0.0]

‎ackermann_steering_controller/test/ackermann_steering_controller_params.yaml

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ test_ackermann_steering_controller:
22
ros__parameters:
33

44
reference_timeout: 2.0
5-
front_steering: true
65
open_loop: false
76
velocity_rolling_window_size: 10
87
position_feedback: false
9-
rear_wheels_names: [rear_right_wheel_joint, rear_left_wheel_joint]
10-
front_wheels_names: [front_right_steering_joint, front_left_steering_joint]
8+
wheels_names: [rear_right_wheel_joint, rear_left_wheel_joint]
9+
steers_names: [front_right_steering_joint, front_left_steering_joint]
1110

1211
wheelbase: 3.24644
13-
front_wheel_track: 2.12321
14-
rear_wheel_track: 1.76868
15-
front_wheels_radius: 0.45
16-
rear_wheels_radius: 0.45
12+
traction_wheel_track: 1.76868
13+
traction_wheels_radius: 0.45
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
test_ackermann_steering_controller:
22
ros__parameters:
33
reference_timeout: 2.0
4-
front_steering: true
54
open_loop: false
65
velocity_rolling_window_size: 10
76
position_feedback: false
8-
rear_wheels_names: [pid_controller/rear_right_wheel_joint, pid_controller/rear_left_wheel_joint]
9-
front_wheels_names: [pid_controller/front_right_steering_joint, pid_controller/front_left_steering_joint]
10-
rear_wheels_state_names: [rear_right_wheel_joint, rear_left_wheel_joint]
11-
front_wheels_state_names: [front_right_steering_joint, front_left_steering_joint]
7+
wheels_names: [pid_controller/rear_right_wheel_joint, pid_controller/rear_left_wheel_joint]
8+
steers_names: [pid_controller/front_right_steering_joint, pid_controller/front_left_steering_joint]
9+
wheels_state_names: [rear_right_wheel_joint, rear_left_wheel_joint]
10+
steers_state_names: [front_right_steering_joint, front_left_steering_joint]
1211
wheelbase: 3.24644
13-
front_wheel_track: 2.12321
14-
rear_wheel_track: 1.76868
15-
front_wheels_radius: 0.45
16-
rear_wheels_radius: 0.45
12+
traction_wheel_track: 1.76868
13+
traction_wheels_radius: 0.45

‎ackermann_steering_controller/test/test_ackermann_steering_controller.cpp

+12-21
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,14 @@ TEST_F(AckermannSteeringControllerTest, all_parameters_set_configure_success)
3131

3232
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), NODE_SUCCESS);
3333

34-
ASSERT_THAT(
35-
controller_->params_.rear_wheels_names, testing::ElementsAreArray(rear_wheels_names_));
36-
ASSERT_THAT(
37-
controller_->params_.front_wheels_names, testing::ElementsAreArray(front_wheels_names_));
38-
ASSERT_EQ(controller_->params_.front_steering, front_steering_);
34+
ASSERT_THAT(controller_->params_.wheels_names, testing::ElementsAreArray(wheels_names_));
35+
ASSERT_THAT(controller_->params_.steers_names, testing::ElementsAreArray(steers_names_));
3936
ASSERT_EQ(controller_->params_.open_loop, open_loop_);
4037
ASSERT_EQ(controller_->params_.velocity_rolling_window_size, velocity_rolling_window_size_);
4138
ASSERT_EQ(controller_->params_.position_feedback, position_feedback_);
4239
ASSERT_EQ(controller_->ackermann_params_.wheelbase, wheelbase_);
43-
ASSERT_EQ(controller_->ackermann_params_.front_wheels_radius, front_wheels_radius_);
44-
ASSERT_EQ(controller_->ackermann_params_.rear_wheels_radius, rear_wheels_radius_);
45-
ASSERT_EQ(controller_->ackermann_params_.front_wheel_track, front_wheel_track_);
46-
ASSERT_EQ(controller_->ackermann_params_.rear_wheel_track, rear_wheel_track_);
40+
ASSERT_EQ(controller_->ackermann_params_.traction_wheels_radius, traction_wheels_radius_);
41+
ASSERT_EQ(controller_->ackermann_params_.traction_wheel_track, traction_wheel_track_);
4742
}
4843

4944
TEST_F(AckermannSteeringControllerTest, check_exported_interfaces)
@@ -55,33 +50,29 @@ TEST_F(AckermannSteeringControllerTest, check_exported_interfaces)
5550
auto cmd_if_conf = controller_->command_interface_configuration();
5651
ASSERT_EQ(cmd_if_conf.names.size(), joint_command_values_.size());
5752
EXPECT_EQ(
58-
cmd_if_conf.names[CMD_TRACTION_RIGHT_WHEEL],
59-
rear_wheels_names_[0] + "/" + traction_interface_name_);
53+
cmd_if_conf.names[CMD_TRACTION_RIGHT_WHEEL], wheels_names_[0] + "/" + traction_interface_name_);
6054
EXPECT_EQ(
61-
cmd_if_conf.names[CMD_TRACTION_LEFT_WHEEL],
62-
rear_wheels_names_[1] + "/" + traction_interface_name_);
55+
cmd_if_conf.names[CMD_TRACTION_LEFT_WHEEL], wheels_names_[1] + "/" + traction_interface_name_);
6356
EXPECT_EQ(
64-
cmd_if_conf.names[CMD_STEER_RIGHT_WHEEL],
65-
front_wheels_names_[0] + "/" + steering_interface_name_);
57+
cmd_if_conf.names[CMD_STEER_RIGHT_WHEEL], steers_names_[0] + "/" + steering_interface_name_);
6658
EXPECT_EQ(
67-
cmd_if_conf.names[CMD_STEER_LEFT_WHEEL],
68-
front_wheels_names_[1] + "/" + steering_interface_name_);
59+
cmd_if_conf.names[CMD_STEER_LEFT_WHEEL], steers_names_[1] + "/" + steering_interface_name_);
6960
EXPECT_EQ(cmd_if_conf.type, controller_interface::interface_configuration_type::INDIVIDUAL);
7061

7162
auto state_if_conf = controller_->state_interface_configuration();
7263
ASSERT_EQ(state_if_conf.names.size(), joint_state_values_.size());
7364
EXPECT_EQ(
7465
state_if_conf.names[STATE_TRACTION_RIGHT_WHEEL],
75-
controller_->rear_wheels_state_names_[0] + "/" + traction_interface_name_);
66+
controller_->wheels_state_names_[0] + "/" + traction_interface_name_);
7667
EXPECT_EQ(
7768
state_if_conf.names[STATE_TRACTION_LEFT_WHEEL],
78-
controller_->rear_wheels_state_names_[1] + "/" + traction_interface_name_);
69+
controller_->wheels_state_names_[1] + "/" + traction_interface_name_);
7970
EXPECT_EQ(
8071
state_if_conf.names[STATE_STEER_RIGHT_WHEEL],
81-
controller_->front_wheels_state_names_[0] + "/" + steering_interface_name_);
72+
controller_->steers_state_names_[0] + "/" + steering_interface_name_);
8273
EXPECT_EQ(
8374
state_if_conf.names[STATE_STEER_LEFT_WHEEL],
84-
controller_->front_wheels_state_names_[1] + "/" + steering_interface_name_);
75+
controller_->steers_state_names_[1] + "/" + steering_interface_name_);
8576
EXPECT_EQ(state_if_conf.type, controller_interface::interface_configuration_type::INDIVIDUAL);
8677

8778
// check ref itfsTIME

‎ackermann_steering_controller/test/test_ackermann_steering_controller.hpp

+17-26
Original file line numberDiff line numberDiff line change
@@ -165,47 +165,41 @@ class AckermannSteeringControllerFixture : public ::testing::Test
165165
command_ifs.reserve(joint_command_values_.size());
166166

167167
command_itfs_.emplace_back(hardware_interface::CommandInterface(
168-
rear_wheels_names_[0], traction_interface_name_,
168+
wheels_names_[0], traction_interface_name_,
169169
&joint_command_values_[CMD_TRACTION_RIGHT_WHEEL]));
170170
command_ifs.emplace_back(command_itfs_.back());
171171

172172
command_itfs_.emplace_back(hardware_interface::CommandInterface(
173-
rear_wheels_names_[1], steering_interface_name_,
174-
&joint_command_values_[CMD_TRACTION_LEFT_WHEEL]));
173+
wheels_names_[1], steering_interface_name_, &joint_command_values_[CMD_TRACTION_LEFT_WHEEL]));
175174
command_ifs.emplace_back(command_itfs_.back());
176175

177176
command_itfs_.emplace_back(hardware_interface::CommandInterface(
178-
front_wheels_names_[0], steering_interface_name_,
179-
&joint_command_values_[CMD_STEER_RIGHT_WHEEL]));
177+
steers_names_[0], steering_interface_name_, &joint_command_values_[CMD_STEER_RIGHT_WHEEL]));
180178
command_ifs.emplace_back(command_itfs_.back());
181179

182180
command_itfs_.emplace_back(hardware_interface::CommandInterface(
183-
front_wheels_names_[1], steering_interface_name_,
184-
&joint_command_values_[CMD_STEER_LEFT_WHEEL]));
181+
steers_names_[1], steering_interface_name_, &joint_command_values_[CMD_STEER_LEFT_WHEEL]));
185182
command_ifs.emplace_back(command_itfs_.back());
186183

187184
std::vector<hardware_interface::LoanedStateInterface> state_ifs;
188185
state_itfs_.reserve(joint_state_values_.size());
189186
state_ifs.reserve(joint_state_values_.size());
190187

191188
state_itfs_.emplace_back(hardware_interface::StateInterface(
192-
rear_wheels_names_[0], traction_interface_name_,
189+
wheels_names_[0], traction_interface_name_,
193190
&joint_state_values_[STATE_TRACTION_RIGHT_WHEEL]));
194191
state_ifs.emplace_back(state_itfs_.back());
195192

196193
state_itfs_.emplace_back(hardware_interface::StateInterface(
197-
rear_wheels_names_[1], traction_interface_name_,
198-
&joint_state_values_[STATE_TRACTION_LEFT_WHEEL]));
194+
wheels_names_[1], traction_interface_name_, &joint_state_values_[STATE_TRACTION_LEFT_WHEEL]));
199195
state_ifs.emplace_back(state_itfs_.back());
200196

201197
state_itfs_.emplace_back(hardware_interface::StateInterface(
202-
front_wheels_names_[0], steering_interface_name_,
203-
&joint_state_values_[STATE_STEER_RIGHT_WHEEL]));
198+
steers_names_[0], steering_interface_name_, &joint_state_values_[STATE_STEER_RIGHT_WHEEL]));
204199
state_ifs.emplace_back(state_itfs_.back());
205200

206201
state_itfs_.emplace_back(hardware_interface::StateInterface(
207-
front_wheels_names_[1], steering_interface_name_,
208-
&joint_state_values_[STATE_STEER_LEFT_WHEEL]));
202+
steers_names_[1], steering_interface_name_, &joint_state_values_[STATE_STEER_LEFT_WHEEL]));
209203
state_ifs.emplace_back(state_itfs_.back());
210204

211205
controller_->assign_interfaces(std::move(command_ifs), std::move(state_ifs));
@@ -276,29 +270,26 @@ class AckermannSteeringControllerFixture : public ::testing::Test
276270
protected:
277271
// Controller-related parameters
278272
double reference_timeout_ = 2.0;
279-
bool front_steering_ = true;
280273
bool open_loop_ = false;
281274
unsigned int velocity_rolling_window_size_ = 10;
282275
bool position_feedback_ = false;
283-
std::vector<std::string> rear_wheels_names_ = {"rear_right_wheel_joint", "rear_left_wheel_joint"};
284-
std::vector<std::string> front_wheels_names_ = {
276+
std::vector<std::string> wheels_names_ = {"rear_right_wheel_joint", "rear_left_wheel_joint"};
277+
std::vector<std::string> steers_names_ = {
285278
"front_right_steering_joint", "front_left_steering_joint"};
286279
std::vector<std::string> joint_names_ = {
287-
rear_wheels_names_[0], rear_wheels_names_[1], front_wheels_names_[0], front_wheels_names_[1]};
280+
wheels_names_[0], wheels_names_[1], steers_names_[0], steers_names_[1]};
288281

289-
std::vector<std::string> rear_wheels_preceeding_names_ = {
282+
std::vector<std::string> wheels_preceeding_names_ = {
290283
"pid_controller/rear_right_wheel_joint", "pid_controller/rear_left_wheel_joint"};
291-
std::vector<std::string> front_wheels_preceeding_names_ = {
284+
std::vector<std::string> steers_preceeding_names_ = {
292285
"pid_controller/front_right_steering_joint", "pid_controller/front_left_steering_joint"};
293286
std::vector<std::string> preceeding_joint_names_ = {
294-
rear_wheels_preceeding_names_[0], rear_wheels_preceeding_names_[1],
295-
front_wheels_preceeding_names_[0], front_wheels_preceeding_names_[1]};
287+
wheels_preceeding_names_[0], wheels_preceeding_names_[1], steers_preceeding_names_[0],
288+
steers_preceeding_names_[1]};
296289

297290
double wheelbase_ = 3.24644;
298-
double front_wheel_track_ = 2.12321;
299-
double rear_wheel_track_ = 1.76868;
300-
double front_wheels_radius_ = 0.45;
301-
double rear_wheels_radius_ = 0.45;
291+
double traction_wheel_track_ = 1.76868;
292+
double traction_wheels_radius_ = 0.45;
302293

303294
std::array<double, 4> joint_state_values_ = {0.5, 0.5, 0.0, 0.0};
304295
std::array<double, 4> joint_command_values_ = {1.1, 3.3, 2.2, 4.4};

‎ackermann_steering_controller/test/test_ackermann_steering_controller_preceeding.cpp

+12-17
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,15 @@ TEST_F(AckermannSteeringControllerTest, all_parameters_set_configure_success)
3232
ASSERT_EQ(controller_->on_configure(rclcpp_lifecycle::State()), NODE_SUCCESS);
3333

3434
ASSERT_THAT(
35-
controller_->params_.rear_wheels_names,
36-
testing::ElementsAreArray(rear_wheels_preceeding_names_));
35+
controller_->params_.wheels_names, testing::ElementsAreArray(wheels_preceeding_names_));
3736
ASSERT_THAT(
38-
controller_->params_.front_wheels_names,
39-
testing::ElementsAreArray(front_wheels_preceeding_names_));
40-
ASSERT_EQ(controller_->params_.front_steering, front_steering_);
37+
controller_->params_.steers_names, testing::ElementsAreArray(steers_preceeding_names_));
4138
ASSERT_EQ(controller_->params_.open_loop, open_loop_);
4239
ASSERT_EQ(controller_->params_.velocity_rolling_window_size, velocity_rolling_window_size_);
4340
ASSERT_EQ(controller_->params_.position_feedback, position_feedback_);
4441
ASSERT_EQ(controller_->ackermann_params_.wheelbase, wheelbase_);
45-
ASSERT_EQ(controller_->ackermann_params_.front_wheels_radius, front_wheels_radius_);
46-
ASSERT_EQ(controller_->ackermann_params_.rear_wheels_radius, rear_wheels_radius_);
47-
ASSERT_EQ(controller_->ackermann_params_.front_wheel_track, front_wheel_track_);
48-
ASSERT_EQ(controller_->ackermann_params_.rear_wheel_track, rear_wheel_track_);
42+
ASSERT_EQ(controller_->ackermann_params_.traction_wheels_radius, traction_wheels_radius_);
43+
ASSERT_EQ(controller_->ackermann_params_.traction_wheel_track, traction_wheel_track_);
4944
}
5045

5146
TEST_F(AckermannSteeringControllerTest, check_exported_interfaces)
@@ -58,32 +53,32 @@ TEST_F(AckermannSteeringControllerTest, check_exported_interfaces)
5853
ASSERT_EQ(cmd_if_conf.names.size(), joint_command_values_.size());
5954
EXPECT_EQ(
6055
cmd_if_conf.names[CMD_TRACTION_RIGHT_WHEEL],
61-
preceeding_prefix_ + "/" + rear_wheels_names_[0] + "/" + traction_interface_name_);
56+
preceeding_prefix_ + "/" + wheels_names_[0] + "/" + traction_interface_name_);
6257
EXPECT_EQ(
6358
cmd_if_conf.names[CMD_TRACTION_LEFT_WHEEL],
64-
preceeding_prefix_ + "/" + rear_wheels_names_[1] + "/" + traction_interface_name_);
59+
preceeding_prefix_ + "/" + wheels_names_[1] + "/" + traction_interface_name_);
6560
EXPECT_EQ(
6661
cmd_if_conf.names[CMD_STEER_RIGHT_WHEEL],
67-
preceeding_prefix_ + "/" + front_wheels_names_[0] + "/" + steering_interface_name_);
62+
preceeding_prefix_ + "/" + steers_names_[0] + "/" + steering_interface_name_);
6863
EXPECT_EQ(
6964
cmd_if_conf.names[CMD_STEER_LEFT_WHEEL],
70-
preceeding_prefix_ + "/" + front_wheels_names_[1] + "/" + steering_interface_name_);
65+
preceeding_prefix_ + "/" + steers_names_[1] + "/" + steering_interface_name_);
7166
EXPECT_EQ(cmd_if_conf.type, controller_interface::interface_configuration_type::INDIVIDUAL);
7267

7368
auto state_if_conf = controller_->state_interface_configuration();
7469
ASSERT_EQ(state_if_conf.names.size(), joint_state_values_.size());
7570
EXPECT_EQ(
7671
state_if_conf.names[STATE_TRACTION_RIGHT_WHEEL],
77-
controller_->rear_wheels_state_names_[0] + "/" + traction_interface_name_);
72+
controller_->wheels_state_names_[0] + "/" + traction_interface_name_);
7873
EXPECT_EQ(
7974
state_if_conf.names[STATE_TRACTION_LEFT_WHEEL],
80-
controller_->rear_wheels_state_names_[1] + "/" + traction_interface_name_);
75+
controller_->wheels_state_names_[1] + "/" + traction_interface_name_);
8176
EXPECT_EQ(
8277
state_if_conf.names[STATE_STEER_RIGHT_WHEEL],
83-
controller_->front_wheels_state_names_[0] + "/" + steering_interface_name_);
78+
controller_->steers_state_names_[0] + "/" + steering_interface_name_);
8479
EXPECT_EQ(
8580
state_if_conf.names[STATE_STEER_LEFT_WHEEL],
86-
controller_->front_wheels_state_names_[1] + "/" + steering_interface_name_);
81+
controller_->steers_state_names_[1] + "/" + steering_interface_name_);
8782
EXPECT_EQ(state_if_conf.type, controller_interface::interface_configuration_type::INDIVIDUAL);
8883

8984
// check ref itfs

‎bicycle_steering_controller/src/bicycle_steering_controller.cpp

+2-11
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,9 @@ controller_interface::CallbackReturn BicycleSteeringController::configure_odomet
3232
bicycle_params_ = bicycle_param_listener_->get_params();
3333

3434
const double wheelbase = bicycle_params_.wheelbase;
35-
const double front_wheel_radius = bicycle_params_.front_wheel_radius;
36-
const double rear_wheel_radius = bicycle_params_.rear_wheel_radius;
37-
38-
if (params_.front_steering)
39-
{
40-
odometry_.set_wheel_params(rear_wheel_radius, wheelbase);
41-
}
42-
else
43-
{
44-
odometry_.set_wheel_params(front_wheel_radius, wheelbase);
45-
}
35+
const double traction_wheel_radius = bicycle_params_.traction_wheel_radius;
4636

37+
odometry_.set_wheel_params(traction_wheel_radius, wheelbase);
4738
odometry_.set_odometry_type(steering_odometry::BICYCLE_CONFIG);
4839

4940
set_interface_numbers(NR_STATE_ITFS, NR_CMD_ITFS, NR_REF_ITFS);

‎bicycle_steering_controller/src/bicycle_steering_controller.yaml

+2-13
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,11 @@ bicycle_steering_controller:
1010
}
1111
}
1212

13-
front_wheel_radius:
13+
traction_wheel_radius:
1414
{
1515
type: double,
1616
default_value: 0.0,
17-
description: "Front wheel radius.",
18-
read_only: false,
19-
validation: {
20-
gt<>: [0.0]
21-
}
22-
}
23-
24-
rear_wheel_radius:
25-
{
26-
type: double,
27-
default_value: 0.0,
28-
description: "Rear wheel radius.",
17+
description: "Steering wheel radius.",
2918
read_only: false,
3019
validation: {
3120
gt<>: [0.0]

0 commit comments

Comments
 (0)