# Dung beetle Robot Manual :bug:
<!-- For Ball rolling DEMO ( rolling{ normal → move around ball → normal } ) -->
## New version of the manual:
Please go to [this](https://www.notion.so/Dung-beetle-Project-How-to-Run-e00de2f939b349a2a927346626cfba73?pvs=4) for new version of the manual
## Robot setup:
The Robot and equipments are placing at the cart.

#### Power the robot
Connect power to both sides of the connector (yellow- XT60), using 12 V voltage supply to power dynamixel motors. There are 2 options that we can puower the robot
- option 1: power the robot by using power supply. This option is suitable for Labaratory Experiment. Set the voltage of the power supply to be 14 V (because of small voltage drop of the circuit). Set the current to the maximum (specifically for rolling behavior which use high energy consumption compare to locomotion).

- option 2: power the robot by using 2 pack of the LiPo battery (each pack is 24 V, with 1850 mAh)

To open the OdroidC4, push a power switch on the top of robot. <b> Note:</b> If the power is plug in to the motor, you should see the red blink at the dynamixel motor.

## Setup the Computer
This manual assume that the ROS2 is already installed in the computer. We have test this software in the ubuntu 22.04 with ROS desktop Humble.
### setup the network connection for ROS2 communication
#### setup wifi hotspot
In our network setup, the Odroid will connect to the wifi hotspot (name: dbAlphaAP, no password) which created from the TP-link wifi adapter (adapter plugin to the computer).
There are 2 option to set up the wifi hotspot: 1. go to the setting of the ubuntu and create the hotspot (do not set password) or 2. create the hotspot by using the [software for creating hotspot in ubuntu](https://github.com/oblique/create_ap).

- <b>Note:</b> if haven't install the driver for the wifi adapter, please follow this manual [link](https://community.tp-link.com/en/home/forum/topic/547276)
#### setup ROS 2 parameters
set up the ROS_DOMAIN_ID in the ~/.barchrc file to equal to 3. <b>Note: </b>this parameter is already set in the ubuntu Mate 22 of odroidC4 to enabling the communication between machine.
```
ROS_DOMAIN_ID=3
```
#### Check odroid connection
To check if the odroid connect to the hotspot, ping to the ip of the odroid.
```
ping odroid@192.168.12.35
```
- if cannot ping to the odroid, reinsert the odroid wifi adapter to make it reset the wifi connection and ping the odroid again.

### setup robot controller
#### Download robot controller software
The neural control software for locomotion and object manipulation is located in the gorobots repository of ENS_SDU and also in BrainLab biorobotic Repo.
- Open new terminal (Ctrl+T). Then, create a workspace and download the neural control software.
```
mkdir -p workspace
cd workspace
git clone https://gitlab.com/BRAIN_Lab/public/imnc.git
```
#### build package
- In the terminal go to imnc/projects/db_alpha/walking_neural_control/real/ros2_ws. Then, build the package using colcon build.
```
cd /workspace/imnc/projects/db_alpha/walking_neural_control/real/ros2_ws
colcon build
```
- After finish build process, source the package to enable the terminal to find the package.
```
. install/setup.bash
```
#### Test run
- test running the software
```
ros2 run walking_neural_controller db_beta_controller
```
- Try Press “w” button on Keyboard, to see if the controller exibit forward walking control.
<!-- - Lift the robot on the ball, Press “R” button on Keyboard -->
### Running the simple demo
#### SSH to the Odroid
- SSH to the Odroid run robot driver node. the password for log in is 'odroid'
```
ssh odroid@192.168.12.35
```
#### motor interface
- source and run dynamixel motor interface (db_beta_interface position controller). The control will hardening the motor if running succesfully.
```
sros2dxl
db_beta_interface_pos
```
- <b> Note: </b> If the motors are distorq when running the program, run the reboot program in the window that running the dynamixel motor interface
#### IMU interface
To interface the Phidgets IMU, we need to open a new terminal and ssh to the odroid using the prevous commands.
- source and run phidget imu driver. The control will hardening the motor if running succesfully.
```
sros2phidgets
phidgets_db
```
After runnning the dynamixel motor and phidget IMU interface, try to run the neural controller on the computer to see if the computer can send and recieve data with Odroid.
- In the terminal window of the computer, run the neural control.
```
ros2 run walking_neural_controller db_beta_controller
```
- Try Press “w” button on Keyboard, to see if the controller exibit forward walking control.
## Robot maintenance
#### Screw tightening
Every time before and after experiment, check the tightness of the screw or look if the screw is loosed (screw move out of the ).
#### dynamixel motor wire
If running the motor interface and cannot found the motor, the wire connect to the motor might be broken.
#### Lipo Battery
Lipo battery can power the robot for around 1 hr. Charge the LiPo battery with Balanced charge mode (6s, 1.5A) at the LiPo charger. take around 1 hr to fully charge.