Testing Connected Car Apps with Simulated Data
In order to start working with simulated car data we are recommending going through each of the following steps. Every underlying aspect will be explained in more detail both in the video of our second Open Dev Talk and this article.
- Preparing the test environment
- Adding a new virtual car
- Linking app and car simulator
- Simulating connected car scenarios
- Testing with simulated car data
Setting up the Test Environment
In our example, we are going to simulate an electric vehicle’s charging session. Usually, this process takes hours and involves not only accessing a connected car but also connecting to a charging station. Using free High Mobility tools, we will be able to emulate the charging process and visualize data points such as the state of charge and plugged-in event.
At first, you need to prepare the test environment in a way that you have a sending subject (car simulator) and a receiving end. While the receiver can be any kind of application or prototype that integrates our connected car interface, we have used High Mobility’s dashboard sample app which can be downloaded for free. You can start off setting up the sample application by creating a new app container using the sandbox environment on our platform. Please make sure to select only those data permissions that are required to fulfill the underlying use case. For simulating the charging session we have chosen the estimated range, battery level, plugged-in status and charging status data points.
Since High Mobility’s sample app is implementing the GraphQL version of our Auto API you need to copy the corresponding credentials listed in the app container to the configuration form. Furthermore, you will be asked to enter the OAuth client credentials which can be found in the settings view of your High Mobility account. The next step is to create a virtual car that sends data signals to the sample dashboard app or your own application.
Generating a virtual car
Using a virtual car simulator is like working with a digital twin. Trips and car-related events can be simulated conveniently in the browser while the data is generated in the same format and structure as if you would test with a real vehicle.
In order to create your very own virtual car you must go to the Simulation Studio that will be highlighted after you have logged in to our High Mobility developer platform. Here you can create a new vehicle instance and set up a name that you can easily remember. We are recommending the Porsche Cayenne as it brings all data capabilities for various use cases. However, brand and model are only fulfilling visual purposes and do not necessarily correspond to the available data points that real cars are able to provide.
If your simulation should involve multiple cars you are always free to create additional instances that can then be used in parallel later on.
Linking app and car simulator
We assume that a privately owned car is used for our simulated charging session. Consequently, we first need to allow sharing the car’s data and grant access to the permissions we have selected before. High Mobility’s dashboard sample app includes the B2C consent flow that works both with real cars and our emulators. However, you will find a streamlined version of the B2C consent flow in our sandbox environment. This version skips the registration for Driver and also the authorization in the manufacturer portal. Before you can go through the consent flow you need to make sure that the simulator has been introduced to your app container. You will find a “Link new simulator” button in the corresponding menu that will fulfill this requirement accordingly.
If you are using the sample app you are able to connect the simulator by clicking on “Add a vehicle”. After having selected the simulator you can finalise the process by granting access to the requested data points. As long as you have not launched the emulator, the sample app will show all data points in a grid or list view but not display any corresponding values.
Creating a simulated connected scenario
Going back to the build environment the emulator can be launched either in the Simulation Studio or when setting up the app container. It shows the virtual car in the middle of the screen accompanied by some selected data points that can be adjusted directly using the 2D or 3D view. Every adjustment and manipulation is going to be reported in the console area down below. On the right hand side you will find numerous options for editing specific data points or for triggering car-related events.
Our Open Dev Talk host Anissa has focused on the simulation capabilities of the car emulator to demonstrate a simulated charging session. A new simulation can be created with a click on the “Create” button and by entering a name for the desired scenario (e.g. “Charging Session”). The simulator itself will highlight a timeline for events and data points as well as controls to play and pause the simulation. By selecting an item in the first table column you are able to decide which data point categories or events should be simulated. Every following block in the row can be then added in order to define the specific value of the data points at the corresponding point of time.
In our example, we have selected the battery level to be 0% in the beginning and we continually letting this value increase by 20% for each timestamp in a way that it will be at 100% at the end of our simulation. Corresponding to the state of charge, we have configured an increasing estimated range and a plugged-in/plugged-out event at the beginning and end of the charging session.
Testing with simulated car data
Finally, you will be able to play and replay the simulation using the controls on top of the timeline view. Meanwhile, the result can be inspected in the sample app or using your own prototype application that consumes that simulated data. The corresponding data points will be now filled with the values generated by the car emulator.
By adjusting the update rate of the sample app or simulator you can even optimize the time required for running through the simulation. Advanced users will be able to follow a trick that our Customer Success Manager has revealed in the Open Dev Talk: By hitting the ‘R’ key the demo app will be triggered to update the view automatically.
High Mobility Open Dev Talks
At High Mobility, we are passionate about new technology. We offer free open source tools and developer friendly documentation for any projects to be integrated smoothly. More than 800 developers and product managers have already signed up for our moderated community platform and we are hosting connected car competitions for your innovative, connected car ideas.
In our free monthly, 30-minute Open Dev Talk online session we are explaining exciting connected car related topics in 15 minutes and dedicate the rest of the time to your questions and ideas.
Join our community on Slack