Skip to content
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

update controllers template to be compileable under rolling, warnings are still present #198

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
15 changes: 8 additions & 7 deletions scripts/ros2_control/setup-controller-package.bash
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ for SED_FILE in "${FILES_TO_SED[@]}"; do
sed -i "s/TEMPLATES__ROS2_CONTROL__CONTROLLER__DUMMY_PACKAGE_NAMESPACE/${PKG_NAME^^}/g" $SED_FILE # package name for include guard
sed -i "s/TEMPLATES__ROS2_CONTROL__VISIBILITY/${PKG_NAME^^}__VISIBILITY/g" $SED_FILE # visibility defines
sed -i "s/dummy_package_namespace/${PKG_NAME}/g" $SED_FILE # package name for includes
sed -i "s/dummy_library_path/${FILE_NAME}/g" $SED_FILE # library path for pluginlib
sed -i "s/dummy_controller/${FILE_NAME}/g" $SED_FILE # file name
sed -i "s/dummy_chainable_controller/${FILE_NAME}/g" $SED_FILE # file name
sed -i "s/DUMMY_CONTROLLER/${FILE_NAME^^}/g" $SED_FILE # file name for include guard
Expand Down Expand Up @@ -355,11 +356,11 @@ if [[ "$package_configured" == "no" ]]; then

for DEP_PKG in "${DEP_PKGS[@]}"; do
# package.xml
if `grep -q "<depend>${DEP_PKG}</depend>" package.xml`; then
if grep -q "<depend>${DEP_PKG}</depend>" package.xml; then
echo "'$DEP_PKG' is already listed in package.xml"
else
append_to_string="<build_depend>generate_parameter_library<\/build_depend>"
sed -i "s/$append_to_string/$append_to_string\\n\\n <depend>${DEP_PKG}<\/depend>/g" package.xml
sed -i "s/$append_to_string/$append_to_string\\n <depend>${DEP_PKG}<\/depend>/g" package.xml
fi
done
fi
Expand All @@ -371,19 +372,19 @@ TEST_DEP_PKGS=("ros2_control_test_assets" "hardware_interface" "controller_manag
for DEP_PKG in "${TEST_DEP_PKGS[@]}"; do

# CMakeLists.txt
if `grep -q " find_package(${DEP_PKG} REQUIRED)" CMakeLists.txt`; then
if grep -q " find_package(${DEP_PKG} REQUIRED)" CMakeLists.txt; then
echo "'$DEP_PKG' is already listed in CMakeLists.txt"
else
append_to_string="ament_lint_auto_find_test_dependencies()"
append_to_string="if(BUILD_TESTING)"
sed -i "s/$append_to_string/$append_to_string\\n find_package(${DEP_PKG} REQUIRED)/g" CMakeLists.txt
fi

# package.xml
if `grep -q "<test_depend>${DEP_PKG}</test_depend>" package.xml`; then
if grep -q "<test_depend>${DEP_PKG}</test_depend>" package.xml; then
echo "'$DEP_PKG' is already listed in package.xml"
else
append_to_string="<test_depend>ament_lint_common<\/test_depend>"
sed -i "s/$append_to_string/$append_to_string\\n <test_depend>${DEP_PKG}<\/test_depend>/g" package.xml
append_to_string="<export>"
sed -i "s/$append_to_string/<test_depend>${DEP_PKG}<\/test_depend>\\n $append_to_string/g" package.xml
fi
done

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ controller_interface::CallbackReturn DummyClassName::on_deactivate(
return controller_interface::CallbackReturn::SUCCESS;
}

controller_interface::return_type DummyClassName::update_reference_from_subscribers()
controller_interface::return_type DummyClassName::update_reference_from_subscribers(
const rclcpp::Time & /*time*/, const rclcpp::Duration & /*period*/)
{
auto current_ref = input_ref_.readFromRT();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Source of this file are templates in
[RosTeamWorkspace](https://github.com/StoglRobotics/ros_team_workspace) repository.
-->

<library path="dummy_package_namespace">
<library path="dummy_library_path">
<class name="dummy_package_namespace/DummyClassName"
type="dummy_package_namespace::DummyClassName" base_class_type="controller_interface::ChainableControllerInterface">
<description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class DummyClassName : public controller_interface::ChainableControllerInterface
const rclcpp_lifecycle::State & previous_state) override;

TEMPLATES__ROS2_CONTROL__VISIBILITY_PUBLIC
controller_interface::return_type update_reference_from_subscribers() override;
controller_interface::return_type update_reference_from_subscribers(
const rclcpp::Time & time, const rclcpp::Duration & period) override;

TEMPLATES__ROS2_CONTROL__VISIBILITY_PUBLIC
controller_interface::return_type update_and_write_commands(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
// [RosTeamWorkspace](https://github.com/StoglRobotics/ros_team_workspace) repository.
//

#ifndef TEMPLATES__ROS2_CONTROL__CONTROLLER__TEST_DUMMY_CHAINABLE_CONTROLLER_HPP_
#define TEMPLATES__ROS2_CONTROL__CONTROLLER__TEST_DUMMY_CHAINABLE_CONTROLLER_HPP_
#ifndef TEST_DUMMY_CHAINABLE_CONTROLLER_HPP_
#define TEST_DUMMY_CHAINABLE_CONTROLLER_HPP_

#include <chrono>
#include <limits>
Expand Down Expand Up @@ -128,7 +128,7 @@ class DummyClassNameFixture : public ::testing::Test

command_publisher_node_ = std::make_shared<rclcpp::Node>("command_publisher");
command_publisher_ = command_publisher_node_->create_publisher<ControllerReferenceMsg>(
"/test_dummy_controller/commands", rclcpp::SystemDefaultsQoS());
"/test_dummy_controller/reference", rclcpp::SystemDefaultsQoS());

service_caller_node_ = std::make_shared<rclcpp::Node>("service_caller");
slow_control_service_client_ = service_caller_node_->create_client<ControllerModeSrvType>(
Expand All @@ -142,7 +142,12 @@ class DummyClassNameFixture : public ::testing::Test
protected:
void SetUpController(const std::string controller_name = "test_dummy_controller")
{
ASSERT_EQ(controller_->init(controller_name), controller_interface::return_type::OK);
auto options = rclcpp::NodeOptions()
.allow_undeclared_parameters(false)
.automatically_declare_parameters_from_overrides(false);
ASSERT_EQ(
controller_->init(controller_name, "", 0, "", options),
controller_interface::return_type::OK);

std::vector<hardware_interface::LoanedCommandInterface> command_ifs;
command_itfs_.reserve(joint_command_values_.size());
Expand Down Expand Up @@ -278,4 +283,4 @@ class DummyClassNameFixture : public ::testing::Test
rclcpp::Client<ControllerModeSrvType>::SharedPtr slow_control_service_client_;
};

#endif // TEMPLATES__ROS2_CONTROL__CONTROLLER__TEST_DUMMY_CHAINABLE_CONTROLLER_HPP_
#endif // TEST_DUMMY_CHAINABLE_CONTROLLER_HPP_
9 changes: 7 additions & 2 deletions templates/ros2_control/controller/test_dummy_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class DummyClassNameFixture : public ::testing::Test

command_publisher_node_ = std::make_shared<rclcpp::Node>("command_publisher");
command_publisher_ = command_publisher_node_->create_publisher<ControllerReferenceMsg>(
"/test_dummy_controller/commands", rclcpp::SystemDefaultsQoS());
"/test_dummy_controller/reference", rclcpp::SystemDefaultsQoS());

service_caller_node_ = std::make_shared<rclcpp::Node>("service_caller");
slow_control_service_client_ = service_caller_node_->create_client<ControllerModeSrvType>(
Expand All @@ -132,7 +132,12 @@ class DummyClassNameFixture : public ::testing::Test
protected:
void SetUpController(const std::string controller_name = "test_dummy_controller")
{
ASSERT_EQ(controller_->init(controller_name), controller_interface::return_type::OK);
auto options = rclcpp::NodeOptions()
.allow_undeclared_parameters(false)
.automatically_declare_parameters_from_overrides(false);
ASSERT_EQ(
controller_->init(controller_name, "", 0, "", options),
controller_interface::return_type::OK);

std::vector<hardware_interface::LoanedCommandInterface> command_ifs;
command_itfs_.reserve(joint_command_values_.size());
Expand Down
Loading