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 admittance controller #370

Merged
merged 128 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
0206ee6
Make forward controller chainable.
destogl Mar 21, 2022
43f39a0
Enabling chanable mode for forward command controllers.
destogl Mar 23, 2022
29c4393
Fix all bugs in chained-controllers mode.
destogl Mar 24, 2022
6f2f956
Remove debug output from forwarding controller.
destogl Mar 29, 2022
704ba5d
Make forward controller chainable.
destogl Mar 21, 2022
6759bb5
Enabling chanable mode for forward command controllers.
destogl Mar 23, 2022
7afdefc
Fix all bugs in chained-controllers mode.
destogl Mar 24, 2022
7c03f79
Remove debug output from forwarding controller.
destogl Mar 29, 2022
f8556ea
Some compile fixes
destogl Apr 26, 2022
d77b4b6
Fix some small issues.
destogl Apr 26, 2022
778ed13
Update to use class.
destogl May 16, 2022
39b640e
added admittance controller
pac48 Jun 19, 2022
be2f308
merge fwd chainable controller
pac48 Jun 20, 2022
4f3d709
merged additional from fwd chainable controllers
pac48 Jun 20, 2022
fcc2be2
fixed interface memory bug
pac48 Jun 20, 2022
0aac28e
changed position/velocity reference fields
pac48 Jun 20, 2022
7033048
added gravity compensation
pac48 Jun 20, 2022
1a266bc
replaced Eigen 3.4 API with Eigen 3.3
pac48 Jun 20, 2022
8dc9b37
clean up and TODOs
pac48 Jun 20, 2022
1563113
removed reshaped operation and fix forward velocity
pac48 Jun 21, 2022
5d59427
code cleanup and refactored gravity compensation
pac48 Jun 22, 2022
18097a2
replaced parameter handler with auto-generated struct
pac48 Jun 25, 2022
dfc27bf
dynamic parameter updating enabled
pac48 Jun 25, 2022
2db281f
enable/disable parameter update during execution + fill state message
pac48 Jun 27, 2022
9990dca
remove unused code
pac48 Jun 28, 2022
690b89b
eliminate ik drift: broken
pac48 Jun 28, 2022
0e6cfb1
correct drift from integrating position
pac48 Jun 28, 2022
79a54dc
working drift correction for position and rotation
pac48 Jun 29, 2022
23ed194
Merge branch 'master' into add-admittance-controller
pac48 Jun 30, 2022
c54d46c
fix pparameter copying behaviour
pac48 Jun 30, 2022
906c602
add parameter field for IK package
pac48 Jul 1, 2022
4a6f779
fix struct formatting
pac48 Jul 1, 2022
84ccdde
enable tests: currently failing
pac48 Jul 4, 2022
976d286
updated auto generated struct with parameter validation
pac48 Jul 5, 2022
965c226
added parameter validation and descriptions
pac48 Jul 6, 2022
a0f4bae
general code clean up
pac48 Jul 6, 2022
27ea60f
parameter handling tests passing
pac48 Jul 7, 2022
737363c
declare parameters in test
pac48 Jul 19, 2022
6936c5d
change parameter struct format
pac48 Jul 27, 2022
382a1b6
passing tests
pac48 Jul 28, 2022
cbd124c
add error checks on all public methods
pac48 Jul 28, 2022
967f64f
code clean up
pac48 Jul 28, 2022
bcac129
added parameters for drift correction
pac48 Jul 31, 2022
7b29386
Update controllers with new get_name hardware interfaces (#369)
Schulze18 Jul 2, 2022
da52b32
integrate motion in joint space to eliminate drift error
pac48 Aug 3, 2022
0951605
remove drift correction parameters
pac48 Aug 3, 2022
f2acf62
Merge branch 'add-admittance-controller' of https://github.com/pac48/…
pac48 Aug 3, 2022
9885432
move interface vector reset to on_activate
pac48 Aug 3, 2022
7d5fcf2
remove interface maps
pac48 Aug 4, 2022
f19b096
Merge branch 'master' of https://github.com/ros-controls/ros2_control…
pac48 Aug 4, 2022
cf7031f
fix JTC with newest ros_control
pac48 Aug 4, 2022
bdb32b4
mend
pac48 Aug 5, 2022
ed37061
revert forward command controller changes
pac48 Aug 5, 2022
c7c7312
update force reading in hardware read function
pac48 Aug 5, 2022
7a3ecf9
Merge branch 'add-admittance-controller' of https://github.com/pac48/…
pac48 Aug 5, 2022
45b8afd
initialize reference vectors properly
pac48 Aug 6, 2022
893cea6
resize states in activate
pac48 Aug 6, 2022
13959e1
Merge branch 'add-admittance-controller' of https://github.com/pac48/…
pac48 Aug 5, 2022
911ecdd
use reference wrapper instead of double pointer
pac48 Aug 8, 2022
d8999a5
remove rotation struct
pac48 Aug 8, 2022
6c4bf66
Merge branch 'add-admittance-controller' of github.com:pac48/ros2_con…
pac48 Aug 8, 2022
4833f4a
update test
pac48 Aug 8, 2022
7f22790
remove generated code
pac48 Aug 8, 2022
451f6d4
use Eigen tranformation types
pac48 Aug 9, 2022
8c1bcf4
update state message
pac48 Aug 9, 2022
bff17df
remove warnings
pac48 Aug 9, 2022
2c1282e
implement state message information and enable selected axes
pac48 Aug 10, 2022
cc90178
add test
pac48 Aug 10, 2022
3086290
Merge branch 'master' of https://github.com/ros-controls/ros2_control…
pac48 Aug 10, 2022
d850b47
update README
pac48 Aug 10, 2022
51e85c6
update variable names
pac48 Aug 10, 2022
1541318
update kinematics interface use
pac48 Aug 11, 2022
932a554
Make tricycle controller the same as master.
destogl Aug 20, 2022
a15728e
Revert "Make tricycle controller the same as master."
destogl Aug 20, 2022
f97f7d9
Merge remote-tracking branch 'upstream/master' into add-admittance-co…
destogl Aug 20, 2022
ccec03d
Correct formatting and linting issues.
destogl Aug 21, 2022
01f5e3e
Merge remote-tracking branch 'upstream/master' into add-admittance-co…
destogl Aug 21, 2022
9760b92
JTC should be the same as on master.
destogl Aug 21, 2022
6ba8bcc
A bit more code cleaning and polishing.
destogl Aug 21, 2022
9a08f77
update control_msgs repo
pac48 Aug 22, 2022
8011760
Merge branch 'add-admittance-controller' of github.com:pac48/ros2_con…
pac48 Aug 22, 2022
4b0b4b2
remove joint limits from package
pac48 Aug 22, 2022
8f85ead
add kinematics_interface to not released .repo files
pac48 Aug 22, 2022
742b252
add tf2_kdl to admittance package.xml
pac48 Aug 22, 2022
9774584
add kinematics_interface to all .repo files
pac48 Aug 22, 2022
a225c17
add generate_parameter_library to .repos
pac48 Aug 22, 2022
dc1641b
fix url
pac48 Aug 22, 2022
84fa4fe
add control_msgs to not-released .repos
pac48 Aug 22, 2022
8ae5090
update kinematics plugin name
pac48 Aug 22, 2022
e323d14
fix parameter update on restart
pac48 Aug 22, 2022
9c148a0
update repos
pac48 Aug 22, 2022
795cdce
Precommit
pac48 Aug 22, 2022
2f609be
update repos
pac48 Aug 22, 2022
7710448
fix test output
pac48 Aug 23, 2022
a5847a2
move parameter initialization to controller class
pac48 Aug 23, 2022
d8674cd
use single admittance transforms struct
pac48 Aug 23, 2022
d1d42df
rename cog_ and ee_weight_ variables
pac48 Aug 23, 2022
d6050dd
Update admittance_controller/include/admittance_controller/admittance…
pac48 Aug 23, 2022
93bd627
reset on values deactivate
pac48 Aug 23, 2022
ac307ce
fix admittance reset
pac48 Aug 23, 2022
ed0b014
add joint damping parameter
pac48 Aug 23, 2022
ba73aee
update documenation in admittance_rule
pac48 Aug 23, 2022
c61217b
Update comments
pac48 Aug 23, 2022
dacd8bb
update descriptions for the admittance parameters
pac48 Aug 23, 2022
ce583b0
refactor indexing to be like JTC
pac48 Aug 23, 2022
d814028
clear joint_command_interface_ and joint_state_interface_ in deactivate
pac48 Aug 24, 2022
c4ae3da
fix include for rolling
pac48 Aug 24, 2022
3dc1816
update README
pac48 Aug 24, 2022
3287740
update comments
pac48 Aug 24, 2022
bde3d39
Update admittance_controller/include/admittance_controller/admittance…
pac48 Aug 24, 2022
f23b6a6
Update admittance_controller/src/admittance_controller.cpp
pac48 Aug 24, 2022
bbdc506
Update admittance_controller/src/admittance_controller.cpp
pac48 Aug 24, 2022
c45b668
move dynamic allocations in state message to reset method
pac48 Aug 24, 2022
a4817c1
Merge branch 'add-admittance-controller' of github.com:pac48/ros2_con…
pac48 Aug 24, 2022
ea59076
Update admittance_controller/src/admittance_controller.cpp
pac48 Aug 24, 2022
f94ca25
Update admittance_controller/include/admittance_controller/admittance…
pac48 Aug 24, 2022
6a0281f
Remove unneeded code and chnage field name
pac48 Aug 24, 2022
4346e3d
update comments/docs
pac48 Aug 24, 2022
82c0018
remove tmp variables
pac48 Aug 24, 2022
2855cc7
Merge branch 'master' into add-admittance-controller
destogl Aug 31, 2022
91af1ac
Merge branch 'master' into add-admittance-controller
Sep 23, 2022
2644a4e
Improve some comments
Sep 23, 2022
ec55e5c
Merge branch 'master' into add-admittance-controller
destogl Oct 6, 2022
08b3909
Merge branch 'master' into add-admittance-controller
destogl Oct 10, 2022
83c6e5d
Updated documentation.
destogl Oct 10, 2022
2e57e4a
Fixing linters.
destogl Oct 10, 2022
28c5665
Small polishing
destogl Oct 10, 2022
e9c7432
Update upstream repo.
destogl Oct 10, 2022
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
122 changes: 122 additions & 0 deletions admittance_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
cmake_minimum_required(VERSION 3.5)
project(admittance_controller)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()

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

# find dependencies
set(THIS_PACKAGE_INCLUDE_DEPENDS
angles
control_msgs
control_toolbox
controller_interface
kinematics_interface
Eigen3
generate_parameter_library
geometry_msgs
hardware_interface
joint_trajectory_controller
pluginlib
rclcpp
rclcpp_lifecycle
realtime_tools
tf2
tf2_eigen
tf2_geometry_msgs
tf2_kdl
tf2_ros
trajectory_msgs
)

find_package(ament_cmake REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
endforeach()

add_library(${PROJECT_NAME} SHARED src/admittance_controller.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE include)
generate_parameter_library(${PROJECT_NAME}_parameters src/admittance_controller_parameters.yaml)
target_link_libraries(${PROJECT_NAME} admittance_controller_parameters)
ament_target_dependencies(${PROJECT_NAME} ${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(${PROJECT_NAME} PRIVATE "ADMITTANCE_CONTROLLER_BUILDING_DLL")

pluginlib_export_plugin_description_file(controller_interface admittance_controller.xml)

install(DIRECTORY include/
DESTINATION include
)

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

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

## create custom test function to pass yaml file into test main
#function(add_test_with_yaml_input TARGET SOURCES YAML_FILE)
#add_executable(${TARGET} ${SOURCES})
#_ament_cmake_gmock_find_gmock()
#target_include_directories(${TARGET} PUBLIC "${GMOCK_INCLUDE_DIRS}")
#target_link_libraries(${TARGET} ${GMOCK_LIBRARIES})
#set(executable "$<TARGET_FILE:${TARGET}>")
#set(result_file "${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${TARGET}.gtest.xml")
#ament_add_test(
#${TARGET}
#COMMAND ${executable} --ros-args --params-file ${YAML_FILE}
#--gtest_output=xml:${result_file}
#OUTPUT_FILE ${AMENT_TEST_RESULTS_DIR}/${PROJECT_NAME}/${TARGET}.txt
#RESULT_FILE ${result_file}
#)
#endfunction()

# test loading admittance controller
add_rostest_with_parameters_gmock(test_load_admittance_controller test/test_load_admittance_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/test_params.yaml)
target_include_directories(test_load_admittance_controller PUBLIC ${GMOCK_INCLUDE_DIRS})
target_link_libraries(test_load_admittance_controller ${GMOCK_LIBRARIES})
ament_target_dependencies(
test_load_admittance_controller
controller_manager
hardware_interface
ros2_control_test_assets
)
# test admittance controller function
add_rostest_with_parameters_gmock(test_admittance_controller test/test_admittance_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/test_params.yaml)
target_include_directories(test_admittance_controller PRIVATE include)
target_link_libraries(test_admittance_controller admittance_controller)
ament_target_dependencies(
test_admittance_controller
control_msgs
controller_interface
hardware_interface
ros2_control_test_assets
)
endif()

ament_export_include_directories(
include
)
ament_export_dependencies(
${THIS_PACKAGE_INCLUDE_DEPENDS}
)
ament_export_libraries(
${PROJECT_NAME}
)
ament_package()
9 changes: 9 additions & 0 deletions admittance_controller/admittance_controller.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<library path="admittance_controller">
<class name="admittance_controller/AdmittanceController"
type="admittance_controller::AdmittanceController"
base_class_type="controller_interface::ChainableControllerInterface">
<description>
AdmittanceController ros2_control controller.
</description>
</class>
</library>
58 changes: 58 additions & 0 deletions admittance_controller/doc/userdoc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.. _joint_trajectory_controller_userdoc:

Admittance Controller
======================

Admittance controller enables you do zero-force control from a force measured on your TCP.
The controller implements ``ChainedControllerInterface``, so it is possible to add another controllers in front of it, e.g., ``JointTrajectoryController``.

The controller requires an external kinematics plugin to function. The `kinematics_interface <https://github.com/ros-controls/kinematics_interface>`_ repository provides an interface and an implementation that the admittance controller can use.

Parameters:



ROS2 interface of the controller
---------------------------------

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

The admittance controller's uses the `generate_parameter_library <https://github.com/PickNikRobotics/generate_parameter_library>`_ to handle its parameters.
The parameter `definition file located in the src folder <https://github.com/ros-controls/ros2_controllers/blob/master/admittance_controller/src/admittance_controller_parameters.yaml>`_ contains descriptions for all the parameters used by the controller.
An example parameter file can be found in the `test folder of the controller <https://github.com/ros-controls/ros2_controllers/blob/master/admittance_controller/test/test_params.yaml>`_


Topics
^^^^^^^

~/joint_references (input topic) [trajectory_msgs::msg::JointTrajectoryPoint]
Target joint commands when controller is not in chained mode.

~/state (output topic) [control_msgs::msg::AdmittanceControllerState]
Topic publishing internal states.


ros2_control interfaces
------------------------

References
^^^^^^^^^^^
The controller has ``position`` and ``velocity`` reference interfaces exported in the format:
``<controller_name>/<joint_name>/[position|velocity]``


States
^^^^^^^
The state interfaces are defined with ``joints`` and ``state_interfaces`` parameters as follows: ``<joint>/<state_interface>``.
Supported state interfaces are ``position``, ``velocity``, and ``acceleration`` as defined in the `hardware_interface/hardware_interface_type_values.hpp <https://github.com/ros-controls/ros2_control/blob/master/hardware_interface/include/hardware_interface/types/hardware_interface_type_values.hpp>`_.
If some interface is not provided, the last commanded interface will be used for calculation.

For handling TCP wrenches `*Force Torque Sensor* semantic component (from package *controller_interface*) <https://github.com/ros-controls/ros2_control/blob/master/controller_interface/include/semantic_components/force_torque_sensor.hpp>`_ is used.
The interfaces have prefix ``ft_sensor.name``, building the interfaces: ``<sensor_name>/[force.x|force.y|force.z|torque.x|torque.y|torque.z]``.


Commands
^^^^^^^^^
The command interfaces are defined with ``joints`` and ``command_interfaces`` parameters as follows: ``<joint>/<command_interface>``.
Supported state interfaces are ``position``, ``velocity``, and ``acceleration`` as defined in the `hardware_interface/hardware_interface_type_values.hpp <https://github.com/ros-controls/ros2_control/blob/master/hardware_interface/include/hardware_interface/types/hardware_interface_type_values.hpp>`_.
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
// Copyright (c) 2022, PickNik, Inc.
//
// 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: Denis Stogl, Andy Zelenak, Paul Gesel

#ifndef ADMITTANCE_CONTROLLER__ADMITTANCE_CONTROLLER_HPP_
#define ADMITTANCE_CONTROLLER__ADMITTANCE_CONTROLLER_HPP_

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

// include generated parameter library
#include "admittance_controller_parameters.hpp"

#include "admittance_controller/admittance_rule.hpp"
#include "admittance_controller/visibility_control.h"
#include "control_msgs/msg/admittance_controller_state.hpp"
#include "controller_interface/chainable_controller_interface.hpp"
#include "geometry_msgs/msg/pose_stamped.hpp"
#include "geometry_msgs/msg/transform_stamped.hpp"
#include "geometry_msgs/msg/wrench_stamped.hpp"
#include "hardware_interface/types/hardware_interface_type_values.hpp"
#include "pluginlib/class_loader.hpp"
#include "rclcpp/duration.hpp"
#include "rclcpp/time.hpp"
#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
#include "rclcpp_lifecycle/state.hpp"
#include "realtime_tools/realtime_buffer.h"
#include "realtime_tools/realtime_publisher.h"
#include "semantic_components/force_torque_sensor.hpp"

#include "trajectory_msgs/msg/joint_trajectory.hpp"

namespace admittance_controller
{
using ControllerStateMsg = control_msgs::msg::AdmittanceControllerState;

class AdmittanceController : public controller_interface::ChainableControllerInterface
{
public:
ADMITTANCE_CONTROLLER_PUBLIC
controller_interface::CallbackReturn on_init() override;

/// Export configuration of required state interfaces.
/**
* Allowed types of state interfaces are \ref hardware_interface::POSITION,
* \ref hardware_interface::VELOCITY, \ref hardware_interface::ACCELERATION.
*/
ADMITTANCE_CONTROLLER_PUBLIC
controller_interface::InterfaceConfiguration command_interface_configuration() const override;

/// Export configuration of required state interfaces.
/**
* Allowed types of state interfaces are \ref hardware_interface::POSITION,
* \ref hardware_interface::VELOCITY, \ref hardware_interface::ACCELERATION.
*/
ADMITTANCE_CONTROLLER_PUBLIC
controller_interface::InterfaceConfiguration state_interface_configuration() const override;

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

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

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

ADMITTANCE_CONTROLLER_PUBLIC
controller_interface::CallbackReturn on_cleanup(
const rclcpp_lifecycle::State & previous_state) override;

ADMITTANCE_CONTROLLER_PUBLIC
controller_interface::CallbackReturn on_error(
const rclcpp_lifecycle::State & previous_state) override;

ADMITTANCE_CONTROLLER_PUBLIC
controller_interface::return_type update_and_write_commands(
const rclcpp::Time & time, const rclcpp::Duration & period) override;

protected:
std::vector<hardware_interface::CommandInterface> on_export_reference_interfaces() override;

controller_interface::return_type update_reference_from_subscribers() override;

size_t num_joints_ = 0;
std::vector<std::string> command_joint_names_;

// The interfaces are defined as the types in 'allowed_interface_types_' member.
// For convenience, for each type the interfaces are ordered so that i-th position
// matches i-th index in joint_names_
template <typename T>
using InterfaceReferences = std::vector<std::vector<std::reference_wrapper<T>>>;

InterfaceReferences<hardware_interface::LoanedCommandInterface> joint_command_interface_;
InterfaceReferences<hardware_interface::LoanedStateInterface> joint_state_interface_;

bool has_position_state_interface_ = false;
bool has_velocity_state_interface_ = false;
bool has_acceleration_state_interface_ = false;
bool has_position_command_interface_ = false;
bool has_velocity_command_interface_ = false;
bool has_acceleration_command_interface_ = false;
bool has_effort_command_interface_ = false;

// To reduce number of variables and to make the code shorter the interfaces are ordered in types
// as the following constants
const std::vector<std::string> allowed_interface_types_ = {
hardware_interface::HW_IF_POSITION, hardware_interface::HW_IF_VELOCITY,
hardware_interface::HW_IF_ACCELERATION};

// internal reference values
const std::vector<std::string> allowed_reference_interfaces_types_ = {
hardware_interface::HW_IF_POSITION, hardware_interface::HW_IF_VELOCITY};
std::vector<std::reference_wrapper<double>> position_reference_;
std::vector<std::reference_wrapper<double>> velocity_reference_;

// Admittance rule and dependent variables;
std::unique_ptr<admittance_controller::AdmittanceRule> admittance_;

// force torque sensor
std::unique_ptr<semantic_components::ForceTorqueSensor> force_torque_sensor_;

// ROS subscribers
rclcpp::Subscription<trajectory_msgs::msg::JointTrajectoryPoint>::SharedPtr
input_joint_command_subscriber_;
rclcpp::Publisher<control_msgs::msg::AdmittanceControllerState>::SharedPtr s_publisher_;

// admittance parameters
std::shared_ptr<admittance_controller::ParamListener> parameter_handler_;

// ROS messages
std::shared_ptr<trajectory_msgs::msg::JointTrajectoryPoint> joint_command_msg_;

// real-time buffer
realtime_tools::RealtimeBuffer<std::shared_ptr<trajectory_msgs::msg::JointTrajectoryPoint>>
input_joint_command_;
std::unique_ptr<realtime_tools::RealtimePublisher<ControllerStateMsg>> state_publisher_;

trajectory_msgs::msg::JointTrajectoryPoint last_commanded_;
trajectory_msgs::msg::JointTrajectoryPoint last_reference_;

// control loop data
// reference_: reference value read by the controller
// joint_state_: current joint readings from the hardware
// reference_admittance_: reference value used by the controller after the admittance values are
// applied ft_values_: values read from the force torque sensor
trajectory_msgs::msg::JointTrajectoryPoint reference_, joint_state_, reference_admittance_;
geometry_msgs::msg::Wrench ft_values_;

/**
* @brief Read values from hardware interfaces and set corresponding fields of state_current and ft_values
*/
void read_state_from_hardware(
trajectory_msgs::msg::JointTrajectoryPoint & state_current,
geometry_msgs::msg::Wrench & ft_values);

/**
* @brief Set fields of state_reference with values from controllers exported position and velocity references
*/
void read_state_reference_interfaces(trajectory_msgs::msg::JointTrajectoryPoint & state);

/**
* @brief Write values from state_command to claimed hardware interfaces
*/
void write_state_to_hardware(const trajectory_msgs::msg::JointTrajectoryPoint & state_command);
};

} // namespace admittance_controller

#endif // ADMITTANCE_CONTROLLER__ADMITTANCE_CONTROLLER_HPP_
Loading