-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ros2_control Hardware Interface bringup (#10)
* Run formatter * Remove Node interface from RDT driver * Start hardware interface * Finish implementing hardware interface * Add better error handling if sensor isn't found * Add newlines at end of files
- Loading branch information
1 parent
476d02c
commit ddccade
Showing
16 changed files
with
1,122 additions
and
604 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
Language: Cpp | ||
BasedOnStyle: Google | ||
|
||
AccessModifierOffset: -2 | ||
AlignAfterOpenBracket: AlwaysBreak | ||
BraceWrapping: | ||
AfterClass: true | ||
AfterFunction: true | ||
AfterNamespace: true | ||
AfterStruct: true | ||
AfterEnum: true | ||
BreakBeforeBraces: Custom | ||
ColumnLimit: 100 | ||
ConstructorInitializerIndentWidth: 0 | ||
ContinuationIndentWidth: 2 | ||
DerivePointerAlignment: false | ||
PointerAlignment: Middle | ||
ReflowComments: false | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
C++ class and ROS node for ATI force/torque sensors connected to a Netbox. Includes gravity compensation and transformations. | ||
|
||
# Usage | ||
There are two main ways to use this package: | ||
1. With a direct ROS node | ||
1. Using `ros2_control` hardware interface and a `force_torque_broadcaster` | ||
|
||
To launch the direct node, run the following with the correct IP address | ||
```sh | ||
ros2 run netft_utils netft_node --address WWW.XXX.YYY.ZZZ | ||
``` | ||
|
||
To run an example launch for `ros2_control` run the following with option namespace | ||
```sh | ||
ros2 launch netft_utils netft.launch.py node_namespace:="test_ns/" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
$(var node_namespace)controller_manager: | ||
ros__parameters: | ||
update_rate: 500 # Hz | ||
|
||
force_torque_sensor_broadcaster: | ||
type: force_torque_sensor_broadcaster/ForceTorqueSensorBroadcaster | ||
|
||
|
||
$(var node_namespace)force_torque_sensor_broadcaster: | ||
ros__parameters: | ||
sensor_name: netft_sensor | ||
state_interface_names: | ||
- force.x | ||
- force.y | ||
- force.z | ||
- torque.x | ||
- torque.y | ||
- torque.z | ||
frame_id: netft_link |
68 changes: 68 additions & 0 deletions
68
netft_utils/include/netft_utils/netft_hardware_interface.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// 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. | ||
|
||
// | ||
// Authors: Subhas Das, Denis Stogl | ||
// | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "hardware_interface/handle.hpp" | ||
#include "hardware_interface/hardware_info.hpp" | ||
#include "hardware_interface/sensor_interface.hpp" | ||
#include "hardware_interface/types/hardware_interface_return_values.hpp" | ||
#include "netft_utils/netft_rdt_driver.h" | ||
#include "netft_utils/visibility_control.h" | ||
#include "rclcpp/macros.hpp" | ||
|
||
namespace netft_hardware_interface | ||
{ | ||
class NetFTHardwareInterface : public hardware_interface::SensorInterface | ||
{ | ||
public: | ||
RCLCPP_SHARED_PTR_DEFINITIONS(NetFTHardwareInterface) | ||
|
||
NETFT_HARDWARE_INTERFACE_PUBLIC | ||
hardware_interface::CallbackReturn on_init( | ||
const hardware_interface::HardwareInfo & info) override; | ||
|
||
NETFT_HARDWARE_INTERFACE_PUBLIC | ||
std::vector<hardware_interface::StateInterface> export_state_interfaces() override; | ||
|
||
NETFT_HARDWARE_INTERFACE_PUBLIC | ||
hardware_interface::CallbackReturn on_activate( | ||
const rclcpp_lifecycle::State & previous_state) override; | ||
|
||
NETFT_HARDWARE_INTERFACE_PUBLIC | ||
hardware_interface::CallbackReturn on_deactivate( | ||
const rclcpp_lifecycle::State & previous_state) override; | ||
|
||
NETFT_HARDWARE_INTERFACE_PUBLIC | ||
hardware_interface::return_type read( | ||
const rclcpp::Time & time, const rclcpp::Duration & period) override; | ||
|
||
private: | ||
// Store the sensor states | ||
std::vector<double> hw_sensor_states_; | ||
|
||
// For talking to the sensor | ||
std::string ip_address_; | ||
std::unique_ptr<netft_rdt_driver::NetFTRDTDriver> ft_driver_; | ||
}; | ||
|
||
} // namespace netft_hardware_interface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2021 ros2_control Development Team | ||
// | ||
// 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. | ||
|
||
/* This header must be included by all rclcpp headers which declare symbols | ||
* which are defined in the rclcpp library. When not building the rclcpp | ||
* library, i.e. when using the headers in other package's code, the contents | ||
* of this header change the visibility of certain symbols which the rclcpp | ||
* library cannot have, but the consuming code must have inorder to link. | ||
*/ | ||
|
||
#pragma once | ||
|
||
// 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 NETFT_HARDWARE_INTERFACE_EXPORT __attribute__((dllexport)) | ||
#define NETFT_HARDWARE_INTERFACE_IMPORT __attribute__((dllimport)) | ||
#else | ||
#define NETFT_HARDWARE_INTERFACE_EXPORT __declspec(dllexport) | ||
#define NETFT_HARDWARE_INTERFACE_IMPORT __declspec(dllimport) | ||
#endif | ||
#ifdef NETFT_HARDWARE_INTERFACE_BUILDING_DLL | ||
#define NETFT_HARDWARE_INTERFACE_PUBLIC NETFT_HARDWARE_INTERFACE_EXPORT | ||
#else | ||
#define NETFT_HARDWARE_INTERFACE_PUBLIC NETFT_HARDWARE_INTERFACE_IMPORT | ||
#endif | ||
#define NETFT_HARDWARE_INTERFACE_PUBLIC_TYPE NETFT_HARDWARE_INTERFACE_PUBLIC | ||
#define NETFT_HARDWARE_INTERFACE_LOCAL | ||
#else | ||
#define NETFT_HARDWARE_INTERFACE_EXPORT __attribute__((visibility("default"))) | ||
#define NETFT_HARDWARE_INTERFACE_IMPORT | ||
#if __GNUC__ >= 4 | ||
#define NETFT_HARDWARE_INTERFACE_PUBLIC __attribute__((visibility("default"))) | ||
#define NETFT_HARDWARE_INTERFACE_LOCAL __attribute__((visibility("hidden"))) | ||
#else | ||
#define NETFT_HARDWARE_INTERFACE_PUBLIC | ||
#define NETFT_HARDWARE_INTERFACE_LOCAL | ||
#endif | ||
#define NETFT_HARDWARE_INTERFACE_PUBLIC_TYPE | ||
#endif |
Oops, something went wrong.