This repo contains the second practice lab for robotics class at Universidad Nacional de Colombia
- ROS Noetic
- Dynamixel workbench controllers package (
sudo apt install ros-noetic-dynamixel-workbench
) - ROS toolbox for MATLAB
- Pynput library for python (
pip install pynput
orpip3 install pynput
) - PincherX 100 Robot arm
In order to create a new package, we used the next command (in the workspace folder):
catkin create pkg px100_description -m "Cristian Chitiva" "[email protected]" -m "Brayan Estupinan" "[email protected]" -l "MIT" --catkin-deps rospy dynamixel_workbench_controllers
The dependencies of this package are:
- rospy
- dynamixel_workbench_controllers
To run the container, first we need to build the image:
docker build -t px100:latest .
Then, we can run the container with the next commands:
xhost + # Allow connections from any host
docker run -it \
--rm \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
-v $PWD:/root/catkin_ws/src/px100_description \
--name px100 \
px100:latest
In order to connect the USB devices from Windows to WSL, it is necessary to install USBIP in both systems. The steps to follow are:
-
Install USBIP in Windows:
winget install --interactive --exact dorssel.usbipd-win
-
Install USBIP tools in WSL:
sudo apt install linux-tools-generic hwdata sudo update-alternatives --install /usr/local/bin/usbip usbip /usr/lib/linux-tools/*-generic/usbip 20
-
Attach the USB device to the USBIP server:
usbip wsl list usbip bind --busid <busid>
Note: Run the commands in PowerShell as administrator.
-
lsusb
should show the device connected to the USBIP server.
To properly move the robot, a model was first created taking into account the measurements made with a vernier caliper.
where the measurements are:
$L_1=44.5~mm$ $L_2=101~mm$ $L_3=101~mm$ $L_4=109~mm$ $L_m=31.5~mm$
Note:
$L_r=\sqrt{L_m^2+L_2^2}$
Based on the dynamixel workbench packages in ROS, we created a Python script that calls the dynamixel_command service to move each of the manipulator's joints (waist, shoulder, elbow, wrist). This movement is done between two characteristic positions (home and goal) and can be switched using the following keys:
- w: Select next joint (if are selected the waist, pass to the shoulder)
- s: Select previous joint (if are selected the gripper, pass to the wrist)
- a: Go the selected joint to home position.
- d: Go the selected joint to goal position.
Note: The change between joints is cyclic, so if you select the gripper, the next joint will be the waist and vice versa.
The code used to move the manipulator uses the pynput library to detect the keys pressed, and the dynamixel_command service to send commands to dynamixel motors. The code is available in this file.
In order to visualize the robot in RViz, we created a URDF file. This file contains the information on how the links and joints of the robot are connected, in addition to the CAD models1 for a closer view of reality. The structure to create a urdf can be seen in the following image2:
Finally, the robot model in RViz is:
To display the joints and links correctly in RViz, it is necessary to run the nodes that publish the robot and joint states (and RViz node). These nodes must be run every time you want to check the package and it becomes tedious, so you create a launch file that runs the dynamixel packages and Rviz.
This package has two launch files, the first file to run RViz with a joint state publisher gui. And the second file runs Rviz but the python file is used to move the joints.
The first launch file can be executed with the following command:
roslaunch px100_description visualize.launch
and the second launch file with the following command:
roslaunch px100_description px100.launch run_dynamixel:=true
Note: The second launch file can receive an argument to run or not the dynamixel_workbench packages, which is responsible for publishing the joint states by making a remap of the /dynamixel_workbench/joint_states to /joint_states topic.
To use the python node in launch with rviz, you need to run the following command:
rosnode kill /joint_state_publisher_gui
rosrun px100_description key_control.py True
The files to setup the parameter needed to run the dynamixel_workbench package are in the configuration folder.
In the urdf we add the cad model of the gripper fingers, along with its respective prismatic joints and the mimic attribute to establish a relationship between the movement of the last motor (joint 4) and the movement of the gripper.
To create the robot in Peter Corke's toolbox for MATLAB, we use the SerialLink object and the DH parameter table.
In order to display the noa
frame, we use the tool property in the SerialLink object. Other configurations of the robot are shown in the following image:
- $\begin{bmatrix}\pi/6&\pi/3&-\pi&3\pi/4\end{bmatrix}$
- $\begin{bmatrix}\pi/3&\pi/6&\pi/7&3\pi/7\end{bmatrix}$
- $\begin{bmatrix}-\pi/6&\pi/5&\pi/4&\pi\end{bmatrix}$
- $\begin{bmatrix}\pi&\pi/9&-\pi/2&-3\pi/4\end{bmatrix}$
The development of this code is in px file.
To establish the MATLAB connection with the dynamixel package, the tutorial described at this repo was used. To send each joint position, we create a ROS client and the position and id of each motor is sent with a message.
Finally, the connection with MATLAB, ROS and python is shown in the following video:
My.Video.mp4
Footnotes
-
PincherX 100 Robot Arm - X-Series Robotic Arm.. ↩