C++ Manual Vehicle Model Creation
Learn how to create a Vehicle Model manually for C++
With the release of our new
model lifecycle approach on Friday, 2023-03-03, the model is now automatically generated with the instantiation of the devContainer from a model source referenced in the app manifest.
The approach described here, using pre-generated model repositories, is deprecated as of now. But it is still available and must be used if you need access to vehicle services. Please be aware, that you would either have to use template versions before the above mentioned release, or you need to adapt the newer versions of the template using the old approach.
This tutorial will show you how to:
A Vehicle Model should be defined in its own package. This makes it possible to distribute the Vehicle Model later as a standalone package and to use it in different Vehicle App projects.
The creation of a new vehicle model is only required if the vehicle signals (like sensors and actuators) defined in the current version of the
COVESA Vehicle Signal Specification (VSS) is not sufficient for the definition of your vehicle API. Otherwise you could use the default vehicle model we already generated for you, see
A Vehicle Model can be generated from a COVESA Vehicle Signal Specification (VSS). VSS introduces a domain taxonomy for vehicle signals, in the sense of classical attributes, sensors and actuators with the raw data communicated over vehicle buses and data. The Velocitas vehicle-model-generator creates a Vehicle Model from the given specification and generates a package for use in Vehicle App projects.
Follow the steps to generate a Vehicle Model.
Clone the vehicle-model-generator repository in a container volume.
In this container volume, clone the vehicle-signal-specification repository and if required checkout a particular branch:
git clone https://github.com/COVESA/vehicle_signal_specification
cd vehicle_signal_specification
git checkout <branch-name>
In case the VSS vspec doesn’t contain the required signals, you can create a vspec using the VSS Rule Set .
Execute the command
python3 gen_vehicle_model.py -I ./vehicle_signal_specification/spec ./vehicle_signal_specification/spec/VehicleSignalSpecification.vspec -l <lang> -T sdv_model -N sdv_model
or if you want to generate it from a .json file
python3 gen_vehicle_model.py <path_to_your_json_file> -l <lang> -T sdv_model
Depending on the value of lang
, which can assume the values python
and cpp
, this creates a sdv_model
directory in the root of repository along with all generated source files for the given programming language.
Here is an overview of what is generated for every available value of lang
:
lang | output |
---|---|
python |
Python sources and a setup.py ready to be used as Python package |
cpp |
C++ sources, headers and a CMakeLists.txt ready to be used as a CMake project |
To have a custom model name, refer to README of vehicle-model-generator repository.
For Python: Change the version of package in setup.py
manually (defaults to 0.1.0).
Now the newly generated sdv_model
can be used for distribution. (See
Distributing your Vehicle Model
)
Alternative to the generation from a VSS specification you could create the Vehicle Model manually. The following sections describing the required steps.
Once you have created your Vehicle Model either manually or via the Vehicle Model Generator, you need to distribute your model to use it in an application. Follow the links below for language specific tutorials on how to distribute your freshly created Vehicle Model.
Learn how to create a Vehicle Model manually for C++
Learn how to create a Vehicle Model manually for Python
Learn how to distribute a Vehicle Model.