Eecs 4314 Assignment 2
Eecs 4314 Assignment 2
Group: Beyond
Authors
Table of Contents
Abstract.............................................................................................................................2
Introduction....................................................................................................................... 2
System Overview and Top-Level Subsystems..................................................................3
Interactions between subsystems.....................................................................................4
Derivation Process............................................................................................................6
Architectural Styles........................................................................................................... 7
Assigned Subsystem........................................................................................................ 9
Conceptual vs Concrete Architecture and Modifications................................................ 12
Use Case........................................................................................................................ 13
Lessons Learned............................................................................................................ 14
Conclusion...................................................................................................................... 15
References..................................................................................................................... 15
2
Abstract
This report presents the as-built architecture of the Openpilot, focusing on the concrete
architecture of one of its top-level subsystems. The subsystem in focus is logging and
miscellaneous services of Openpilot. The report outlines the methodology followed to
derive the architecture, including subsystem identification and containment file creation.
It highlights architectural styles, design patterns, and notable interactions within the
subsystem. Furthermore, the report compares the concrete architecture with the
conceptual architecture of Openpilot, providing insights into the evolution and
implementation of the subsystem. Lessons learned from the architecture development
process are discussed as well, providing valuable insights for the future. The utilization
of diagrams is involved within this report, dependency diagrams have helped us derive
the concrete architecture and the architectural styles. Additionally, the report includes a
sequence diagram to provide insight into one of the salient features of the openpilot
driving model. Moreover, the report’s main goal is to provide a thorough understanding
of the internal workings and design components of Openpilot’s logging and
miscellaneous services subsystem.
Introduction
Openpilot is one the top technologies in autonomous driving, rapidly evolving due to the
continuous development of the open source community and Commai. Through an
in-depth analysis, the report will contain various information on the concrete architecture
of Openpilot. The report's main focus is on the logging and miscellaneous services
subsystem of Openpilot. The subsystem consists of numerous components that make
up its core functionality that ensures a smooth operation. For instance, the logger holds
a vital role in the software’s architecture considering it is in charge of recording routes
gained from Openpilot’s usage. By dissecting this subsystem’s architecture, we gain
valuable insight into how Openpilot handles essential functionalities such as data
logging, thermal management, communication using websockets, and user interface
interactions.
Openpilot uses over 300 Python files divided into different categories such as
submodules and dependencies for the system to be functional. In simple terms,
openpilot's core system functionality involves reading the data from the sensors
(camera, IMU, steering wheel angle sensor, GNSS receiver, etc.), processing that data,
and relaying relevant inputs to a neural network. The model achieved by the neural
network and its hyper-parameters produce outputs that are translated to actions and
utilized to apply commands and adjustments to the actuators. For openpilot to work
smoothly, the following open-source dependencies are used:
Sensors and Actuators: It is the main interface between cereal and I/O data. Based on
our derived concrete architecture, It consists of 3 main subsystems (modules). Boardd
It is the manager of the interface between cereal and panda. It reads the data obtained
by the sensors and the peripherals (which are managed by panda) including the GNSS
module, infrared LEDs (for night-time driver monitoring), and the car. Camerad It is the
module responsible for managing the camera data received from both the road and the
driver’s camera. It writes the data directly to visionipc in cereal. It also has auto-focus
and auto-exposure functionalities built-in. The third module is sensord which reads and
configures the remaining sensors including gyro, accelerometer, and light sensors.
Neural Network Runners: This subsystem is responsible for all of the Machine
Learning processes in the system including reading input data, data preprocessing, and
feeding the appropriate set of data into the Neural Network model. Most importantly, It
contains the core logic of the system. Based on our concrete architecture derivation, it
consists of two main modules. Modeld reads the image stream from cereal into the
main driving neural network. Modeld uses this data and the driver’s input to predict the
appropriate driving actions. Dmonitoringd Contains the logic for the driver’s interaction
with the system and the car (e.g., taking over and engaging the system). It also contains
a service for alerting the driver when necessary. This service works based on the
outputs of the dmonitoring model, and other parameters.
Localization and Calibration: It is responsible for the location processing of the car
and calibrating the parameters regarding the position and movement of the car. Based
on our derivation of the concrete architecture of this subsystem, It includes three main
modules. The first module is locationd which is responsible for localizing the car and
4
describing the interactions with its environment (e.g., the car's speed, if the car is going
up or down). Locationd receives the pre-processed data from Kalman Filter which filters
the noisy data from the sensors. Furthermore, it includes two important files,
calibrationd (image normalization) and paramsd (contains specific car model
parameters). The second important module is ubloxd which has one important job, and
that is parsing the GNSS data which is later used for localization. The third service is
rednose which includes Kalman Filter libraries.
Controls: It is responsible for tasks related to controlling the actuators of the car. In
simple terms, this module is the module that controls and drives the car. We derived
three main modules for this service from the concrete architecture. Radard converts
raw data received from different car models to a canonical format. Plannerd contains
the planning logic which consists of two parts: Lateral (steering) planning and
longitudinal (gas and brake) planning. They both use an MPC solver which calculates
the appropriate mechanical parameters for the ride to be correct and smooth given its
final position and destination in the upcoming few seconds. The third module is
controlsd has two main jobs: 1- It contains the service that controls the car. It receives
the plans mentioned above from plannerd and converts them into appropriate control
signals. 2- It parses the CAN data from the car to a canonical format which is then
published to cereal. [2]
Figure 1 illustrates the communication pathways between various subsystems within the
Openpilot system. These subsystems include Neural Network Runners, Localization
and Calibration, Controls, Sensors and Actuators, and System, Logging, and
Miscellaneous Services. Each arrow in the diagram represents the exchange of specific
data between the corresponding subsystems.
The rationale behind these interactions lies in the distributed nature of the Openpilot
system and the specialized functionalities of each subsystem. For instance, Neural
Network Runners are responsible for tasks such as camera odometry and driving
decision predictions, generating essential data for other subsystems to make informed
decisions. The exchange of data between Neural Network Runners and Localization
and Calibration enables accurate localization of the vehicle and calibration of sensors,
contributing to safer and more precise navigation.
Similarly, the interaction between Neural Network Runners and Controls facilitates the
transmission of driving decision predictions and driver monitoring state to control the
vehicle's behavior effectively. Controls, in turn, provide feedback in the form of car state
and control state to ensure smooth operation.
5
Sensors and Actuators play a crucial role in gathering real-time data from various
sensors installed in the vehicle, such as road cameras and GPS receivers. This data is
then utilized by different subsystems for decision-making and system monitoring. The
bidirectional communication between Sensors and Actuators and System, Logging, and
Miscellaneous Services ensures efficient data exchange for logging purposes and
system maintenance.
Furthermore, the interaction between Localization and Calibration and Controls involves
the transmission of location and calibration data to inform control decisions. This
integration enhances the overall performance and accuracy of the Openpilot system.
Overall, the rationale for these interactions lies in the need for seamless data exchange
and coordination between different subsystems to achieve the objectives of
autonomous driving, including safety, efficiency, and reliability. By leveraging the
specialized functionalities of each subsystem and facilitating data sharing, the Openpilot
system can effectively navigate diverse driving scenarios and ensure a smooth driving
experience for users.
Figure 1: The communication pathways between various subsystems within the Openpilot
system
6
Derivation Process
The first thing we did was to download the source code of the openpilot system and run
it through a software tool called Understand which allows us to visualize dependencies
between different parts of the code. Understand generates a dependency graph
according to the directory structure. Though it was very insightful we still needed to
reorganize it according to our subsystems and view the dependencies between them.
So we manually assign modules to each subsystem they belong to based on the 5 main
subsystems we identified along with the components they are made up of mentioned in
the last section. After iteratively assigning all components to the main subsystems we
get our concrete architecture with subsystems interacting with each other.
Figure 2 shows all the subsystems that make up the openpilot broken down into their
constituent subsystems. This also allows us to see the dependencies between the
different subsystems. Even though panda, opendbc, and cereal are not categorized as
subsystems they are added in the architecture independently to make their role more
clear as well as see the architectural structure of the system more evident. One of the
most important things highlighted by the concrete architecture is that all the subsystems
interact with cereal and not with each other directly portraying the implicit invocation
architecture style that is discussed in detail later. Another noteworthy aspect is that the
hardware that is made up of the car body has a bidirectional dependency with the
panda since the car’s sensor data is relayed over to the cereal through the panda, and
control data for actuators is passed onto the car hardware through panda as well from
cereal.
Architectural Styles
A variety of architectural styles are necessary for Openpilot, to function properly and
consistently. Openpilot uses several critical architectural techniques to assist it carry out
its complex operations, which span perception, planning, and control. Let's explore the
architectural styles we concluded for openpilot:
Process Control Architectural Style: At the core of openpilot's functionality lies the
process control architectural style, particularly emphasizing feedback loops (see Figure
3 for visualization). Openpilot constantly monitors sensor data from the car’s hardware,
and that data is sent to the machine learning model (Neural Network Runners) where all
the decision planning takes place. The machine learning model determines the
instructions that have to be given to the vehicle’s actuators to decide the speed and
direction. When the machine learning model finalizes its computation on the sensor
data, it sends the instructions to the actuators of the car to adjust the car’s movement.
Implicit Invocation Architectural Style: This is arguably the most important and
prominent architectural style employed in openpilot software. It is specifically a
publish-subscribe (pub-sub) architectural style. It is observed that every software
subsystem in openpilot uses this for their modules/services to communicate with the
modules/services of other software subsystems. Every software subsystem is
subscribed to Cereal, which is a publisher that helps individual software subsystems
communicate with each other efficiently (see Figure 3).
which shows how each software subsystem is subscribed to cereal for communicating
with each other instead of communicating with the software subsystem on their own
directly.
Assigned Subsystem
The functionalities and interactions with other subsystems of the 5 internal subsystems
are explained below:
logging: Openpilot utilizes a logging system to continuously log camera and sensor
data that is used for training neural network models for enhancing path-predicting
capabilities. The streams from road cameras, wide road cameras as well as driver
cameras are saved in low-resolution versions so that they are small enough for instant
upload on slow internet connections yet remain valuable for analysis and debugging
purposes. All cereal messages exchanged among all subsystems, and system crash
reports are also logged in a serialized capnproto format so we can understand and fix
failures.
thermald: This subsystem manages thermal conditions and hardware states of the
whole system. It defines optimal thermal bands and hardware states and functions to
handle tasks such as reading thermal data, setting off-road alerts, and monitoring
hardware states. Two main threads are spawned to monitor hardware states, manage
thermal conditions, and send status updates to other components. Overall, it ensures
the system operates within safe temperature ranges and manages hardware states
effectively.
UI: This component renders the graphical user interface (GUI) on the comma3X device.
While the car is off, it contains a training guide to onboard new users, shows system
status, and exposes some settings. While the car is on, the road-facing camera stream
11
is shown with overlaid visualizations of the driving path, lane lines, and lead cars. It
subscribes to messages related to device state and control state using
messaging.SubMaster. It defines an update function, periodically invoked by a Timer, to
dynamically adjust the GUI based on received messages about the car's current
location and navigation updates. This function determines the vehicle's on-road or
off-road status, updates label backgrounds and text content based on the control state,
and regulates screen brightness and backlight power as per the vehicle's condition.
Overall, this component provides a real-time interface to display vehicle control state
and alerts to the user.
managerd: This component is a crucial part of the Openpilot system, responsible for
managing various processes and initializing the environment. The manager_init()
function initializes parameters, registers the device, sets up logging, and prepares
processes for execution. The manager_cleanup() function stops all processes and logs
a message indicating the cleanup process. The manager_thread() function runs
continuously, updating the status of managed processes based on the device state and
ensuring necessary processes are running. Signals such as SIGTERM are handled to
ensure proper cleanup and shutdown procedures. Exceptions are caught and logged,
and appropriate actions are taken. If an uninstall, shutdown, or reboot is requested, it's
logged and executed. The main() function initializes the manager, starts the main loop,
handles exceptions, performs cleanup, and executes requested actions. Overall, this
script serves as the backbone for managing processes, handling exceptions, and
ensuring the smooth operation of the Openpilot system.
12
The conceptual architecture details high-level subsystems that are listed within
documentation as well as major components for the system to function. These are
highlighted either upon conception of the project or when detailing the main
functionalities of the project. The conceptual architecture highlights a blueprint of what
components must exist for the project to fulfill its goals so often it will not go into detail
on how each component will work or interact.
The extraction of the concrete architecture grants the ability to compare the conceptual
architecture with the concrete. This often is done to highlight dependencies between
components and subsystems or to compare the architectures for deviations or
absences between them. Over the lifespan of a project, especially ones that are
community-developed and open source will have many changes to optimize speed, add
functionality, remove redundancy, and fix bugs. In the case of openpilot various
components and tools were refactored over time or their functionalities were merged
creating some differences.
When comparing the conceptual architecture to the concrete the main difference is the
large dependency on a component called Cereal, a central communicator between
multiple components. Based on the conceptual architecture it is implied that data flows
linearly between subsystems, such as from neural network runners to controls to
actuators. In reality, a majority of communication is dependent on cereal where they
notify cereal to publish a packet of information which components can interpret for their
own actions. This was most likely a design decision made by a senior developer to
implement a strong implicit invocation architectural style as the framework for
communication.
Use Case
Scenario: A user is on a road trip from one city to another. The road trip comprises
multiple stops and long hours of driving. The user is excited to embark on this journey
but also a little worried as it is their first time driving this far and of all the challenges that
the road trip poses. Since it's their first time, the user seeks assistance while driving on
the highway.
Solution: The user can activate the Openpilot system in their car, which includes a
robust feature of lane maneuvering. Openpilot employs a series of intricate processes to
ensure safe and efficient navigation where the system utilizes sensors and cameras to
monitor the external and internal conditions to maneuver along the lanes on a highway.
A detailed explanation of how Openpilot’s Lane Changing feature works at a high level:
● Sensors scan the environment and collect data, which is then interpreted by
Panda.
● Panda plays a crucial role as it articulates the vehicle's CAN bus traffic and
efficiently interfaces with OpenDBC where the data undergoes further processing
before being transmitted as messages to Cereal.
● Cereal serves as the main central hub, which orchestrates the flow of
information throughout the Openpilot system.
14
● From Cereal, the data is shared with the Localization component, where the
state of the vehicle is accurately described.
● With the localized information in hand, Cereal then sends the calibrated values to
the Neural Network which is tasked with predicting the optimal driving path.
● Once the prediction is made, it is shared back with Cereal.
● After having a refined trajectory, Cereal now collaborates with the Control
module.
● Control takes the responsibility of initializing actuator messages, which are
important in translating the planned trajectory into actionable commands.
● These commands are once again shared back with Cereal.
● Cereal finally sends the information to the hardware, ensuring that the planned
lane-changing maneuver is executed seamlessly by integrating both external and
internal conditions.
Lessons Learned
Throughout the whole process of deriving the concrete architecture based on the
understanding of the Openpilot system, there were several lessons learned. It was
evident that a clear grasp of the conceptual framework was necessary in order to
maintain being on a proper course and avoid misinterpretations and inconsistencies.
One of the key assets that played an important role throughout the derivation of
concrete architecture was Understand. Due to Understand’s amazing analysis
capabilities, it offered a lens into the system's implementation, helping in the extraction
of dependencies and visualization of relationships between entities. However, it was
soon discovered that although Understand offered a solid foundation, it did not eliminate
the need for a manual intervention that is required to check the architecture’s alignment
with conceptual needs.
Deriving the concrete architecture helped us learn and understand the deeper insights
into the Openpilot system's organization and interdependencies. These insights helped
in learning and understanding the architectural styles implemented and potential areas
for optimization and future enhancements.
15
Conclusion
In conclusion, Openpilot served as a great learning experience when diving into its
architecture and offered several key findings that offered insights into the system's
structure and operation. These findings helped us understand Openpilot's functionality
and implications for its overall performance. Openpilot has been identified to have 5
overarching subsystems, the ones that have been highlighted in this report are the
System, Logging, and Misc Services which serve as the backbone of the system’s
functionality.
References
[1] From vision to architecture: How to use openpilot and live. From Vision To
Architecture: How to use openpilot and live - DESOSA 2020. (2020, March 11).
https://desosa.nl/projects/openpilot/2020/03/11/from-vision-to-architecture
[2] How openpilot works in 2021. comma.ai blog. (2021, October 12).
https://blog.comma.ai/openpilot-in-2021/
[3] Enhancing live localization using Laika. comma.ai blog (2022, August 3).
https://blog.comma.ai/laikad/