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

Steering odometry library and controllers #484

Merged
Merged
Show file tree
Hide file tree
Changes from 191 commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
2c744de
created pkg and setup controller from templates rtw
Robotgir Nov 13, 2022
e3be21f
recreated controller setup outside docker to use rtw branch with ref_…
Robotgir Nov 13, 2022
c9b1dad
modified .yaml and controller methods content
Robotgir Nov 13, 2022
568f723
added odometry.hpp
Robotgir Nov 13, 2022
29ef5f8
modified namespace of odometry.hpp and added odometry.cpp
Robotgir Nov 13, 2022
2671377
spotted issue with namespace naming (has xyz_ros2 when namespace eve…
Robotgir Nov 13, 2022
9181e18
corrected the copy paste error in the .yaml file which created the _r…
Robotgir Nov 13, 2022
ff4c3b9
added tests yet to debug few tests
Robotgir Nov 14, 2022
a1cb0bc
Corrected formatting.
destogl Nov 14, 2022
afe5006
Delete services and comment out to compile.
destogl Nov 14, 2022
222a40d
Make compilable on humble.
destogl Nov 14, 2022
72c3ca1
Correct interfaces in ackerman controllers.
destogl Nov 15, 2022
d81513c
all tests pass
Robotgir Nov 15, 2022
82e7cf2
added test_time_stamp_zero test
Robotgir Nov 15, 2022
4d7fa99
ackermann odometry
petkovich Nov 17, 2022
6e9a519
template state publisher
petkovich Nov 17, 2022
8544e3c
interfaces check
Robotgir Nov 17, 2022
96a5879
removed publish_period related code
Robotgir Nov 17, 2022
29df374
compiles, tests passed, publish_period removed
Robotgir Nov 17, 2022
7f36236
state publisher
petkovich Nov 18, 2022
65c69bc
new message published
petkovich Nov 18, 2022
6e52043
added feedback_type() method to choose position or velocity hardware …
Robotgir Nov 22, 2022
c8cbd28
Code optimization.
destogl Nov 24, 2022
4d6dced
Make controller to compile again.
destogl Nov 24, 2022
4ab177b
added unstamped twist topic -clean commit -functional changes
Robotgir Nov 28, 2022
8335f95
using only one realtime buffer handle
Robotgir Nov 28, 2022
dc4a590
Debuging ackermann controller.
destogl Nov 29, 2022
0c54190
updated tests to work with twist and twist_stamped cases
Robotgir Nov 29, 2022
20f5319
modifid config files
Robotgir Nov 29, 2022
0c84ca6
modified cmakelists
Robotgir Nov 29, 2022
c8bbf2c
removed file not needed
Robotgir Nov 29, 2022
fcd3cb4
odom lib creation
petkovich Dec 5, 2022
41df037
refrence new library
petkovich Dec 5, 2022
ce0556d
snake case
petkovich Dec 5, 2022
24802b5
steer names as arrays
petkovich Dec 6, 2022
6a17f95
direct kinematics
petkovich Dec 7, 2022
dd1df2c
replaced bacc acumulator with rcpputils
petkovich Dec 8, 2022
7583c99
migrated to steering_controllers package
petkovich Dec 8, 2022
e7c1a83
cleaned warnings
petkovich Dec 8, 2022
931553d
move tricycle, edit ackermann cmakelists
petkovich Dec 8, 2022
de0e531
tricycle uses steering odometry, keeping odom.cpp for comparison, TOD…
petkovich Dec 8, 2022
9f85d4b
cleaned cmakelists, removed tricycle odometry
petkovich Dec 12, 2022
7bce411
affed steering_controllers package, new base class/package
petkovich Dec 13, 2022
1a1f977
namespace, visibility, parameters
petkovich Dec 15, 2022
ad05e0b
inherited steering controller in ackermann src
petkovich Dec 15, 2022
58c36b9
template for modifying update function
petkovich Dec 15, 2022
067e4df
odom configuration separated
petkovich Dec 16, 2022
effee35
function for changing intefrace number
petkovich Dec 16, 2022
59f4c46
Delete LICENSE
destogl Dec 17, 2022
8f6803c
remove custom msg, integrate new msg from control msgs
petkovich Dec 17, 2022
7ba0580
Update steering_controllers/ackermann_steering_controller/CMakeLists.txt
petkovich Dec 17, 2022
ace1ccb
Update steering_controllers/ackermann_steering_controller/CMakeLists.txt
petkovich Dec 17, 2022
4e132fd
cmakelists build and install interfaces
petkovich Dec 18, 2022
8a4d7c0
license and maintainers
petkovich Dec 18, 2022
27332c5
removed ackermann package, integrated with steering controllers
petkovich Dec 18, 2022
6695ad3
renamed ackermann to steering_controller_implementations
petkovich Dec 18, 2022
eed9310
added bicycle controller (the same as ackermann for now)
petkovich Dec 18, 2022
33597a2
removed template from copyright
petkovich Dec 18, 2022
16842f1
removed template from copyright
petkovich Dec 18, 2022
127f834
defines
petkovich Dec 18, 2022
8267fc8
ported tricycle controller
petkovich Dec 18, 2022
da6198f
export tricycle controller
petkovich Dec 18, 2022
e38b79b
named variables for some odom parameters
petkovich Dec 19, 2022
15a2eb6
integration function, trans rot vel to steering angle arguments
petkovich Dec 19, 2022
ef8fbc9
removed redundant classes and variables
petkovich Dec 19, 2022
6c73ecf
removed some more redundant classes and variables
petkovich Dec 19, 2022
61eaf2a
configure_odometry pure virtual
petkovich Dec 19, 2022
eaa0a3c
removed tricycle package, integrated steering odometry with steering …
petkovich Dec 19, 2022
6a87431
removed subfolder
petkovich Dec 19, 2022
c95c7bb
returned configure odometry implementation that returns error, protec…
petkovich Dec 19, 2022
8904ec2
odometry update implementations for bicycle and tricycle, integration…
petkovich Dec 19, 2022
267de9c
Fix command_interface_configuration iterator
petkovich Dec 19, 2022
9364caa
returned tricycle (in root folder)
petkovich Dec 20, 2022
6fae035
separated implementations in files
petkovich Dec 20, 2022
2d86708
remove lint tests
petkovich Dec 20, 2022
4d14b5f
ControllerTwistReferenceMsg, ControllerAckermannReferenceMsg
petkovich Dec 20, 2022
4a910cd
unstamped twist deprecation, ackermann subscriber
petkovich Dec 20, 2022
8586362
authors, maintainers
petkovich Dec 20, 2022
f4a1880
removed rmw_qos_profile_services_hist_keep_all
petkovich Dec 20, 2022
b1a62f4
changed deprecation error
petkovich Dec 20, 2022
d28e2a4
parameters configured in base class, removed some comments
petkovich Dec 20, 2022
9fe998a
doc folder
petkovich Dec 21, 2022
453a534
virtual classes for odometry
petkovich Dec 21, 2022
e46bafa
ackermann odometry implementation
petkovich Dec 21, 2022
4e4d86a
front_wheels_names, rear_wheels_names
petkovich Dec 21, 2022
97ff28c
precommit and control_msgs repos
petkovich Dec 21, 2022
88c6a7b
Merge branch 'master' into ackermann-odometry-library
destogl Dec 21, 2022
821bfd7
separated implementation-specific parameters to implemenation files
petkovich Dec 24, 2022
d711a96
removed comments in odometry
petkovich Dec 24, 2022
d5b66a3
removed multipliers
petkovich Dec 27, 2022
efbaf67
enable rear steering, different wheels radii
petkovich Dec 27, 2022
f295112
changed SteeringControllerStatus
petkovich Dec 28, 2022
d2b87ca
command interfaces for multiple wheels
petkovich Dec 28, 2022
922099e
odometry types
petkovich Dec 29, 2022
599b223
forward kinematics model template
petkovich Dec 29, 2022
da4b41c
command interface always has traction before steering
petkovich Dec 29, 2022
98eba40
configs
petkovich Dec 29, 2022
0e3aa8f
fwd kinematics implementation, TODO ackermann
petkovich Dec 29, 2022
be9c0e1
steer_pos_ in odometry, adjusted names of arguments for update function
petkovich Dec 29, 2022
e4ff91d
Add new package for Bicycle controller.
destogl Jan 3, 2023
4074602
Add new package for Tricycle controller.
destogl Jan 3, 2023
5c5acb3
Add new package for Ackermann controller.
destogl Jan 3, 2023
0a8a264
Correct authors and descriptions.
destogl Jan 3, 2023
cb3e8af
Rename to steering_controllers_library.
destogl Jan 3, 2023
47f6d2e
Bicycle Controller moved to a separate package.
destogl Jan 3, 2023
b9b2e7e
Cleanup some files.
destogl Jan 3, 2023
378d88b
Move Ackermann steering controller to dedicated package.
destogl Jan 3, 2023
952c784
Moved Tricycle controller.
destogl Jan 3, 2023
82f096d
Updated ackermann controller stuff.
destogl Jan 3, 2023
6625551
Small fixes on bicycl eand library.
destogl Jan 3, 2023
04a18d8
tests build
petkovich Jan 4, 2023
3a81c9b
on cofigure test
petkovich Jan 5, 2023
c96a83b
first test finished
petkovich Jan 5, 2023
d645557
exported intefraces
petkovich Jan 7, 2023
73edcce
on activate
petkovich Jan 7, 2023
b723724
on activate
petkovich Jan 7, 2023
32db0c7
publish_commands
petkovich Jan 7, 2023
467a4a5
publish_commands
petkovich Jan 9, 2023
db15472
cleared slow controllers, publishing test subscriber
petkovich Jan 13, 2023
28ffa17
command_interfaces_ don't update
petkovich Jan 13, 2023
067c41d
fixed reference update
petkovich Jan 13, 2023
872ff14
publisher works
petkovich Jan 13, 2023
e0b0665
bicycle finished
petkovich Jan 13, 2023
e0255e0
tricycle params#
petkovich Jan 13, 2023
a9e249a
tricycle tests compile, ready for implementations
petkovich Jan 13, 2023
8a1da69
bicycle uses CMD_DRIVE_WHEEL etc instead of hardcoded numbers
petkovich Jan 13, 2023
c291ea7
tricycle first test, add subscription fails
petkovich Jan 13, 2023
fafcd20
first test passes
petkovich Jan 13, 2023
1840708
try: first test passes
petkovich Jan 13, 2023
38b7dcc
bi&tri: check_exported_intefaces
petkovich Jan 13, 2023
c6b51a0
tri: activate, update, deactivate, reactivate
petkovich Jan 13, 2023
607a774
update logic init tricycle
petkovich Jan 13, 2023
9c0c93f
update logic tricycle
petkovich Jan 13, 2023
ec851ad
tricycle done
petkovich Jan 13, 2023
e63558f
ackermann tests
petkovich Jan 13, 2023
b0adcaa
Delete steering_controllers.xml
destogl Jan 13, 2023
c0d348d
Update ackermann_steering_controller/ackermann_steering_controller.xml
petkovich Jan 16, 2023
cf4b48a
Update ackermann_steering_controller/include/ackermann_steering_contr…
petkovich Jan 16, 2023
a4c37e2
changed state_drive to state_traction
petkovich Jan 16, 2023
006b241
nr itfs in the header
petkovich Jan 16, 2023
7e31f93
ackermann tests cmd interfaces
petkovich Jan 16, 2023
c2849c9
control tricycle constants
petkovich Jan 16, 2023
5198ddd
control bicycle constants
petkovich Jan 16, 2023
e92a4bd
package descriptions, wheelbase param desc
petkovich Jan 16, 2023
304b288
preceeding ackermann
petkovich Jan 16, 2023
cc72efc
tricycle preceeding
petkovich Jan 16, 2023
5dfdf19
bicycle preceeding
petkovich Jan 16, 2023
abf035f
update logic chained
petkovich Jan 17, 2023
f829c45
removed pragma once
petkovich Jan 17, 2023
6368eca
params and cosmetics
petkovich Jan 17, 2023
bed538f
preceeding params and testing
petkovich Jan 17, 2023
9ccf5b2
cosmetic changes
petkovich Jan 17, 2023
5322b56
reset interfaces to nan
petkovich Jan 17, 2023
db764ab
reduce code for controller state publisher
petkovich Jan 17, 2023
29e9015
steering commands for ackermann
petkovich Jan 17, 2023
e2b8eb3
adding ref_timeout update behavior
Robotgir Jan 18, 2023
5b74105
test header and param
Robotgir Jan 18, 2023
91e2d2c
test cpp
Robotgir Jan 18, 2023
83c882e
working tests for steering_controllers_library
Robotgir Jan 19, 2023
9774c21
reverted to old update_and_write_commands, steering tests do not pass…
petkovich Jan 20, 2023
26772b2
odometry config, some variables renamed
petkovich Jan 20, 2023
797a0ce
cleaned todo
petkovich Jan 26, 2023
38650d4
fixed compile error, exported parameters to include
petkovich Jan 30, 2023
8d46a9a
DESTINATION include/
petkovich Jan 30, 2023
73e32be
Merge branch 'master' into ackermann-odometry-library
destogl Feb 8, 2023
7cd6683
Apply suggestions from code review
destogl Feb 8, 2023
aaf5187
Update ackermann_steering_controller/test/test_ackermann_steering_con…
destogl Feb 8, 2023
2f80658
Update bicycle_steering_controller/src/bicycle_steering_controller.yaml
destogl Feb 8, 2023
8f527f1
Last updates of CMake files copyright year and docs.
destogl Feb 8, 2023
6021447
Update controllers_index.rst
destogl Feb 8, 2023
c1d7515
fix typos
bmagyar Feb 21, 2023
563f8a9
Fix typos
bmagyar Feb 21, 2023
aa41b9d
Merge branch 'master' into ackermann-odometry-library
bmagyar Mar 20, 2023
9b9cadb
Update steering_controllers_library/src/steering_odometry.cpp
destogl Mar 22, 2023
c0144cf
Restore control_msgs repo version
bmagyar Apr 4, 2023
bcbc61c
Merge branch 'master' into ackermann-odometry-library
bmagyar Apr 4, 2023
ba54cb2
Merge branch 'master' into ackermann-odometry-library
bmagyar Apr 5, 2023
2b41621
fix format
bmagyar Apr 5, 2023
469702c
Fix typo in link
bmagyar Apr 5, 2023
63e4c28
Braces are good for you
bmagyar Apr 5, 2023
676239e
Fix typo
bmagyar Apr 5, 2023
ce4f36a
Add units to parameters
bmagyar Apr 5, 2023
c609707
Fix typo
bmagyar Apr 5, 2023
cd7622e
Merge branch 'master' into ackermann-odometry-library
bmagyar Apr 5, 2023
a3083e8
fix format again?!
bmagyar Apr 5, 2023
c1431af
Return update_odometry() instead of return true
bmagyar Apr 5, 2023
d78bb6a
Update to new signature of update_reference_from_subscribers
bmagyar Apr 5, 2023
092b459
Remove odom member from state publishing (doesn't exist)
bmagyar Apr 5, 2023
55d158c
Fix test compilation
bmagyar Apr 12, 2023
ecdf2a5
fix format
bmagyar Apr 12, 2023
d817144
Renovate load controller tests
bmagyar Apr 12, 2023
79f5102
remove typo
bmagyar Apr 26, 2023
96bcefa
fixed use_stamped_vel doc (#12)
ARK3r May 19, 2023
b9bdf63
Steering controller time related test fixes (#13)
ARK3r May 22, 2023
9e9007e
Merge branch 'master' into ackermann-odometry-library
bmagyar May 22, 2023
503f748
Controllers not initialized in the 4 steering controllers (#14)
ARK3r May 26, 2023
a27f976
Update style for lists in docs
bmagyar May 26, 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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ repos:
exclude: CHANGELOG\.rst$

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
rev: v1.10.0
hooks:
- id: rst-backticks
exclude: CHANGELOG\.rst$
Expand Down
104 changes: 104 additions & 0 deletions ackermann_steering_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
cmake_minimum_required(VERSION 3.16)
project(ackermann_steering_controller LANGUAGES CXX)

if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
set(THIS_PACKAGE_INCLUDE_DEPENDS
controller_interface
hardware_interface
generate_parameter_library
pluginlib
rclcpp
rclcpp_lifecycle
realtime_tools
std_srvs
steering_controllers_library
)

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(ackermann_steering_controller_parameters
src/ackermann_steering_controller.yaml
)

add_library(
ackermann_steering_controller
SHARED
src/ackermann_steering_controller.cpp
)
target_compile_features(ackermann_steering_controller PUBLIC cxx_std_17)
target_include_directories(ackermann_steering_controller PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_link_libraries(ackermann_steering_controller PUBLIC
ackermann_steering_controller_parameters)
ament_target_dependencies(ackermann_steering_controller PUBLIC ${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(ackermann_steering_controller PRIVATE "ACKERMANN_STEERING_CONTROLLER_BUILDING_DLL")

pluginlib_export_plugin_description_file(
controller_interface ackermann_steering_controller.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)

ament_add_gmock(test_load_ackermann_steering_controller test/test_load_ackermann_steering_controller.cpp)
target_include_directories(test_load_ackermann_steering_controller PRIVATE include)
ament_target_dependencies(
test_load_ackermann_steering_controller
controller_manager
hardware_interface
ros2_control_test_assets
)

add_rostest_with_parameters_gmock(
test_ackermann_steering_controller test/test_ackermann_steering_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/ackermann_steering_controller_params.yaml)
target_include_directories(test_ackermann_steering_controller PRIVATE include)
target_link_libraries(test_ackermann_steering_controller ackermann_steering_controller)
ament_target_dependencies(
test_ackermann_steering_controller
controller_interface
hardware_interface
)

add_rostest_with_parameters_gmock(
test_ackermann_steering_controller_preceeding test/test_ackermann_steering_controller_preceeding.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/ackermann_steering_controller_preceeding_params.yaml)
target_include_directories(test_ackermann_steering_controller_preceeding PRIVATE include)
target_link_libraries(test_ackermann_steering_controller_preceeding ackermann_steering_controller)
ament_target_dependencies(
test_ackermann_steering_controller_preceeding
controller_interface
hardware_interface
)
endif()

install(
DIRECTORY include/
DESTINATION include/ackermann_steering_controller
)

install(
TARGETS ackermann_steering_controller ackermann_steering_controller_parameters
EXPORT export_ackermann_steering_controller
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

ament_export_targets(export_ackermann_steering_controller HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
ament_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<library path="ackermann_steering_controller">
<class name="ackermann_steering_controller/AckermannSteeringController"
type="ackermann_steering_controller::AckermannSteeringController" base_class_type="controller_interface::ChainableControllerInterface">
<description>
Steering controller for Ackermann (car-like) kinematics with two traction and two steering joints.
</description>
</class>
</library>
18 changes: 18 additions & 0 deletions ackermann_steering_controller/doc/userdoc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.. _ackermann_steering_controller_userdoc:

ackermann_steering_controller
=============================

This controller implements the kinematics with two axes and four wheels, where the wheels on one axis are fixed (traction/drive) wheels, and the wheels on the other axis are steerable.

The controller expects to have two commanding joints for traction, one for each fixed wheel and two commanding joints for steering, one for each wheel.

For more details on controller's execution and interfaces check the :ref:`Steering Controller Library <steering_controllers_library>`.


Parameters
,,,,,,,,,,,

For list of parameters and their meaning YAML file in the ``src`` folder of the controller's package.

For an exemplary parameterization see the ``test`` folder of the controller's package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (c) 2023, 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.
//
// Authors: dr. sc. Tomislav Petkovic, Dr. Ing. Denis Štogl
//

#ifndef ACKERMANN_STEERING_CONTROLLER__ACKERMANN_STEERING_CONTROLLER_HPP_
#define ACKERMANN_STEERING_CONTROLLER__ACKERMANN_STEERING_CONTROLLER_HPP_

#include <memory>

#include "ackermann_steering_controller/visibility_control.h"
#include "ackermann_steering_controller_parameters.hpp"
#include "steering_controllers_library/steering_controllers_library.hpp"

namespace ackermann_steering_controller
{
// name constants for state interfaces
static constexpr size_t STATE_TRACTION_RIGHT_WHEEL = 0;
static constexpr size_t STATE_TRACTION_LEFT_WHEEL = 1;
static constexpr size_t STATE_STEER_RIGHT_WHEEL = 2;
static constexpr size_t STATE_STEER_LEFT_WHEEL = 3;

// name constants for command interfaces
static constexpr size_t CMD_TRACTION_RIGHT_WHEEL = 0;
static constexpr size_t CMD_TRACTION_LEFT_WHEEL = 1;
static constexpr size_t CMD_STEER_RIGHT_WHEEL = 2;
static constexpr size_t CMD_STEER_LEFT_WHEEL = 3;

static constexpr size_t NR_STATE_ITFS = 4;
static constexpr size_t NR_CMD_ITFS = 4;
static constexpr size_t NR_REF_ITFS = 2;

class AckermannSteeringController : public steering_controllers_library::SteeringControllersLibrary
{
public:
AckermannSteeringController();

ACKERMANN_STEERING_CONTROLLER__VISIBILITY_PUBLIC controller_interface::CallbackReturn
configure_odometry() override;

ACKERMANN_STEERING_CONTROLLER__VISIBILITY_PUBLIC bool update_odometry(
const rclcpp::Duration & period) override;

ACKERMANN_STEERING_CONTROLLER__VISIBILITY_PUBLIC void
initialize_implementation_parameter_listener() override;

protected:
std::shared_ptr<ackermann_steering_controller::ParamListener> ackermann_param_listener_;
ackermann_steering_controller::Params ackermann_params_;
};
} // namespace ackermann_steering_controller

#endif // ACKERMANN_STEERING_CONTROLLER__ACKERMANN_STEERING_CONTROLLER_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) 2023, 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.

#ifndef ACKERMANN_STEERING_CONTROLLER__VISIBILITY_CONTROL_H_
#define ACKERMANN_STEERING_CONTROLLER__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 ACKERMANN_STEERING_CONTROLLER__VISIBILITY_EXPORT __attribute__((dllexport))
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_IMPORT __attribute__((dllimport))
#else
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_EXPORT __declspec(dllexport)
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_IMPORT __declspec(dllimport)
#endif
#ifdef ACKERMANN_STEERING_CONTROLLER__VISIBILITY_BUILDING_DLL
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_PUBLIC \
ACKERMANN_STEERING_CONTROLLER__VISIBILITY_EXPORT
#else
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_PUBLIC \
ACKERMANN_STEERING_CONTROLLER__VISIBILITY_IMPORT
#endif
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_PUBLIC_TYPE \
ACKERMANN_STEERING_CONTROLLER__VISIBILITY_PUBLIC
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_LOCAL
#else
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_EXPORT __attribute__((visibility("default")))
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_IMPORT
#if __GNUC__ >= 4
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_PUBLIC __attribute__((visibility("default")))
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_LOCAL __attribute__((visibility("hidden")))
#else
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_PUBLIC
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_LOCAL
#endif
#define ACKERMANN_STEERING_CONTROLLER__VISIBILITY_PUBLIC_TYPE
#endif

#endif // ACKERMANN_STEERING_CONTROLLER__VISIBILITY_CONTROL_H_
36 changes: 36 additions & 0 deletions ackermann_steering_controller/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?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>ackermann_steering_controller</name>
<version>0.0.0</version>
<description>Steering controller for Ackermann kinematics. Rear fixed wheels are powering the vehicle and front wheels are steering it.</description>
<license>Apache License 2.0</license>
<maintainer email="bence.magyar.robotics@gmail.com">Bence Magyar</maintainer>
<maintainer email="denis.stogl@stoglrobotics.de">Dr.-Ing. Denis Štogl</maintainer>
<maintainer email="tomislav.petkovic.fer@gmail.com">dr. sc. Tomislav Petkovic</maintainer>

<author email="denis.stogl@stoglrobotics.de">Dr.-Ing. Denis Štogl</author>
<author email="tomislav.petkovic.fer@gmail.com">dr. sc. Tomislav Petkovic</author>

<buildtool_depend>ament_cmake</buildtool_depend>

<build_depend>generate_parameter_library</build_depend>

<depend>control_msgs</depend>
<depend>controller_interface</depend>
<depend>hardware_interface</depend>
<depend>pluginlib</depend>
<depend>rclcpp</depend>
<depend>rclcpp_lifecycle</depend>
<depend>std_srvs</depend>
<depend>steering_controllers_library</depend>

<test_depend>ament_cmake_gmock</test_depend>
<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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Copyright (c) 2023, 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.

#include "ackermann_steering_controller/ackermann_steering_controller.hpp"

namespace ackermann_steering_controller
{
AckermannSteeringController::AckermannSteeringController()
: steering_controllers_library::SteeringControllersLibrary()
{
}

void AckermannSteeringController::initialize_implementation_parameter_listener()
{
ackermann_param_listener_ =
std::make_shared<ackermann_steering_controller::ParamListener>(get_node());
}

controller_interface::CallbackReturn AckermannSteeringController::configure_odometry()
{
ackermann_params_ = ackermann_param_listener_->get_params();

const double front_wheels_radius = ackermann_params_.front_wheels_radius;
const double rear_wheels_radius = ackermann_params_.rear_wheels_radius;
const double front_wheel_track = ackermann_params_.front_wheel_track;
const double rear_wheel_track = ackermann_params_.rear_wheel_track;
const double wheelbase = ackermann_params_.wheelbase;
destogl marked this conversation as resolved.
Show resolved Hide resolved

if (params_.front_steering)
{
odometry_.set_wheel_params(rear_wheels_radius, wheelbase, rear_wheel_track);
}
else
{
odometry_.set_wheel_params(front_wheels_radius, wheelbase, front_wheel_track);
}

odometry_.set_odometry_type(steering_odometry::ACKERMANN_CONFIG);

set_interface_numbers(NR_STATE_ITFS, NR_CMD_ITFS, NR_REF_ITFS);

RCLCPP_INFO(get_node()->get_logger(), "ackermann odom configure successful");
return controller_interface::CallbackReturn::SUCCESS;
}

bool AckermannSteeringController::update_odometry(const rclcpp::Duration & period)
bmagyar marked this conversation as resolved.
Show resolved Hide resolved
{
if (params_.open_loop)
{
odometry_.update_open_loop(last_linear_velocity_, last_angular_velocity_, period.seconds());
}
else
{
const double rear_right_wheel_value = state_interfaces_[STATE_TRACTION_RIGHT_WHEEL].get_value();
const double rear_left_wheel_value = state_interfaces_[STATE_TRACTION_LEFT_WHEEL].get_value();
const double front_right_steer_position =
state_interfaces_[STATE_STEER_RIGHT_WHEEL].get_value();
const double front_left_steer_position = state_interfaces_[STATE_STEER_LEFT_WHEEL].get_value();
if (
!std::isnan(rear_right_wheel_value) && !std::isnan(rear_left_wheel_value) &&
!std::isnan(front_right_steer_position) && !std::isnan(front_left_steer_position))
{
if (params_.position_feedback)
{
// Estimate linear and angular velocity using joint information
odometry_.update_from_position(
rear_right_wheel_value, rear_left_wheel_value, front_right_steer_position,
front_left_steer_position, period.seconds());
}
else
{
// Estimate linear and angular velocity using joint information
odometry_.update_from_velocity(
rear_right_wheel_value, rear_left_wheel_value, front_right_steer_position,
front_left_steer_position, period.seconds());
}
}
}
return true;
}
} // namespace ackermann_steering_controller

#include "pluginlib/class_list_macros.hpp"

PLUGINLIB_EXPORT_CLASS(
ackermann_steering_controller::AckermannSteeringController,
controller_interface::ChainableControllerInterface)
Loading