# Skill Acquisition
Before programming a sequence of actions that lead to a complete assembly the
user should acquire individual skills for the robot. These skills could be part
picking, part placing, screw driving, etc. Skill acquisition can be performed
kinesthetically by guiding the robot to the desired configurations or with a
joystick interface. The ReconCell provides a Graphical User Interface (GUI) that
facilitates these skill acquisitions. Acquiring a skill means making a new entry
into the **MongoDB** database running in the ROS system.
- [Button Interface](#button-interface)
- [Graphical User Interfaces for Skill Acquisition](#graphical-user-interfaces-for-skill-acquisition)
- [Single Point Acquisition](#single-point-acquisition)
- [Installation and Running Guide](#installation-and-running-guide)
- [GUI Overview](#gui-overview)
- [Whole Trajectory Acquisition](#whole-trajectory-acquisition)
- [Installation and Running Guide](#installation-and-running-guide-1)
- [GUI Overview](#gui-overview-1)
- [Robot Positioning](#robot-positioning)
- [Kinesthetic Teaching](#kinesthetic-teaching)
- [Joystick Interface](#joystick-interface)
## Button Interface
To accelerate the process of robot skill acquisition we designed and built a
custom made plastic cover for one of the robot's joints (see image bellow). The
cover houses two buttons and two switchers. The latter have an LED showing their
status (in the picture below the switch with the label `1` is turned on). These buttons and switches are programmable and their functions differ
depending on the skill acquisition process.
In the manual that follows we will refer to this picture and the labels
for the buttons.
![Buttons interface on the UR10](figures/buttons.png
"Buttons interface on the UR10")
## Graphical User Interfaces for Skill Acquisition
In ReconCell there are two types of skill acquisitions: [Single Point
Acquisition](#single-point-acquisition) and [Whole Trajectory Acquisition](#whole-trajectory-acquisition). The first one consists of
storing a single point (either joint or Cartesian space) to later on use for
trajectory generation. The second one consists of acquiring a whole robot
trajectory and playing it back later on in production.
### Single Point Acquisition
This process and the accompanying GUI is used when acquiring single points in
either joint or Cartesian space. These points are usually used to generate
motions relative to them, which consequently make up for a skill.
#### Installation and Running Guide
This tool is part of the ReconCell ROS stack so no additional installations are
required. To launch this tool simply execute the following command:
```shell
$ rosrun rqt_gui rqt_gui --standalone fc_gui
```
Once the GUI is launched the buttons and the switches from the [Button
Interface](#button-interface) get assigned the following functionalities:
| Button | Function |
|--------|----------|
|Switch 1| **Gravity compensation** mode toggle|
|Switch 2| Lock or unlock the tool exchange system|
|Button A (blue)| Mark the current robot configuration for saving |
|Button B (green)| Toggle the air to the tool exchange system |
#### GUI Overview
The GUI for [Single Point Acquisition](#single-point-acquisition) is shown in
the figure below.
When the GUI is launched, it, as written above, assignes some functionalities to
the custom made button interface. At this point, the user should position the
robot into the desired configuration and press the **Button A** (blue). A signal will be sent to the GUI indicating it has saved the current robot
configuration (both joint and Cartesian space) into a temporary buffer. The user
should now decide if they want to save either the joint or Cartesian space
configuration with the `Joint or Cartesian space radio button`. The final step
is writing the name for the database entry in the `Entry name field` and pressing
`Save`.
![Overview of the Single Point Acquisition GUI](figures/single_point_gui.png
"Overview of the Single Point Acquisition GUI")
### Whole Trajectory Acquisition
This process and the accompanying GUI is used when acquiring full length
trajectories in either joint or Cartesian space. The tool encodes the said
trajectories into [Dynamic Movement
Primitives](https://studywolf.wordpress.com/2013/11/16/dynamic-movement-primitives-part-1-the-basics/)
and saves them into the database.
#### Installation and Running Guide
This tool is part of the ReconCell ROS stack so no additional installations are
required. To launch this tool simply execute the following command:
```shell
$ roslaunch dmp_record_tool dmp_record_gui.launch
```
Once the GUI is launched the buttons and the switches from the [Button
Interface](#button-interface) get assigned the following functionalities:
| Button | Function |
|--------|----------|
|Switch 1|**Gravity compensation** mode toggle|
|Switch 2|Marks the start and end of the recorded trajecotry|
|Button A (blue)| N/A |
|Button B (green)| N/A |
#### GUI Overview
The GUI for [Whole Trajectory Acquisition](#whole-trajectory-acquisition) is
shown in the figure below.
When the GUI is launched it assignes some functionalities to
the custom made button interface. This tool is meant to be used for recording
whole trajectories during a kinesthetic demonstration. Before starting to move
the robot, the user has to fill in the `Topic selection field`. This field should
contain a string to a ROS topic of type
[`sensor_msgs/JointState`](http://docs.ros.org/api/sensor_msgs/html/msg/JointState.html)
or
[`geometry_msgs/PoseStamped.msg`](http://docs.ros.org/api/geometry_msgs/html/msg/PoseStamped.html).
If the type of the entered topic is adequate, the text will turn green, otherwise it will be red.
Once the text is green it means that the GUI has successfully
subscribed to the topic. To record a trajectory, the user should first flip the
switch 1 and activate the **Gravity compensation** mode. The user can now guide
the robot kinesthetically. When the user is ready to record a trajectory, they
should simply flip the switch 2. The light on the switch will turn on which means
that the robot trajectory is being recorded. The user should then move the robot
along the trajectory they want to record. When finished, flip the switch 2 back
so the light is no longer on.
The trajectory is now saved in a buffer. The user should now type the name under
which they want the trajectory to be saved in the databse in the `DMP name
field`. The trajectory is saved in the database after pressing the `Save to
database` button on the GUI.
![Overview of the Whole Trajectory Acquisition GUI](figures/dmp_gui.png
"Overview of the Whole Trajectory Acquisition GUI")
## Robot Positioning
### Kinesthetic Teaching
Traditional robot programming approaches require the user to guide and program
the robot with its controlling interface. By handling either a touchscreen or a
joystick, the user moves the robot to a desired position and defines the type of
motion to that configuration. This method turns out to be relatively slow and
requires a certain proficiency in robot handling. For these exact reasons modern
robots allow for kinesthetic guidance out of the box. Kinesthetic guidance
proves to be a considerably more intuitive approach to move the robot during the
programming phase.
Our setup consisted of two Universal Robot UR10 arms where kinesthetic guidance
is by default implemented with the so called "*Gravity Compensation*" mode. This
mode essentially compensates the effects of gravity by estimating the necessary
torques in the robot joints with the dynamic model. By applying an external
force the user can guide the robot kinesthetically without any additional
sensing equipment.
### Joystick Interface
Moving the robot kinesthetically has its advantages (intuitive, no extra
equipment, etc.). However, it has a significant disadvantage, which is the lack of
precise positioning. With the Universal Robot's implementation of kinesthetic
guidance it is relatively hard to position robot to a desired configuration
with a millimeter precision. We therefore developed a program that lets the
user guide the robot with a joystick interface.
Repository and installation guide available here:
[`https://repo.ijs.si/reconcell/robot_joystick_control`](https://repo.ijs.si/reconcell/robot_joystick_control).
------------------