This repo currently contains the ros packages and arduino scripts needed to enable teleoperation of the hand via gamepad and hand (finger joint) simulation in rviz.
- Make a new workspace: underactuated_ws
- Clone this repo into the src folder of your workspace
- Build the packages by running:
catkin_make
Build the necessary Arduino libraries:
- Run
source ~/underactuated_ws/devel/setup.bash
- Run
rosrun rosserial_arduino make_libraries.py "location of your Arduino libraries folder"
- This should generate a
ros_lib
folder that contains the necessary libraries to compile and upload the arduino script
Note: You must delete ros_lib
if it already exists or the command will not generate the new libraries
- Upload
underactuated_teleoperated_control_daisychain.ino
to the Teensy - Run
roslaunch hand_rviz teleop_sim.launch
to enable teleoperation and open rviz - Run
rosrun hand_rviz underactuated_hand_sim.py
to enable live simulation in rviz
Remember to source your catkin workspace for each unique terminal with source ~/underactuated_ws/devel/setup.bash
- Make sure joy package is installed by running
sudo apt-get install ros-<your_ros_version>-joy
- Upload
underactuated_teleoperated_control_daisychain.ino
to the Teensy - Plug in usb receiver for gamepad
- Run
roslaunch hand_arduino hand.launch
to connect Teensy to rosserial and to start thejoy_node
- In a new terminal run
rosrun hand_arduino hand_teleop.py
You should now be able to control the hand with the gamepad.
Controls:
- Right bumper (RB): grasps hand
- Left bumper (LB): ungrasps hand
- B button: spreads fingers
- X button: unspreads fingers
Note: if you get an error IndexError: tuple index out of range
, (or the hand is not responding to the controller) that means ros is recongizing another controller as joy input. See Configuring and Using a Linux-Supported Joystick with ROS to determine the name of the controller. Once you have determined which jsX is the correct one, you can edit it in line 6 of hand.launch:
<param name="dev" value="/dev/input/jsX" />
(replace X with the number you have just identified)
Remember to source your catkin workspace for each unique terminal with source ~/underactuated_ws/devel/setup.bash
- Install joint state publisher GUI by running
sudo apt install ros-<your_ros_version>-joint-state-publisher-gui
- Run
roslaunch hand_rviz display.launch
- This will open rviz with the URDF of the hand and joint_state_publisher_gui to see how each joint is being actuated
- The previous launch file for teleoperaton aleady enables rosserial connection, so it is not needed again
- Run
rosrun hand_rviz underactuated_hand_sim.py
to start hand simulation script. After confirming the hand is fully opened, rviz should accurately simulate the joint positions of each finger.
- This terminal will show the values of the potentiometers and the roll motor that are being sent to rviz.
- Go to bagfiles directory with
cd ~/underactuated_ws/bagfiles/
- Run
rosbag record -O file_name /pot_pub /joint_states_command /joint_states /joy /force_torque_sensor
to begin recording. All published messages will be recorded. Ctrc^C to stop. - Run
rosbag play file_name
to play back the recording. Note: must stophand_teleop.py
andunderactuated_hand_sim.py
before playback or movements will be janky.
Tips:
- Make sure you have all the other necessary Arduino libraries installed.
- Make sure the correct Teensy port is defined in the launch file (can be confirmed from Arduino IDE)