Skip to content
Merged
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
46 changes: 43 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,53 @@ chmod +x install.sh && . install.sh
## Running sensor server

```console
ros2 launch sas_force_sensor_bota sas_force_sensor_bota_launch.py
ros2 launch sas_force_sensor_bota force_sensor_launch.py
```

The launch file loads the parameters from `config/config.yaml` (override with
`config_file:=/path/to/config.yaml`). The hardware-specific JSON configuration
(`configuration_file_path`) is embedded in the YAML file: `config/config.yaml`
points at `bota_binary_gen0.json` and `config/config_ethercat.yaml` points at
`ethercat_gen0.json` (for the EtherCAT hardware).

| Configurable Parameter | Meaning |
|------------------------|---------|
|`topic_name`| Topic prefix, for instance, if there are multiple sensors in the same `ROS_DOMAIN`.|
|`configuration_file_path`| The path to the `json` configuration file, see examples in the `config` folder.|
| `config_file` (launch argument) | Path to the YAML configuration file. Defaults to `config/config.yaml`; use `config_ethercat.yaml` for the EtherCAT hardware. |

## ROS 2 Nodes & Parameters

### Node: `sas_force_sensor_bota_node`

| Property | Value |
|---|---|
| **Executable** | `sas_force_sensor_bota_node` |
| **ROS node name** | `sas_force_sensor_bota_node` (set by the `name` launch argument of `force_sensor_launch.py`) |
| **Description** | Reads the Bota force/torque sensor, publishes the wrench on `<topic_name>/get/wrench`, and keeps the sensor configured/activated for the node lifetime. |

#### Parameters

| Parameter | Type | Mandatory / Optional | Default | Purpose |
|---|---|---|---|---|
| `topic_name` | string | Optional | `/sas_force_sensor_bota` | Topic prefix; e.g. when there are multiple sensors in the same `ROS_DOMAIN` |
| `configuration_file_path` | string | Optional | in-code default pointing at `config/bota_binary_gen0.json` in the package share directory | Path to the Bota JSON configuration file (hardware-specific). May be given as an absolute path or as a filename relative to the package `config/` directory (as in the sample YAML files) |
| `sampling_time` | double | Optional | `0.01` | Sampling period of the read loop, in seconds |

**How mandatory/optional is determined in code:**
- **Mandatory** params are declared without a default — the node fails if they are not provided.
- **Optional** params are declared with an in-code default.

#### Sample launch

```console
ros2 launch sas_force_sensor_bota force_sensor_launch.py
```

To use the EtherCAT JSON configuration (select the EtherCAT YAML, which
embeds `configuration_file_path: ethercat_gen0.json`):

```console
ros2 launch sas_force_sensor_bota force_sensor_launch.py config_file:=$(ros2 pkg prefix sas_force_sensor_bota --share)/config/config_ethercat.yaml
```

## Example client

Expand Down
13 changes: 13 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Parameters for the sas_force_sensor_bota node.
#
# Loaded by force_sensor_launch.py via its `config_file` argument. The
# hardware-specific `configuration_file_path` (a JSON file in this directory)
# is embedded here; use config_ethercat.yaml for the EtherCAT hardware.

# sas_force_sensor_bota_node
sas_force_sensor_bota_node:
ros__parameters:
topic_name: '/sas_force_sensor_bota'
# Relative to the package config/ directory; absolute paths are also accepted.
configuration_file_path: 'bota_binary_gen0.json'
sampling_time: 0.01 # 100 Hz
13 changes: 13 additions & 0 deletions config/config_ethercat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Parameters for the sas_force_sensor_bota node — EtherCAT hardware variant.
#
# Loaded by force_sensor_launch.py via its `config_file` argument
# (config_file:=.../config_ethercat.yaml). The only difference from
# config.yaml is the hardware-specific `configuration_file_path`.

# sas_force_sensor_bota_node
sas_force_sensor_bota_node:
ros__parameters:
topic_name: '/sas_force_sensor_bota'
# Relative to the package config/ directory; absolute paths are also accepted.
configuration_file_path: 'ethercat_gen0.json'
sampling_time: 0.01 # 100 Hz
2 changes: 1 addition & 1 deletion docker/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
cd /root/sas_force_sensor_bota_devel
&& colcon build
&& source install/setup.bash
&& timeout -s INT $$TIMEOUT ros2 launch sas_force_sensor_bota sas_force_sensor_bota_launch.py"
&& timeout -s INT $$TIMEOUT ros2 launch sas_force_sensor_bota force_sensor_launch.py"

sas_force_sensor_bota_client:
build:
Expand Down
2 changes: 1 addition & 1 deletion docker/compose_ethercat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
cd /root/sas_force_sensor_bota_devel
&& colcon build
&& source install/setup.bash
&& timeout -s INT $$TIMEOUT ros2 launch sas_force_sensor_bota sas_force_sensor_bota_launch.py configuration_file_path:=/root/sas_force_sensor_bota_devel/src/sas_force_sensor_bota/config/ethercat_gen0.json"
&& timeout -s INT $$TIMEOUT ros2 launch sas_force_sensor_bota force_sensor_launch.py config_file:=$$(ros2 pkg prefix sas_force_sensor_bota --share)/config/config_ethercat.yaml"

sas_force_sensor_bota_client:
build: .
Expand Down
2 changes: 1 addition & 1 deletion docker/demo/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
&& chmod +x install.sh
&& . install.sh
&& source /opt/ros/jazzy/setup.bash
&& timeout -s INT $$TIMEOUT ros2 launch sas_force_sensor_bota sas_force_sensor_bota_launch.py"
&& timeout -s INT $$TIMEOUT ros2 launch sas_force_sensor_bota force_sensor_launch.py"

sas_force_sensor_bota_client:
image: murilomarinho/sas:jazzy
Expand Down
39 changes: 39 additions & 0 deletions launch/force_sensor_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os.path

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description():
"""Launch the Bota force sensor node.

Parameters are loaded from a YAML configuration file. Pass a different
file with ``config_file:=/path/to/config.yaml`` (e.g.
``config_ethercat.yaml`` for the EtherCAT hardware). The
hardware-specific ``configuration_file_path`` (a JSON file in ``config/``)
is embedded in the YAML configuration file.
"""
name = LaunchConfiguration('name')
config_file = LaunchConfiguration('config_file')

return LaunchDescription([
DeclareLaunchArgument(
'name',
default_value='sas_force_sensor_bota_node'
),
DeclareLaunchArgument(
'config_file',
default_value=os.path.join(get_package_share_directory('sas_force_sensor_bota'), 'config', 'config.yaml')
),
Node(
package='sas_force_sensor_bota',
executable='sas_force_sensor_bota_node',
output='screen',
emulate_tty=True,
name=name,
parameters=[config_file]
)
])
38 changes: 0 additions & 38 deletions launch/sas_force_sensor_bota_launch.py

This file was deleted.

10 changes: 9 additions & 1 deletion sas_force_sensor_bota/force_sensor_bota.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
You should have received a copy of the GNU General Public License along with this program. If not,
see <https://www.gnu.org/licenses/>.
"""
import os.path
import pathlib
import bota_driver

Expand All @@ -26,11 +27,18 @@ def __init__(self):

this_package_share_directory = get_package_share_directory('sas_force_sensor_bota')
default_configuration_file_path = str(this_package_share_directory / pathlib.Path("config") / pathlib.Path(
"../config/bota_binary_gen0.json"))
"bota_binary_gen0.json"))

self.declare_parameter('configuration_file_path', default_configuration_file_path)
configuration_file_path = self.get_parameter('configuration_file_path').get_parameter_value().string_value

# A path relative to the package config/ directory (as in the sample
# YAML configurations) is resolved against that directory. Absolute
# paths are used as given.
if not os.path.isabs(configuration_file_path):
configuration_file_path = str(this_package_share_directory / pathlib.Path("config") / pathlib.Path(
configuration_file_path))

self.declare_parameter('sampling_time', 0.01)
sampling_time = self.get_parameter('sampling_time').get_parameter_value().double_value

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
(os.path.join('share', package_name, 'launch'), glob(os.path.join('launch', '*launch.[pxy][yma]*'))),
(os.path.join('share', package_name, 'config'), glob(os.path.join('config', '*.json')))
(os.path.join('share', package_name, 'config'), glob(os.path.join('config', '*.json'))),
(os.path.join('share', package_name, 'config'), glob(os.path.join('config', '*.yaml')))
],
install_requires=['setuptools'],
zip_safe=True,
Expand Down