# Control and following of the robot arm
## 1 Slider Control
Open a command line and run:
mechArm-M5 version:
```bash
# The default serial port name of the mechArm-M5 version is "/dev/ttyUSB0", and the baud rate is 115200". The serial port name of some models is "dev/ttyACM0". If the default serial port name is wrong, you can change the serial port name to "/ dev/ttyACM0".
roslaunch mecharm slider_control.launch port:=/dev/ttyUSB0 baud:=115200
```
mechArm-PI version:
```bash
# The default serial port name of the mechArm-PI version is "/dev/ttyAMA0", and the baud rate is 1000000".
roslaunch mecharm_pi slider_control.launch port:=/dev/ttyAMA0 baud:=1000000
```
**rviz and a slider component will be opened**, and you will see the following interface:
Then you can **control the model in rviz to make it move by dragging the slider**. If you want the real mechArm to move with the model, you need to open another command line and run:
mechArm-M5 version:
```bash
# The default serial port name of the mechArm-M5 version is "/dev/ttyUSB0", and the baud rate is 115200". The serial port name of some models is "dev/ttyACM0". If the default serial port name is wrong, you can change the serial port name to "/ dev/ttyACM0".
rosrun mecharm slider_control.py _port:=/dev/ttyUSB0 _baud:=115200
```
mechArm-PI version:
```bash
# The default serial port name of the mechArm-PI version is "/dev/ttyAMA0", and the baud rate is 1000000".
rosrun mecharm_pi slider_control.py _port:=/dev/ttyAMA0 _baud:=1000000
```
**Note: Since the robot arm will move to the current position of the model when the command is input, make sure that the model in rviz does not appear to be worn out before you use the command.**
**Do not drag the slider quickly after connecting the robot arm to prevent damage to the robot arm.**
## 2 Model Following
In addition to the above controls, we can also let the model move by following the real robot arm. Open a command line and run:
mechArm-M5 version:
```bash
# The default serial port name of the mechArm-M5 version is "/dev/ttyUSB0", and the baud rate is 115200". The serial port name of some models is "dev/ttyACM0". If the default serial port name is wrong, you can change the serial port name to "/ dev/ttyACM0".
rosrun mecharm follow_display.py _port:=/dev/ttyUSB0 _baud:=115200
```
mechArm-PI version:
```bash
# The default serial port name of the mechArm-PI version is "/dev/ttyAMA0", and the baud rate is 1000000".
rosrun mecharm_pi follow_display.py _port:=/dev/ttyAMA0 _baud:=1000000
```
Then open another command line and run:
mechArm-M5 version:
```bash
roslaunch mecharm follow.launch
```
mechArm-PI version:
```bash
roslaunch mecharm_pi follow.launch
```
It will **open rviz to show the model following effect.**
## 3 GUI control
On the basis of the previous contents, this package also **provides a simple GUI control interface.** This method is used for interaction between real robot arms. Connect to mecharm.
Open a command line:
mechArm-M5 version:
```bash
# The default serial port name of the mechArm-M5 version is "/dev/ttyUSB0", and the baud rate is 115200". The serial port name of some models is "dev/ttyACM0". If the default serial port name is wrong, you can change the serial port name to "/ dev/ttyACM0".
roslaunch mecharm simple_gui.launch port:=/dev/ttyUSB0 baud:=115200
```
mechArm-PI version:
```bash
# The default serial port name of the mechArm-PI version is "/dev/ttyAMA0", and the baud rate is 1000000".
roslaunch mecharm_pi simple_gui.launch port:=/dev/ttyAMA0 baud:=1000000
```
Running effect:
## 4 Keyboard control
**Keyboard control is added** in `mecharm` package, and real-time Synchronization is performed in rviz. This function depends on pythonApi, so be sure to connect with the real robot arm.
Open a command line and run:
mechArm-M5 version:
```bash
# The default serial port name of the mechArm-M5 version is "/dev/ttyUSB0", and the baud rate is 115200". The serial port name of some models is "dev/ttyACM0". If the default serial port name is wrong, you can change the serial port name to "/ dev/ttyACM0".
roslaunch mecharm teleop_keyboard.launch port:=/dev/ttyUSB0 baud:=115200
```
mechArm-PI version:
```bash
# The default serial port name of the mechArm-PI version is "/dev/ttyAMA0", and the baud rate is 1000000".
roslaunch mecharm_pi teleop_keyboard.launch port:=/dev/ttyAMA0 baud:=1000000
```
Running effect is as follows:
mechArm information will be output in the command line as follows:
```bash
SUMMARY
========
PARAMETERS
* /mecharm_services/baud: 1000000
* /mecharm_services/port: /dev/ttyAMA0
* /robot_description: