dispatch.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2018, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Dataspeed Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef _DATASPEED_ULC_CAN_DISPATCH_H
36 #define _DATASPEED_ULC_CAN_DISPATCH_H
37 #include <stdint.h>
38 
40 {
41 
42 typedef struct {
43  int16_t lon_command :16; // speed mode: 0.0025 m/s, -81.920 to 81.915 m/s, +-183 mph
44  // accel mode: 5e-4 m/s^2, -16.384 to 16.3835 m/s^2
45  int16_t yaw_command :16; // yaw rate mode: 0.00025 rad/s, -8.1920 to 8.1915 rad/s
46  // curvature mode: 0.0000061 1/m, -0.1999 1/m to 0.1999 1/m
47 
48  uint8_t steering_mode :1; // 0 = yaw rate mode, 1 = curvature mode
49  uint8_t shift_from_park :1;
50  uint8_t enable_shifting :1;
51  uint8_t enable_steering :1;
52  uint8_t enable_pedals :1;
53  uint8_t clear :1;
54  uint8_t pedals_mode :1; // 0 = speed mode, 1 = accel mode
55  uint8_t coast_decel :1;
56 
57  uint8_t :8;
58  uint8_t :8;
59  uint8_t wdc;
60 } MsgUlcCmd;
61 
62 typedef struct {
63  uint8_t linear_accel; // 0.025 m/s^2, 0 to 6.375 m/s^2
64  uint8_t linear_decel; // 0.025 m/s^2, 0 to 6.375 m/s^2
65  uint8_t lateral_accel; // 0.05 m/s^2, 0 to 12.75 m/s^2
66  uint8_t angular_accel; // 0.02 rad/s^2, 0 to 5.1 rad/s^2
67  uint8_t jerk_limit_throttle; // 0.1 m/s^3, 0 to 25.5 m/s^3
68  uint8_t jerk_limit_brake; // 0.1 m/s^3, 0 to 25.5 m/s^3
69  uint8_t :8;
70  uint8_t wdc;
71 } MsgUlcCfg;
72 
73 typedef struct {
74  int16_t speed_ref :13; // 0.02 m/s,
75  uint16_t timeout :1;
76  uint16_t pedals_enabled :1;
77  uint16_t pedals_mode :1;
78  int16_t speed_meas :13; // 0.02 m/s
79  uint16_t override :1;
80  uint16_t steering_enabled :1;
81  uint16_t steering_mode: 1;
82  int8_t accel_ref; // 0.05 m/s^2
83  int8_t accel_meas; // 0.05 m/s^2
84  uint8_t max_steering_angle: 7; // 5 deg
85  uint8_t coasting: 1;
86  uint8_t max_steering_vel :6; // 8 deg/s
87  uint8_t steering_preempted: 1;
88  uint8_t speed_preempted: 1;
89 } MsgUlcReport;
90 
91 typedef struct {
92  uint8_t module;
93  uint8_t platform;
94  uint16_t major;
95  uint16_t minor;
96  uint16_t build;
97 } MsgVersion;
98 
99 #define BUILD_ASSERT(cond) do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
100 static void dispatchAssertSizes() {
101  BUILD_ASSERT(8 == sizeof(MsgUlcCmd));
102  BUILD_ASSERT(8 == sizeof(MsgUlcCfg));
103  BUILD_ASSERT(8 == sizeof(MsgUlcReport));
104  BUILD_ASSERT(8 == sizeof(MsgVersion));
105 }
106 #undef BUILD_ASSERT
107 
108 enum {
109  ID_ULC_CMD = 0x076,
110  ID_ULC_CONFIG = 0x077,
111  ID_ULC_REPORT = 0x078,
112  ID_VERSION = 0x07F,
113 };
114 
115 } // namespace dataspeed_ulc_can
116 
117 #endif // _DATASPEED_ULC_CAN_DISPATCH_H
118 
#define BUILD_ASSERT(cond)
Definition: dispatch.h:99
static void dispatchAssertSizes()
Definition: dispatch.h:100


dataspeed_ulc_can
Author(s): Micho Radovnikovich
autogenerated on Fri Dec 2 2022 03:20:37