00001 /********************************************************************* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2018, Dataspeed Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Dataspeed Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 *********************************************************************/ 00034 00035 #ifndef _DATASPEED_ULC_CAN_DISPATCH_H 00036 #define _DATASPEED_ULC_CAN_DISPATCH_H 00037 #include <stdint.h> 00038 00039 namespace dataspeed_ulc_can 00040 { 00041 00042 typedef struct { 00043 int16_t linear_velocity :16; // 0.0025 m/s, -81.920 to 81.915 m/s, +-183 mph 00044 int16_t yaw_command :16; // yaw rate mode: 0.00025 rad/s, -8.1920 to 8.1915 rad/s 00045 // curvature mode: 0.0000061 1/m, -0.1999 1/m to 0.1999 1/m 00046 00047 uint8_t steering_mode :1; // 0 = yaw rate mode, 1 = curvature mode 00048 uint8_t shift_from_park :1; 00049 uint8_t enable_shifting :1; 00050 uint8_t enable_steering :1; 00051 uint8_t enable_pedals :1; 00052 uint8_t clear :1; 00053 uint8_t :2; 00054 00055 uint8_t :8; 00056 uint8_t :8; 00057 uint8_t wdc; 00058 } MsgUlcCmd; 00059 00060 typedef struct { 00061 uint8_t linear_accel; // 0.02 m/s^2, 0 to 5.1 m/s^2 00062 uint8_t linear_decel; // 0.02 m/s^2, 0 to 5.1 m/s^2 00063 uint8_t lateral_accel; // 0.05 m/s^2, 0 to 12.75 m/s^2 00064 uint8_t angular_accel; // 0.02 rad/s^2, 0 to 5.1 rad/s^2 00065 uint8_t :8; 00066 uint8_t :8; 00067 uint8_t :8; 00068 uint8_t wdc; 00069 } MsgUlcCfg; 00070 00071 typedef struct { 00072 int16_t speed_ref :13; // 0.02 m/s, 00073 uint16_t timeout :1; 00074 uint16_t pedals_enabled :1; 00075 uint16_t tracking_mode :1; 00076 int16_t speed_meas :13; // 0.02 m/s 00077 uint16_t override :1; 00078 uint16_t steering_enabled :1; 00079 uint16_t steering_mode: 1; 00080 int8_t accel_ref; // 0.05 m/s^2 00081 int8_t accel_meas; // 0.05 m/s^2 00082 uint8_t max_steering_angle: 7; // 5 deg 00083 uint8_t:1; 00084 uint8_t max_steering_vel :6; // 8 deg/s 00085 uint8_t steering_preempted: 1; 00086 uint8_t speed_preempted: 1; 00087 } MsgUlcReport; 00088 00089 #define BUILD_ASSERT(cond) do { (void) sizeof(char [1 - 2*!(cond)]); } while(0) 00090 static void dispatchAssertSizes() { 00091 BUILD_ASSERT(8 == sizeof(MsgUlcCmd)); 00092 BUILD_ASSERT(8 == sizeof(MsgUlcCfg)); 00093 BUILD_ASSERT(8 == sizeof(MsgUlcReport)); 00094 } 00095 #undef BUILD_ASSERT 00096 00097 enum { 00098 ID_ULC_CMD = 0x076, 00099 ID_ULC_CONFIG = 0x077, 00100 ID_ULC_REPORT = 0x078, 00101 }; 00102 00103 } // namespace dataspeed_ulc_can 00104 00105 #endif // _DATASPEED_ULC_CAN_DISPATCH_H 00106