DriveWorks SDK Reference
3.5.78 Release
For Test and Development only

control/vehicleio/docs/usecase1.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020 NVIDIA CORPORATION. All rights reserved.
2 
3 @page vehicleio_usecase1 VehicleIO Workflow
4 
5 @note SW Release Applicability: This tutorial is applicable to modules in both **NVIDIA DriveWorks** and **NVIDIA DRIVE Software** releases.
6 
7 #### Initialization
8 
9 The `dwVehicleIO_initialize()` function creates a VehicleIO instance. That functions takes the following parameters:
10 
11 - VehicleIO handle: `::dwVehicleIOHandle_t`
12 - Type of interface device: `::dwVehicleIOType` (::DW_VEHICLEIO_DATASPEED / ::DW_VEHICLEIO_GENERIC / ::DW_VEHICLEIO_SPACEDRIVE / ::DW_VEHICLEIO_CUSTOM)
13 - Handle to the vehicle: `dwVehicle`
14 
15 @note Before creating a VehicleIO instance, you must initialize the rig configuration module using `dwRig_initializeFromFile()` and then get the vehicle properties using `dwRig_getVehicle()`. For more information, see Rig Configuration in this guide.
16 
17 - Context Handle : `::dwContextHandle_t`
18 
19 #### Driving Mode
20 
21 The `dwVehicleIO_setDrivingMode()` function sets the driving mode. This function consumes the dwVehicleIODrivingMode() enum as an argument, which is defined as
22 ```{.cpp}
23 typedef enum dwVehicleIODrivingMode
24 {
25  /// Comfortable driving is expected (most conservative). Commands that leave
26  /// the comfort zone are treated as unsafe, which immediately leads to
27  /// VehicleIO being disabled.
28  DW_VEHICLEIO_DRIVING_LIMITED = 0x000,
29  /// Same as above, but unsafe commands are clamped to safe limits and
30  /// warnings are isssued. VehicleIO stays enabled.
31  DW_VEHICLEIO_DRIVING_LIMITED_ND = 0x100,
32  /// Safety checks suitable for collision avoidance logic (right now same as
33  /// NO_SAFETY below).
34  DW_VEHICLEIO_DRIVING_COLLISION_AVOIDANCE = 0x200,
35  /// VehicleIO will bypass all safety checks.
36  DW_VEHICLEIO_DRIVING_NO_SAFETY = 0x300
37 } dwVehicleIODrivingMode;
38 ```
39 #### Vehicle State Information
40 
41 The `dwVehicleIO_consumeCANFrame()` function parses received CAN messages. The resulting parsed messages generate certain reports, which can be gathered using the predefined callbacks.
42 
43 The current vehicle state information can be retrieved with `dwVehicleIO_getVehicleState()`, which returns the vehicle state in the `dwVehicleIOState` format.
44 
45 #### Sending Vehicle Commands
46 
47 The `dwVehicleIO_sendVehicleCommand()` function sends a command to the vehicle via VehicleIO. The command is sent in the `dwVehicleIOCommand` format and is passed as one of the arguments. An additional argument is passed as a handle to the underlying sensor that VehicleIO uses to pass this command.
48 
49 #### Selecting Driver Overrides
50 
51 Signals that the driver uses to override Vehicle control are configurable and can be selected using `dwVehicleIO_selectDriverOverrides()`. The driver can override vehicle control with any combination of throttle, steering, brake, and/or gear.
52 
53 ## Conditions for Engagement and Disengagement
54 
55 In order to enable vehicle actuation (i.e. engage), several conditions must be
56 satisfied:
57 
58 - `dwVehicleIOCommand::enable` must be set to `true`.
59 - Desired `dwVehicleIOCommand::*Valid` flags must be set to `true`, for example
60  `dwVehicleIOCommand::brakeValid` to actuate vehicle braking.
61 - All bits in `dwVehicleIOState::faults` must be clear. Recoverable faults can
62  be cleared by sending a command with `dwVehicleIOCommand::clearFaults` set to
63  `true`.
64 - `dwVehicleIOState::overrides` must be clear for all enabled driver overrides.
65  To clear `dwVehicleIOState::overrides`, one has to send a command with
66  `dwVehicleIOCommand::clearFaults` set to `true` (same field is used to clear
67  faults and overrides).
68 
69 Once engaged, both Drive-By-Wire hardware and/or VehicleIO might decide to
70 disable vehicle actuation (i.e. disengage), there are a few cases when this
71 might happen:
72 
73 - Application-requested disengagement: `dwVehicleIOCommand::enable` is set to
74  `false`.
75 - Disengagement due to Drive-By-Wire faults. Which hardware actuation unit
76  caused the disengagement will be indicated via `dwVehicleIOState::faults` (see
77  corresponding `::dwVehicleIOFaults` enumeration). Exact reason for
78  disengagement can be traced back using CAN logs and Drive-By-Wire vendor
79  documentation.
80 - Disengagement due to driver overrides as detected by Drive-By-Wire hardware.
81  Exact reason will be indicated via corresponding bits in
82  `dwVehicleIOState::overrides` (see corresponding `::dwVehicleIOOverrides`
83  enumeration).
84 - If VehicleIO is in `::DW_VEHICLEIO_DRIVING_LIMITED` mode, some commands (such
85  as braking) that are considered not appropriate for limited actuation will
86  cause VehicleIO to stop sending commands to the vehicle (i.e. VehicleIO will
87  disengage). In this case, `::DW_VEHICLEIO_FAULT_SAFETY` bit will set in
88  `dwVehicleIOState::faults`.
89 - If VehicleIO stopped receiving Drive-By-Wire reports for more than 100
90  milliseconds and VehicleIO is in `::DW_VEHICLEIO_DRIVING_LIMITED` mode, then
91  `::DW_VEHICLEIO_FAULT_SAFETY` bit will set in `dwVehicleIOState::faults` and
92  VehicleIO will disengage.
93 
94 #### VehicleIO Sample
95 
96 See @ref dwx_vehicleio_sample