Skip to content

Commit 253f5d0

Browse files
authored
Merge branch 'master' into feature/swerve-drive-controller
2 parents 7e44f0b + 9817475 commit 253f5d0

File tree

7 files changed

+47
-27
lines changed

7 files changed

+47
-27
lines changed

admittance_controller/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ set(THIS_PACKAGE_INCLUDE_DEPENDS
2323
tf2_geometry_msgs
2424
tf2_kdl
2525
tf2_ros
26+
TinyXML2
2627
trajectory_msgs
2728
)
2829

@@ -65,7 +66,8 @@ target_link_libraries(admittance_controller PUBLIC
6566
${geometry_msgs_TARGETS}
6667
${trajectory_msgs_TARGETS}
6768
${control_msgs_TARGETS}
68-
${tf2_geometry_msgs_TARGETS})
69+
${tf2_geometry_msgs_TARGETS}
70+
${TinyXML2_LIBRARIES})
6971

7072
pluginlib_export_plugin_description_file(controller_interface admittance_controller.xml)
7173

admittance_controller/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<depend>tf2_kdl</depend>
4343
<depend>tf2_ros</depend>
4444
<depend>tf2</depend>
45+
<depend>tinyxml2</depend>
4546
<depend>trajectory_msgs</depend>
4647

4748
<test_depend>ament_cmake_gmock</test_depend>

admittance_controller/src/admittance_controller.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "admittance_controller/admittance_controller.hpp"
1818

19+
#include <tinyxml2.h>
1920
#include <cmath>
2021
#include <memory>
2122
#include <string>
@@ -92,6 +93,33 @@ controller_interface::CallbackReturn AdmittanceController::on_init()
9293
reference_admittance_ = last_reference_;
9394
joint_state_ = last_reference_;
9495

96+
std::string robot_description = this->get_robot_description();
97+
98+
if (robot_description.empty())
99+
{
100+
RCLCPP_ERROR(get_node()->get_logger(), "'robot_description' parameter is empty.");
101+
return controller_interface::CallbackReturn::ERROR;
102+
}
103+
104+
tinyxml2::XMLDocument doc;
105+
if (!doc.Parse(robot_description.c_str()) && doc.Error())
106+
{
107+
RCLCPP_ERROR(
108+
get_node()->get_logger(),
109+
"Failed to parse robot description XML from parameter "
110+
"'robot_description': %s",
111+
doc.ErrorStr());
112+
return controller_interface::CallbackReturn::ERROR;
113+
}
114+
if (doc.Error())
115+
{
116+
RCLCPP_ERROR(
117+
get_node()->get_logger(),
118+
"Error parsing robot description XML from parameter "
119+
"'robot_description': %s",
120+
doc.ErrorStr());
121+
return controller_interface::CallbackReturn::ERROR;
122+
}
95123
return controller_interface::CallbackReturn::SUCCESS;
96124
}
97125

admittance_controller/test/test_admittance_controller.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,10 @@ INSTANTIATE_TEST_SUITE_P(
6262
// wrong length selected axes
6363
std::make_tuple(
6464
std::string("admittance.selected_axes"),
65-
rclcpp::ParameterValue(std::vector<double>() = {1, 2, 3}))
65+
rclcpp::ParameterValue(std::vector<double>() = {1, 2, 3})),
6666
// invalid robot description.
67-
// TODO(anyone): deactivated, because SetUpController returns SUCCESS here?
68-
// ,std::make_tuple(
69-
// std::string("robot_description"), rclcpp::ParameterValue(std::string() = "bad_robot")))
70-
));
67+
std::make_tuple(
68+
std::string("robot_description"), rclcpp::ParameterValue(std::string() = "bad_robot"))));
7169

7270
// Test on_init returns ERROR when a parameter is invalid
7371
TEST_P(AdmittanceControllerTestParameterizedInvalidParameters, invalid_parameters)

admittance_controller/test/test_admittance_controller.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ class TestableAdmittanceController : public admittance_controller::AdmittanceCon
7777
CallbackReturn on_init() override
7878
{
7979
get_node()->declare_parameter("robot_description", rclcpp::ParameterType::PARAMETER_STRING);
80-
get_node()->declare_parameter(
81-
"robot_description_semantic", rclcpp::ParameterType::PARAMETER_STRING);
8280
get_node()->set_parameter({"robot_description", robot_description_});
83-
get_node()->set_parameter({"robot_description_semantic", robot_description_semantic_});
8481

8582
return admittance_controller::AdmittanceController::on_init();
8683
}
@@ -107,8 +104,7 @@ class TestableAdmittanceController : public admittance_controller::AdmittanceCon
107104
}
108105
}
109106

110-
const std::string robot_description_ = ros2_control_test_assets::valid_6d_robot_urdf;
111-
const std::string robot_description_semantic_ = ros2_control_test_assets::valid_6d_robot_srdf;
107+
std::string robot_description_ = ros2_control_test_assets::valid_6d_robot_urdf;
112108
};
113109

114110
class AdmittanceControllerTest : public ::testing::Test
@@ -166,6 +162,15 @@ class AdmittanceControllerTest : public ::testing::Test
166162
{
167163
controller_interface::ControllerInterfaceParams params;
168164
params.controller_name = controller_name;
165+
// Extract robot_description from parameter overrides
166+
auto it = std::find_if(
167+
options.parameter_overrides().begin(), options.parameter_overrides().end(),
168+
[](const rclcpp::Parameter & p) { return p.get_name() == "robot_description"; });
169+
170+
if (it != options.parameter_overrides().end())
171+
{
172+
controller_->robot_description_ = it->as_string();
173+
}
169174
params.robot_description = controller_->robot_description_;
170175
params.update_rate = 0;
171176
params.node_namespace = "";
@@ -384,8 +389,6 @@ class AdmittanceControllerTest : public ::testing::Test
384389
const std::string ik_base_frame_ = "base_link";
385390
const std::string ik_tip_frame_ = "tool0";
386391
const std::string ik_group_name_ = "arm";
387-
// const std::string robot_description_ = ros2_control_test_assets::valid_6d_robot_urdf;
388-
// const std::string robot_description_semantic_ = ros2_control_test_assets::valid_6d_robot_srdf;
389392

390393
const std::string control_frame_ = "tool0";
391394
const std::string endeffector_frame_ = "endeffector_frame";

diff_drive_controller/src/diff_drive_controller_parameter.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ diff_drive_controller:
2626
wheel_radius: {
2727
type: double,
2828
default_value: 0.0,
29-
description: "Radius of a wheel, i.e., wheels size, used for transformation of linear velocity into wheel rotations. If this parameter is wrong the robot will move faster or slower then expected.",
29+
description: "Radius of a wheel, i.e., wheels size, used for transformation of linear velocity into wheel rotations. If this parameter is wrong the robot will move faster or slower than expected.",
3030
validation: {
3131
gt<>: [0.0]
3232
}
3333
}
3434
wheel_separation_multiplier: {
3535
type: double,
3636
default_value: 1.0,
37-
description: "Correction factor for wheel separation (TODO(destogl): Please help me describe this correctly)",
37+
description: "Correction factor when the actual wheel separation differs from the nominal value in the ``wheel_separation`` parameter.",
3838
}
3939
left_wheel_radius_multiplier: {
4040
type: double,

joint_trajectory_controller/include/joint_trajectory_controller/interpolation_methods.hpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,6 @@ enum class InterpolationMethod
6767
*/
6868
const InterpolationMethod DEFAULT_INTERPOLATION = InterpolationMethod::VARIABLE_DEGREE_SPLINE;
6969

70-
/**
71-
* @brief Maps string representations to their corresponding InterpolationMethod enum values.
72-
*
73-
* @deprecated This map is deprecated. Use the direct lookup methods instead.
74-
* (Original use: Converting strings into the InterpolationMethod).
75-
*/
76-
[[deprecated(
77-
"InterpolationMethodMap will be removed in future releases. "
78-
"Instead, use the direct lookup methods.")]]
79-
const std::unordered_map<std::string, InterpolationMethod> InterpolationMethodMap(
80-
{{"none", InterpolationMethod::NONE}, {"splines", InterpolationMethod::VARIABLE_DEGREE_SPLINE}});
81-
8270
/**
8371
* \brief Returns corresponding string value for the `InterpolationMethod`.
8472
* This function uses simple switch-case lookup to directly assign string value to

0 commit comments

Comments
 (0)