cychitivav / px100_description

ROS package to move the pincher x100 robot with python or MATLAB. This repo contains the second practice lab for robotics class at Universidad Nacional de Colombia

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PincherX 100 description

This repo contains the second practice lab for robotics class at Universidad Nacional de Colombia

Requirements

  • ROS Noetic
  • Dynamixel workbench controllers package (sudo apt install ros-noetic-dynamixel-workbench)
  • ROS toolbox for MATLAB
  • Pynput library for python (pip install pynput or pip3 install pynput)
  • PincherX 100 Robot arm

Package creation

In order to create a new package, we used the next command (in the workspace folder):

catkin create pkg px100_description -m "Cristian Chitiva" "cychitivav@unal.edu.co" -m "Brayan Estupinan" "blestupinanp@unal.edu.co" -l "MIT" --catkin-deps rospy dynamixel_workbench_controllers 

The dependencies of this package are:

  • rospy
  • dynamixel_workbench_controllers

Docker

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

From WSL2

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:

  1. Install USBIP in Windows:

    winget install --interactive --exact dorssel.usbipd-win
  2. 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
  3. Attach the USB device to the USBIP server:

    usbip wsl list
    usbip bind --busid <busid>

    Note: Run the commands in PowerShell as administrator.

  4. lsusb should show the device connected to the USBIP server.

Robot description

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$

Denavit-Hartenberg standard parameters

$\mathbf{i}$ $\mathbf{\theta_i}$ $\mathbf{d_i}$ $\mathbf{a_i}$ $\mathbf{\alpha_i}$
$1$ $q_1$ $L_1$ $0$ $-\frac{\pi}{2}$
$2$ $q_2$ $0$ $L_r$ $0$
$3$ $q_3$ $0$ $L_3$ $0$
$4$ $q_4$ $0$ $L_4$ $0$

Note: $L_r=\sqrt{L_m^2+L_2^2}$

ROS

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.

URDF (Unified Robot Description Format)

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:

joints and links urdf

Finally, the robot model in RViz is:

rviz

Launch file

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.

Execution

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.

Run python node key control

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
Configuration files

The files to setup the parameter needed to run the dynamixel_workbench package are in the configuration folder.

Bonus

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.

Robotics toolbox by Peter Corke

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:

  1. $\begin{bmatrix}\pi/6&\pi/3&-\pi&3\pi/4\end{bmatrix}$
  2. $\begin{bmatrix}\pi/3&\pi/6&\pi/7&3\pi/7\end{bmatrix}$
  3. $\begin{bmatrix}-\pi/6&\pi/5&\pi/4&\pi\end{bmatrix}$
  4. $\begin{bmatrix}\pi&\pi/9&-\pi/2&-3\pi/4\end{bmatrix}$

The development of this code is in px file.

MATLAB connection

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

Youtube

References

Footnotes

  1. PincherX 100 Robot Arm - X-Series Robotic Arm..

  2. Urdf/Tutorials - ROS Wiki.

About

ROS package to move the pincher x100 robot with python or MATLAB. This repo contains the second practice lab for robotics class at Universidad Nacional de Colombia

License:MIT License


Languages

Language:CMake 46.1%Language:Python 32.3%Language:MATLAB 17.8%Language:Dockerfile 3.7%