Go to the documentation of this file.00001 #ifndef PACMOD3_CORE_HPP
00002 #define PACMOD3_CORE_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <cstring>
00012 #include <sstream>
00013 #include <cstdint>
00014 #include <memory>
00015 #include <vector>
00016
00017 namespace AS
00018 {
00019 namespace Drivers
00020 {
00021 namespace PACMod3
00022 {
00023 enum VehicleType
00024 {
00025 POLARIS_GEM,
00026 POLARIS_RANGER,
00027 INTERNATIONAL_PROSTAR_122,
00028 LEXUS_RX_450H,
00029 VEHICLE_4,
00030 VEHICLE_5
00031 };
00032
00033 enum DimLevel
00034 {
00035 DIM_LEVEL_MIN = 0,
00036 DIM_LEVEL_1 = 1,
00037 DIM_LEVEL_2 = 2,
00038 DIM_LEVEL_3 = 3,
00039 DIM_LEVEL_4 = 4,
00040 DIM_LEVEL_5 = 5,
00041 DIM_LEVEL_6 = 6,
00042 DIM_LEVEL_7 = 7,
00043 DIM_LEVEL_8 = 8,
00044 DIM_LEVEL_9 = 9,
00045 DIM_LEVEL_10 = 10,
00046 DIM_LEVEL_11 = 11,
00047 DIM_LEVEL_MAX = 12
00048 };
00049
00050 class Pacmod3TxMsg
00051 {
00052 public:
00053 static std::shared_ptr<Pacmod3TxMsg> make_message(const int64_t& can_id);
00054 virtual void parse(uint8_t *in) = 0;
00055 virtual bool isSystem();
00056 };
00057
00058 class SystemRptMsg :
00059 public Pacmod3TxMsg
00060 {
00061 public:
00062 SystemRptMsg();
00063
00064 bool isSystem();
00065
00066 bool enabled;
00067 bool override_active;
00068 bool command_output_fault;
00069 bool input_output_fault;
00070 bool output_reported_fault;
00071 bool pacmod_fault;
00072 bool vehicle_fault;
00073 };
00074
00075 class SystemRptBoolMsg :
00076 public SystemRptMsg
00077 {
00078 public:
00079 SystemRptBoolMsg();
00080
00081 bool manual_input;
00082 bool command;
00083 bool output;
00084
00085 void parse(uint8_t *in);
00086 };
00087
00088 class SystemRptIntMsg :
00089 public SystemRptMsg
00090 {
00091 public:
00092 SystemRptIntMsg();
00093
00094 uint8_t manual_input;
00095 uint8_t command;
00096 uint8_t output;
00097
00098 void parse(uint8_t *in);
00099 };
00100
00101 class SystemRptFloatMsg :
00102 public SystemRptMsg
00103 {
00104 public:
00105 SystemRptFloatMsg();
00106
00107 double manual_input;
00108 double command;
00109 double output;
00110
00111 void parse(uint8_t *in);
00112 };
00113
00114
00115 class GlobalRptMsg :
00116 public Pacmod3TxMsg
00117 {
00118 public:
00119 static const int64_t CAN_ID;
00120
00121 bool enabled;
00122 bool override_active;
00123 bool fault_active;
00124 bool config_fault_active;
00125 bool user_can_timeout;
00126 bool steering_can_timeout;
00127 bool brake_can_timeout;
00128 bool subsystem_can_timeout;
00129 bool vehicle_can_timeout;
00130 uint16_t user_can_read_errors;
00131
00132 void parse(uint8_t *in);
00133 };
00134
00135
00136 class AccelRptMsg :
00137 public SystemRptFloatMsg
00138 {
00139 public:
00140 static const int64_t CAN_ID;
00141 };
00142
00143 class BrakeRptMsg :
00144 public SystemRptFloatMsg
00145 {
00146 public:
00147 static const int64_t CAN_ID;
00148 };
00149
00150 class CruiseControlButtonsRptMsg :
00151 public SystemRptIntMsg
00152 {
00153 public:
00154 static const int64_t CAN_ID;
00155 };
00156
00157 class DashControlsLeftRptMsg :
00158 public SystemRptIntMsg
00159 {
00160 public:
00161 static const int64_t CAN_ID;
00162 };
00163
00164 class DashControlsRightRptMsg :
00165 public SystemRptIntMsg
00166 {
00167 public:
00168 static const int64_t CAN_ID;
00169 };
00170
00171 class HazardLightRptMsg :
00172 public SystemRptBoolMsg
00173 {
00174 public:
00175 static const int64_t CAN_ID;
00176 };
00177
00178 class HeadlightRptMsg :
00179 public SystemRptIntMsg
00180 {
00181 public:
00182 static const int64_t CAN_ID;
00183 };
00184
00185 class HornRptMsg :
00186 public SystemRptBoolMsg
00187 {
00188 public:
00189 static const int64_t CAN_ID;
00190 };
00191
00192 class MediaControlsRptMsg :
00193 public SystemRptIntMsg
00194 {
00195 public:
00196 static const int64_t CAN_ID;
00197 };
00198
00199 class ParkingBrakeRptMsg :
00200 public SystemRptBoolMsg
00201 {
00202 public:
00203 static const int64_t CAN_ID;
00204 };
00205
00206 class ShiftRptMsg :
00207 public SystemRptIntMsg
00208 {
00209 public:
00210 static const int64_t CAN_ID;
00211 };
00212
00213 class SteerRptMsg :
00214 public SystemRptFloatMsg
00215 {
00216 public:
00217 static const int64_t CAN_ID;
00218 };
00219
00220 class TurnSignalRptMsg :
00221 public SystemRptIntMsg
00222 {
00223 public:
00224 static const int64_t CAN_ID;
00225 };
00226
00227 class WiperRptMsg :
00228 public SystemRptIntMsg
00229 {
00230 public:
00231 static const int64_t CAN_ID;
00232 };
00233
00234
00235 class AccelAuxRptMsg :
00236 public Pacmod3TxMsg
00237 {
00238 public:
00239 static const int64_t CAN_ID;
00240
00241 float raw_pedal_pos;
00242 float raw_pedal_force;
00243 bool user_interaction;
00244 bool raw_pedal_pos_is_valid;
00245 bool raw_pedal_force_is_valid;
00246 bool user_interaction_is_valid;
00247
00248 void parse(uint8_t *in);
00249 };
00250
00251 class BrakeAuxRptMsg :
00252 public Pacmod3TxMsg
00253 {
00254 public:
00255 static const int64_t CAN_ID;
00256
00257 float raw_pedal_pos;
00258 float raw_pedal_force;
00259 float raw_brake_pressure;
00260 bool user_interaction;
00261 bool brake_on_off;
00262 bool raw_pedal_pos_is_valid;
00263 bool raw_pedal_force_is_valid;
00264 bool raw_brake_pressure_is_valid;
00265 bool user_interaction_is_valid;
00266 bool brake_on_off_is_valid;
00267
00268 void parse(uint8_t *in);
00269 };
00270
00271 class HeadlightAuxRptMsg :
00272 public Pacmod3TxMsg
00273 {
00274 public:
00275 static const int64_t CAN_ID;
00276
00277 bool headlights_on;
00278 bool headlights_on_bright;
00279 bool fog_lights_on;
00280 uint8_t headlights_mode;
00281 bool headlights_on_is_valid;
00282 bool headlights_on_bright_is_valid;
00283 bool fog_lights_on_is_valid;
00284 bool headlights_mode_is_valid;
00285
00286 void parse(uint8_t *in);
00287 };
00288
00289 class ShiftAuxRptMsg :
00290 public Pacmod3TxMsg
00291 {
00292 public:
00293 static const int64_t CAN_ID;
00294
00295 bool between_gears;
00296 bool stay_in_neutral_mode;
00297 bool brake_interlock_active;
00298 bool speed_interlock_active;
00299 bool between_gears_is_valid;
00300 bool stay_in_neutral_mode_is_valid;
00301 bool brake_interlock_active_is_valid;
00302 bool speed_interlock_active_is_valid;
00303
00304 void parse(uint8_t *in);
00305 };
00306
00307 class SteerAuxRptMsg :
00308 public Pacmod3TxMsg
00309 {
00310 public:
00311 static const int64_t CAN_ID;
00312
00313 float raw_position;
00314 float raw_torque;
00315 float rotation_rate;
00316 bool user_interaction;
00317 bool raw_position_is_valid;
00318 bool raw_torque_is_valid;
00319 bool rotation_rate_is_valid;
00320 bool user_interaction_is_valid;
00321
00322 void parse(uint8_t *in);
00323 };
00324
00325 class TurnAuxRptMsg :
00326 public Pacmod3TxMsg
00327 {
00328 public:
00329 static const int64_t CAN_ID;
00330
00331 bool driver_blinker_bulb_on;
00332 bool passenger_blinker_bulb_on;
00333 bool driver_blinker_bulb_on_is_valid;
00334 bool passenger_blinker_bulb_on_is_valid;
00335
00336 void parse(uint8_t *in);
00337 };
00338
00339 class WiperAuxRptMsg :
00340 public Pacmod3TxMsg
00341 {
00342 public:
00343 static const int64_t CAN_ID;
00344
00345 bool front_wiping;
00346 bool front_spraying;
00347 bool rear_wiping;
00348 bool rear_spraying;
00349 bool spray_near_empty;
00350 bool spray_empty;
00351 bool front_wiping_is_valid;
00352 bool front_spraying_is_valid;
00353 bool rear_wiping_is_valid;
00354 bool rear_spraying_is_valid;
00355 bool spray_near_empty_is_valid;
00356 bool spray_empty_is_valid;
00357
00358 void parse(uint8_t *in);
00359 };
00360
00361
00362 class RearLightsRptMsg :
00363 public Pacmod3TxMsg
00364 {
00365 public:
00366 static const int64_t CAN_ID;
00367
00368 bool brake_lights_on;
00369 bool brake_lights_on_is_valid;
00370 bool reverse_lights_on;
00371 bool reverse_lights_on_is_valid;
00372
00373 void parse(uint8_t *in);
00374 };
00375
00376 class InteriorLightsRptMsg :
00377 public Pacmod3TxMsg
00378 {
00379 public:
00380 static const int64_t CAN_ID;
00381
00382 bool front_dome_lights_on;
00383 bool front_dome_lights_on_is_valid;
00384 bool rear_dome_lights_on;
00385 bool rear_dome_lights_on_is_valid;
00386 bool mood_lights_on;
00387 bool mood_lights_on_is_valid;
00388 DimLevel dim_level;
00389 bool dim_level_is_valid;
00390
00391 void parse(uint8_t *in);
00392 };
00393
00394 class OccupancyRptMsg :
00395 public Pacmod3TxMsg
00396 {
00397 public:
00398 static const int64_t CAN_ID;
00399
00400 bool driver_seat_occupied;
00401 bool driver_seat_occupied_is_valid;
00402 bool passenger_seat_occupied;
00403 bool passenger_seat_occupied_is_valid;
00404 bool rear_seat_occupied;
00405 bool rear_seat_occupied_is_valid;
00406 bool driver_seatbelt_buckled;
00407 bool driver_seatbelt_buckled_is_valid;
00408 bool passenger_seatbelt_buckled;
00409 bool passenger_seatbelt_buckled_is_valid;
00410 bool rear_seatbelt_buckled;
00411 bool rear_seatbelt_buckled_is_valid;
00412
00413 void parse(uint8_t *in);
00414 };
00415
00416 class MotorRpt1Msg :
00417 public Pacmod3TxMsg
00418 {
00419 public:
00420 double current;
00421 double position;
00422
00423 void parse(uint8_t *in);
00424 };
00425
00426 class MotorRpt2Msg :
00427 public Pacmod3TxMsg
00428 {
00429 public:
00430 double encoder_temp;
00431 double motor_temp;
00432 double velocity;
00433
00434 void parse(uint8_t *in);
00435 };
00436
00437 class MotorRpt3Msg :
00438 public Pacmod3TxMsg
00439 {
00440 public:
00441 double torque_output;
00442 double torque_input;
00443
00444 void parse(uint8_t *in);
00445 };
00446
00447 class BrakeMotorRpt1Msg :
00448 public MotorRpt1Msg
00449 {
00450 public:
00451 static const int64_t CAN_ID;
00452 };
00453
00454 class BrakeMotorRpt2Msg :
00455 public MotorRpt2Msg
00456 {
00457 public:
00458 static const int64_t CAN_ID;
00459 };
00460
00461 class BrakeMotorRpt3Msg :
00462 public MotorRpt3Msg
00463 {
00464 public:
00465 static const int64_t CAN_ID;
00466 };
00467
00468 class DateTimeRptMsg :
00469 public Pacmod3TxMsg
00470 {
00471 public:
00472 static const int64_t CAN_ID;
00473
00474 uint32_t year;
00475 uint8_t month;
00476 uint8_t day;
00477 uint8_t hour;
00478 uint8_t minute;
00479 uint8_t second;
00480
00481 void parse(uint8_t *in);
00482 };
00483
00484 class DoorRptMsg :
00485 public Pacmod3TxMsg
00486 {
00487 public:
00488 static const int64_t CAN_ID;
00489
00490 bool driver_door_open;
00491 bool driver_door_open_is_valid;
00492 bool passenger_door_open;
00493 bool passenger_door_open_is_valid;
00494 bool rear_driver_door_open;
00495 bool rear_driver_door_open_is_valid;
00496 bool rear_passenger_door_open;
00497 bool rear_passenger_door_open_is_valid;
00498 bool hood_open;
00499 bool hood_open_is_valid;
00500 bool trunk_open;
00501 bool trunk_open_is_valid;
00502 bool fuel_door_open;
00503 bool fuel_door_open_is_valid;
00504
00505 void parse(uint8_t *in);
00506 };
00507
00508 class LatLonHeadingRptMsg :
00509 public Pacmod3TxMsg
00510 {
00511 public:
00512 static const int64_t CAN_ID;
00513
00514 int latitude_degrees;
00515 uint32_t latitude_minutes;
00516 uint32_t latitude_seconds;
00517 int longitude_degrees;
00518 uint32_t longitude_minutes;
00519 uint32_t longitude_seconds;
00520 double heading;
00521
00522 void parse(uint8_t *in);
00523 };
00524
00525 class SteeringPIDRpt1Msg :
00526 public Pacmod3TxMsg
00527 {
00528 public:
00529 static const int64_t CAN_ID;
00530
00531 double dt;
00532 double Kp;
00533 double Ki;
00534 double Kd;
00535
00536 void parse(uint8_t *in);
00537 };
00538
00539 class SteeringPIDRpt2Msg :
00540 public Pacmod3TxMsg
00541 {
00542 public:
00543 static const int64_t CAN_ID;
00544
00545 double P_term;
00546 double I_term;
00547 double D_term;
00548 double all_terms;
00549
00550 void parse(uint8_t *in);
00551 };
00552
00553 class SteeringPIDRpt3Msg :
00554 public Pacmod3TxMsg
00555 {
00556 public:
00557 static const int64_t CAN_ID;
00558
00559 double new_torque;
00560 double str_angle_desired;
00561 double str_angle_actual;
00562 double error;
00563
00564 void parse(uint8_t *in);
00565 };
00566
00567 class SteeringPIDRpt4Msg :
00568 public Pacmod3TxMsg
00569 {
00570 public:
00571 static const int64_t CAN_ID;
00572
00573 double angular_velocity;
00574 double angular_acceleration;
00575
00576 void parse(uint8_t *in);
00577 };
00578
00579 class SteerMotorRpt1Msg :
00580 public MotorRpt1Msg
00581 {
00582 public:
00583 static const int64_t CAN_ID;
00584 };
00585
00586 class SteerMotorRpt2Msg :
00587 public MotorRpt2Msg
00588 {
00589 public:
00590 static const int64_t CAN_ID;
00591 };
00592
00593 class SteerMotorRpt3Msg :
00594 public MotorRpt3Msg
00595 {
00596 public:
00597 static const int64_t CAN_ID;
00598 };
00599
00600 class VehicleSpeedRptMsg :
00601 public Pacmod3TxMsg
00602 {
00603 public:
00604 static const int64_t CAN_ID;
00605
00606 double vehicle_speed;
00607 bool vehicle_speed_valid;
00608 uint8_t vehicle_speed_raw[2];
00609
00610 void parse(uint8_t *in);
00611 };
00612
00613 class VinRptMsg :
00614 public Pacmod3TxMsg
00615 {
00616 public:
00617 static const int64_t CAN_ID;
00618
00619 std::string mfg_code;
00620 std::string mfg;
00621 char model_year_code;
00622 uint32_t model_year;
00623 uint32_t serial;
00624
00625 void parse(uint8_t *in);
00626 };
00627
00628 class YawRateRptMsg :
00629 public Pacmod3TxMsg
00630 {
00631 public:
00632 static const int64_t CAN_ID;
00633
00634 double yaw_rate;
00635
00636 void parse(uint8_t *in);
00637 };
00638
00639 class WheelSpeedRptMsg :
00640 public Pacmod3TxMsg
00641 {
00642 public:
00643 static const int64_t CAN_ID;
00644
00645 double front_left_wheel_speed;
00646 double front_right_wheel_speed;
00647 double rear_left_wheel_speed;
00648 double rear_right_wheel_speed;
00649
00650 void parse(uint8_t *in);
00651 };
00652
00653 class DetectedObjectRptMsg :
00654 public Pacmod3TxMsg
00655 {
00656 public:
00657 static const int64_t CAN_ID;
00658 double front_object_distance_low_res;
00659 double front_object_distance_high_res;
00660
00661 void parse(uint8_t *in);
00662 };
00663
00664 class VehicleSpecificRpt1Msg :
00665 public Pacmod3TxMsg
00666 {
00667 public:
00668 static const int64_t CAN_ID;
00669
00670 uint8_t shift_pos_1;
00671 uint8_t shift_pos_2;
00672
00673 void parse(uint8_t *in);
00674 };
00675
00676 class VehicleDynamicsRptMsg :
00677 public Pacmod3TxMsg
00678 {
00679 public:
00680 static const int64_t CAN_ID;
00681
00682 uint8_t g_forces;
00683 double brake_torque;
00684
00685 void parse(uint8_t *in);
00686 };
00687
00688
00689 class Pacmod3RxMsg
00690 {
00691 public:
00692 std::vector<uint8_t> data;
00693 };
00694
00695 class SystemCmdBool :
00696 public Pacmod3RxMsg
00697 {
00698 public:
00699 void encode(bool enable,
00700 bool ignore_overrides,
00701 bool clear_override,
00702 bool cmd);
00703 };
00704
00705 class SystemCmdFloat :
00706 public Pacmod3RxMsg
00707 {
00708 public:
00709 void encode(bool enable,
00710 bool ignore_overrides,
00711 bool clear_override,
00712 float cmd);
00713 };
00714
00715 class SystemCmdInt :
00716 public Pacmod3RxMsg
00717 {
00718 public:
00719 void encode(bool enable,
00720 bool ignore_overrides,
00721 bool clear_override,
00722 uint8_t cmd);
00723 };
00724
00725
00726 class AccelCmdMsg :
00727 public SystemCmdFloat
00728 {
00729 public:
00730 static const int64_t CAN_ID;
00731 };
00732
00733 class BrakeCmdMsg :
00734 public SystemCmdFloat
00735 {
00736 public:
00737 static const int64_t CAN_ID;
00738 };
00739
00740 class CruiseControlButtonsCmdMsg :
00741 public SystemCmdInt
00742 {
00743 public:
00744 static const int64_t CAN_ID;
00745 };
00746
00747 class DashControlsLeftCmdMsg :
00748 public SystemCmdInt
00749 {
00750 public:
00751 static const int64_t CAN_ID;
00752 };
00753
00754 class DashControlsRightCmdMsg :
00755 public SystemCmdInt
00756 {
00757 public:
00758 static const int64_t CAN_ID;
00759 };
00760
00761 class HazardLightCmdMsg :
00762 public SystemCmdBool
00763 {
00764 public:
00765 static const int64_t CAN_ID;
00766 };
00767
00768 class HeadlightCmdMsg :
00769 public SystemCmdInt
00770 {
00771 public:
00772 static const int64_t CAN_ID;
00773 };
00774
00775 class HornCmdMsg :
00776 public SystemCmdBool
00777 {
00778 public:
00779 static const int64_t CAN_ID;
00780 };
00781
00782 class MediaControlsCmdMsg :
00783 public SystemCmdInt
00784 {
00785 public:
00786 static const int64_t CAN_ID;
00787 };
00788
00789 class ParkingBrakeCmdMsg :
00790 public SystemCmdBool
00791 {
00792 public:
00793 static const int64_t CAN_ID;
00794 };
00795
00796 class ShiftCmdMsg :
00797 public SystemCmdInt
00798 {
00799 public:
00800 static const int64_t CAN_ID;
00801 };
00802
00803 class SteerCmdMsg :
00804 public SystemCmdFloat
00805 {
00806 public:
00807 static const int64_t CAN_ID;
00808
00809 void encode(bool enabled,
00810 bool ignore_overrides,
00811 bool clear_override,
00812 float steer_pos,
00813 float steer_spd);
00814 };
00815
00816 class TurnSignalCmdMsg :
00817 public SystemCmdInt
00818 {
00819 public:
00820 static const int64_t CAN_ID;
00821 };
00822
00823 class WiperCmdMsg :
00824 public SystemCmdInt
00825 {
00826 public:
00827 static const int64_t CAN_ID;
00828 };
00829 }
00830 }
00831 }
00832
00833 #endif