<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.elcanoproject.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=ShivBhatt</id>
	<title>Elcano Project Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.elcanoproject.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=ShivBhatt"/>
	<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/Special:Contributions/ShivBhatt"/>
	<updated>2026-08-25T19:57:31Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.32.2</generator>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Main_Page&amp;diff=696</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Main_Page&amp;diff=696"/>
		<updated>2026-06-27T22:31:40Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Welcome to the Elcano Project Wiki */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
= Welcome to the Elcano Project Wiki =&lt;br /&gt;
As the title says, WELCOME TO THE ELCANO PROJECT! Over the past few years, many different teams have been working hard to create Cheap and Modular autonomy at the University of Washington Bothell. We have developed two prototype recumbent tricycles and also worked on an ELF tricycle. Using affordable microcontrollers such as the Arduino Due and Jetson Nano, CAN bus communication, and Pixhawk, we are working towards creating Autonomy for anyone to build anywhere, with electronics and software under $2000 and fully open-source. But we don't plan to stop there, no. That is just the first step toward our ultimate goal: making our systems applicable to any desired ground vehicle, such as cars. Autonomy is nothing new; in fact, it has been around for over 40 years. The difference is that now we can make it available for anyone who desires to further their knowledge or simply find a safer way to work.&lt;br /&gt;
&lt;br /&gt;
Elcano Project Main Website: [//www.elcanoproject.org]&lt;br /&gt;
&lt;br /&gt;
Visit our GitHub repositories: [https://github.com/elcano]. &lt;br /&gt;
&lt;br /&gt;
To '''edit articles''' or '''upload files''', please create an account and request editing rights from a [//www.elcanoproject.org/wiki/index.php?title=Special:ListUsers&amp;amp;group=bureaucrat member of the &amp;quot;bureaucrat&amp;quot; group].&lt;br /&gt;
&lt;br /&gt;
For editing, help visit https://www.mediawiki.org/wiki/Help:Editing_pages or https://www.mediawiki.org/wiki/Help:Formatting.&lt;br /&gt;
--------&lt;br /&gt;
[[File:Catrikes.JPG|1000px]]&lt;br /&gt;
== [[ElcanoIntro | Overview]] ==&lt;br /&gt;
The basic concept of how the Elcano Project vehicle works.&lt;br /&gt;
&lt;br /&gt;
== [[System Architecture]] ==&lt;br /&gt;
How processors connect to sensors, each other, actuators, and other hardware. Includes processor-to-processor communication protocol.&lt;br /&gt;
&lt;br /&gt;
== [[Communication | Communication (CAN Bus)]] ==&lt;br /&gt;
How processors exchange data on the vehicle and a description of data packet contents.&lt;br /&gt;
&lt;br /&gt;
== [[Power System]] ==&lt;br /&gt;
How different modules connect to the batteries or power subsystem hardware.&lt;br /&gt;
&lt;br /&gt;
== [[Drive-By-Wire]] ==&lt;br /&gt;
How the version 5 Drive-By-Wire system (aka Low-Level) uses inputs to control actuators to steer, move, and stop the vehicle.&lt;br /&gt;
&lt;br /&gt;
== [[Navigation Computer]] ==&lt;br /&gt;
How the system uses GNSS to formulate movement instructions sent to Drive-by-Wire.&lt;br /&gt;
&lt;br /&gt;
== [[RemoteControl]] ==&lt;br /&gt;
A radio communication link allows human control. There are also onboard controls. The goal is to use neither and have control come from the Nav computer.&lt;br /&gt;
&lt;br /&gt;
== [[ Simulator]] ==&lt;br /&gt;
Instead of the Drive-by-Wire board and navigation computer controlling the real trike, another Arduino routes their I/O to a virtual vehicle.&lt;br /&gt;
&lt;br /&gt;
== [[SensorsPage]] ==&lt;br /&gt;
&lt;br /&gt;
=== [[SteeringSensor]] ===&lt;br /&gt;
The front wheel angle detector. Sensors are mounted on the left steering column and/or right steering column. Sensors in use as of 2026 are analog. There are two varieties. Each is sensitive to 1/3 of a degree. The original is good for 360 degrees. Thus there are 1080 possible values. When these are spread over 3.3V, each step is 3 mV. Since the long wire from the sensor to the Arduino acts as an antenna, noise can be significant. There are two methods to reduce noise.&lt;br /&gt;
&lt;br /&gt;
1) The present analog sensor is only good for 60 degrees, which is more than the +/- 25 degree maximum turn. This makes the minimum step 18 mV.&lt;br /&gt;
&lt;br /&gt;
2) The ground signal on the sensor is sent back on either L_RTN (left steering column) or R_RTN (right steering column). Both the wires carrying the signal and the return wire are expected to pick up the same noise. A chip on the DBW board subtracts the two to get a value closer to the original.&lt;br /&gt;
&lt;br /&gt;
Noise could be eliminated by using a digital signal. A future sensor might use SPI. Jumpers can be installed to replace the sensor signals with MOSI, SCK and CS. Another digital solution is to purchase a sensor that puts its information on the CAN bus.&lt;br /&gt;
&lt;br /&gt;
=== Speedometer ===&lt;br /&gt;
&lt;br /&gt;
There are two magnetic pickups on the wheel. One goes to a standard bicycle cyclometer which shows speed and distance. The other goes to DBW where the software interprets the once per revolution click. Speed resolution is limited by the wheel circumference and cannot detect very low speeds.&lt;br /&gt;
&lt;br /&gt;
More accurate speed information could be obtained from the Hall sensor on the e-bike controller, but this has never been done.&lt;br /&gt;
&lt;br /&gt;
=== GPS ===&lt;br /&gt;
&lt;br /&gt;
The Pixhawk handles GPS. It includes inertial sensors and a Kalman filter and thus improves on raw GPS. Various sensors can be purchased. Some use Global Network Satellite Systems (GNSS) from other countries to improve on the US Global Positioning System.&lt;br /&gt;
&lt;br /&gt;
== [[ActuatorPage]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Current Board Diagrams]] ==&lt;br /&gt;
Images of Elcano Project's printed circuit boards for reference. PCB source files and schematics are maintained and stored at [//github.com/elcano].&lt;br /&gt;
&lt;br /&gt;
== Software development procedures ==&lt;br /&gt;
&lt;br /&gt;
=== [[Software repositories]] ===&lt;br /&gt;
What's in each of our GitHub repositories.&lt;br /&gt;
&lt;br /&gt;
Luke Kustra's repo: https://github.com/luke-kustra/JetHawk-LKustra.git &lt;br /&gt;
&lt;br /&gt;
Luke's contribution was experimenting with the LiDAR sensor. He was able to get the LiDAR to deactivate and display information about its surroundings, including the number of objects and their distance from the LiDAR sensor. Of course, the sensor should never deactivate when in real use; however, this deactivation is proof that the LiDAR is ready to be utilized in a larger system such as a vehicle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Henry Haight's repo: https://github.com/Autonomous-ATV-Capstone-Team-Sequence/-LIDAR&lt;br /&gt;
&lt;br /&gt;
=== [[Arduino software]] ===&lt;br /&gt;
Getting started; references; development tools. Dealing with libraries and different parameters for each vehicle.&lt;br /&gt;
&lt;br /&gt;
=== [[Using Git and GitHub]] ===&lt;br /&gt;
Practices for maintaining code and source files on Elcano Project's GitHub repositories.&lt;br /&gt;
&lt;br /&gt;
= Archived material =&lt;br /&gt;
&lt;br /&gt;
== [[Old Architecture]] ==&lt;br /&gt;
&lt;br /&gt;
== [[ATV Power System]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Low Level]] ==&lt;br /&gt;
&lt;br /&gt;
== [[High Level]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Old RemoteControl]] ==&lt;br /&gt;
&lt;br /&gt;
== [[CARLA Simulator]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Old Sensors]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Old Actuators]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Board Diagrams]] ==&lt;br /&gt;
&lt;br /&gt;
==[[FilesPage | Files]] ==&lt;br /&gt;
These are media files (pictures, videos, etc.) that are part of the project but are not maintained under version control.&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Main_Page&amp;diff=695</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Main_Page&amp;diff=695"/>
		<updated>2026-06-27T22:30:57Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Welcome to the Elcano Project Wiki */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
= Welcome to the Elcano Project Wiki =&lt;br /&gt;
As the title says, WELCOME TO THE ELCANO PROJECT! Over the past few years, many different teams have been working hard to create Cheap and Modular autonomy at the University of Washington Bothell. We have developed two prototype recumbent tricycles and also worked on an ELF tricycle. With the use of affordable microcontrollers, such as the Arduino Due, Jetson Nano, and Pixhawk, we are working towards creating Autonomy for anyone to build anywhere, with electronics and software under $2000 and fully open-source. But we don't plan to stop there, no. That is just the first step in reaching our ultimate goal, which is making our systems applicable to any desired ground vehicles, such as cars and other vehicles. Autonomy is nothing new; in fact, it has been around for over 40 years. The difference is that now we can make it available for anyone who desires to further their knowledge or simply find a safer way to work.&lt;br /&gt;
&lt;br /&gt;
Elcano Project Main Website: [//www.elcanoproject.org]&lt;br /&gt;
&lt;br /&gt;
Visit our GitHub repositories: [https://github.com/elcano]. &lt;br /&gt;
&lt;br /&gt;
To '''edit articles''' or '''upload files''', please create an account and request editing rights from a [//www.elcanoproject.org/wiki/index.php?title=Special:ListUsers&amp;amp;group=bureaucrat member of the &amp;quot;bureaucrat&amp;quot; group].&lt;br /&gt;
&lt;br /&gt;
For editing, help visit https://www.mediawiki.org/wiki/Help:Editing_pages or https://www.mediawiki.org/wiki/Help:Formatting.&lt;br /&gt;
--------&lt;br /&gt;
[[File:Catrikes.JPG|1000px]]&lt;br /&gt;
== [[ElcanoIntro | Overview]] ==&lt;br /&gt;
The basic concept of how the Elcano Project vehicle works.&lt;br /&gt;
&lt;br /&gt;
== [[System Architecture]] ==&lt;br /&gt;
How processors connect to sensors, each other, actuators, and other hardware. Includes processor-to-processor communication protocol.&lt;br /&gt;
&lt;br /&gt;
== [[Communication | Communication (CAN Bus)]] ==&lt;br /&gt;
How processors exchange data on the vehicle and a description of data packet contents.&lt;br /&gt;
&lt;br /&gt;
== [[Power System]] ==&lt;br /&gt;
How different modules connect to the batteries or power subsystem hardware.&lt;br /&gt;
&lt;br /&gt;
== [[Drive-By-Wire]] ==&lt;br /&gt;
How the version 5 Drive-By-Wire system (aka Low-Level) uses inputs to control actuators to steer, move, and stop the vehicle.&lt;br /&gt;
&lt;br /&gt;
== [[Navigation Computer]] ==&lt;br /&gt;
How the system uses GNSS to formulate movement instructions sent to Drive-by-Wire.&lt;br /&gt;
&lt;br /&gt;
== [[RemoteControl]] ==&lt;br /&gt;
A radio communication link allows human control. There are also onboard controls. The goal is to use neither and have control come from the Nav computer.&lt;br /&gt;
&lt;br /&gt;
== [[ Simulator]] ==&lt;br /&gt;
Instead of the Drive-by-Wire board and navigation computer controlling the real trike, another Arduino routes their I/O to a virtual vehicle.&lt;br /&gt;
&lt;br /&gt;
== [[SensorsPage]] ==&lt;br /&gt;
&lt;br /&gt;
=== [[SteeringSensor]] ===&lt;br /&gt;
The front wheel angle detector. Sensors are mounted on the left steering column and/or right steering column. Sensors in use as of 2026 are analog. There are two varieties. Each is sensitive to 1/3 of a degree. The original is good for 360 degrees. Thus there are 1080 possible values. When these are spread over 3.3V, each step is 3 mV. Since the long wire from the sensor to the Arduino acts as an antenna, noise can be significant. There are two methods to reduce noise.&lt;br /&gt;
&lt;br /&gt;
1) The present analog sensor is only good for 60 degrees, which is more than the +/- 25 degree maximum turn. This makes the minimum step 18 mV.&lt;br /&gt;
&lt;br /&gt;
2) The ground signal on the sensor is sent back on either L_RTN (left steering column) or R_RTN (right steering column). Both the wires carrying the signal and the return wire are expected to pick up the same noise. A chip on the DBW board subtracts the two to get a value closer to the original.&lt;br /&gt;
&lt;br /&gt;
Noise could be eliminated by using a digital signal. A future sensor might use SPI. Jumpers can be installed to replace the sensor signals with MOSI, SCK and CS. Another digital solution is to purchase a sensor that puts its information on the CAN bus.&lt;br /&gt;
&lt;br /&gt;
=== Speedometer ===&lt;br /&gt;
&lt;br /&gt;
There are two magnetic pickups on the wheel. One goes to a standard bicycle cyclometer which shows speed and distance. The other goes to DBW where the software interprets the once per revolution click. Speed resolution is limited by the wheel circumference and cannot detect very low speeds.&lt;br /&gt;
&lt;br /&gt;
More accurate speed information could be obtained from the Hall sensor on the e-bike controller, but this has never been done.&lt;br /&gt;
&lt;br /&gt;
=== GPS ===&lt;br /&gt;
&lt;br /&gt;
The Pixhawk handles GPS. It includes inertial sensors and a Kalman filter and thus improves on raw GPS. Various sensors can be purchased. Some use Global Network Satellite Systems (GNSS) from other countries to improve on the US Global Positioning System.&lt;br /&gt;
&lt;br /&gt;
== [[ActuatorPage]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Current Board Diagrams]] ==&lt;br /&gt;
Images of Elcano Project's printed circuit boards for reference. PCB source files and schematics are maintained and stored at [//github.com/elcano].&lt;br /&gt;
&lt;br /&gt;
== Software development procedures ==&lt;br /&gt;
&lt;br /&gt;
=== [[Software repositories]] ===&lt;br /&gt;
What's in each of our GitHub repositories.&lt;br /&gt;
&lt;br /&gt;
Luke Kustra's repo: https://github.com/luke-kustra/JetHawk-LKustra.git &lt;br /&gt;
&lt;br /&gt;
Luke's contribution was experimenting with the LiDAR sensor. He was able to get the LiDAR to deactivate and display information about its surroundings, including the number of objects and their distance from the LiDAR sensor. Of course, the sensor should never deactivate when in real use; however, this deactivation is proof that the LiDAR is ready to be utilized in a larger system such as a vehicle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Henry Haight's repo: https://github.com/Autonomous-ATV-Capstone-Team-Sequence/-LIDAR&lt;br /&gt;
&lt;br /&gt;
=== [[Arduino software]] ===&lt;br /&gt;
Getting started; references; development tools. Dealing with libraries and different parameters for each vehicle.&lt;br /&gt;
&lt;br /&gt;
=== [[Using Git and GitHub]] ===&lt;br /&gt;
Practices for maintaining code and source files on Elcano Project's GitHub repositories.&lt;br /&gt;
&lt;br /&gt;
= Archived material =&lt;br /&gt;
&lt;br /&gt;
== [[Old Architecture]] ==&lt;br /&gt;
&lt;br /&gt;
== [[ATV Power System]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Low Level]] ==&lt;br /&gt;
&lt;br /&gt;
== [[High Level]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Old RemoteControl]] ==&lt;br /&gt;
&lt;br /&gt;
== [[CARLA Simulator]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Old Sensors]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Old Actuators]] ==&lt;br /&gt;
&lt;br /&gt;
== [[Board Diagrams]] ==&lt;br /&gt;
&lt;br /&gt;
==[[FilesPage | Files]] ==&lt;br /&gt;
These are media files (pictures, videos, etc.) that are part of the project but are not maintained under version control.&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=538</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=538"/>
		<updated>2026-06-06T22:22:25Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Architecture */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
&lt;br /&gt;
=== Overview ===&lt;br /&gt;
The 2026 simulator differs significantly from the original 2019–2020 CARLA-based simulator. While the original simulator focused on integrating the CARLA driving simulator with Elcano hardware through a Router Board, the 2026 effort focuses on lightweight vehicle simulation, hardware-in-the-loop testing, and future Jetson Nano integration.&lt;br /&gt;
&lt;br /&gt;
=== Major Changes ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 2019–2020 Simulator&lt;br /&gt;
! 2026 Simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| CARLA-based simulation environment&lt;br /&gt;
| Lightweight custom vehicle simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Required CARLA server and high-performance computer&lt;br /&gt;
| Runs on standard desktop hardware&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Router Board translated data between CARLA and Elcano hardware&lt;br /&gt;
| Arduino Due directly simulates vehicle sensors and responses&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| High-Level navigation executed on Arduino Due Sensor Hub&lt;br /&gt;
| Planned migration to Jetson Nano navigation computer&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Focused on CARLA sensor emulation (GPS, vehicle state, etc.)&lt;br /&gt;
| Focused on vehicle dynamics, sensor emulation, and DBW testing&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Required multiple Arduino boards and CARLA infrastructure&lt;br /&gt;
| Can operate as a standalone desktop or hardware-in-the-loop simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Primarily demonstrated communication between CARLA and Elcano subsystems&lt;br /&gt;
| Primarily validates DBW behavior and prepares for Jetson Nano integration&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Desktop Vehicle Simulator ===&lt;br /&gt;
A new Python-based simulator was developed using Pygame. New functionality includes:&lt;br /&gt;
* Real-time vehicle visualization&lt;br /&gt;
* Vehicle position tracking&lt;br /&gt;
* Heading estimation&lt;br /&gt;
* Steering angle simulation&lt;br /&gt;
* Throttle delay modeling&lt;br /&gt;
* Momentum and friction modeling&lt;br /&gt;
* Brake simulation&lt;br /&gt;
* CSV data logging&lt;br /&gt;
&lt;br /&gt;
This simulator provides a simple environment for validating vehicle motion without requiring CARLA.&lt;br /&gt;
&lt;br /&gt;
=== Arduino Due Hardware Simulator ===&lt;br /&gt;
A new Arduino Due simulator was developed to emulate physical vehicle sensors. Features include:&lt;br /&gt;
* Simulated wheel speed pulses&lt;br /&gt;
* Simulated steering sensor outputs&lt;br /&gt;
* Vehicle position estimation&lt;br /&gt;
* Throttle response modeling&lt;br /&gt;
* SD card and serial logging&lt;br /&gt;
* Integer-only arithmetic for compatibility with project requirements&lt;br /&gt;
&lt;br /&gt;
The simulator allows the Drive-By-Wire system to operate as though it were connected to a physical trike.&lt;br /&gt;
&lt;br /&gt;
=== Jetson Nano Integration Path ===&lt;br /&gt;
The original simulator architecture relied on the Sensor Hub Arduino for navigation functions. The 2026 architecture is designed to support:&lt;br /&gt;
* Jetson Nano waypoint processing&lt;br /&gt;
* CAN-based communication with Drive-By-Wire&lt;br /&gt;
* Hardware-in-the-loop testing using simulated sensor data&lt;br /&gt;
* Future replacement of Sensor Hub navigation functionality&lt;br /&gt;
&lt;br /&gt;
This allows navigation software to be developed and tested before deployment onto physical vehicles.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
The updated simulator architecture provides:&lt;br /&gt;
* Reduced hardware requirements&lt;br /&gt;
* Faster development cycles&lt;br /&gt;
* Lower risk of vehicle damage&lt;br /&gt;
* Easier debugging and testing&lt;br /&gt;
* Direct support for future Jetson Nano development&lt;br /&gt;
* Improved support for CAN-based hardware-in-the-loop testing&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
&lt;br /&gt;
The 2026 simulator effort consists of two complementary systems: a desktop vehicle simulator and an Arduino Due hardware simulator. Together, these systems provide a safe and repeatable environment for developing, testing, and validating Elcano software without requiring a physical trike.&lt;br /&gt;
&lt;br /&gt;
==== Desktop Vehicle Simulator ====&lt;br /&gt;
&lt;br /&gt;
The desktop simulator provides a graphical representation of vehicle behavior using a simplified vehicle dynamics model. Its primary purpose is to:&lt;br /&gt;
&lt;br /&gt;
* Visualize vehicle motion in real time.&lt;br /&gt;
* Demonstrate the effects of throttle, steering, and braking inputs.&lt;br /&gt;
* Validate vehicle motion algorithms before deployment to hardware.&lt;br /&gt;
* Generate logged data for analysis and debugging.&lt;br /&gt;
* Provide a lightweight alternative to CARLA for rapid software testing.&lt;br /&gt;
&lt;br /&gt;
By simulating vehicle position, heading, speed, and steering behavior, developers can quickly evaluate software changes without requiring specialized hardware.&lt;br /&gt;
&lt;br /&gt;
==== Arduino Due Hardware Simulator ====&lt;br /&gt;
&lt;br /&gt;
The Arduino Due simulator functions as a hardware-in-the-loop testing platform. Rather than visualizing the vehicle, it emulates the sensors and feedback signals that would normally be produced by a physical trike.&lt;br /&gt;
&lt;br /&gt;
Its primary purpose is to:&lt;br /&gt;
&lt;br /&gt;
* Simulate wheel speed sensor outputs.&lt;br /&gt;
* Simulate steering sensor readings.&lt;br /&gt;
* Generate vehicle position and heading estimates.&lt;br /&gt;
* Allow Drive-By-Wire (DBW) software to operate as if connected to a real vehicle.&lt;br /&gt;
* Support CAN communication testing between vehicle subsystems.&lt;br /&gt;
* Enable bench testing without risk of damage to physical hardware.&lt;br /&gt;
&lt;br /&gt;
This allows developers to observe how the Drive-By-Wire system responds to simulated vehicle behavior before testing on a physical platform.&lt;br /&gt;
&lt;br /&gt;
==== Combined Purpose ====&lt;br /&gt;
&lt;br /&gt;
Together, the desktop simulator and Arduino Due simulator reduce development risk, accelerate testing, and provide a foundation for future Jetson Nano integration. The simulator architecture enables software validation, CAN communication testing, and hardware-in-the-loop experimentation while minimizing the need for physical vehicle operation.&lt;br /&gt;
&lt;br /&gt;
== Architecture ==&lt;br /&gt;
&lt;br /&gt;
The 2026 simulator architecture consists of two independent but complementary systems: a desktop vehicle simulator and an Arduino Due hardware simulator.&lt;br /&gt;
&lt;br /&gt;
==== Desktop Vehicle Simulator ====&lt;br /&gt;
&lt;br /&gt;
The desktop simulator is implemented in Python and uses the Pygame library for graphics and user interaction.&lt;br /&gt;
&lt;br /&gt;
The simulator contains:&lt;br /&gt;
&lt;br /&gt;
* A vehicle dynamics model that estimates position, heading, speed, and steering behavior.&lt;br /&gt;
* A graphical user interface that visualizes vehicle movement in real time.&lt;br /&gt;
* Keyboard-based control inputs for throttle, steering, and braking.&lt;br /&gt;
* CSV logging for recording vehicle state information during testing.&lt;br /&gt;
&lt;br /&gt;
Vehicle state is updated at fixed intervals and displayed graphically, allowing developers to observe the effects of control inputs and verify simulator behavior.&lt;br /&gt;
&lt;br /&gt;
==== Arduino Due Hardware Simulator ====&lt;br /&gt;
&lt;br /&gt;
The hardware simulator is designed as a hardware-in-the-loop testing platform. It consists of a central CAN bus network connecting one or more Arduino Due boards that emulate vehicle subsystems.&lt;br /&gt;
&lt;br /&gt;
Typical configuration:&lt;br /&gt;
&lt;br /&gt;
* Central CAN bus communication network.&lt;br /&gt;
* One to three Arduino Due boards depending on testing requirements.&lt;br /&gt;
* Simulated sensor outputs including wheel speed and steering position.&lt;br /&gt;
* Drive-By-Wire (DBW) interface connections.&lt;br /&gt;
* Data logging through Serial or SD card storage.&lt;br /&gt;
&lt;br /&gt;
The Arduino Due simulator generates the same types of signals that would normally be produced by a physical vehicle, allowing other Elcano subsystems to operate without modification.&lt;br /&gt;
&lt;br /&gt;
==== System Integration ====&lt;br /&gt;
&lt;br /&gt;
The simulator architecture is designed to support future Jetson Nano integration.&lt;br /&gt;
&lt;br /&gt;
The intended communication path is:&lt;br /&gt;
&lt;br /&gt;
Jetson Nano → CAN Bus → Drive-By-Wire (DBW) → Simulated Vehicle&lt;br /&gt;
&lt;br /&gt;
In this configuration:&lt;br /&gt;
&lt;br /&gt;
* The Jetson Nano performs navigation and waypoint processing.&lt;br /&gt;
* CAN Bus provides communication between subsystems.&lt;br /&gt;
* Drive-By-Wire interprets vehicle control commands.&lt;br /&gt;
* The simulator emulates vehicle sensors and responses.&lt;br /&gt;
&lt;br /&gt;
This architecture allows software developed for the simulator to be transferred to the physical trike with minimal changes.&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=537</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=537"/>
		<updated>2026-06-06T02:35:05Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Purpose */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
&lt;br /&gt;
=== Overview ===&lt;br /&gt;
The 2026 simulator differs significantly from the original 2019–2020 CARLA-based simulator. While the original simulator focused on integrating the CARLA driving simulator with Elcano hardware through a Router Board, the 2026 effort focuses on lightweight vehicle simulation, hardware-in-the-loop testing, and future Jetson Nano integration.&lt;br /&gt;
&lt;br /&gt;
=== Major Changes ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 2019–2020 Simulator&lt;br /&gt;
! 2026 Simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| CARLA-based simulation environment&lt;br /&gt;
| Lightweight custom vehicle simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Required CARLA server and high-performance computer&lt;br /&gt;
| Runs on standard desktop hardware&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Router Board translated data between CARLA and Elcano hardware&lt;br /&gt;
| Arduino Due directly simulates vehicle sensors and responses&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| High-Level navigation executed on Arduino Due Sensor Hub&lt;br /&gt;
| Planned migration to Jetson Nano navigation computer&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Focused on CARLA sensor emulation (GPS, vehicle state, etc.)&lt;br /&gt;
| Focused on vehicle dynamics, sensor emulation, and DBW testing&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Required multiple Arduino boards and CARLA infrastructure&lt;br /&gt;
| Can operate as a standalone desktop or hardware-in-the-loop simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Primarily demonstrated communication between CARLA and Elcano subsystems&lt;br /&gt;
| Primarily validates DBW behavior and prepares for Jetson Nano integration&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Desktop Vehicle Simulator ===&lt;br /&gt;
A new Python-based simulator was developed using Pygame. New functionality includes:&lt;br /&gt;
* Real-time vehicle visualization&lt;br /&gt;
* Vehicle position tracking&lt;br /&gt;
* Heading estimation&lt;br /&gt;
* Steering angle simulation&lt;br /&gt;
* Throttle delay modeling&lt;br /&gt;
* Momentum and friction modeling&lt;br /&gt;
* Brake simulation&lt;br /&gt;
* CSV data logging&lt;br /&gt;
&lt;br /&gt;
This simulator provides a simple environment for validating vehicle motion without requiring CARLA.&lt;br /&gt;
&lt;br /&gt;
=== Arduino Due Hardware Simulator ===&lt;br /&gt;
A new Arduino Due simulator was developed to emulate physical vehicle sensors. Features include:&lt;br /&gt;
* Simulated wheel speed pulses&lt;br /&gt;
* Simulated steering sensor outputs&lt;br /&gt;
* Vehicle position estimation&lt;br /&gt;
* Throttle response modeling&lt;br /&gt;
* SD card and serial logging&lt;br /&gt;
* Integer-only arithmetic for compatibility with project requirements&lt;br /&gt;
&lt;br /&gt;
The simulator allows the Drive-By-Wire system to operate as though it were connected to a physical trike.&lt;br /&gt;
&lt;br /&gt;
=== Jetson Nano Integration Path ===&lt;br /&gt;
The original simulator architecture relied on the Sensor Hub Arduino for navigation functions. The 2026 architecture is designed to support:&lt;br /&gt;
* Jetson Nano waypoint processing&lt;br /&gt;
* CAN-based communication with Drive-By-Wire&lt;br /&gt;
* Hardware-in-the-loop testing using simulated sensor data&lt;br /&gt;
* Future replacement of Sensor Hub navigation functionality&lt;br /&gt;
&lt;br /&gt;
This allows navigation software to be developed and tested before deployment onto physical vehicles.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
The updated simulator architecture provides:&lt;br /&gt;
* Reduced hardware requirements&lt;br /&gt;
* Faster development cycles&lt;br /&gt;
* Lower risk of vehicle damage&lt;br /&gt;
* Easier debugging and testing&lt;br /&gt;
* Direct support for future Jetson Nano development&lt;br /&gt;
* Improved support for CAN-based hardware-in-the-loop testing&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
&lt;br /&gt;
The 2026 simulator effort consists of two complementary systems: a desktop vehicle simulator and an Arduino Due hardware simulator. Together, these systems provide a safe and repeatable environment for developing, testing, and validating Elcano software without requiring a physical trike.&lt;br /&gt;
&lt;br /&gt;
==== Desktop Vehicle Simulator ====&lt;br /&gt;
&lt;br /&gt;
The desktop simulator provides a graphical representation of vehicle behavior using a simplified vehicle dynamics model. Its primary purpose is to:&lt;br /&gt;
&lt;br /&gt;
* Visualize vehicle motion in real time.&lt;br /&gt;
* Demonstrate the effects of throttle, steering, and braking inputs.&lt;br /&gt;
* Validate vehicle motion algorithms before deployment to hardware.&lt;br /&gt;
* Generate logged data for analysis and debugging.&lt;br /&gt;
* Provide a lightweight alternative to CARLA for rapid software testing.&lt;br /&gt;
&lt;br /&gt;
By simulating vehicle position, heading, speed, and steering behavior, developers can quickly evaluate software changes without requiring specialized hardware.&lt;br /&gt;
&lt;br /&gt;
==== Arduino Due Hardware Simulator ====&lt;br /&gt;
&lt;br /&gt;
The Arduino Due simulator functions as a hardware-in-the-loop testing platform. Rather than visualizing the vehicle, it emulates the sensors and feedback signals that would normally be produced by a physical trike.&lt;br /&gt;
&lt;br /&gt;
Its primary purpose is to:&lt;br /&gt;
&lt;br /&gt;
* Simulate wheel speed sensor outputs.&lt;br /&gt;
* Simulate steering sensor readings.&lt;br /&gt;
* Generate vehicle position and heading estimates.&lt;br /&gt;
* Allow Drive-By-Wire (DBW) software to operate as if connected to a real vehicle.&lt;br /&gt;
* Support CAN communication testing between vehicle subsystems.&lt;br /&gt;
* Enable bench testing without risk of damage to physical hardware.&lt;br /&gt;
&lt;br /&gt;
This allows developers to observe how the Drive-By-Wire system responds to simulated vehicle behavior before testing on a physical platform.&lt;br /&gt;
&lt;br /&gt;
==== Combined Purpose ====&lt;br /&gt;
&lt;br /&gt;
Together, the desktop simulator and Arduino Due simulator reduce development risk, accelerate testing, and provide a foundation for future Jetson Nano integration. The simulator architecture enables software validation, CAN communication testing, and hardware-in-the-loop experimentation while minimizing the need for physical vehicle operation.&lt;br /&gt;
&lt;br /&gt;
==Architecture==&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=536</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=536"/>
		<updated>2026-06-06T02:34:43Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Purpose */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
&lt;br /&gt;
=== Overview ===&lt;br /&gt;
The 2026 simulator differs significantly from the original 2019–2020 CARLA-based simulator. While the original simulator focused on integrating the CARLA driving simulator with Elcano hardware through a Router Board, the 2026 effort focuses on lightweight vehicle simulation, hardware-in-the-loop testing, and future Jetson Nano integration.&lt;br /&gt;
&lt;br /&gt;
=== Major Changes ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 2019–2020 Simulator&lt;br /&gt;
! 2026 Simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| CARLA-based simulation environment&lt;br /&gt;
| Lightweight custom vehicle simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Required CARLA server and high-performance computer&lt;br /&gt;
| Runs on standard desktop hardware&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Router Board translated data between CARLA and Elcano hardware&lt;br /&gt;
| Arduino Due directly simulates vehicle sensors and responses&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| High-Level navigation executed on Arduino Due Sensor Hub&lt;br /&gt;
| Planned migration to Jetson Nano navigation computer&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Focused on CARLA sensor emulation (GPS, vehicle state, etc.)&lt;br /&gt;
| Focused on vehicle dynamics, sensor emulation, and DBW testing&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Required multiple Arduino boards and CARLA infrastructure&lt;br /&gt;
| Can operate as a standalone desktop or hardware-in-the-loop simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Primarily demonstrated communication between CARLA and Elcano subsystems&lt;br /&gt;
| Primarily validates DBW behavior and prepares for Jetson Nano integration&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Desktop Vehicle Simulator ===&lt;br /&gt;
A new Python-based simulator was developed using Pygame. New functionality includes:&lt;br /&gt;
* Real-time vehicle visualization&lt;br /&gt;
* Vehicle position tracking&lt;br /&gt;
* Heading estimation&lt;br /&gt;
* Steering angle simulation&lt;br /&gt;
* Throttle delay modeling&lt;br /&gt;
* Momentum and friction modeling&lt;br /&gt;
* Brake simulation&lt;br /&gt;
* CSV data logging&lt;br /&gt;
&lt;br /&gt;
This simulator provides a simple environment for validating vehicle motion without requiring CARLA.&lt;br /&gt;
&lt;br /&gt;
=== Arduino Due Hardware Simulator ===&lt;br /&gt;
A new Arduino Due simulator was developed to emulate physical vehicle sensors. Features include:&lt;br /&gt;
* Simulated wheel speed pulses&lt;br /&gt;
* Simulated steering sensor outputs&lt;br /&gt;
* Vehicle position estimation&lt;br /&gt;
* Throttle response modeling&lt;br /&gt;
* SD card and serial logging&lt;br /&gt;
* Integer-only arithmetic for compatibility with project requirements&lt;br /&gt;
&lt;br /&gt;
The simulator allows the Drive-By-Wire system to operate as though it were connected to a physical trike.&lt;br /&gt;
&lt;br /&gt;
=== Jetson Nano Integration Path ===&lt;br /&gt;
The original simulator architecture relied on the Sensor Hub Arduino for navigation functions. The 2026 architecture is designed to support:&lt;br /&gt;
* Jetson Nano waypoint processing&lt;br /&gt;
* CAN-based communication with Drive-By-Wire&lt;br /&gt;
* Hardware-in-the-loop testing using simulated sensor data&lt;br /&gt;
* Future replacement of Sensor Hub navigation functionality&lt;br /&gt;
&lt;br /&gt;
This allows navigation software to be developed and tested before deployment onto physical vehicles.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
The updated simulator architecture provides:&lt;br /&gt;
* Reduced hardware requirements&lt;br /&gt;
* Faster development cycles&lt;br /&gt;
* Lower risk of vehicle damage&lt;br /&gt;
* Easier debugging and testing&lt;br /&gt;
* Direct support for future Jetson Nano development&lt;br /&gt;
* Improved support for CAN-based hardware-in-the-loop testing&lt;br /&gt;
&lt;br /&gt;
=== Purpose ===&lt;br /&gt;
&lt;br /&gt;
The 2026 simulator effort consists of two complementary systems: a desktop vehicle simulator and an Arduino Due hardware simulator. Together, these systems provide a safe and repeatable environment for developing, testing, and validating Elcano software without requiring a physical trike.&lt;br /&gt;
&lt;br /&gt;
==== Desktop Vehicle Simulator ====&lt;br /&gt;
&lt;br /&gt;
The desktop simulator provides a graphical representation of vehicle behavior using a simplified vehicle dynamics model. Its primary purpose is to:&lt;br /&gt;
&lt;br /&gt;
* Visualize vehicle motion in real time.&lt;br /&gt;
* Demonstrate the effects of throttle, steering, and braking inputs.&lt;br /&gt;
* Validate vehicle motion algorithms before deployment to hardware.&lt;br /&gt;
* Generate logged data for analysis and debugging.&lt;br /&gt;
* Provide a lightweight alternative to CARLA for rapid software testing.&lt;br /&gt;
&lt;br /&gt;
By simulating vehicle position, heading, speed, and steering behavior, developers can quickly evaluate software changes without requiring specialized hardware.&lt;br /&gt;
&lt;br /&gt;
==== Arduino Due Hardware Simulator ====&lt;br /&gt;
&lt;br /&gt;
The Arduino Due simulator functions as a hardware-in-the-loop testing platform. Rather than visualizing the vehicle, it emulates the sensors and feedback signals that would normally be produced by a physical trike.&lt;br /&gt;
&lt;br /&gt;
Its primary purpose is to:&lt;br /&gt;
&lt;br /&gt;
* Simulate wheel speed sensor outputs.&lt;br /&gt;
* Simulate steering sensor readings.&lt;br /&gt;
* Generate vehicle position and heading estimates.&lt;br /&gt;
* Allow Drive-By-Wire (DBW) software to operate as if connected to a real vehicle.&lt;br /&gt;
* Support CAN communication testing between vehicle subsystems.&lt;br /&gt;
* Enable bench testing without risk of damage to physical hardware.&lt;br /&gt;
&lt;br /&gt;
This allows developers to observe how the Drive-By-Wire system responds to simulated vehicle behavior before testing on a physical platform.&lt;br /&gt;
&lt;br /&gt;
==== Combined Purpose ====&lt;br /&gt;
&lt;br /&gt;
Together, the desktop simulator and Arduino Due simulator reduce development risk, accelerate testing, and provide a foundation for future Jetson Nano integration. The simulator architecture enables software validation, CAN communication testing, and hardware-in-the-loop experimentation while minimizing the need for physical vehicle operation.&lt;br /&gt;
&lt;br /&gt;
==Architecture==&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=535</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=535"/>
		<updated>2026-06-05T22:54:30Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
&lt;br /&gt;
=== Overview ===&lt;br /&gt;
The 2026 simulator differs significantly from the original 2019–2020 CARLA-based simulator. While the original simulator focused on integrating the CARLA driving simulator with Elcano hardware through a Router Board, the 2026 effort focuses on lightweight vehicle simulation, hardware-in-the-loop testing, and future Jetson Nano integration.&lt;br /&gt;
&lt;br /&gt;
=== Major Changes ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 2019–2020 Simulator&lt;br /&gt;
! 2026 Simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| CARLA-based simulation environment&lt;br /&gt;
| Lightweight custom vehicle simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Required CARLA server and high-performance computer&lt;br /&gt;
| Runs on standard desktop hardware&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Router Board translated data between CARLA and Elcano hardware&lt;br /&gt;
| Arduino Due directly simulates vehicle sensors and responses&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| High-Level navigation executed on Arduino Due Sensor Hub&lt;br /&gt;
| Planned migration to Jetson Nano navigation computer&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Focused on CARLA sensor emulation (GPS, vehicle state, etc.)&lt;br /&gt;
| Focused on vehicle dynamics, sensor emulation, and DBW testing&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Required multiple Arduino boards and CARLA infrastructure&lt;br /&gt;
| Can operate as a standalone desktop or hardware-in-the-loop simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Primarily demonstrated communication between CARLA and Elcano subsystems&lt;br /&gt;
| Primarily validates DBW behavior and prepares for Jetson Nano integration&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Desktop Vehicle Simulator ===&lt;br /&gt;
A new Python-based simulator was developed using Pygame. New functionality includes:&lt;br /&gt;
* Real-time vehicle visualization&lt;br /&gt;
* Vehicle position tracking&lt;br /&gt;
* Heading estimation&lt;br /&gt;
* Steering angle simulation&lt;br /&gt;
* Throttle delay modeling&lt;br /&gt;
* Momentum and friction modeling&lt;br /&gt;
* Brake simulation&lt;br /&gt;
* CSV data logging&lt;br /&gt;
&lt;br /&gt;
This simulator provides a simple environment for validating vehicle motion without requiring CARLA.&lt;br /&gt;
&lt;br /&gt;
=== Arduino Due Hardware Simulator ===&lt;br /&gt;
A new Arduino Due simulator was developed to emulate physical vehicle sensors. Features include:&lt;br /&gt;
* Simulated wheel speed pulses&lt;br /&gt;
* Simulated steering sensor outputs&lt;br /&gt;
* Vehicle position estimation&lt;br /&gt;
* Throttle response modeling&lt;br /&gt;
* SD card and serial logging&lt;br /&gt;
* Integer-only arithmetic for compatibility with project requirements&lt;br /&gt;
&lt;br /&gt;
The simulator allows the Drive-By-Wire system to operate as though it were connected to a physical trike.&lt;br /&gt;
&lt;br /&gt;
=== Jetson Nano Integration Path ===&lt;br /&gt;
The original simulator architecture relied on the Sensor Hub Arduino for navigation functions. The 2026 architecture is designed to support:&lt;br /&gt;
* Jetson Nano waypoint processing&lt;br /&gt;
* CAN-based communication with Drive-By-Wire&lt;br /&gt;
* Hardware-in-the-loop testing using simulated sensor data&lt;br /&gt;
* Future replacement of Sensor Hub navigation functionality&lt;br /&gt;
&lt;br /&gt;
This allows navigation software to be developed and tested before deployment onto physical vehicles.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
The updated simulator architecture provides:&lt;br /&gt;
* Reduced hardware requirements&lt;br /&gt;
* Faster development cycles&lt;br /&gt;
* Lower risk of vehicle damage&lt;br /&gt;
* Easier debugging and testing&lt;br /&gt;
* Direct support for future Jetson Nano development&lt;br /&gt;
* Improved support for CAN-based hardware-in-the-loop testing&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
&lt;br /&gt;
==Architecture==&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=534</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=534"/>
		<updated>2026-06-05T22:44:59Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
&lt;br /&gt;
=== Overview ===&lt;br /&gt;
The 2026 simulator differs significantly from the original 2019–2020 [Elcano Project Wiki](https://www.elcanoproject.org/wiki/Simulator) CARLA-based simulator. While the original simulator focused on integrating the CARLA driving simulator with Elcano hardware through a Router Board, the 2026 effort focuses on lightweight vehicle simulation, hardware-in-the-loop testing, and future Jetson Nano integration.&lt;br /&gt;
&lt;br /&gt;
=== Major Changes ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 2019–2020 Simulator&lt;br /&gt;
! 2026 Simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| CARLA-based simulation environment&lt;br /&gt;
| Lightweight custom vehicle simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Required CARLA server and high-performance computer&lt;br /&gt;
| Runs on standard desktop hardware&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Router Board translated data between CARLA and Elcano hardware&lt;br /&gt;
| Arduino Due directly simulates vehicle sensors and responses&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| High-Level navigation executed on Arduino Due Sensor Hub&lt;br /&gt;
| Planned migration to Jetson Nano navigation computer&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Focused on CARLA sensor emulation (GPS, vehicle state, etc.)&lt;br /&gt;
| Focused on vehicle dynamics, sensor emulation, and DBW testing&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Required multiple Arduino boards and CARLA infrastructure&lt;br /&gt;
| Can operate as a standalone desktop or hardware-in-the-loop simulator&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| Primarily demonstrated communication between CARLA and Elcano subsystems&lt;br /&gt;
| Primarily validates DBW behavior and prepares for Jetson Nano integration&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Desktop Vehicle Simulator ===&lt;br /&gt;
A new Python-based simulator was developed using Pygame. New functionality includes:&lt;br /&gt;
* Real-time vehicle visualization&lt;br /&gt;
* Vehicle position tracking&lt;br /&gt;
* Heading estimation&lt;br /&gt;
* Steering angle simulation&lt;br /&gt;
* Throttle delay modeling&lt;br /&gt;
* Momentum and friction modeling&lt;br /&gt;
* Brake simulation&lt;br /&gt;
* CSV data logging&lt;br /&gt;
&lt;br /&gt;
This simulator provides a simple environment for validating vehicle motion without requiring CARLA.&lt;br /&gt;
&lt;br /&gt;
=== Arduino Due Hardware Simulator ===&lt;br /&gt;
A new Arduino Due simulator was developed to emulate physical vehicle sensors. Features include:&lt;br /&gt;
* Simulated wheel speed pulses&lt;br /&gt;
* Simulated steering sensor outputs&lt;br /&gt;
* Vehicle position estimation&lt;br /&gt;
* Throttle response modeling&lt;br /&gt;
* SD card and serial logging&lt;br /&gt;
* Integer-only arithmetic for compatibility with project requirements&lt;br /&gt;
&lt;br /&gt;
The simulator allows the Drive-By-Wire system to operate as though it were connected to a physical trike.&lt;br /&gt;
&lt;br /&gt;
=== Jetson Nano Integration Path ===&lt;br /&gt;
The original simulator architecture relied on the Sensor Hub Arduino for navigation functions. The 2026 architecture is designed to support:&lt;br /&gt;
* Jetson Nano waypoint processing&lt;br /&gt;
* CAN-based communication with Drive-By-Wire&lt;br /&gt;
* Hardware-in-the-loop testing using simulated sensor data&lt;br /&gt;
* Future replacement of Sensor Hub navigation functionality&lt;br /&gt;
&lt;br /&gt;
This allows navigation software to be developed and tested before deployment onto physical vehicles.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
The updated simulator architecture provides:&lt;br /&gt;
* Reduced hardware requirements&lt;br /&gt;
* Faster development cycles&lt;br /&gt;
* Lower risk of vehicle damage&lt;br /&gt;
* Easier debugging and testing&lt;br /&gt;
* Direct support for future Jetson Nano development&lt;br /&gt;
* Improved support for CAN-based hardware-in-the-loop testing&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
&lt;br /&gt;
==Architecture==&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=533</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=533"/>
		<updated>2026-06-05T22:43:46Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
== Changes ==&lt;br /&gt;
&lt;br /&gt;
=== Overview ===&lt;br /&gt;
&lt;br /&gt;
The 2026 simulator differs significantly from the original 2019–2020 CARLA-based simulator. While the original simulator focused on integrating the CARLA driving simulator with Elcano hardware through a Router Board, the 2026 effort focuses on lightweight vehicle simulation, hardware-in-the-loop testing, and future Jetson Nano integration.&lt;br /&gt;
&lt;br /&gt;
=== Major Changes ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 2019–2020 Simulator&lt;br /&gt;
&lt;br /&gt;
| ! 2026 Simulator                                                          |&lt;br /&gt;
| ------------------------------------------------------------------------- |&lt;br /&gt;
| CARLA-based simulation environment                                        |&lt;br /&gt;
| Lightweight custom vehicle simulator                                      |&lt;br /&gt;
| -                                                                         |&lt;br /&gt;
| Required CARLA server and high-performance computer                       |&lt;br /&gt;
| Runs on standard desktop hardware                                         |&lt;br /&gt;
| -                                                                         |&lt;br /&gt;
| Router Board translated data between CARLA and Elcano hardware            |&lt;br /&gt;
| Arduino Due directly simulates vehicle sensors and responses              |&lt;br /&gt;
| -                                                                         |&lt;br /&gt;
| High-Level navigation executed on Arduino Due Sensor Hub                  |&lt;br /&gt;
| Planned migration to Jetson Nano navigation computer                      |&lt;br /&gt;
| -                                                                         |&lt;br /&gt;
| Focused on CARLA sensor emulation (GPS, vehicle state, etc.)              |&lt;br /&gt;
| Focused on vehicle dynamics, sensor emulation, and DBW testing            |&lt;br /&gt;
| -                                                                         |&lt;br /&gt;
| Required multiple Arduino boards and CARLA infrastructure                 |&lt;br /&gt;
| Can operate as a standalone desktop or hardware-in-the-loop simulator     |&lt;br /&gt;
| -                                                                         |&lt;br /&gt;
| Primarily demonstrated communication between CARLA and Elcano subsystems  |&lt;br /&gt;
| Primarily validates DBW behavior and prepares for Jetson Nano integration |&lt;br /&gt;
| }                                                                         |&lt;br /&gt;
&lt;br /&gt;
=== Desktop Vehicle Simulator ===&lt;br /&gt;
&lt;br /&gt;
A new Python-based simulator was developed using Pygame.&lt;br /&gt;
&lt;br /&gt;
New functionality includes:&lt;br /&gt;
&lt;br /&gt;
* Real-time vehicle visualization&lt;br /&gt;
* Vehicle position tracking&lt;br /&gt;
* Heading estimation&lt;br /&gt;
* Steering angle simulation&lt;br /&gt;
* Throttle delay modeling&lt;br /&gt;
* Momentum and friction modeling&lt;br /&gt;
* Brake simulation&lt;br /&gt;
* CSV data logging&lt;br /&gt;
&lt;br /&gt;
This simulator provides a simple environment for validating vehicle motion without requiring CARLA.&lt;br /&gt;
&lt;br /&gt;
=== Arduino Due Hardware Simulator ===&lt;br /&gt;
&lt;br /&gt;
A new Arduino Due simulator was developed to emulate physical vehicle sensors.&lt;br /&gt;
&lt;br /&gt;
Features include:&lt;br /&gt;
&lt;br /&gt;
* Simulated wheel speed pulses&lt;br /&gt;
* Simulated steering sensor outputs&lt;br /&gt;
* Vehicle position estimation&lt;br /&gt;
* Throttle response modeling&lt;br /&gt;
* SD card and serial logging&lt;br /&gt;
* Integer-only arithmetic for compatibility with project requirements&lt;br /&gt;
&lt;br /&gt;
The simulator allows the Drive-By-Wire system to operate as though it were connected to a physical trike.&lt;br /&gt;
&lt;br /&gt;
=== Jetson Nano Integration Path ===&lt;br /&gt;
&lt;br /&gt;
The original simulator architecture relied on the Sensor Hub Arduino for navigation functions.&lt;br /&gt;
&lt;br /&gt;
The 2026 architecture is designed to support:&lt;br /&gt;
&lt;br /&gt;
* Jetson Nano waypoint processing&lt;br /&gt;
* CAN-based communication with Drive-By-Wire&lt;br /&gt;
* Hardware-in-the-loop testing using simulated sensor data&lt;br /&gt;
* Future replacement of Sensor Hub navigation functionality&lt;br /&gt;
&lt;br /&gt;
This allows navigation software to be developed and tested before deployment onto physical vehicles.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
The updated simulator architecture provides:&lt;br /&gt;
&lt;br /&gt;
* Reduced hardware requirements&lt;br /&gt;
* Faster development cycles&lt;br /&gt;
* Lower risk of vehicle damage&lt;br /&gt;
* Easier debugging and testing&lt;br /&gt;
* Direct support for future Jetson Nano development&lt;br /&gt;
* Improved support for CAN-based hardware-in-the-loop testing&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
&lt;br /&gt;
==Architecture==&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=532</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=532"/>
		<updated>2026-06-05T22:42:37Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
==Changes==&lt;br /&gt;
&lt;br /&gt;
'''Overview'''&lt;br /&gt;
&lt;br /&gt;
The 2026 simulator differs significantly from the original 2019–2020 CARLA-based simulator. While the original simulator focused on integrating the CARLA driving simulator with Elcano hardware through a Router Board, the 2026 effort focuses on lightweight vehicle simulation, hardware-in-the-loop testing, and future Jetson Nano integration.&lt;br /&gt;
&lt;br /&gt;
'''Major Changes'''&lt;br /&gt;
&lt;br /&gt;
2019–2020 Simulator	                                                        2026 Simulator&lt;br /&gt;
CARLA-based simulation environment	                                        Lightweight custom vehicle simulator&lt;br /&gt;
Required CARLA server and high-performance computer	                        Runs on standard desktop hardware&lt;br /&gt;
Router Board translated data between CARLA and Elcano hardware	                Arduino Due directly simulates vehicle sensors and responses&lt;br /&gt;
High-Level navigation executed on Arduino Due Sensor Hub	                Planned migration to Jetson Nano navigation computer&lt;br /&gt;
Focused on CARLA sensor emulation (GPS, vehicle state, etc.)	                Focused on vehicle dynamics, sensor emulation, and DBW testing&lt;br /&gt;
Required multiple Arduino boards and CARLA infrastructure	                Can operate as a standalone desktop or hardware-in-the-loop simulator&lt;br /&gt;
Primarily demonstrated communication between CARLA and Elcano subsystems	Primarily validates DBW behavior and prepares for Jetson Nano integration&lt;br /&gt;
Desktop Vehicle Simulator&lt;br /&gt;
&lt;br /&gt;
A new Python-based simulator was developed using Pygame.&lt;br /&gt;
&lt;br /&gt;
New functionality includes:&lt;br /&gt;
&lt;br /&gt;
Real-time vehicle visualization&lt;br /&gt;
Vehicle position tracking&lt;br /&gt;
Heading estimation&lt;br /&gt;
Steering angle simulation&lt;br /&gt;
Throttle delay modeling&lt;br /&gt;
Momentum and friction modeling&lt;br /&gt;
Brake simulation&lt;br /&gt;
CSV data logging&lt;br /&gt;
&lt;br /&gt;
This simulator provides a simple environment for validating vehicle motion without requiring CARLA.&lt;br /&gt;
&lt;br /&gt;
Arduino Due Hardware Simulator&lt;br /&gt;
&lt;br /&gt;
A new Arduino Due simulator was developed to emulate physical vehicle sensors.&lt;br /&gt;
&lt;br /&gt;
Features include:&lt;br /&gt;
&lt;br /&gt;
Simulated wheel speed pulses&lt;br /&gt;
Simulated steering sensor outputs&lt;br /&gt;
Vehicle position estimation&lt;br /&gt;
Throttle response modeling&lt;br /&gt;
SD card and serial logging&lt;br /&gt;
Integer-only arithmetic for compatibility with project requirements&lt;br /&gt;
&lt;br /&gt;
The simulator allows the Drive-By-Wire system to operate as though it were connected to a physical trike.&lt;br /&gt;
&lt;br /&gt;
Jetson Nano Integration Path&lt;br /&gt;
&lt;br /&gt;
The original simulator architecture relied on the Sensor Hub Arduino for navigation functions.&lt;br /&gt;
&lt;br /&gt;
The 2026 architecture is designed to support:&lt;br /&gt;
&lt;br /&gt;
Jetson Nano waypoint processing&lt;br /&gt;
CAN-based communication with Drive-By-Wire&lt;br /&gt;
Hardware-in-the-loop testing using simulated sensor data&lt;br /&gt;
Future replacement of Sensor Hub navigation functionality&lt;br /&gt;
&lt;br /&gt;
This allows navigation software to be developed and tested before deployment onto physical vehicles.&lt;br /&gt;
&lt;br /&gt;
'''Benefits'''&lt;br /&gt;
&lt;br /&gt;
The updated simulator architecture provides:&lt;br /&gt;
&lt;br /&gt;
Reduced hardware requirements&lt;br /&gt;
Faster development cycles&lt;br /&gt;
Lower risk of vehicle damage&lt;br /&gt;
Easier debugging and testing&lt;br /&gt;
Direct support for future Jetson Nano development&lt;br /&gt;
Improved support for CAN-based hardware-in-the-loop testing&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
&lt;br /&gt;
==Architecture==&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=531</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=531"/>
		<updated>2026-06-05T22:41:59Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
==Changes==&lt;br /&gt;
&lt;br /&gt;
'''Overview'''&lt;br /&gt;
&lt;br /&gt;
The 2026 simulator differs significantly from the original 2019–2020 CARLA-based simulator. While the original simulator focused on integrating the CARLA driving simulator with Elcano hardware through a Router Board, the 2026 effort focuses on lightweight vehicle simulation, hardware-in-the-loop testing, and future Jetson Nano integration.&lt;br /&gt;
&lt;br /&gt;
'''Major Changes'''&lt;br /&gt;
&lt;br /&gt;
2019–2020 Simulator	                                                        2026 Simulator&lt;br /&gt;
CARLA-based simulation environment	                                        Lightweight custom vehicle simulator&lt;br /&gt;
Required CARLA server and high-performance computer	                        Runs on standard desktop hardware&lt;br /&gt;
Router Board translated data between CARLA and Elcano hardware	                Arduino Due directly simulates vehicle sensors and responses&lt;br /&gt;
High-Level navigation executed on Arduino Due Sensor Hub	                Planned migration to Jetson Nano navigation computer&lt;br /&gt;
Focused on CARLA sensor emulation (GPS, vehicle state, etc.)	                Focused on vehicle dynamics, sensor emulation, and DBW testing&lt;br /&gt;
Required multiple Arduino boards and CARLA infrastructure	                Can operate as a standalone desktop or hardware-in-the-loop simulator&lt;br /&gt;
Primarily demonstrated communication between CARLA and Elcano subsystems	Primarily validates DBW behavior and prepares for Jetson Nano integration&lt;br /&gt;
Desktop Vehicle Simulator&lt;br /&gt;
&lt;br /&gt;
A new Python-based simulator was developed using Pygame.&lt;br /&gt;
&lt;br /&gt;
New functionality includes:&lt;br /&gt;
&lt;br /&gt;
Real-time vehicle visualization&lt;br /&gt;
Vehicle position tracking&lt;br /&gt;
Heading estimation&lt;br /&gt;
Steering angle simulation&lt;br /&gt;
Throttle delay modeling&lt;br /&gt;
Momentum and friction modeling&lt;br /&gt;
Brake simulation&lt;br /&gt;
CSV data logging&lt;br /&gt;
&lt;br /&gt;
This simulator provides a simple environment for validating vehicle motion without requiring CARLA.&lt;br /&gt;
&lt;br /&gt;
Arduino Due Hardware Simulator&lt;br /&gt;
&lt;br /&gt;
A new Arduino Due simulator was developed to emulate physical vehicle sensors.&lt;br /&gt;
&lt;br /&gt;
Features include:&lt;br /&gt;
&lt;br /&gt;
Simulated wheel speed pulses&lt;br /&gt;
Simulated steering sensor outputs&lt;br /&gt;
Vehicle position estimation&lt;br /&gt;
Throttle response modeling&lt;br /&gt;
SD card and serial logging&lt;br /&gt;
Integer-only arithmetic for compatibility with project requirements&lt;br /&gt;
&lt;br /&gt;
The simulator allows the Drive-By-Wire system to operate as though it were connected to a physical trike.&lt;br /&gt;
&lt;br /&gt;
Jetson Nano Integration Path&lt;br /&gt;
&lt;br /&gt;
The original simulator architecture relied on the Sensor Hub Arduino for navigation functions.&lt;br /&gt;
&lt;br /&gt;
The 2026 architecture is designed to support:&lt;br /&gt;
&lt;br /&gt;
Jetson Nano waypoint processing&lt;br /&gt;
CAN-based communication with Drive-By-Wire&lt;br /&gt;
Hardware-in-the-loop testing using simulated sensor data&lt;br /&gt;
Future replacement of Sensor Hub navigation functionality&lt;br /&gt;
&lt;br /&gt;
This allows navigation software to be developed and tested before deployment onto physical vehicles.&lt;br /&gt;
&lt;br /&gt;
Benefits&lt;br /&gt;
&lt;br /&gt;
The updated simulator architecture provides:&lt;br /&gt;
&lt;br /&gt;
Reduced hardware requirements&lt;br /&gt;
Faster development cycles&lt;br /&gt;
Lower risk of vehicle damage&lt;br /&gt;
Easier debugging and testing&lt;br /&gt;
Direct support for future Jetson Nano development&lt;br /&gt;
Improved support for CAN-based hardware-in-the-loop testing&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
&lt;br /&gt;
==Architecture==&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=530</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=530"/>
		<updated>2026-06-05T22:40:41Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
==Changes==&lt;br /&gt;
Overview&lt;br /&gt;
&lt;br /&gt;
The 2026 simulator differs significantly from the original 2019–2020 CARLA-based simulator. While the original simulator focused on integrating the CARLA driving simulator with Elcano hardware through a Router Board, the 2026 effort focuses on lightweight vehicle simulation, hardware-in-the-loop testing, and future Jetson Nano integration.&lt;br /&gt;
&lt;br /&gt;
Major Changes&lt;br /&gt;
2019–2020 Simulator	2026 Simulator&lt;br /&gt;
CARLA-based simulation environment	Lightweight custom vehicle simulator&lt;br /&gt;
Required CARLA server and high-performance computer	Runs on standard desktop hardware&lt;br /&gt;
Router Board translated data between CARLA and Elcano hardware	Arduino Due directly simulates vehicle sensors and responses&lt;br /&gt;
High-Level navigation executed on Arduino Due Sensor Hub	Planned migration to Jetson Nano navigation computer&lt;br /&gt;
Focused on CARLA sensor emulation (GPS, vehicle state, etc.)	Focused on vehicle dynamics, sensor emulation, and DBW testing&lt;br /&gt;
Required multiple Arduino boards and CARLA infrastructure	Can operate as a standalone desktop or hardware-in-the-loop simulator&lt;br /&gt;
Primarily demonstrated communication between CARLA and Elcano subsystems	Primarily validates DBW behavior and prepares for Jetson Nano integration&lt;br /&gt;
Desktop Vehicle Simulator&lt;br /&gt;
&lt;br /&gt;
A new Python-based simulator was developed using Pygame.&lt;br /&gt;
&lt;br /&gt;
New functionality includes:&lt;br /&gt;
&lt;br /&gt;
Real-time vehicle visualization&lt;br /&gt;
Vehicle position tracking&lt;br /&gt;
Heading estimation&lt;br /&gt;
Steering angle simulation&lt;br /&gt;
Throttle delay modeling&lt;br /&gt;
Momentum and friction modeling&lt;br /&gt;
Brake simulation&lt;br /&gt;
CSV data logging&lt;br /&gt;
&lt;br /&gt;
This simulator provides a simple environment for validating vehicle motion without requiring CARLA.&lt;br /&gt;
&lt;br /&gt;
Arduino Due Hardware Simulator&lt;br /&gt;
&lt;br /&gt;
A new Arduino Due simulator was developed to emulate physical vehicle sensors.&lt;br /&gt;
&lt;br /&gt;
Features include:&lt;br /&gt;
&lt;br /&gt;
Simulated wheel speed pulses&lt;br /&gt;
Simulated steering sensor outputs&lt;br /&gt;
Vehicle position estimation&lt;br /&gt;
Throttle response modeling&lt;br /&gt;
SD card and serial logging&lt;br /&gt;
Integer-only arithmetic for compatibility with project requirements&lt;br /&gt;
&lt;br /&gt;
The simulator allows the Drive-By-Wire system to operate as though it were connected to a physical trike.&lt;br /&gt;
&lt;br /&gt;
Jetson Nano Integration Path&lt;br /&gt;
&lt;br /&gt;
The original simulator architecture relied on the Sensor Hub Arduino for navigation functions.&lt;br /&gt;
&lt;br /&gt;
The 2026 architecture is designed to support:&lt;br /&gt;
&lt;br /&gt;
Jetson Nano waypoint processing&lt;br /&gt;
CAN-based communication with Drive-By-Wire&lt;br /&gt;
Hardware-in-the-loop testing using simulated sensor data&lt;br /&gt;
Future replacement of Sensor Hub navigation functionality&lt;br /&gt;
&lt;br /&gt;
This allows navigation software to be developed and tested before deployment onto physical vehicles.&lt;br /&gt;
&lt;br /&gt;
Benefits&lt;br /&gt;
&lt;br /&gt;
The updated simulator architecture provides:&lt;br /&gt;
&lt;br /&gt;
Reduced hardware requirements&lt;br /&gt;
Faster development cycles&lt;br /&gt;
Lower risk of vehicle damage&lt;br /&gt;
Easier debugging and testing&lt;br /&gt;
Direct support for future Jetson Nano development&lt;br /&gt;
Improved support for CAN-based hardware-in-the-loop testing&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
&lt;br /&gt;
==Architecture==&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=529</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=529"/>
		<updated>2026-06-05T22:38:07Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* 2026 Simulator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
==Changes==&lt;br /&gt;
&lt;br /&gt;
==Purpose==&lt;br /&gt;
&lt;br /&gt;
==Architecture==&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=528</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=528"/>
		<updated>2026-06-05T22:29:27Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Architecture */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
=='''Changes'''==&lt;br /&gt;
&lt;br /&gt;
=='''Purpose'''==&lt;br /&gt;
&lt;br /&gt;
=='''Architecture'''==&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=527</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=527"/>
		<updated>2026-06-05T22:29:16Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* Purpose */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
=='''Changes'''==&lt;br /&gt;
&lt;br /&gt;
=='''Purpose'''==&lt;br /&gt;
&lt;br /&gt;
==='''Architecture'''===&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=526</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=526"/>
		<updated>2026-06-05T22:29:07Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* 2026 Simulator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
=='''Changes'''==&lt;br /&gt;
&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
&lt;br /&gt;
==='''Architecture'''===&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=525</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=525"/>
		<updated>2026-06-05T22:28:42Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* 2026 Simulator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
==='''Changes'''===&lt;br /&gt;
&lt;br /&gt;
==='''Purpose'''===&lt;br /&gt;
&lt;br /&gt;
==='''Architecture'''===&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=524</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=524"/>
		<updated>2026-06-05T22:28:15Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* 2026 Simulator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
==='''Changes'''===&lt;br /&gt;
&lt;br /&gt;
Purpose&lt;br /&gt;
&lt;br /&gt;
Architecture&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=523</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=523"/>
		<updated>2026-06-05T22:27:43Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* 2026 Simulator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
'''Changes'''&lt;br /&gt;
&lt;br /&gt;
Purpose&lt;br /&gt;
&lt;br /&gt;
Architecture&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
	<entry>
		<id>https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=522</id>
		<title>Simulator</title>
		<link rel="alternate" type="text/html" href="https://www.elcanoproject.org/wiki/index.php?title=Simulator&amp;diff=522"/>
		<updated>2026-06-05T22:27:20Z</updated>

		<summary type="html">&lt;p&gt;ShivBhatt: /* 2026 Simulator */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Elcano Carla Simulation External Specification =&lt;br /&gt;
&lt;br /&gt;
[http://carla.org/ CARLA] is an open-source driving simulator. During 2019-20 students develop3e a  go-between circuit board to transfer data between CARLA simulation and the sensor slots of the Elcano hardware. The CARLA software allows users to emulate trike parameters under controlled conditions within a virtual world, providing an efficient system for testing sensor behavior, design implementation, and bench-marking overall vehicle progress. The CARLA software can simulate a variety of road conditions such as traffic patterns, inclines, and weather as well as provide users control over vehicle parameters including weight, engine power, and aerodynamic properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An Arduino Due serves as a router to transfer data from vehicle systems to CARLA under a variety of test conditions, enabling the software to replicate responses and return sensor data to be reevaluated for accuracy. The [https://micro-av.com/store/ols/products/carla-bridge CARLA Micro-AV Bridge] includes the Router, Sensor Hub and Drive-by-wire Arduinos. It permits testing the Elcano trike software, including camera, sonar, throttle, steering and brake systems. Simulation allows users to immediately see the results of adjustments to vehicle parameters and highlight physical aspects of the trike within the virtual environment. This project enables users to efficiently implement improvements and track the immediate effects of design changes without spending the time and resources it would take to transport or operate the trike in real world test scenarios. It enables developers to improve the software without needing to invest in a vehicle.&lt;br /&gt;
&lt;br /&gt;
[[File:Architecture_CAN_Sim_7_7_20.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose ==&lt;br /&gt;
The following is a generalized list of the desired functionality of the simulator.&lt;br /&gt;
* Simulate data for all sensors associated with Elcano Trike.&lt;br /&gt;
* Simulate Elcano behavior to throttle, brake, and steering.&lt;br /&gt;
* Have low and high-level boards function normally with the simulated sensor data without knowing data is being simulated.&lt;br /&gt;
* Allow low and high-level board interaction to be tested.&lt;br /&gt;
* Allow autonomous driving to be tested.&lt;br /&gt;
&lt;br /&gt;
== Components ==&lt;br /&gt;
''' Simulation''' &lt;br /&gt;
Code to be executed by a computer that has access to a Carla server, either locally, or through a network.  Controls all objects in Carla simulation.  Retrieves sensor data from Carla, and sends router board.  Also retrieves actuation instructions from the router board and sends to Carla.&lt;br /&gt;
&lt;br /&gt;
'''Sensor Hub [aka High Level] Processor''' &lt;br /&gt;
The same code is used for the virtual or physical vehicle, sending and receiving messages over the CAN Bus. The CARLA Bridge replaces sensor data that would normally come from instruments.&lt;br /&gt;
&lt;br /&gt;
'''Drive-by-wire [aks C2 LowLevel] Processor''' &lt;br /&gt;
Current Elcano Drive-by-wirel code. Actuator data is routed to CARLA.&lt;br /&gt;
&lt;br /&gt;
'''[https://micro-av.com/store/ols/products/carla-bridge Router Board]''' &lt;br /&gt;
Code is executed on the Arduino Due that functions as the router board.  Routes commands from Drive-by-wire to Carla via Python scripts.  Also routes sensor data from Carla to Sensor Hub processor.&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020A.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
[[File:RouterBoard2020B.jpg|800px|]]&lt;br /&gt;
&lt;br /&gt;
==  Current Functionality of Simulation ==&lt;br /&gt;
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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Demo Guide (How to Set-Up) ==&lt;br /&gt;
The following is a guide to set up the Elcano simulator.&lt;br /&gt;
&lt;br /&gt;
===''' Materials '''===&lt;br /&gt;
* 1 Assembled Elcano Simulator Printed Circuit Board (PCB)&lt;br /&gt;
* 2 Arduino Due&lt;br /&gt;
* 1 Arduino Mega 2560&lt;br /&gt;
* 1 Box (200 x 150 x 70 mm)&lt;br /&gt;
* 2 Voltage Level Converter (included w/Simulator PCB)&lt;br /&gt;
* 1 SD Card (w/map files)&lt;br /&gt;
* 1 USB AB Cable (for Arduino Mega)&lt;br /&gt;
* 1 USB Micro Cable (for Arduino Due)&lt;br /&gt;
* 1 computer capable of running Carla&lt;br /&gt;
&lt;br /&gt;
===''' Pre-installation '''===&lt;br /&gt;
Use the following instructions to install the required software to run the simulation.&lt;br /&gt;
&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Python '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#* Install Python 3 (if not installed already)&lt;br /&gt;
#::-experiments used version 3.7.6&lt;br /&gt;
#* In a terminal, move to .\Simulation\&lt;br /&gt;
#* Run the command “pip3 install -r requirements.txt” to have pip install all the required python libraries for the simulator&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' CARLA '''''&amp;lt;/u&amp;gt;&lt;br /&gt;
#*Download [https://carla.org/2020/03/09/release-0.9.8/ CARLA (0.9.8)]&lt;br /&gt;
#*CARLA requirements:&amp;lt;br /&amp;gt;[[File:Carla_Requirements.jpg|500px|]]&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Arduino Libraries '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;Download these Arduino libraries prior to running the simulation:&lt;br /&gt;
#* [https://github.com/Seeed-Studio/CAN_BUS_Shield CAN_BUS_SHIELD by Seeed-Studio]&lt;br /&gt;
#* [https://github.com/br3ttb/Arduino-PID-Library PID by Brett Beauregard]&lt;br /&gt;
#* [https://github.com/NicoHood/PinChangeInterrupt Pin Change Interrupt by Nico Hood]&lt;br /&gt;
#* [https://github.com/SweBarre/MCP48x2 MCP48x2 DAC by Jonas Forsberg]&lt;br /&gt;
#* [https://github.com/ivanseidel/DueTimer Arduino Due Timer Interrupts by Ivan Seidel]&lt;br /&gt;
#* 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.&lt;br /&gt;
#&amp;lt;u&amp;gt;''''' Elcano Repositories '''''&amp;lt;/u&amp;gt;&amp;lt;br /&amp;gt;The Elcano repositories are needed to run the simulation:&lt;br /&gt;
#*[https://github.com/elcano/HighLevel High Level]&lt;br /&gt;
#*[https://github.com/elcano/Simulator Simulator (Router Board &amp;amp; Simulator Script)]&lt;br /&gt;
#*[https://github.com/elcano/Drive-by-wire Drive-by-wire (Low Level)]&lt;br /&gt;
===''' Run Simulation '''===&lt;br /&gt;
Once all the requirements are installed, use the following instructions to run the simulation. &lt;br /&gt;
&amp;lt;br /&amp;gt;[[File:Router_PCB_Connections.jpg|500px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;'''''Step 1: Program all Arduinos'''''&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;router_board_v1.ino&amp;lt;/b&amp;gt; to the router Arduino Due programming port &lt;br /&gt;
#Upload &amp;lt;b&amp;gt;High_Level.ino&amp;lt;/b&amp;gt; to the high level Arduino Due programming port&lt;br /&gt;
#Upload &amp;lt;b&amp;gt;Drive_By_Wire.ino&amp;lt;/b&amp;gt; to the low level Arduino Mega 2560&lt;br /&gt;
'''''Step 2: Run CARLA'''''&lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the directory where CARLA is installed (CARLAUE4.exe)&lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\ElcanoInstaller\CARLA\WindowsNoEditor&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From the CARLA directory, type:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
#:Or, to run in low resolution mode:&lt;br /&gt;
#:&amp;lt;code&amp;gt;CARLAUE4.exe -ResX=720 -ResY=480 -quality-level=Low&amp;lt;/code&amp;gt;&lt;br /&gt;
'''''Step 3: Run Simulation'''''&lt;br /&gt;
#Connect your PC to the native port on the Router Board Due &lt;br /&gt;
#Open a command prompt (type cmd in the windows search box)&lt;br /&gt;
#Go to the Simulation directory &lt;br /&gt;
#:&amp;lt;code&amp;gt;cd C:\Users\bobross\Documents\Simulator\Simulation&amp;lt;/code&amp;gt;&lt;br /&gt;
#::-You may have it saved to a different directory&lt;br /&gt;
#From Simulation directory, start the Simulator UI &lt;br /&gt;
#:&amp;lt;code&amp;gt;.\Simulation\start.bat&amp;lt;/code&amp;gt;&lt;br /&gt;
#By default, the Simulator UI will populate local running CARLA settings&lt;br /&gt;
#*For control via the router board, leave mode as Auto&lt;br /&gt;
#*To control via manual keyboard input, change mode to Manual.&lt;br /&gt;
#*If running a network-based CARLA server, enter IP and Port of CARLA into the respective boxes. (i.e. 192.168.1.1, 2010)&lt;br /&gt;
#Click &amp;quot;Connect to CARLA&amp;quot;&lt;br /&gt;
#*If Auto mode, it will pop up a selection of COM devices, select routerboard native port COM to begin and press go. &lt;br /&gt;
#*If Manual mode, client will start with keyboard controls (WASD)&lt;br /&gt;
#Observe behavior in simulator.  &lt;br /&gt;
#If car gets stuck, kill current simulator.py process and restart.&lt;br /&gt;
===''' Debug/Logging '''===&lt;br /&gt;
*High Level uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
*Router Board uses the Programming Port to display debug messages over serial monitor&lt;br /&gt;
&lt;br /&gt;
== Out of Scope Functionality Tested/Implemented ==&lt;br /&gt;
* Our project required us to delve into pieces of code within the Elcano project outside of our scope.  Understanding of how sensors are read by the high and low-level boards is necessary for the simulation of the sensors.  We were able to fix some issues regarding the CAN communication between the high and low-level boards.  The modified low-level code was not pushed to the main low-level code folder in the repository on Github, however, it is included within the simulator documentation.  The following were implemented.&lt;br /&gt;
* Unification of the proposed CAN message structure and the actual CAN message processing on the low-level code for CAN messages with ID 0x350 (High-level drive instructions).  These are CAN messages the high-level will send to the low level to facilitate autonomy.&lt;br /&gt;
* Fixing the DAC output voltage by using the MCP48x2 library by Jonas Forsberg.&lt;br /&gt;
== To Do (Software): ==&lt;br /&gt;
'''&lt;br /&gt;
&lt;br /&gt;
== Bugs Within Simulator ==&lt;br /&gt;
* Occasionally the simulator and router board will desync and the NMEA GPS messages received by the router board will be faulty.  This is usually followed by a crash of simulator.py.  If not, simply press Ctrl^C and restart simulator.py.&lt;br /&gt;
* If simulator.py unexpectedly terminates, the created actors and sensors in Carla will not be properly destroyed.  This usually does not cause problems for the simulation but proper termination in the future would be safer.  For now if it is causing problems, simply restart Carla.&lt;br /&gt;
* Carla does not stop outputting sensor data even if asked to stop.  This is a bug with Carla and not in our scope.&lt;br /&gt;
* Most malfunctions can be temporarily fixed by restarting the simulator.py instance.&lt;br /&gt;
* While we were able to implement the code for the low-level CAN interpretation of the throttle and brake commands from high-level CAN messages, coding for PWM requires additional testing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Additional Notes ==&lt;br /&gt;
* Currently, the order that you output data from the router board to the computer running simulator.py is non-trivial.  Data is interpreted based on the order which it is received.&lt;br /&gt;
* Carla sensor listening was flawed at the time this was made; .stop() would not stop the sensor from executing its attached function at each tick of Carla.  Therefore speed was implemented without the use of sensors, and instead uses a command that accesses the speed only when needed.  This is the suggested method until sensors are fixed.  Certain sensors such as NMEA GPS, however, are only implementable using Carla sensors.  Additional information can be found on Carla Documentation.&lt;br /&gt;
* In PowerShell, in CarlaUE4 path, run Carla as: ***Start-Process CarlaUE4 -ArgumentList “—quality-level=Low”*** to lower gpu load.&lt;br /&gt;
* Headless mode can be enabled for complete removal of graphics rendering, however, visual debugging is extremely useful.&lt;br /&gt;
&lt;br /&gt;
= 2026 Simulator =&lt;br /&gt;
&lt;br /&gt;
Changes&lt;br /&gt;
&lt;br /&gt;
Purpose&lt;br /&gt;
&lt;br /&gt;
Architecture&lt;/div&gt;</summary>
		<author><name>ShivBhatt</name></author>
		
	</entry>
</feed>