---
# System prepended metadata

title: Autonomous Tests on E2O
tags: [ALIVE]

---


## Systems

|          IP          |   Hostname   | Password  | Used For                         |
|:--------------------:|:------------:|:--------- |:-------------------------------- |
|  nuc@192.168.1.101   | nuc-planner  | nuc       | ROS Master, Localization, Estimation, P&C, Reverse planner, Behavior Tree   |
|  ~~nuc3@192.168.1.201~~  |  ~~nuc3-yolo~~  | ~~nuc3-yolo~~ | ~~RoadPlane estimation~~             |
|  nuc2@192.168.1.200  | nuc2-desktop | nuc3456   | Connected to CAN, runs Ubuntu 18 |
|  nuc@192.168.1.202   |    nuc-pc    | nuc       | Floam and ALiVE Android App      |
| nvidia@192.168.1.203 |    ubuntu    | orin@agx  | GPU - AGX runs yolop model       |
| jetson@192.168.1.204 |    jetson    | jetson    | GPU - Runs YOLOv5, Tracking, Rear Collision Warning |


For adding a new system to E2O, check [this](https://hackmd.io/vAJwMddzSa2sfbOgV2JDZw).

Switch on power supply and all nucs, including  the one near CAN
On nuc-planner
```bash!
roscore
# do not let roscore shutdown till you shutdown the car
# new-terminal
cd alive-dev
# perform necessary git commands
# below uses ssh -X and gives terminal windows to monitor all systems
./top_level_build.bash 
```

## Setting up CAN 
On nuc2-desktop
```bash!
sudo ip link add can0 type can
sudo -S ip link set can0 type can bitrate 500000
sudo -S ip link set can0 up
# green light should blink on the usb can interface connected in the front of the car
```
IF ANY OF THE ABOVE STEPS ERRORS:
1. Plug in the USB properly and retry from top
2. Load systec_can as shown below and retry from top
    ```bash!
    # from https://www.systec-electronic.com/en/company/support/driver
    cd systeccan
    make -j4
    sudo make firmwareinstall
    sudo make modulesinstall
    sudo modprobe systeccan
    ```

## Running CAN
On nuc2-desktop
```bash!
cd alive-dev
rosrun can can_node
# dumps a lot of stuff to terminal
# open new terminal
python src/e2o/scripts/e2o_odom.py
rostopic hz /odom_can
# should be 100
```

## Running LIDAR and camera
On nuc-planner
```bash!
cd alive-dev/sensor_setup
roslaunch all_sensors.launch platform:=car
```

## Running MAVROS for GPS and IMU
On nuc-planner
```bash!
~/Downloads/QGroundControl.AppImage
# (or double click), this setups tty to get mavlink data and lets you check gps lock
# ctrl c or exit QGroundControl
roslaunch mavros apm.launch
# new terminal to check
rostopic hz /mavros/imu/data
# should be above 20 hz
# if data rate low, run below command
rosrun mavros mavsys rate --all 100
```

## ALiVE Android App
This node uploads GPS position and orientation to the Firebase database which is then read by the ALiVE android app

On nuc-pc
```bash!
cd alive-dev
roslaunch alive_app alive_app.launch use_sim_time:=false
```

## Localisation
On nuc-pc
```bash!
cd alive-dev
roslaunch floam floam_velodyne.launch use_sim_time:=false
```

## Estimation and Planning
On nuc-planner

If you are using the *somusan_btree* branch: Reverse planner is not integrated with the behavior tree, so **if you want to demo the reverse planner**, open `src/structured_planner/config/e2o_parameters.yaml` and set `skip_forward_planner` to `true`. This forces the forward planner to pass the received goal as it is to the reverse planner. Note that the goal should be within the estimator grid; goal outside the grid won't be accepted by the reverse planner.

```bash!
# new terminal
roslaunch localisation_fusion ekf.launch use_sim_time:=false
# new terminal
roslaunch top_level.launch simulation_state:=false use_sim_time:=false platform:=e2o three_lidar:=true remote_launch:=false
```

## Traffic Light Following Without YOLOP (only when you are using Behavior Tree)
On nuc-planner
```bash!
# new terminal
roslaunch alive_behavior_tree alive_behavior_tree.launch use_sim_time:=false simulation_state:=false is_tl_virtual:=true
# new terminal
python3 src/tl_stopping_profile/scripts/user_input_tl_state.py
# new terminal
rosrun tl_stopping_profile set_goal_node
```

**Don't forget to set the traffic light color using keys 'r' and 'g'**

## Traffic Light Following With YOLOP (only when you are using Behavior Tree)
On nuc-planner
```bash!
# new terminal
roslaunch alive_behavior_tree alive_behavior_tree.launch use_sim_time:=false simulation_state:=false is_tl_virtual:=false

# new terminal
rosrun tl_stopping_profile set_goal_node
```

On Orin-ubuntu
First, download the model weight `bdd_campus_croptl_90.pt` from  [google drive](https://drive.google.com/drive/folders/1WZYkqbkkBaQA5rtx1lVpQY1eHY_wMbUv?usp=sharing) and place the file inside `src/yolop/src/models/`. 
```bash!
# new terminal
roslaunch yolop yolop_tl.launch simulation_state:=false
```


## GUI Instructions
1. Use the floam velodyne rviz window (loads the full map) and set the green 2D pose where the vehicle currently is
2. Wait for localisation to stabilise
3. Set purple goal pose to set goal 
4. Observe /trajectory_rollout and /trajectory_rollout_vis to view debug messages


## Reversing
On nuc-planner
```bash!
# new terminal
roslaunch hybrid_astar dynamic.launch
# new terminal
roslaunch planning_local_nav teb.launch platform:=e2o
```

## Starting autonomous run
### ALL STEPS MUST BE DONE AGAIN IN THE SAME ORDER FOR EACH RUN
1. On a new terminal in the nuc2-desktop / nuc-can
```bash!
# if you want to do autonomous testing, to be reset on each run
rosrun e2o e2o_node_auto
# this has an internal pid control, initially it forces the steering wheel to neutral
# wait atleast 10 seconds before starting pid control
```
**Kill (ctrl+c) the above to force stop the car wherever it is.**

2. Press the green button to go into auto mode on the can dashboard near passenger seat. Green light next to "Auto Mode" should glow after this.
3. Give a verbal warning to the driver before pressing enter on the following command on the **planner-nuc** because, in some cases, it can respond badly.

4. **Note: For reverse autorun switch *teb:=true* in the following code.**
```bash!
# wait till the window in 1. has no warnings
roslaunch cascaded_pid pi_controller.launch simulation_state:=false teb:=false
# teb=false is to use the default planner, teb=true means use reverse planner
```

## Record bagfile
Option -b 0 ensures that we maintain an infinite size buffer and messages are not dropped
```bash!
rosbag record -b 0 /tf /lidar103/velodyne_packets /lidar102/velodyne_packets /lidar104/velodyne_packets /mavros/imu/data /mavros/global_position/global /odom_can /odom /odometry/filtered/global /pose /velodyne_obstacles /trajectory_rollout /pid_info /details /can_node/e2o_info /info_to_e2o_debug /realsense_cam/color/image_raw -o "name"
```

To record all topics (**use only when required**)
```bash!
rosbag record -a -b 0 -o "name"
```