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

add a broadcaster for range sensor #725

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
13edd07
add range_sensor_broadcaster
flochre Jan 24, 2023
2b9dc02
delete wrongly commented lines
flochre Jul 27, 2023
5a134da
run pre-commit script + small corrections
flochre Jul 27, 2023
b53fc79
correct style devergence
flochre Jul 27, 2023
fc5f7c6
add readme and doc
flochre Jul 28, 2023
3604fd7
update ros2_controllers/packages.xml
flochre Jan 24, 2023
d84115f
adding first tests to the package
flochre Aug 1, 2023
58a3166
add variance to the range_sensor_broadcaster
flochre Aug 1, 2023
b2d0d4e
add more tests to the broadcaster
flochre Aug 1, 2023
17cbd2c
Merge branch 'master' into feature/add-range-sensor-broadcast
flochre Aug 1, 2023
22834ca
run pre-commit script
flochre Aug 2, 2023
814c944
get the version to match the rest of the repo
flochre Aug 2, 2023
1281b48
Merge branch 'master' into feature/add-range-sensor-broadcast
flochre Aug 2, 2023
7fa64fb
re-run pre-commit with clang-format installed and updates CMakelist t…
flochre Aug 2, 2023
ae9f8bb
Merge branch 'master' into feature/add-range-sensor-broadcast
flochre Aug 15, 2023
476c312
delete EXPECT_PRED_FORMAT2 test by EXPECT_THAT
flochre Aug 15, 2023
6a59509
delete useless comment
flochre Aug 15, 2023
6de3bd2
add copyright to test_range_sensor_broadcaster + include missing headers
flochre Aug 15, 2023
bad2463
Merge branch 'master' into feature/add-range-sensor-broadcast
flochre Aug 18, 2023
ef9f1a8
bump version
bmagyar Aug 19, 2023
c029063
Update range_sensor_broadcaster/package.xml
flochre Aug 20, 2023
e39ac26
update to real name
flochre Aug 20, 2023
380e329
deleted useless lines in test
flochre Aug 20, 2023
e2f6bdd
add load test
flochre Aug 20, 2023
c69fb7e
add the load test to the CMakeList
flochre Aug 20, 2023
c1358bb
Merge branch 'master' into feature/add-range-sensor-broadcast
flochre Aug 20, 2023
19e53a8
Merge branch 'master' into feature/add-range-sensor-broadcast
flochre Aug 27, 2023
c3b55b6
Merge branch 'master' into feature/add-range-sensor-broadcast
flochre Sep 5, 2023
f795157
cleanup
bmagyar Sep 6, 2023
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
95 changes: 95 additions & 0 deletions range_sensor_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
cmake_minimum_required(VERSION 3.8)
project(range_sensor_broadcaster)

# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(THIS_PACKAGE_INCLUDE_DEPENDS
controller_interface
generate_parameter_library
hardware_interface
pluginlib
rclcpp
rclcpp_lifecycle
realtime_tools
sensor_msgs
)

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(backward_ros REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()


generate_parameter_library(range_sensor_broadcaster_parameters
src/range_sensor_broadcaster_parameters.yaml
)

add_library(
range_sensor_broadcaster SHARED
src/range_sensor_broadcaster.cpp
)
target_include_directories(range_sensor_broadcaster
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE $<INSTALL_INTERFACE:include>
)
ament_target_dependencies(range_sensor_broadcaster ${THIS_PACKAGE_INCLUDE_DEPENDS})
# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(range_sensor_broadcaster PRIVATE "RANGE_SENSOR_BROADCASTER_BUILDING_DLL")
target_link_libraries(range_sensor_broadcaster
range_sensor_broadcaster_parameters
)

pluginlib_export_plugin_description_file(
controller_interface range_sensor_broadcaster.xml)

if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
find_package(controller_manager REQUIRED)
find_package(hardware_interface REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

add_rostest_with_parameters_gmock(test_range_sensor_broadcaster
test/test_range_sensor_broadcaster.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/range_sensor_broadcaster_params.yaml)
target_include_directories(test_range_sensor_broadcaster PRIVATE include)
target_link_libraries(test_range_sensor_broadcaster
range_sensor_broadcaster
)
ament_target_dependencies(test_range_sensor_broadcaster
hardware_interface
)


bmagyar marked this conversation as resolved.
Show resolved Hide resolved
endif()

install(
DIRECTORY include/
DESTINATION include
)

install(
TARGETS
range_sensor_broadcaster
range_sensor_broadcaster_parameters
EXPORT export_range_sensor_broadcaster
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
INCLUDES DESTINATION include
)

ament_export_targets(export_range_sensor_broadcaster HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})

ament_package()
8 changes: 8 additions & 0 deletions range_sensor_broadcaster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
range_sensor_broadcaster
==========================================

Controller to publish readings of Range sensors.

Pluginlib-Library: range_sensor_broadcaster

Plugin: range_sensor_broadcaster/RangeSensorBroadcaster (controller_interface::ControllerInterface)
15 changes: 15 additions & 0 deletions range_sensor_broadcaster/doc/userdoc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
:github_url: https://github.com/ros-controls/ros2_controllers/blob/{REPOS_FILE_BRANCH}/range_sensor_broadcaster/doc/userdoc.rst

.. _range_sensor_broadcaster_userdoc:

Range Sensor Broadcaster
--------------------------------
Broadcaster of messages from Range sensor.
The published message type is ``sensor_msgs/msg/Range``.

The controller is a wrapper around ``RangeSensor`` semantic component (see ``controller_interface`` package).

Parameters
^^^^^^^^^^^

.. generate_parameter_library_details:: ../src/range_sensor_broadcaster_parameters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright 2021 PAL Robotics SL.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*
* Authors: Subhas Das, Denis Stogl, Victor Lopez
*/

#ifndef RANGE_SENSOR_BROADCASTER__RANGE_SENSOR_BROADCASTER_HPP_
#define RANGE_SENSOR_BROADCASTER__RANGE_SENSOR_BROADCASTER_HPP_

#include <memory>
#include <string>
#include <vector>

#include "controller_interface/controller_interface.hpp"
#include "range_sensor_broadcaster/visibility_control.h"
#include "range_sensor_broadcaster_parameters.hpp"
#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
#include "rclcpp_lifecycle/state.hpp"
#include "realtime_tools/realtime_publisher.h"
#include "semantic_components/range_sensor.hpp"
#include "sensor_msgs/msg/range.hpp"

namespace range_sensor_broadcaster
{
class RangeSensorBroadcaster : public controller_interface::ControllerInterface
{
public:
RANGE_SENSOR_BROADCASTER_PUBLIC
controller_interface::InterfaceConfiguration command_interface_configuration() const override;

RANGE_SENSOR_BROADCASTER_PUBLIC
controller_interface::InterfaceConfiguration state_interface_configuration() const override;

RANGE_SENSOR_BROADCASTER_PUBLIC controller_interface::CallbackReturn on_init() override;

RANGE_SENSOR_BROADCASTER_PUBLIC
controller_interface::CallbackReturn on_configure(
const rclcpp_lifecycle::State & previous_state) override;

RANGE_SENSOR_BROADCASTER_PUBLIC
controller_interface::CallbackReturn on_activate(
const rclcpp_lifecycle::State & previous_state) override;

RANGE_SENSOR_BROADCASTER_PUBLIC
controller_interface::CallbackReturn on_deactivate(
const rclcpp_lifecycle::State & previous_state) override;

RANGE_SENSOR_BROADCASTER_PUBLIC
controller_interface::return_type update(
const rclcpp::Time & time, const rclcpp::Duration & period) override;

protected:
std::shared_ptr<ParamListener> param_listener_;
Params params_;

std::unique_ptr<semantic_components::RangeSensor> range_sensor_;

using StatePublisher = realtime_tools::RealtimePublisher<sensor_msgs::msg::Range>;
rclcpp::Publisher<sensor_msgs::msg::Range>::SharedPtr sensor_state_publisher_;
std::unique_ptr<StatePublisher> realtime_publisher_;
};

} // namespace range_sensor_broadcaster

#endif // RANGE_SENSOR_BROADCASTER__RANGE_SENSOR_BROADCASTER_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) 2021, Stogl Robotics Consulting UG (haftungsbeschränkt)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*
* Author: Subhas Das, Denis Stogl
*/

#ifndef RANGE_SENSOR_BROADCASTER__VISIBILITY_CONTROL_H_
#define RANGE_SENSOR_BROADCASTER__VISIBILITY_CONTROL_H_

// This logic was borrowed (then namespaced) from the examples on the gcc wiki:
// https://gcc.gnu.org/wiki/Visibility

#if defined _WIN32 || defined __CYGWIN__
#ifdef __GNUC__
#define RANGE_SENSOR_BROADCASTER_EXPORT __attribute__((dllexport))
#define RANGE_SENSOR_BROADCASTER_IMPORT __attribute__((dllimport))
#else
#define RANGE_SENSOR_BROADCASTER_EXPORT __declspec(dllexport)
#define RANGE_SENSOR_BROADCASTER_IMPORT __declspec(dllimport)
#endif
#ifdef RANGE_SENSOR_BROADCASTER_BUILDING_DLL
#define RANGE_SENSOR_BROADCASTER_PUBLIC RANGE_SENSOR_BROADCASTER_EXPORT
#else
#define RANGE_SENSOR_BROADCASTER_PUBLIC RANGE_SENSOR_BROADCASTER_IMPORT
#endif
#define RANGE_SENSOR_BROADCASTER_PUBLIC_TYPE RANGE_SENSOR_BROADCASTER_PUBLIC
#define RANGE_SENSOR_BROADCASTER_LOCAL
#else
#define RANGE_SENSOR_BROADCASTER_EXPORT __attribute__((visibility("default")))
#define RANGE_SENSOR_BROADCASTER_IMPORT
#if __GNUC__ >= 4
#define RANGE_SENSOR_BROADCASTER_PUBLIC __attribute__((visibility("default")))
#define RANGE_SENSOR_BROADCASTER_LOCAL __attribute__((visibility("hidden")))
#else
#define RANGE_SENSOR_BROADCASTER_PUBLIC
#define RANGE_SENSOR_BROADCASTER_LOCAL
#endif
#define RANGE_SENSOR_BROADCASTER_PUBLIC_TYPE
#endif

#endif // RANGE_SENSOR_BROADCASTER__VISIBILITY_CONTROL_H_
32 changes: 32 additions & 0 deletions range_sensor_broadcaster/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>range_sensor_broadcaster</name>
<version>3.12.0</version>
bmagyar marked this conversation as resolved.
Show resolved Hide resolved
<description>Controller to publish readings of Range sensors.</description>
<maintainer email="[email protected]">flochre</maintainer>
flochre marked this conversation as resolved.
Show resolved Hide resolved
<license>Apache License 2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>backward_ros</depend>
<depend>controller_interface</depend>
<depend>generate_parameter_library</depend>
<depend>hardware_interface</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>realtime_tools</depend>
<depend>sensor_msgs</depend>

<test_depend>ament_cmake_gmock</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
bmagyar marked this conversation as resolved.
Show resolved Hide resolved
<test_depend>controller_manager</test_depend>
<test_depend>hardware_interface</test_depend>
<test_depend>ros2_control_test_assets</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
8 changes: 8 additions & 0 deletions range_sensor_broadcaster/range_sensor_broadcaster.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<library path="range_sensor_broadcaster">
<class name="range_sensor_broadcaster/RangeSensorBroadcaster"
type="range_sensor_broadcaster::RangeSensorBroadcaster" base_class_type="controller_interface::ControllerInterface">
<description>
This controller publishes the readings of an Range sensor as sensor_msgs/Range message.
</description>
</class>
</library>
Loading
Loading