Giter Club home page Giter Club logo

mockservice's Introduction

Vehicle Mock Service

About

The vehicle mock service is a service dummy allowing to control all specified actuator- and sensor-signals via a configuration file. These configuration files are expressed in a Python-based domain-specific language (DSL).

Why

When developing further vehicle applications, it can be very useful to be able to mock VSS actuators or sensors by specifying configuration files and without developing a new service from scratch. This vehicle mock service provides developers with the ability to do just that. Have a look at the complete concept and design ideas here

Component diagram

flowchart LR
    BrokerIF(( ))
    ValIF(( ))
    ServiceIF(( ))
    id1[KUKSA.val databroker] -- sdv.databroker.v1 --- BrokerIF
    ServiceIF -- kuksa.val.v1 --- id1
    id1 -- kuksa.val.v1 --- ValIF
    id2[Vehicle Mock Service] <--> ServiceIF
    BrokerIF<--> id3[Vehicle App]
    ValIF <--> id3
Loading

Running mockservice

Firstly, you will need to install all necessary Python dependencies by issuing the following command in your favorite terminal:

python3 -m pip install -r ./requirements.txt

You can then run the vehicle mock service with

python3 mockservice.py

As an alternative, you can build and execute the container from the Dockerfile or through the docker-build.sh script.

Another option, when using VS Code, is to use the provided VSCode task run-mockservice which will set up all necessary environment variables and parameters for the service to start up properly.

Configuration

Vehicle Mock Service

parameter default value Environment variable description
listen address "127.0.0.1:50053" MOCK_ADDR Listen for rpc calls
broker address "127.0.0.1:55555" if DAPR_GRPC_PORT is set:
"127.0.0.1:$DAPR_GRPC_PORT"
else:
VDB_ADDRESS
The address of the KUKSA.val databroker to connect to
broker app id "vehicledatabroker" VEHICLEDATABROKER_DAPR_APP_ID When using DAPR, this allows to configure the id of the KUKSA.val databroker to connect to.

Configuration options have the following priority (highest at top):

  1. environment variable
  2. default value

Mocking Configuration

By default, the vehicle mock service reads the configuration for the datapoints to mock from the mock.py Python file at runtime. This file is a good starting point edit own mock configurations.

The default configuration contains behavior for:

  • Vehicle.Speed
  • Vehicle.Cabin.Seat.Row1.Pos1.Position
  • Vehicle.Body.Windshield.Front.Wiping.System.Mode
  • Vehicle.Body.Windshield.Front.Wiping.System.TargetPosition
  • Vehicle.Body.Windshield.Front.Wiping.System.ActualPosition

This allows the vehicle mock service to be used with the Velocitas Seat Adjuster example, as well as the initial Vehicle App template. Furthermore, it can be used to develop a wiping application for the front wipers.

Custom mocking configuration

If the mocked datapoints are not enough, the mock.py in this repository can be modified and mounted into the vehicle mock service container - it will then overwrite the default mock configuration with the custom one.

The full Python mocking DSL is available here

Generating API documentation

The API documentation is generated from Python docs and embedded into markdown files for easy rendering on Github without external hosting. The workflow ensure-docs-up2date makes sure that the API docs are up to date before merging a pull request. To update the docs, run

./update-api-docs.sh

Using mockservice dynamically

To use the mockservice dynamically you need to use the same process. For an example see threaded_mock.py.

What's not supported?

Any form of array support e.g no VSS datapoint that has DataType.*ARRAY. If values in Kuksa Databroker are modified outside of behaviors, the changes won't be picked up by the mock service. Instead try to model another behavior that listens to ACTUATOR_TARGET/VALUE and set it like this.

mockservice's People

Contributors

kowshikk2 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.