====== Yumi experiment with the tactile table ======
Tests:
[[marytts#[The python API]]]
{{section>marytts#[The python API]}}
{{count>+}}
{{searchtags}}
{{topic>software}}
====== Introduction ======
{{tag> hardware robot software }}
Whatever ABB station is used, real or virtual, this tutorial shall show you how to control it using our controller framework.
On the robot, a controller is running, it can execute programs written in a language called RAPID.
Those RAPID programs, are what the robot execute in real time.
The PC controller, written in C# fulfills two roles:
* controlling the robot, by remotely changing and reading variables of running RAPID programs, stopping them, starting them, and checking the robot internal state
* running a proxy server to enable remote programs to send commands to the robot (e.g. SGIM program).
Then, an external program, written in any language, can interact with the PC controller using zeroMQ library.
====== Easy Use ======
Open Robotstudio
Load saved station or import rsbag of the station (for the first use)
Go to RAPID tab and wait for controller to be fully loaded
Check the correct tasks are selected for running (deselect the others)
* T_ROB_R (mechanic task)
* T_ROB_R_b (background task)
Go to Add-ins tab
Load the RobotStudioEmptyAddin1 (in General folder, right-click then load)
Start the Yumi PC Controller (yumi_control/PC_SDK/YumiControlPC/bin/Debug/YumiControlPC.exe)
A window should open
Select the Yumi controller in the list, then click on "Connect", then "Start server" (Let the fields at default values. Important, do not close this window)
Then search and launch your client program (e.g. the yumi_control.py script)
====== Content of yumi_control code ======
Two folders:
* RAPID: contains the RAPID modules which runs on the robot
* PC_SDK: contains C# VisualStudio projects enabling to control the robot
===== RAPID folder =====
Contains different test modules.
The only important ones are the following:
* CalibData.mod: contains calibration information for the robot (DO NOT MODIFY IT!)
* FileTransfer.sys: contains functions to serialize and deserialize specific data
* RecordingModule.mod: main module running on the background task, it records in TCP and joint space the trajectory of the arm
* MainModule.mod: old main module to be used on real robot, however too complex as it contains too many different functions, also deprecated (can be used as reference for RAPID implementation)
* MainSimuModule.mod: main module running on the main task (T_ROB_R), waits for joint trajectory to execute motion
* YumiProgram.pgf: xml description of the whole program, used to import whole program using the flex pendant (NOT UP TO DATE)
On the robot, 3 tasks exist:
* T_ROB_R: main mechanical task for the right arm
* T_ROB_L: main mechanical task for left arm
* T_ROB_R_b: background task for right arm
T_ROB_L is not used, T_ROB_R controls in real time the right arm motions and T_ROB_R_b is a background task recording the current trajectory of the arm (both in joint and TCP space).
===== PC_SDK subfolder =====
Contains different VisualStudio projects:
* RecordYumi: client application that will connect to the running YumiControlPC server to make it record/play trajectories from files (DEPRECATED)
* RobotStudioEmptyAddin1: Add-in for RobotStudio which sets the right arm joints to initial configuration when requested, hosts a zeroMQ server to do so
* YumiControlPC: the controller for the robot, implements a visual interface to connect to the robot, it controls the execution of the RAPID programs on the robot and hosts a zeroMQ server for external application to command the robot (also connect to the RobotStudioEmptyAddin1 for resetting environment)
==== YumiControlPC ====
The code is splat in 3 parts:
* SimuYumiNode.cs: contains the code managing the zeroMQ communication protocol, called when receiving external commands
* SimuYumiController.cs: contains the code interfacing with the robot remote controller
* YumiController.cs: contains the callbacks for the visual interface created when starting the application
==== Communication protocol ====
The communication between the PC SDK controller and an external program wanting to control the robot is done using the zeroMQ library.
The protocol used is of type Server/client and the message exchanged are JSON formatted.
A client order is formatted like this:
{
"type": order type,
"payload": input parameters
}
The server acknowledgement is shaped:
{
"type": error if the order was badly formatted, order type otherwise,
"payload": contains output if needed,
"valid": true if order was executed correctly, wrong otherwise
}
Functioning orders:
* motion execution:
{
"type": "move",
"payload": {
"dt": timestep as float,
"path": [
[joint_1_t_1,
joint_2_t_1,
...
joint_7_t_1],
[joint_1_t_2,
...
joint_7_t_2],
...
]
}
}
acknowledgenemt:
{
"type": "move",
"valid": true or false,
"payload": {
"pose": [TCP_final_pose_x, y, z, q1, q2, q3, q4],
"joints": [TCP_final_joints_1, 2, 3, 4, 5, 6, 7],
"trajectory": complete TCP trajectory shaped like the order "path" field
}
}
* reset order:
{
"type": "reset",
"payload": [initial_joint_pose_1, 2, 3, 4, 5, 6, 7] as double
}
acknowledgement:
{
"type": "reset",
"payload": "",
"valid": true or false
}
======Real Yumi Robot======
First, connect the robot to power.
Make sure, the flex pendant is connected too.
If you want to connect to the robot through a LAN, connect an Ethernet cable to its WAN Ethernet port.
If you want to connect directly a computer to the robot, connect it with Ethernet cable to its service port.
Then you can power up the robot by rotating the power switch (near the flex pendant connector).
You can control the robot using the flex pendant (make sure it's configured in manual mode before).
It can launch programs, configure the robot, test the motions of individual joints, etc.
However, in our case, we will prefer the automatic mode, which will enable the controlling computer to command the robot without validation on the flex pendant.
If, at some point after booting the robot, it says some of its joints are wrongly calibrated, you will need to launch the manual
calibration routine.
I haven't done the tutorial for this part, but you can find the explanation in the Yumi documentation.
To connect to the robot with the computer, launch Robotstudio, and choose "Online" mode (in the File menu).
Then you choose a method to select the robot and you will connect to it.
Afterwards, you can control the robot using Robotstudio.
Certain commands require writing privileges, you can take them by login on the robot and ask them.
The default user only has limited rights, though they should be enough.
If you need to move the robot's joints manually, you must power down the motors beforehand, and disable the mechanical brakes by pushing continuously the black buttons under the robot torso.
====== Installation ======
First, we need a windows computer (at least Windows 7).
We need to install Visual Studio 2015+ (the community edition is free and works fine)
Then we need to install Robotstudio 6.05 (not tested for other versions)
Then we can install Robotstudio SDK and PC SDK
Then we must adapt the custom Robotstudio Add-In to the new computer, and copy it among other Add-Ins.
The file is yumi_control/PC_SDK/RobotStudioEmptyAddin1/RobotStudioAddin1/RobotStudioAddin1.rsaddin.
We must change the two paths in the section, and make it point yumi_control/PC_SDK/RobotStudioEmptyAddin1/RobotStudioAddin1/bin/Debug and yumi_control/PC_SDK/RobotStudioEmptyAddin1/RobotStudioAddin1/bin/Release (absolute paths).
Then the file shall be copied into Robotstudio Add-Ins folder (usually in Program Files (x86)/ABB IndustrialIT/RoboticsIT/RobotStudio 6.05/Bin/Addins.
At any time, we can install python 2.7 (let it be configured in environment variables for access using command line)
Install required library python-zeromq, matplotlib, numpy, scipy
Can be installed through pip:
pip install numpy scipy matplotlib python-zmq
====== API and packages used ======
===== PC SDK =====
This package enables to control an ABB controller using C# or Visual Basic.
It can connect to the controller, log in, start/stop tasks, change/read module variables, change signal values, upload/download file, etc.
We cannot send directly commands to the robot RAPID controller, but through variables modifications and file exchanges, we can set input parameters, then start the tasks.
To get more documentation on the PC SDK API, go to [[http://developercenter.robotstudio.com/pcsdk/api_reference]]
===== Robotstudio SDK =====
This package enables to write Add-Ins and Smart Component for Robotstudio applications.
More documentation on the Robotstudio SDK API, go to [[http://developercenter.robotstudio.com/robotstudio/api_reference]]