Difference between revisions of "CARLA Simulator"
Elcanoadmin (talk | contribs) (Created page with "== Current Functionality of Simulation == At the end our Autumn 2019 Capstone, we were able to deliver a demo that demonstrated communication between all components; high-lev...") |
Elcanoadmin (talk | contribs) (→Current Functionality of Simulation) |
||
| Line 6: | Line 6: | ||
* Implementation of timing structure. Computer running simulator.py waits for data to be interpreted from the router board while the router board executes its update 10 times per second. This is the desired speed for both sensor data and actuation data to be updated. | * Implementation of timing structure. Computer running simulator.py waits for data to be interpreted from the router board while the router board executes its update 10 times per second. This is the desired speed for both sensor data and actuation data to be updated. | ||
* Implementation of vehicle control updaters through throttle, brake, and steering data. The computer running simulator.py can take desired throttle, brake, and steering and convert them into corresponding commands for Carla using Carla API. These commands move the vehicle within Carla. This is the primarily what the demo shows. | * Implementation of vehicle control updaters through throttle, brake, and steering data. The computer running simulator.py can take desired throttle, brake, and steering and convert them into corresponding commands for Carla using Carla API. These commands move the vehicle within Carla. This is the primarily what the demo shows. | ||
| + | |||
| + | == Demo Guide (How to Set-Up) == | ||
| + | The following is a guide to set up the Elcano simulator. | ||
| + | |||
| + | ===''' Materials '''=== | ||
| + | * 1 Assembled Elcano Simulator Printed Circuit Board (PCB) | ||
| + | * 2 Arduino Due | ||
| + | * 1 Arduino Mega 2560 | ||
| + | * 1 Box (200 x 150 x 70 mm) | ||
| + | * 2 Voltage Level Converter (included w/Simulator PCB) | ||
| + | * 1 SD Card (w/map files) | ||
| + | * 1 USB AB Cable (for Arduino Mega) | ||
| + | * 1 USB Micro Cable (for Arduino Due) | ||
| + | * 1 computer capable of running Carla | ||
| + | |||
| + | ===''' Pre-installation '''=== | ||
| + | Use the following instructions to install the required software to run the simulation. | ||
| + | |||
| + | #<u>''''' Python '''''</u> | ||
| + | #* Install Python 3 (if not installed already) | ||
| + | #::-experiments used version 3.7.6 | ||
| + | #* In a terminal, move to .\Simulation\ | ||
| + | #* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator | ||
| + | #<u>''''' CARLA '''''</u> | ||
| + | #*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)] | ||
| + | #*CARLA requirements:<br />[[File:Carla_Requirements.jpg|500px|]] | ||
| + | #<u>''''' Arduino Libraries '''''</u><br />Download these Arduino libraries prior to running the simulation: | ||
| + | #* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio] | ||
| + | #* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard] | ||
| + | #* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood] | ||
| + | #* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg] | ||
| + | #* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel] | ||
| + | #* Previous version of [https://github.com/collin80/due_can Arduino Due CAN Bus library] is used but the necessary files are included within the repository. | ||
| + | #<u>''''' Elcano Repositories '''''</u><br />The Elcano repositories are needed to run the simulation: | ||
| + | #*[https://github.com/elcano/HighLevel High Level] | ||
| + | #*[https://github.com/elcano/Simulator Simulator (Router Board & Simulator Script)] | ||
| + | #*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)] | ||
| + | ===''' Run Simulation '''=== | ||
| + | Once all the requirements are installed, use the following instructions to run the simulation. | ||
| + | <br />[[File:Router_PCB_Connections.jpg|500px]] | ||
| + | <br /><br />'''''Step 1: Program all Arduinos''''' | ||
| + | #Upload <b>router_board_v1.ino</b> to the router Arduino Due programming port | ||
| + | #Upload <b>High_Level.ino</b> to the high level Arduino Due programming port | ||
| + | #Upload <b>Drive_By_Wire.ino</b> to the low level Arduino Mega 2560 | ||
| + | '''''Step 2: Run CARLA''''' | ||
| + | #Open a command prompt (type cmd in the windows search box) | ||
| + | #Go to the directory where CARLA is installed (CARLAUE4.exe) | ||
| + | #:<code>cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor</code> | ||
| + | #::-You may have it saved to a different directory | ||
| + | #From the CARLA directory, type: | ||
| + | #:<code>CARLAUE4.exe</code> | ||
| + | #:Or, to run in low resolution mode: | ||
| + | #:<code>CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low</code> | ||
| + | '''''Step 3: Run Simulation''''' | ||
| + | #Connect your PC to the native port on the Router Board Due | ||
| + | #Open a command prompt (type cmd in the windows search box) | ||
| + | #Go to the Simulation directory | ||
| + | #:<code>cd C:\Users\bobross\Documents\Simulator\Simulation</code> | ||
| + | #::-You may have it saved to a different directory | ||
| + | #From Simulation directory, start the Simulator UI | ||
| + | #:<code>.\Simulation\start.bat</code> | ||
| + | #By default, the Simulator UI will populate local running CARLA settings | ||
| + | #*For control via the router board, leave mode as Auto | ||
| + | #*To control via manual keyboard input, change mode to Manual. | ||
| + | #*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010) | ||
| + | #Click "Connect to CARLA" | ||
| + | #*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. | ||
| + | #*If Manual mode, client will start with keyboard controls (WASD) | ||
| + | #Observe behavior in simulator. | ||
| + | #If car gets stuck, kill current simulator.py process and restart. | ||
| + | ===''' Debug/Logging '''=== | ||
| + | *High Level uses the Programming Port to display debug messages over serial monitor | ||
| + | *Router Board uses the Programming Port to display debug messages over serial monitor | ||
Revision as of 01:05, 12 June 2026
Contents
Current Functionality of Simulation
At the end our Autumn 2019 Capstone, we were able to deliver a demo that demonstrated communication between all components; high-level board (Arduino Due), low-level board (Arduino Mega 2560) with shield running low level code, router board (Arduino Due), and the instance of Carla. The instructions on how to reproduce the demo will be given later in this document. The primary roadblock that prevented further development into this project was the state of the CAN system of the Elcano trike (particularly the transceiver board which seems to have a flawed design). These are the current features of the simulator.
- Implementation of USB serial communication between router board and computer running simulator.py. Both entities (Computer and ArduinoDue) can send and receive data through USB connection.
- Implementation of a cyclometer. Router board can receive the current speed of the simulated vehicle in Carla and convert it into an interrupt-based cyclometer pulse, based on the wheel dimension of the Elcano. Also considers the random error of cyclometer present on the Elcano trike. This can be debugged with the built-in LED on the router board.
- Implementation of NMEA GPS sensor. Carla is able the output NMEA GPS data to the router board 10 times per second, effectively simulating the GPS sensor on the high-level board. Router board is successfully able to output it to UART serial which is how it is transmitted to the high-level board.
- Implementation of timing structure. Computer running simulator.py waits for data to be interpreted from the router board while the router board executes its update 10 times per second. This is the desired speed for both sensor data and actuation data to be updated.
- Implementation of vehicle control updaters through throttle, brake, and steering data. The computer running simulator.py can take desired throttle, brake, and steering and convert them into corresponding commands for Carla using Carla API. These commands move the vehicle within Carla. This is the primarily what the demo shows.
Demo Guide (How to Set-Up)
The following is a guide to set up the Elcano simulator.
Materials
- 1 Assembled Elcano Simulator Printed Circuit Board (PCB)
- 2 Arduino Due
- 1 Arduino Mega 2560
- 1 Box (200 x 150 x 70 mm)
- 2 Voltage Level Converter (included w/Simulator PCB)
- 1 SD Card (w/map files)
- 1 USB AB Cable (for Arduino Mega)
- 1 USB Micro Cable (for Arduino Due)
- 1 computer capable of running Carla
Pre-installation
Use the following instructions to install the required software to run the simulation.
- Python
- Install Python 3 (if not installed already)
- -experiments used version 3.7.6
- In a terminal, move to .\Simulation\
- Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator
- CARLA
- Download CARLA (0.9.8)
- CARLA requirements:

- Arduino Libraries
Download these Arduino libraries prior to running the simulation:- CAN_BUS_SHIELD by Seeed-Studio
- PID by Brett Beauregard
- Pin Change Interrupt by Nico Hood
- MCP48x2 DAC by Jonas Forsberg
- Arduino Due Timer Interrupts by Ivan Seidel
- Previous version of Arduino Due CAN Bus library is used but the necessary files are included within the repository.
- Elcano Repositories
The Elcano repositories are needed to run the simulation:
Run Simulation
Once all the requirements are installed, use the following instructions to run the simulation.
Step 1: Program all Arduinos
- Upload router_board_v1.ino to the router Arduino Due programming port
- Upload High_Level.ino to the high level Arduino Due programming port
- Upload Drive_By_Wire.ino to the low level Arduino Mega 2560
Step 2: Run CARLA
- Open a command prompt (type cmd in the windows search box)
- Go to the directory where CARLA is installed (CARLAUE4.exe)
cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor- -You may have it saved to a different directory
- From the CARLA directory, type:
CARLAUE4.exe- Or, to run in low resolution mode:
CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low
Step 3: Run Simulation
- Connect your PC to the native port on the Router Board Due
- Open a command prompt (type cmd in the windows search box)
- Go to the Simulation directory
cd C:\Users\bobross\Documents\Simulator\Simulation- -You may have it saved to a different directory
- From Simulation directory, start the Simulator UI
.\Simulation\start.bat
- By default, the Simulator UI will populate local running CARLA settings
- For control via the router board, leave mode as Auto
- To control via manual keyboard input, change mode to Manual.
- If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)
- Click "Connect to CARLA"
- If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go.
- If Manual mode, client will start with keyboard controls (WASD)
- Observe behavior in simulator.
- If car gets stuck, kill current simulator.py process and restart.
Debug/Logging
- High Level uses the Programming Port to display debug messages over serial monitor
- Router Board uses the Programming Port to display debug messages over serial monitor