Skip to content

Commit 259505d

Browse files
ADD ISAAC SIM package
1 parent b3fadc1 commit 259505d

27 files changed

+295
-11
lines changed

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,27 @@ These packages are tested on ROS2 Humble(Ubuntu 22.04). It will likely not work
3030
- allegro_hand_driver : Main driver for sending and receiving data with the Allegro Hand.
3131
- CANAPI : Drivers for CAN communication.
3232
- rs485 : Drivers for RS-485 communication.
33+
- allegro_hand_isaacsim : Node that receives position datas from ISAAC SIM, sorts them in correct order and resends the datas to REAL Allegro Hand.
3334
- allegro_hand_keyboard : Node that sends the command to control Allegro Hand. All commands need to be pre-defined.
3435
- allegro_hand_moveit : Provide MOVEIT2 package for Allegro Hand V5-3Finger.
3536
- allegro_hand_gui : Node that control the allegro hand with gui program.
3637
- bhand : Library files for the predefined grasps and actions., available on 64 bit versions.
38+
-**Default: x86-64-bit.** If using a **ARM64**, update the symlink accordingly from [here](https://github.com/Wonikrobotics-git/Bhandlib_ARM).
39+
40+
## Topic description
41+
42+
- Control
43+
- /allegroHand_(NUM)/lib_cmd : Hand command.
44+
- /allegroHand_(NUM)/joint_cmd : Desired hand joint positions and control REAL Allegro Hand.
45+
- /allegroHand_(NUM)/force_chg : Change grasp force of grasping algrotihm(grasp_3).
46+
- /allegroHand_(NUM)/time_chg : Change time of moving target positions of each joints.
47+
- /allegroHand_(NUM)/envelop_torque : Change torque of envelop command.
48+
- Joint States
49+
- /allegroHand_(NUM)/joint_states : REAL Allegro Hand current joint positions.
50+
- /allegroHand_sim/joint_states : ISAAC SIM Allegro Hand current joint positions.
51+
- Sensors
52+
- /allegroHand_(NUM)/tactile_sensors : REAL tactile sensors data { Finger1 , Finger2 , Finger3 }.
53+
- /allegroHand_sim/contact_sensors : ISAAC SIM contact sensors data { Finger1 , Finger2 , Finger3 }.
3754

3855
## Install the PCAN driver
3956

@@ -63,9 +80,6 @@ mkdir allegro_ws
6380
sudo apt-get update
6481
sudo apt-get install ros-<distro>-xacro
6582
sudo apt install ros-humble-moveit
66-
sudo apt install ros-<distro>-controller-manager
67-
sudo apt install ros-<distro>-joint-state-broadcaster
68-
sudo apt install ros-<distro>-joint-trajectory-controller
6983
~~~
7084

7185
3. Download ROS2 package for Allegro Hand V5 using below command.
@@ -113,6 +127,7 @@ VISUALIZE:=true|false (default is false)
113127
MOVEIT:=true|false (default is false)
114128
GUI:=true|false (default is false)
115129
RS485:=true|false (default is false)
130+
ISAAC:=true|false (default is false)
116131
~~~
117132

118133
- If you want to visualize Allegro Hand on Rviz2:
@@ -133,7 +148,12 @@ ros2 launch allegro_hand_controllers allegro_hand.launch.py GUI:=true
133148
- If you want to control Allegro Hand through RS-485:
134149
~~~bash
135150
ros2 launch allegro_hand_controllers allegro_hand.launch.py RS485:=true
136-
~~~
151+
~~~
152+
153+
- If you want to use Allegro Hand with ISAAC SIM SIM2REAL:
154+
~~~bash
155+
ros2 launch allegro_hand_controllers allegro_hand.launch.py ISAAC:=true
156+
~~~
137157

138158
## Control more than one hand
139159

@@ -195,6 +215,14 @@ ros2 run allegro_hand_keyboards allegro_hand_keyboard --ros-args allegroHand_0/l
195215
~~~
196216

197217
**These are example commands.You may need to change CAN_DEVICE, PORT and NUM arguments accroding to your system.**
218+
219+
## ISAACSIM
220+
221+
We now introuce two features —REAL2SIM and SIM2REAL—that integrate the Allegro Hand V5 with Isaac Sim.
222+
223+
Please refer to the following guide for detailed information : [allegro_hand_isaacsim](https://github.com/Wonikrobotics-git/private_allegro_ros2_v5/tree/main/3finger/src/allegro_hand_isaacsim)
224+
225+
198226
## MOVEIT2
199227

200228
Please refer to the ROS1 manual for guidance.
@@ -207,3 +235,4 @@ You can find installation guide in here : [MOVEIT2](https://moveit.picknik.ai/ma
207235

208236
These newly added feature function identically to their ROS1 counterparts. Please refer to the ROS1 manual for guidance.
209237
Our latest Allegro Hand V5 ROS1 package : [ROS1](https://github.com/Wonikrobotics-git/allegro_hand_ros_v5-3Finger)
238+

src/allegro_hand_controllers/launch/allegro_hand.launch.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ def generate_launch_description():
3030
description='Flag to enable/disable GUI'
3131
)
3232

33+
declare_sim_arg = DeclareLaunchArgument(
34+
'ISAAC',
35+
default_value='false',
36+
description='Flag to enable/disable ISAAC SIM2REAL'
37+
)
38+
3339
declare_polling_arg = DeclareLaunchArgument(
3440
'POLLING',
3541
default_value='true',
@@ -96,10 +102,11 @@ def setup_can(context):
96102
declare_polling_arg,
97103
declare_can_device_arg,
98104
declare_num_arg,
99-
declare_moveit_arg,
100-
declare_gui_arg,
101-
declare_rs485_arg,
102-
declare_port_arg,
105+
declare_moveit_arg,
106+
declare_gui_arg,
107+
declare_rs485_arg,
108+
declare_port_arg,
109+
declare_sim_arg,
103110
OpaqueFunction(function=setup_can,
104111
condition=UnlessCondition(LaunchConfiguration('RS485'))),
105112
Node(
@@ -128,7 +135,8 @@ def setup_can(context):
128135
),
129136
Node(
130137
package='robot_state_publisher',
131-
output='screen',
138+
output='log',
139+
arguments=['--ros-args', '--log-level', 'WARN'],
132140
executable='robot_state_publisher',
133141
parameters=[{'robot_description': Command(['xacro ', urdf_path])}],
134142
remappings=[
@@ -156,6 +164,13 @@ def setup_can(context):
156164
('forcechange',PythonExpression(["'allegroHand_",LaunchConfiguration('NUM'),"/force_chg'"])),
157165
('timechange',PythonExpression(["'allegroHand_",LaunchConfiguration('NUM'),"/time_chg'"]))],
158166
condition=IfCondition(LaunchConfiguration('GUI'))
167+
),
168+
Node(
169+
package='allegro_hand_isaacsim',
170+
executable='allegro_hand_sim2real',
171+
output='screen',
172+
remappings=[('allegroHand/joint_cmd',PythonExpression(["'allegroHand_",LaunchConfiguration('NUM'),"/joint_cmd'"]))],
173+
condition=IfCondition(LaunchConfiguration('ISAAC'))
159174
)
160175

161176
])

src/allegro_hand_controllers/src/allegro_node.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ AllegroNode::AllegroNode(const std::string nodeName, bool sim /* = false */)
5858
// Advertise current joint state publisher and subscribe to desired joint
5959
// states.
6060
joint_state_pub = this->create_publisher<sensor_msgs::msg::JointState>(JOINT_STATE_TOPIC, 3);
61+
tactile_sensor_pub = this->create_publisher<std_msgs::msg::Int32MultiArray>(TACTILE_SENSOR_TOPIC, 10);
62+
6163
joint_cmd_sub = this->create_subscription<sensor_msgs::msg::JointState>(DESIRED_STATE_TOPIC, 1, // queue size
6264
std::bind(&AllegroNode::desiredStateCallback, this, std::placeholders::_1));
6365
time_sub = this->create_subscription<std_msgs::msg::Float32>("timechange", 1, // queue size
@@ -98,6 +100,8 @@ void AllegroNode::publishData() {
98100
current_joint_state.velocity[i] = current_velocity[i];
99101
current_joint_state.effort[i] = desired_torque[i];
100102
}
103+
tactile_sensor.data = std::vector<int>(std::begin(fingertip_sensor), std::end(fingertip_sensor));
104+
tactile_sensor_pub->publish(tactile_sensor);
101105
joint_state_pub->publish(current_joint_state);
102106
}
103107

@@ -128,6 +132,13 @@ void AllegroNode::updateController() {
128132
// update joint positions:
129133
canDevice->getJointInfo(current_position);
130134

135+
for(int i =0; i<9; i++){
136+
if(current_position[i] < -3.14)
137+
current_position[i] += 3.14;
138+
if(current_position[i] > 3.14)
139+
current_position[i] -= 3.14;
140+
}
141+
131142
OperatingMode = 0;
132143

133144
if (OperatingMode == 0) {
@@ -137,7 +148,7 @@ void AllegroNode::updateController() {
137148
f[0] = f[1] = f[2] = 5.0f;
138149
}
139150

140-
151+
// std::cout << current_position[1]*180/3.141592 <<" "<< current_position[4]*180/3.141592<<" "<<current_position[7]*180/3.141592<<" "<<std::endl;
141152
// calculate control torque:
142153
computeDesiredTorque();
143154

src/allegro_hand_controllers/src/allegro_node.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ using namespace allegro;
1515

1616
#include "sensor_msgs/msg/joint_state.hpp"
1717
#include "std_msgs/msg/string.hpp"
18-
#include "std_msgs/msg/u_int8_multi_array.hpp"
18+
#include "std_msgs/msg/int32_multi_array.hpp"
1919
#include "bhand/BHand.h"
2020
#include <std_msgs/msg/float32.hpp>
21+
#include <vector>
2122

2223
// Forward declaration.
2324
class AllegroHandDrv;
@@ -28,6 +29,7 @@ class AllegroHandDrv;
2829
const std::string JOINT_STATE_TOPIC = "allegroHand/joint_states";
2930
const std::string DESIRED_STATE_TOPIC = "allegroHand/joint_cmd";
3031
const std::string LIB_CMD_TOPIC = "allegroHand/lib_cmd";
32+
const std::string TACTILE_SENSOR_TOPIC = "allegroHand/tactile_sensors";
3133

3234
class AllegroNode: public rclcpp::Node {
3335
public:
@@ -77,6 +79,7 @@ class AllegroNode: public rclcpp::Node {
7779

7880
// ROS stuff
7981
rclcpp::Publisher<sensor_msgs::msg::JointState>::SharedPtr joint_state_pub;
82+
rclcpp::Publisher<std_msgs::msg::Int32MultiArray>::SharedPtr tactile_sensor_pub;
8083
rclcpp::Time t_last_pub;
8184
rclcpp::Subscription<sensor_msgs::msg::JointState>::SharedPtr joint_cmd_sub;
8285
rclcpp::Subscription<std_msgs::msg::Float32>::SharedPtr time_sub;
@@ -87,6 +90,8 @@ class AllegroNode: public rclcpp::Node {
8790
sensor_msgs::msg::JointState current_joint_state;
8891
sensor_msgs::msg::JointState desired_joint_state;
8992

93+
std_msgs::msg::Int32MultiArray tactile_sensor;
94+
9095
// ROS Time
9196
rclcpp::Time tstart;
9297
rclcpp::Time tnow;
1.58 KB
Binary file not shown.
16.3 MB
Binary file not shown.
4.78 KB
Binary file not shown.
652 Bytes
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
project(allegro_hand_isaacsim)
3+
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
4+
# Default to C++14
5+
if(NOT CMAKE_CXX_STANDARD)
6+
set(CMAKE_CXX_STANDARD 14)
7+
endif()
8+
9+
# find dependencies
10+
find_package(ament_cmake REQUIRED)
11+
find_package(rclcpp REQUIRED)
12+
find_package(sensor_msgs REQUIRED)
13+
14+
15+
add_executable(allegro_hand_sim2real src/sim2real.cpp)
16+
17+
ament_target_dependencies(allegro_hand_sim2real
18+
rclcpp
19+
sensor_msgs
20+
)
21+
22+
install(TARGETS
23+
allegro_hand_sim2real
24+
DESTINATION lib/${PROJECT_NAME}
25+
)
26+
27+
ament_package()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# allegro_hand_isaacsim_package
2+
3+
4+
5+
# Setup
6+
7+
## REAL2SIM
8+
9+
|**Instruction**|**Figure**|
10+
|----------------------------------------------|----------------------|
11+
| 1. Launch Isaac Sim & Check Extenstions(ROS2 Bridge) | <img width="100%" height="100%" src="./asset/Check_extensions.png"> |
12+
| 2. Open AH_V5(3F)_REAL2SIM.usd file & Select ‘Yes’ on the warning message. | <img width="100%" height="100%" src="./asset/REAL2SIM_warning.png"> |
13+
| 3. Check Action Graph : <br> - **ROS Subscriber** <br> topic name : allegroHand_0/joint_states <br> - **Articulation Controller** <br> target prim : /World/allegro_hand | <img width="100%" height="100%" src="./asset/ROS_subscribe_joint_states.png"> |
14+
| 4. Launch Allegro Hand V5 controller node |``` ros2 launch allegro_hand_controllers allegro_hand.launch.py ``` |
15+
| 5. Press Play Button &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| <img width="100%" height="100%" src="./asset/REAL2SIM_play_3F.png">|
16+
17+
18+
## SIM2REAL
19+
20+
|**Instruction**|**Figure**|
21+
|------------------------|----------------------|
22+
| 1. Launch Isaac Sim & Check Extenstions(ROS2 Bridge) | <img width="100%" height="100%" src="./asset/Check_extensions.png"> |
23+
| 2. Open AH_V5(3F)_SIM2REAL.usd file| <img width="100%" height="100%" src="./asset/SIM2REAL.png"> |
24+
| 3. Check Action Graph : <br> - **ROS Publisher(Joint states)** <br> topic name : allegroHand_sim/joint_states <br> targetPrim : /World/allegro_hand/root_joint <br> - **ROS Publisher(Contact sensor)** <br> topic name : allegroHand_sim/contact_sensors <br> - **Articulation Controller** <br> target prim : /World/allegro_hand/root_joint | <img width="100%" height="100%" src="./asset/SIM2REAL_actiongraph.png"> |
25+
| 4. Launch Allegro Hand V5 controller node with Isaac arguments | ``` ros2 launch allegro_hand_controllers allegro_hand.launch.py ISAAC:=true ``` |
26+
| 5. Press Play Button & Control the hand joint changing joint_positions_array of ActionGraph| <img width="100%" height="100%" src="./asset/SIM2REAL_play_3F.png"> |
27+

0 commit comments

Comments
 (0)