Skip to content

Commit 46e9794

Browse files
Added a gravity compensation package, modified sleep positions (#225)
* added demo of gravity compensation on xsarm * added config and launch files for gravity compensation demo on xsarm * updated doc for gravity compensation * properly formatted * move the config doc to interbotix_gravity_compensation * use namespace in the launch file * fixed typo in the grav comp yaml files, pointed to the closer example config * two arms can run at the same time, added parameters for friction modelling * corrected some entries of the URDF for the aloha wx250s * updated the config file for more sophisticated friction compensation, updated the corresponding contents at the readme file, updated the URDF file for the aloha wx250s. TO DO: update the link to the documentation of the motor specs configuration. * fixed an incorrect doc link * changed the sleep positions so the arm doesn't drop as much The arms involved: aloha wx250s, aloha vx300s * updated README for the gravity compensation package - matched the node name with the one used in the code * Updated README.md for the interbotix_xsarm_gravity_compensation package added link to the doc page with a example motor specs configuration * Minor fixes on gravity compensation readme - used the Github provided warning block - added empty lines after headers mode configs - changed the port setting to the default /dev/ttyDXL - merged the two mode configs file launch - limited choices to wx250s and aloha_wx250s - improved readability for path concatenations package.xml - added dependency for interbotix_xsarm_control * Minor fixes on the gravity compensation package - change file path concatenation style for better readability * Minor fixes on the gravity compensation demo package mode_configs.yaml - removed launch script - removed unused mode configs argument - removed unused get_interbotix_xsarm_models import readme - updated the description about the launch script arguments - updated the dummy namespace to match the launch script logic: we used the robot name as the namespace
1 parent 3eecabf commit 46e9794

File tree

9 files changed

+424
-66
lines changed

9 files changed

+424
-66
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(interbotix_xsarm_gravity_compensation)
3+
4+
if(NOT CMAKE_CXX_STANDARD)
5+
set(CMAKE_CXX_STANDARD 14)
6+
endif()
7+
8+
if(CMAKE_COMPILER_IS_GNUXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
9+
add_compile_options(-Wall -Wextra -Wpedantic)
10+
endif()
11+
12+
find_package(ament_cmake REQUIRED)
13+
14+
install(
15+
DIRECTORY
16+
config
17+
launch
18+
DESTINATION
19+
share/${PROJECT_NAME}
20+
)
21+
22+
if(BUILD_TESTING)
23+
find_package(ament_lint_auto REQUIRED)
24+
ament_lint_auto_find_test_dependencies()
25+
endif()
26+
27+
ament_package()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# interbotix_xsarm_gravity_compensation
2+
3+
## Overview
4+
5+
This package demos the interbotix_gravity_compensation package on an Interbotix arm.
6+
As of now, the supported arms include: WidowX-250 6DOF and ALOHA WidowX-250 6DOF.
7+
8+
## Configuration
9+
10+
Please refer to the documentations for [`mode_configs`](https://docs.trossenrobotics.com/interbotix_xsarms_docs/ros_interface/ros2/config.html#mode-configs) and [`motor_specs`](https://docs.trossenrobotics.com/interbotix_xsarms_docs/ros2_packages/gravity_compensation.html#configuration) for details.
11+
12+
## Usage
13+
14+
Run the following launch command where `robot_model` is a mandatory choice between `aloha_wx250s` and `wx250s`, `robot_name` defaults to be the same as `robot_model` but can be anything, and `motor_specs` defaults to `<path_to_this_package>/config/motor_specs_<robot_model>.yaml`:
15+
```
16+
ros2 launch interbotix_xsarm_gravity_compensation interbotix_gravity_compensation.launch.py robot_model:=xxx [robot_name:=xxx] [motor_specs:=xxx]
17+
```
18+
It runs the `gravity_compensation` node and launches the xsarm_control script to bring up the arm.
19+
20+
Then, enable/disable the gravity compensation with the following service call:
21+
```
22+
ros2 service call /<robot_name>/gravity_compensation_enable std_srvs/srv/SetBool 'data: [true/false]'
23+
```
24+
25+
The arm will hold itself against gravity and can be moved freely when the gravity compensation is enabled.
26+
It will lock in its current position when the gravity compensation is disabled.
27+
28+
29+
> [!WARNING]
30+
> WARNING: the arm WILL torque off and drop for a short period of time while enabling/disabling. Please make sure it is in a resting position or manually held.
31+
32+
> [!WARNING]
33+
> WARNING: the joints not supporting current control WILL torque off. Please make sure to use arm with at least the first three joints supporting current control, e.g., RX, WX, VX series.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Motor Assist: scale the no-load currents which alleviate the effects of friction
2+
# If the values are invalid, they default to 0
3+
# Joints not specified in the motor_assist or motor_specs sections
4+
# do not support the current control mode
5+
motor_assist:
6+
# Set 'all' to [0, 1] to scale the no load currents of all joints uniformly
7+
# Or to -1 and use joint specific values
8+
all: -1
9+
# Set the joint specific values to [0, 1] to scale differently for each joint
10+
waist: 0.5
11+
shoulder: 0.5
12+
elbow: 0.5
13+
forearm_roll: 0.5
14+
wrist_angle: 0.5
15+
wrist_rotate: 0.5
16+
17+
# Dither: add a oscillatory motion proportional to the load to break static friction
18+
# It is helpful when slow and smooth movements are needed
19+
# WARNING: excessive dithering WILL cause heat and wear on the joints
20+
dither: false
21+
22+
motor_specs:
23+
waist:
24+
# torque constant (Nm/A): how much torque is produced per Amp of current
25+
torque_constant: 1.793
26+
# current unit (A): how much current command is needed to produce 1 Amp of current
27+
current_unit: 0.00269
28+
# no load current (A): the maximum no load current applied when motor_assist == 1
29+
# should be as large as possible without the joint accelerating by itself
30+
no_load_current: 0.0
31+
# kinetic friction (Nm/Nm): the kinetic friction coefficient
32+
# should be tuned so that the friction is uniform over the entire joint range
33+
kinetic_friction_coefficient: 0.0
34+
# static friction coefficient (Nm/Nm): the static friction coefficient
35+
# affects the amplitude of the dithering motion
36+
static_friction_coefficient: 0.0
37+
# dither speed (rad/s): the speed under which the joint dithers
38+
dither_speed: 0.0
39+
40+
shoulder:
41+
torque_constant: 1.793
42+
current_unit: 0.00269
43+
no_load_current: 0.0
44+
kinetic_friction_coefficient: 0.1
45+
static_friction_coefficient: 0.4
46+
dither_speed: 0.5
47+
48+
elbow:
49+
torque_constant: 1.793
50+
current_unit: 0.00269
51+
no_load_current: 0.0
52+
kinetic_friction_coefficient: 0.1
53+
static_friction_coefficient: 0.6
54+
dither_speed: 0.5
55+
56+
forearm_roll:
57+
torque_constant: 0.897
58+
current_unit: 0.00269
59+
no_load_current: 0.2
60+
kinetic_friction_coefficient: 0.0
61+
static_friction_coefficient: 0.0
62+
dither_speed: 0.0
63+
64+
wrist_angle:
65+
torque_constant: 0.897
66+
current_unit: 0.00269
67+
no_load_current: 0.1
68+
kinetic_friction_coefficient: 0.1
69+
static_friction_coefficient: 0.4
70+
dither_speed: 0.5
71+
72+
wrist_rotate:
73+
torque_constant: 0.897
74+
current_unit: 0.00269
75+
no_load_current: 0.2
76+
kinetic_friction_coefficient: 0.0
77+
static_friction_coefficient: 0.0
78+
dither_speed: 0.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Please refer to the motor_specs_aloha_wx250s.yaml file
2+
# for a detailed explanation of the parameters
3+
motor_assist:
4+
all: -1
5+
waist: 0.5
6+
shoulder: 0.5
7+
elbow: 0.5
8+
forearm_roll: 0.5
9+
wrist_angle: 0.5
10+
11+
dither: false
12+
13+
motor_specs:
14+
waist:
15+
torque_constant: 1.793
16+
current_unit: 0.00269
17+
no_load_current: 0.1
18+
kinetic_friction_coefficient: 0.0
19+
static_friction_coefficient: 0.0
20+
dither_speed: 0.0
21+
22+
shoulder:
23+
torque_constant: 1.793
24+
current_unit: 0.00269
25+
no_load_current: 0.0
26+
kinetic_friction_coefficient: 0.0
27+
static_friction_coefficient: 0.0
28+
dither_speed: 0.0
29+
30+
elbow:
31+
torque_constant: 1.793
32+
current_unit: 0.00269
33+
no_load_current: 0.0
34+
kinetic_friction_coefficient: 0.0
35+
static_friction_coefficient: 0.0
36+
dither_speed: 0.0
37+
38+
forearm_roll:
39+
torque_constant: 0.897
40+
current_unit: 0.00269
41+
no_load_current: 0.1
42+
kinetic_friction_coefficient: 0.0
43+
static_friction_coefficient: 0.0
44+
dither_speed: 0.0
45+
46+
wrist_angle:
47+
torque_constant: 0.897
48+
current_unit: 0.00269
49+
no_load_current: 0.0
50+
kinetic_friction_coefficient: 0.0
51+
static_friction_coefficient: 0.0
52+
dither_speed: 0.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright 2024 Trossen Robotics
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are met:
7+
#
8+
# * Redistributions of source code must retain the above copyright
9+
# notice, this list of conditions and the following disclaimer.
10+
#
11+
# * Redistributions in binary form must reproduce the above copyright
12+
# notice, this list of conditions and the following disclaimer in the
13+
# documentation and/or other materials provided with the distribution.
14+
#
15+
# * Neither the name of the copyright holder nor the names of its
16+
# contributors may be used to endorse or promote products derived from
17+
# this software without specific prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29+
# POSSIBILITY OF SUCH DAMAGE.
30+
31+
from typing import List
32+
33+
from launch import LaunchDescription
34+
from launch.actions import (
35+
IncludeLaunchDescription,
36+
DeclareLaunchArgument,
37+
OpaqueFunction
38+
)
39+
from launch.launch_description_sources import PythonLaunchDescriptionSource
40+
from launch.substitutions import (
41+
LaunchConfiguration,
42+
PathJoinSubstitution,
43+
)
44+
from launch_ros.actions import Node
45+
from launch_ros.substitutions import FindPackageShare
46+
47+
48+
def launch_setup(context, *args, **kwargs):
49+
# Define the launch arguments
50+
robot_model_launch_arg = LaunchConfiguration('robot_model')
51+
robot_name_launch_arg = LaunchConfiguration('robot_name')
52+
motor_specs_launch_arg = LaunchConfiguration('motor_specs')
53+
54+
# Create the gravity compensation node
55+
gravity_compensation_node = Node(
56+
package='interbotix_gravity_compensation',
57+
executable='interbotix_gravity_compensation',
58+
name='gravity_compensation',
59+
namespace=robot_name_launch_arg,
60+
output='screen',
61+
emulate_tty=True,
62+
parameters=[{'motor_specs': motor_specs_launch_arg}]
63+
)
64+
65+
# include the xsarm_control_launch with arguments
66+
xsarm_control_launch = IncludeLaunchDescription(
67+
PythonLaunchDescriptionSource([
68+
PathJoinSubstitution([
69+
FindPackageShare('interbotix_xsarm_control'),
70+
'launch',
71+
'xsarm_control.launch.py'
72+
])
73+
]),
74+
launch_arguments={
75+
'robot_model': robot_model_launch_arg,
76+
'robot_name': robot_name_launch_arg,
77+
}.items()
78+
)
79+
80+
return [gravity_compensation_node, xsarm_control_launch]
81+
82+
83+
def generate_launch_description():
84+
# Create a list of all the launch arguments
85+
declared_arguments: List[DeclareLaunchArgument] = []
86+
declared_arguments.append(
87+
DeclareLaunchArgument(
88+
'robot_model',
89+
choices=('wx250s', 'aloha_wx250s'),
90+
description='model type of the Interbotix Arm such as `wx200` or `rx150`.'
91+
)
92+
)
93+
declared_arguments.append(
94+
DeclareLaunchArgument(
95+
'robot_name',
96+
default_value=LaunchConfiguration('robot_model'),
97+
description=(
98+
'name of the robot (typically equal to `robot_model`, but could be anything).'
99+
),
100+
)
101+
)
102+
declared_arguments.append(
103+
DeclareLaunchArgument(
104+
'motor_specs',
105+
default_value=[PathJoinSubstitution([
106+
FindPackageShare('interbotix_xsarm_gravity_compensation'),
107+
'config',
108+
"motor_specs_"]), LaunchConfiguration('robot_model'), '.yaml'
109+
],
110+
description="the file path to the 'motor specs' YAML file.",
111+
)
112+
)
113+
return LaunchDescription(declared_arguments + [OpaqueFunction(function=launch_setup)])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>interbotix_xsarm_gravity_compensation</name>
5+
<version>0.0.0</version>
6+
<description>The demo of the interbotix_gravity_compensation package on xsarm</description>
7+
<maintainer email="[email protected]">Luke Schmitt</maintainer>
8+
<license>BSD-3-Clause</license>
9+
<author email="[email protected]">Shiming Liang</author>
10+
11+
<buildtool_depend>ament_cmake</buildtool_depend>
12+
<depend>interbotix_gravity_compensation</depend>
13+
<depend>interbotix_xsarm_control</depend>
14+
15+
<test_depend>ament_lint_auto</test_depend>
16+
<test_depend>ament_lint_common</test_depend>
17+
18+
<export>
19+
<build_type>ament_cmake</build_type>
20+
</export>
21+
</package>

interbotix_ros_xsarms/interbotix_xsarm_control/config/aloha_vx300s.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
joint_order: [waist, shoulder, elbow, forearm_roll, wrist_angle, wrist_rotate, gripper]
2-
sleep_positions: [0, -1.80, 1.55, 0, -1.57, 0, 0]
2+
sleep_positions: [0, -2.05, 1.7, 0, -2.0, 0, 0]
33

44
joint_state_publisher:
55
update_rate: 100

interbotix_ros_xsarms/interbotix_xsarm_control/config/aloha_wx250s.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
joint_order: [waist, shoulder, elbow, forearm_roll, wrist_angle, wrist_rotate, gripper]
2-
sleep_positions: [0, -1.80, 1.55, 0, -1.57, 0, 0]
2+
sleep_positions: [0, -1.88, 1.6, 0, -1.6, 0, 0]
33

44
joint_state_publisher:
55
update_rate: 100

0 commit comments

Comments
 (0)