Qt for Android Automotive : Outrun Demo Integration

The Outrun project was started to demonstrate the development process when using the unified design and development tools that Qt offers, by creating a digital cockpit from early design to UI implementation, visual effect creation, building connectivity, and finally running it on various environments.

The last step in the Outrun project development is connecting the UI to the vehicle platform. Currently the Qt for Android Automotive module provides vehicle properties through both C++ and QML APIs. It also offers a submodule to access Android notifications (to be released later). If we analogize the project to solving a jigsaw puzzle, connecting the UI to the vehicle would be the last pieces of the puzzle. You probably know that placing the final pieces of a jigsaw puzzle should be much easier than the first pieces.

qtaa1

The Outrun demo consists of IVI, HVAC and Cluster apps. The IVI app is for the center display as the infotainment interface, the HVAC app as the climate control panel, and the Cluster app sits in front of the driver as the digital instrument panel. Although each part of the Outrun project can operate independently, they have an MQTT client to communicate and synchronize user or vehicle information with other apps through an MQTT broker.

Vehicle Property Bindings

The Qt IF Android vehicle properties module is a submodule of Qt for Android Automotive that is an extension of the similar Qt IF Vehicle Functions Module. It provides a C++ and QML wrapper for Android Automotive Vehicle Properties as a Qt IF plugin.

It is worth mentioning that each app in the Outrun project has a state management component. Various UI elements in each class can read from and/or write to the properties of that shared component. Connecting vehicle properties from the Qt IF Android vehicle properties module to the state management component could be as simple as importing the appropriate QML module and adding property bindings. We should integrate several vehicle property bindings related to windows, doors, lights, climate, seats, tires, and car information into the Outrun project. In this example, we add the bindings to connect the UI to the trunk door position.

import QtQml
import QtIf.Android.VehicleProperties

QtObject {
    id: root

    property DoorControl doorControl: DoorControl {
        id: doorControl
    }
    property list<Binding> bindings: [
        Binding {
            target: dData
            property: 'trunkOpen'
            value: doorControl.zoneAt.Rear.doorPos > 0
            delayed: true
        },
        Binding {
            target: doorControl.zoneAt.Rear
            property: 'doorPos'
            value: dData.trunkOpen ? 1 : 0
            delayed: true
        }
        // ... other bindings
    ]
}

There is still something more to consider. The design team is doing the UI development process in Qt Design Studio on desktop machines. As a result, importing Qt for Android Automotive modules is not an option because of unmet dependencies to Qt for Android Automotive modules as it's only available for Android by its nature. To overcome this issue, we will try to load the QML component(s) that import Qt for Android Automotive QML submodules dynamically. We will be able to handle the situation where the submodules are not available by implementing a fallback scenario.

var component = Qt.createComponent(Qt.resolvedUrl('VehicleBindings.qml'));
if (component.status === Component.Error)
    component = Qt.createComponent(Qt.resolvedUrl('VehicleBindingsStub.qml'));

component.createObject(aParent)

 


As you see in this short video, The Android emulator provides an interface in the extended panel (right-side window) to view or change vehicle properties (rear door position in this case). The car 3D model reacts to changes of the rear door position in the extended panel.

Android Notifications

In the IVI part of the Outrun project, there is a drawer containing a list of notifications. The QtAndroidNotificationsListener submodule provides a model that includes a list of Android notifications and the ability to interact with each notification item. A basic usage might look like this.

import QtQuick
import QtAndroidAutomotive.NotificationsListener

ListView {
    model : AndroidNotificationListener.notificationsModel
    delegate : NotificationDelegate {
        key: model.key
        title: model.title
        //other properties to set
        onDismiss: AndroidNotificationListener.dismissNotification(key)
    }
}

Again, when targeting a desktop environment during development iterations, we should have a mocking model with the same roles as Qt for Android Automotive provides. Our implementation dynamically loads the matching model based on the target platform to keep the application functional even if the QtAndroidNotificationsListener submodule is not present.

NotificationModelLoader { id: modelLoader }

ListView {
    model : modelLoader.model
    delegate : NotificationItem {
    //properties to set
    }
}

And the NotificationModelLoader component

import QtQml

QtObject {
    id: root
    property variant model
    
    Component.onCompleted: {
        var component = Qt.createComponent(Qt.resolvedUrl('AndroidNotifications.qml'));
        if (component.status === Component.Error)
            component = Qt.createComponent(Qt.resolvedUrl('AndroidNotificationsStub.qml'));
        
        root.model = component.createObject(root)
    }
}

Now the Outrun demo is connected to a set of vehicle properties through Qt for Android Automotive and shows an interactive list of Android Notifications when targeting an Android Automotive platform.

More submodules (Qt Android Apps Utils, Qt Android Activity View, and future submodules) are supposed to be integrated into the Outrun project as well. Then, we would say that the last pieces of the jigsaw puzzle of having a fully functional digital cockpit are in their proper place.

qtaa2

 


Blog Topics:

Comments