repo_id
stringlengths
19
138
file_path
stringlengths
32
200
content
stringlengths
1
12.9M
__index_level_0__
int64
0
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/occupancy_rpt_415.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Occupancyrpt415 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Occupancyrpt415(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'REAR_SEATBELT_BUCKLED_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 13, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool rear_seatbelt_buckled_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PASS_SEATBELT_BUCKLED_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 12, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool pass_seatbelt_buckled_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'DRIVER_SEATBELT_BUCKLED_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 11, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool driver_seatbelt_buckled_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'REAR_SEAT_OCCUPIED_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 10, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool rear_seat_occupied_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PASS_SEAT_OCCUPIED_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 9, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool pass_seat_occupied_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'DRIVER_SEAT_OCCUPIED_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 8, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool driver_seat_occupied_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'REAR_SEATBELT_BUCKLED', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 5, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool rear_seatbelt_buckled(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PASS_SEATBELT_BUCKLED', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool pass_seatbelt_buckled(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'DRIVER_SEATBELT_BUCKLED', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool driver_seatbelt_buckled(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'REAR_SEAT_OCCUPIED', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool rear_seat_occupied(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PASS_SEAT_OCCUPIED', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool pass_seat_occupied(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'DRIVER_SEAT_OCCUPIED', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 0, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool driver_seat_occupied(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/brake_aux_rpt_304.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/brake_aux_rpt_304.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Brakeauxrpt304::Brakeauxrpt304() {} const int32_t Brakeauxrpt304::ID = 0x304; void Brakeauxrpt304::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_brake_aux_rpt_304() ->set_brake_on_off_is_valid(brake_on_off_is_valid(bytes, length)); chassis->mutable_brake_aux_rpt_304()->set_brake_on_off( brake_on_off(bytes, length)); chassis->mutable_brake_aux_rpt_304()->set_user_interaction_is_valid( user_interaction_is_valid(bytes, length)); chassis->mutable_brake_aux_rpt_304()->set_user_interaction( user_interaction(bytes, length)); chassis->mutable_brake_aux_rpt_304()->set_raw_brake_pressure_is_valid( raw_brake_pressure_is_valid(bytes, length)); chassis->mutable_brake_aux_rpt_304()->set_raw_brake_pressure( raw_brake_pressure(bytes, length)); chassis->mutable_brake_aux_rpt_304()->set_raw_pedal_force_is_valid( raw_pedal_force_is_valid(bytes, length)); chassis->mutable_brake_aux_rpt_304()->set_raw_pedal_force( raw_pedal_force(bytes, length)); chassis->mutable_brake_aux_rpt_304()->set_raw_pedal_pos_is_valid( raw_pedal_pos_is_valid(bytes, length)); chassis->mutable_brake_aux_rpt_304()->set_raw_pedal_pos( raw_pedal_pos(bytes, length)); } // config detail: {'name': 'brake_on_off_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 60, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Brakeauxrpt304::brake_on_off_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'brake_on_off', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 49, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Brakeauxrpt304::brake_on_off(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'user_interaction_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 59, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Brakeauxrpt304::user_interaction_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'user_interaction', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 48, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Brakeauxrpt304::user_interaction(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'raw_brake_pressure_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 58, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Brakeauxrpt304::raw_brake_pressure_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'raw_brake_pressure', 'offset': 0.0, // 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range': // '[-32.768|32.767]', 'bit': 39, 'type': 'double', 'order': 'motorola', // 'physical_unit': ''} double Brakeauxrpt304::raw_brake_pressure(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 5); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x; return ret; } // config detail: {'name': 'raw_pedal_force_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 57, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Brakeauxrpt304::raw_pedal_force_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'raw_pedal_force', 'offset': 0.0, 'precision': 1.0, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double Brakeauxrpt304::raw_pedal_force(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 3); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x; return ret; } // config detail: {'name': 'raw_pedal_pos_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 56, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Brakeauxrpt304::raw_pedal_pos_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'raw_pedal_pos', 'offset': 0.0, 'precision': 1.0, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double Brakeauxrpt304::raw_pedal_pos(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 1); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/hazard_lights_rpt_214.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/hazard_lights_rpt_214.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Hazardlightsrpt214::Hazardlightsrpt214() {} const int32_t Hazardlightsrpt214::ID = 0x214; void Hazardlightsrpt214::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_hazard_lights_rpt_214()->set_output_value( output_value(bytes, length)); chassis->mutable_hazard_lights_rpt_214()->set_commanded_value( commanded_value(bytes, length)); chassis->mutable_hazard_lights_rpt_214()->set_manual_input( manual_input(bytes, length)); chassis->mutable_hazard_lights_rpt_214()->set_vehicle_fault( vehicle_fault(bytes, length)); chassis->mutable_hazard_lights_rpt_214()->set_pacmod_fault( pacmod_fault(bytes, length)); chassis->mutable_hazard_lights_rpt_214()->set_override_active( override_active(bytes, length)); chassis->mutable_hazard_lights_rpt_214()->set_output_reported_fault( output_reported_fault(bytes, length)); chassis->mutable_hazard_lights_rpt_214()->set_input_output_fault( input_output_fault(bytes, length)); chassis->mutable_hazard_lights_rpt_214()->set_enabled( enabled(bytes, length)); chassis->mutable_hazard_lights_rpt_214()->set_command_output_fault( command_output_fault(bytes, length)); } // config detail: {'name': 'output_value', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 24, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hazardlightsrpt214::output_value(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'commanded_value', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 16, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hazardlightsrpt214::commanded_value(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'manual_input', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 8, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hazardlightsrpt214::manual_input(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'vehicle_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hazardlightsrpt214::vehicle_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(6, 1); bool ret = x; return ret; } // config detail: {'name': 'pacmod_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hazardlightsrpt214::pacmod_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'override_active', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hazardlightsrpt214::override_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'output_reported_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hazardlightsrpt214::output_reported_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'input_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hazardlightsrpt214::input_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'enabled', 'offset': 0.0, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', // 'order': 'motorola', 'physical_unit': ''} bool Hazardlightsrpt214::enabled(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'command_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hazardlightsrpt214::command_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/steering_aux_rpt_32c.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Steeringauxrpt32c : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Steeringauxrpt32c(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'USER_INTERACTION_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 59, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool user_interaction_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'USER_INTERACTION', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 48, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool user_interaction(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'ROTATION_RATE_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 58, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool rotation_rate_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'ROTATION_RATE', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': // 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'} double rotation_rate(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'RAW_TORQUE_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 57, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool raw_torque_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'RAW_TORQUE', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double raw_torque(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'RAW_POSITION_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 56, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool raw_position_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'RAW_POSITION', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double raw_position(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/yaw_rate_rpt_40d.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Yawraterpt40d : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Yawraterpt40d(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'YAW_RATE', 'offset': 0.0, 'precision': 0.01, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-327.68|327.67]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'} double yaw_rate(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/rear_lights_rpt_418.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Rearlightsrpt418 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Rearlightsrpt418(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'REVERSE_LIGHTS_ON_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 9, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool reverse_lights_on_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'BRAKE_LIGHTS_ON_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 8, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool brake_lights_on_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'REVERSE_LIGHTS_ON', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool reverse_lights_on(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'BRAKE_LIGHTS_ON', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool brake_lights_on(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/horn_rpt_21c.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/horn_rpt_21c.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Hornrpt21c::Hornrpt21c() {} const int32_t Hornrpt21c::ID = 0x21C; void Hornrpt21c::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_horn_rpt_21c()->set_vehicle_fault( vehicle_fault(bytes, length)); chassis->mutable_horn_rpt_21c()->set_pacmod_fault( pacmod_fault(bytes, length)); chassis->mutable_horn_rpt_21c()->set_override_active( override_active(bytes, length)); chassis->mutable_horn_rpt_21c()->set_output_reported_fault( output_reported_fault(bytes, length)); chassis->mutable_horn_rpt_21c()->set_input_output_fault( input_output_fault(bytes, length)); chassis->mutable_horn_rpt_21c()->set_enabled( enabled(bytes, length)); chassis->mutable_horn_rpt_21c()->set_command_output_fault( command_output_fault(bytes, length)); chassis->mutable_horn_rpt_21c()->set_output_value( output_value(bytes, length)); chassis->mutable_horn_rpt_21c()->set_commanded_value( commanded_value(bytes, length)); chassis->mutable_horn_rpt_21c()->set_manual_input( manual_input(bytes, length)); } // config detail: {'name': 'vehicle_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hornrpt21c::vehicle_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(6, 1); bool ret = x; return ret; } // config detail: {'name': 'pacmod_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hornrpt21c::pacmod_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'override_active', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hornrpt21c::override_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'output_reported_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hornrpt21c::output_reported_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'input_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hornrpt21c::input_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'enabled', 'offset': 0.0, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', // 'order': 'motorola', 'physical_unit': ''} bool Hornrpt21c::enabled(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'command_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Hornrpt21c::command_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'output_value', 'enum': {0: 'OUTPUT_VALUE_OFF', 1: // 'OUTPUT_VALUE_ON'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 31, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Horn_rpt_21c::Output_valueType Hornrpt21c::output_value( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Horn_rpt_21c::Output_valueType ret = static_cast<Horn_rpt_21c::Output_valueType>(x); return ret; } // config detail: {'name': 'commanded_value', 'enum': {0: 'COMMANDED_VALUE_OFF', // 1: 'COMMANDED_VALUE_ON'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 23, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Horn_rpt_21c::Commanded_valueType Hornrpt21c::commanded_value( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Horn_rpt_21c::Commanded_valueType ret = static_cast<Horn_rpt_21c::Commanded_valueType>(x); return ret; } // config detail: {'name': 'manual_input', 'enum': {0: 'MANUAL_INPUT_OFF', 1: // 'MANUAL_INPUT_ON'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Horn_rpt_21c::Manual_inputType Hornrpt21c::manual_input( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Horn_rpt_21c::Manual_inputType ret = static_cast<Horn_rpt_21c::Manual_inputType>(x); return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/shift_aux_rpt_328.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Shiftauxrpt328 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Shiftauxrpt328(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'SPEED_INTERLOCK_ACTIVE_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 11, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool speed_interlock_active_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'SPEED_INTERLOCK_ACTIVE', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool speed_interlock_active(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'BRAKE_INTERLOCK_ACTIVE_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 10, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool brake_interlock_active_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'BRAKE_INTERLOCK_ACTIVE', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool brake_interlock_active(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'STAY_IN_NEUTRAL_MODE_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 9, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool stay_in_neutral_mode_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'STAY_IN_NEUTRAL_MODE', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool stay_in_neutral_mode(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'BETWEEN_GEARS_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 8, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool between_gears_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'BETWEEN_GEARS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool between_gears(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/shift_cmd_128.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/shift_cmd_128.h" #include "modules/drivers/canbus/common/byte.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; const int32_t Shiftcmd128::ID = 0x128; // public Shiftcmd128::Shiftcmd128() { Reset(); } uint32_t Shiftcmd128::GetPeriod() const { // TODO(QiL) modify every protocol's period manually static const uint32_t PERIOD = 20 * 1000; return PERIOD; } void Shiftcmd128::UpdateData(uint8_t* data) { set_p_ignore_overrides(data, ignore_overrides_); set_p_enable(data, enable_); set_p_clear_override(data, clear_override_); set_p_clear_faults(data, clear_faults_); set_p_shift_cmd(data, shift_cmd_); } void Shiftcmd128::Reset() { // TODO(QiL) you should check this manually ignore_overrides_ = false; enable_ = false; clear_override_ = false; clear_faults_ = false; shift_cmd_ = Shift_cmd_128::SHIFT_CMD_PARK; } Shiftcmd128* Shiftcmd128::set_ignore_overrides(bool ignore_overrides) { ignore_overrides_ = ignore_overrides; return this; } // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Shiftcmd128::set_p_ignore_overrides(uint8_t* data, bool ignore_overrides) { uint8_t x = ignore_overrides; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 1, 1); } Shiftcmd128* Shiftcmd128::set_enable(bool enable) { enable_ = enable; return this; } // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', // 'order': 'motorola', 'physical_unit': ''} void Shiftcmd128::set_p_enable(uint8_t* data, bool enable) { uint8_t x = enable; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 0, 1); } Shiftcmd128* Shiftcmd128::set_clear_override(bool clear_override) { clear_override_ = clear_override; return this; } // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Shiftcmd128::set_p_clear_override(uint8_t* data, bool clear_override) { uint8_t x = clear_override; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 2, 1); } Shiftcmd128* Shiftcmd128::set_clear_faults(bool clear_faults) { clear_faults_ = clear_faults; return this; } // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Shiftcmd128::set_p_clear_faults(uint8_t* data, bool clear_faults) { uint8_t x = clear_faults; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 3, 1); } Shiftcmd128* Shiftcmd128::set_shift_cmd( Shift_cmd_128::Shift_cmdType shift_cmd) { shift_cmd_ = shift_cmd; return this; } // config detail: {'description': 'FORWARD is also HIGH on vehicles with // LOW/HIGH, PARK and LOW only available on certain Vehicles.', 'enum': {0: // 'SHIFT_CMD_PARK', 1: 'SHIFT_CMD_REVERSE', 2: 'SHIFT_CMD_NEUTRAL', 3: // 'SHIFT_CMD_FORWARD_HIGH', 4: 'SHIFT_CMD_LOW', 7: 'SHIFT_CMD_NONE'}, // 'precision': 1.0, 'len': 8, 'name': 'SHIFT_CMD', 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 15, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} void Shiftcmd128::set_p_shift_cmd(uint8_t* data, Shift_cmd_128::Shift_cmdType shift_cmd) { uint8_t x = shift_cmd; Byte to_set(data + 1); to_set.set_value(static_cast<uint8_t>(x), 0, 8); } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/dash_controls_left_rpt_20c.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/dash_controls_left_rpt_20c.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Dashcontrolsleftrpt20c::Dashcontrolsleftrpt20c() {} const int32_t Dashcontrolsleftrpt20c::ID = 0x20C; void Dashcontrolsleftrpt20c::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_dash_controls_left_rpt_20c()->set_output_value( output_value(bytes, length)); chassis->mutable_dash_controls_left_rpt_20c()->set_commanded_value( commanded_value(bytes, length)); chassis->mutable_dash_controls_left_rpt_20c()->set_manual_input( manual_input(bytes, length)); chassis->mutable_dash_controls_left_rpt_20c()->set_vehicle_fault( vehicle_fault(bytes, length)); chassis->mutable_dash_controls_left_rpt_20c()->set_pacmod_fault( pacmod_fault(bytes, length)); chassis->mutable_dash_controls_left_rpt_20c()->set_override_active( override_active(bytes, length)); chassis->mutable_dash_controls_left_rpt_20c()->set_output_reported_fault( output_reported_fault(bytes, length)); chassis->mutable_dash_controls_left_rpt_20c()->set_input_output_fault( input_output_fault(bytes, length)); chassis->mutable_dash_controls_left_rpt_20c()->set_enabled( enabled(bytes, length)); chassis->mutable_dash_controls_left_rpt_20c()->set_command_output_fault( command_output_fault(bytes, length)); } // config detail: {'name': 'output_value', 'enum': {0: // 'OUTPUT_VALUE_DASH_CONTROL_NONE', 1: 'OUTPUT_VALUE_DASH_CONTROL_OK', 2: // 'OUTPUT_VALUE_DASH_CONTROL_LEFT', 3: 'OUTPUT_VALUE_DASH_CONTROL_RIGHT', 4: // 'OUTPUT_VALUE_DASH_CONTROL_UP', 5: 'OUTPUT_VALUE_DASH_CONTROL_DOWN'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|255]', 'bit': 31, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Dash_controls_left_rpt_20c::Output_valueType Dashcontrolsleftrpt20c::output_value(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Dash_controls_left_rpt_20c::Output_valueType ret = static_cast<Dash_controls_left_rpt_20c::Output_valueType>(x); return ret; } // config detail: {'name': 'commanded_value', 'enum': {0: // 'COMMANDED_VALUE_DASH_CONTROL_NONE', 1: 'COMMANDED_VALUE_DASH_CONTROL_OK', 2: // 'COMMANDED_VALUE_DASH_CONTROL_LEFT', 3: 'COMMANDED_VALUE_DASH_CONTROL_RIGHT', // 4: 'COMMANDED_VALUE_DASH_CONTROL_UP', 5: // 'COMMANDED_VALUE_DASH_CONTROL_DOWN'}, 'precision': 1.0, 'len': 8, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|255]', 'bit': // 23, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Dash_controls_left_rpt_20c::Commanded_valueType Dashcontrolsleftrpt20c::commanded_value(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Dash_controls_left_rpt_20c::Commanded_valueType ret = static_cast<Dash_controls_left_rpt_20c::Commanded_valueType>(x); return ret; } // config detail: {'name': 'manual_input', 'enum': {0: // 'MANUAL_INPUT_DASH_CONTROL_NONE', 1: 'MANUAL_INPUT_DASH_CONTROL_OK', 2: // 'MANUAL_INPUT_DASH_CONTROL_LEFT', 3: 'MANUAL_INPUT_DASH_CONTROL_RIGHT', 4: // 'MANUAL_INPUT_DASH_CONTROL_UP', 5: 'MANUAL_INPUT_DASH_CONTROL_DOWN'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|255]', 'bit': 15, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Dash_controls_left_rpt_20c::Manual_inputType Dashcontrolsleftrpt20c::manual_input(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Dash_controls_left_rpt_20c::Manual_inputType ret = static_cast<Dash_controls_left_rpt_20c::Manual_inputType>(x); return ret; } // config detail: {'name': 'vehicle_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Dashcontrolsleftrpt20c::vehicle_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(6, 1); bool ret = x; return ret; } // config detail: {'name': 'pacmod_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Dashcontrolsleftrpt20c::pacmod_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'override_active', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Dashcontrolsleftrpt20c::override_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'output_reported_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Dashcontrolsleftrpt20c::output_reported_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'input_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Dashcontrolsleftrpt20c::input_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'enabled', 'offset': 0.0, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', // 'order': 'motorola', 'physical_unit': ''} bool Dashcontrolsleftrpt20c::enabled(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'command_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Dashcontrolsleftrpt20c::command_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/vehicle_speed_rpt_400.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Vehiclespeedrpt400 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Vehiclespeedrpt400(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'VEHICLE_SPEED', 'offset': 0.0, 'precision': 0.01, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-327.68|327.67]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'm/s'} double vehicle_speed(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'VEHICLE_SPEED_VALID', 'enum': {0: // 'VEHICLE_SPEED_VALID_INVALID', 1: 'VEHICLE_SPEED_VALID_VALID'}, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|1]', 'bit': 16, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Vehicle_speed_rpt_400::Vehicle_speed_validType vehicle_speed_valid( const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/wiper_aux_rpt_334.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/wiper_aux_rpt_334.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Wiperauxrpt334::Wiperauxrpt334() {} const int32_t Wiperauxrpt334::ID = 0x334; void Wiperauxrpt334::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_wiper_aux_rpt_334()->set_spray_empty_is_valid( spray_empty_is_valid(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_spray_empty( spray_empty(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_spray_near_empty_is_valid( spray_near_empty_is_valid(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_spray_near_empty( spray_near_empty(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_rear_spraying_is_valid( rear_spraying_is_valid(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_rear_spraying( rear_spraying(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_rear_wiping_is_valid( rear_wiping_is_valid(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_rear_wiping( rear_wiping(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_front_spraying_is_valid( front_spraying_is_valid(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_front_spraying( front_spraying(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_front_wiping_is_valid( front_wiping_is_valid(bytes, length)); chassis->mutable_wiper_aux_rpt_334()->set_front_wiping( front_wiping(bytes, length)); } // config detail: {'name': 'spray_empty_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 13, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::spray_empty_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'spray_empty', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::spray_empty(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'spray_near_empty_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 12, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::spray_near_empty_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'spray_near_empty', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 4, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::spray_near_empty(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'rear_spraying_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 11, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::rear_spraying_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'rear_spraying', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::rear_spraying(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'rear_wiping_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 10, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::rear_wiping_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'rear_wiping', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::rear_wiping(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'front_spraying_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 9, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::front_spraying_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'front_spraying', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::front_spraying(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'front_wiping_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 8, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::front_wiping_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'front_wiping', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Wiperauxrpt334::front_wiping(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/dash_controls_right_rpt_210.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/dash_controls_right_rpt_210.h" #include "modules/drivers/canbus/common/byte.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; const int32_t Dashcontrolsrightrpt210::ID = 0x210; // public Dashcontrolsrightrpt210::Dashcontrolsrightrpt210() { Reset(); } uint32_t Dashcontrolsrightrpt210::GetPeriod() const { // TODO(QiL) modify every protocol's period manually static const uint32_t PERIOD = 20 * 1000; return PERIOD; } void Dashcontrolsrightrpt210::UpdateData(uint8_t* data) { set_p_output_value(data, output_value_); set_p_commanded_value(data, commanded_value_); set_p_vehicle_fault(data, vehicle_fault_); set_p_pacmod_fault(data, pacmod_fault_); set_p_override_active(data, override_active_); set_p_output_reported_fault(data, output_reported_fault_); set_p_input_output_fault(data, input_output_fault_); set_p_enabled(data, enabled_); set_p_command_output_fault(data, command_output_fault_); set_p_manual_input(data, manual_input_); } void Dashcontrolsrightrpt210::Reset() { // TODO(QiL) you should check this manually output_value_ = Dash_controls_right_rpt_210::OUTPUT_VALUE_DASH_CONTROL_NONE; commanded_value_ = Dash_controls_right_rpt_210::COMMANDED_VALUE_DASH_CONTROL_NONE; vehicle_fault_ = false; pacmod_fault_ = false; override_active_ = false; output_reported_fault_ = false; input_output_fault_ = false; enabled_ = false; command_output_fault_ = false; manual_input_ = Dash_controls_right_rpt_210::MANUAL_INPUT_DASH_CONTROL_NONE; } Dashcontrolsrightrpt210* Dashcontrolsrightrpt210::set_output_value( Dash_controls_right_rpt_210::Output_valueType output_value) { output_value_ = output_value; return this; } // config detail: {'name': 'OUTPUT_VALUE', 'enum': {0: // 'OUTPUT_VALUE_DASH_CONTROL_NONE', 1: 'OUTPUT_VALUE_DASH_CONTROL_OK', 2: // 'OUTPUT_VALUE_DASH_CONTROL_LEFT', 3: 'OUTPUT_VALUE_DASH_CONTROL_RIGHT', 4: // 'OUTPUT_VALUE_DASH_CONTROL_UP', 5: 'OUTPUT_VALUE_DASH_CONTROL_DOWN'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|255]', 'bit': 31, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} void Dashcontrolsrightrpt210::set_p_output_value( uint8_t* data, Dash_controls_right_rpt_210::Output_valueType output_value) { int x = output_value; Byte to_set(data + 3); to_set.set_value(static_cast<uint8_t>(x), 0, 8); } Dashcontrolsrightrpt210* Dashcontrolsrightrpt210::set_commanded_value( Dash_controls_right_rpt_210::Commanded_valueType commanded_value) { commanded_value_ = commanded_value; return this; } // config detail: {'name': 'COMMANDED_VALUE', 'enum': {0: // 'COMMANDED_VALUE_DASH_CONTROL_NONE', 1: 'COMMANDED_VALUE_DASH_CONTROL_OK', 2: // 'COMMANDED_VALUE_DASH_CONTROL_LEFT', 3: 'COMMANDED_VALUE_DASH_CONTROL_RIGHT', // 4: 'COMMANDED_VALUE_DASH_CONTROL_UP', 5: // 'COMMANDED_VALUE_DASH_CONTROL_DOWN'}, 'precision': 1.0, 'len': 8, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|255]', 'bit': // 23, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} void Dashcontrolsrightrpt210::set_p_commanded_value( uint8_t* data, Dash_controls_right_rpt_210::Commanded_valueType commanded_value) { int x = commanded_value; Byte to_set(data + 2); to_set.set_value(static_cast<uint8_t>(x), 0, 8); } Dashcontrolsrightrpt210* Dashcontrolsrightrpt210::set_vehicle_fault( bool vehicle_fault) { vehicle_fault_ = vehicle_fault; return this; } // config detail: {'name': 'VEHICLE_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Dashcontrolsrightrpt210::set_p_vehicle_fault(uint8_t* data, bool vehicle_fault) { int x = vehicle_fault; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 6, 1); } Dashcontrolsrightrpt210* Dashcontrolsrightrpt210::set_pacmod_fault( bool pacmod_fault) { pacmod_fault_ = pacmod_fault; return this; } // config detail: {'name': 'PACMOD_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Dashcontrolsrightrpt210::set_p_pacmod_fault(uint8_t* data, bool pacmod_fault) { int x = pacmod_fault; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 5, 1); } Dashcontrolsrightrpt210* Dashcontrolsrightrpt210::set_override_active( bool override_active) { override_active_ = override_active; return this; } // config detail: {'name': 'OVERRIDE_ACTIVE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Dashcontrolsrightrpt210::set_p_override_active(uint8_t* data, bool override_active) { int x = override_active; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 1, 1); } Dashcontrolsrightrpt210* Dashcontrolsrightrpt210::set_output_reported_fault( bool output_reported_fault) { output_reported_fault_ = output_reported_fault; return this; } // config detail: {'name': 'OUTPUT_REPORTED_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Dashcontrolsrightrpt210::set_p_output_reported_fault( uint8_t* data, bool output_reported_fault) { int x = output_reported_fault; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 4, 1); } Dashcontrolsrightrpt210* Dashcontrolsrightrpt210::set_input_output_fault( bool input_output_fault) { input_output_fault_ = input_output_fault; return this; } // config detail: {'name': 'INPUT_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Dashcontrolsrightrpt210::set_p_input_output_fault( uint8_t* data, bool input_output_fault) { int x = input_output_fault; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 3, 1); } Dashcontrolsrightrpt210* Dashcontrolsrightrpt210::set_enabled(bool enabled) { enabled_ = enabled; return this; } // config detail: {'name': 'ENABLED', 'offset': 0.0, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', // 'order': 'motorola', 'physical_unit': ''} void Dashcontrolsrightrpt210::set_p_enabled(uint8_t* data, bool enabled) { int x = enabled; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 0, 1); } Dashcontrolsrightrpt210* Dashcontrolsrightrpt210::set_command_output_fault( bool command_output_fault) { command_output_fault_ = command_output_fault; return this; } // config detail: {'name': 'COMMAND_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Dashcontrolsrightrpt210::set_p_command_output_fault( uint8_t* data, bool command_output_fault) { int x = command_output_fault; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 2, 1); } Dashcontrolsrightrpt210* Dashcontrolsrightrpt210::set_manual_input( Dash_controls_right_rpt_210::Manual_inputType manual_input) { manual_input_ = manual_input; return this; } // config detail: {'name': 'MANUAL_INPUT', 'enum': {0: // 'MANUAL_INPUT_DASH_CONTROL_NONE', 1: 'MANUAL_INPUT_DASH_CONTROL_OK', 2: // 'MANUAL_INPUT_DASH_CONTROL_LEFT', 3: 'MANUAL_INPUT_DASH_CONTROL_RIGHT', 4: // 'MANUAL_INPUT_DASH_CONTROL_UP', 5: 'MANUAL_INPUT_DASH_CONTROL_DOWN'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|255]', 'bit': 15, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} void Dashcontrolsrightrpt210::set_p_manual_input( uint8_t* data, Dash_controls_right_rpt_210::Manual_inputType manual_input) { int x = manual_input; Byte to_set(data + 1); to_set.set_value(static_cast<uint8_t>(x), 0, 8); } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/interior_lights_rpt_416.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/interior_lights_rpt_416.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Interiorlightsrpt416::Interiorlightsrpt416() {} const int32_t Interiorlightsrpt416::ID = 0x416; void Interiorlightsrpt416::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_interior_lights_rpt_416()->set_dim_level_is_valid( dim_level_is_valid(bytes, length)); chassis->mutable_interior_lights_rpt_416()->set_mood_lights_on_is_valid( mood_lights_on_is_valid(bytes, length)); chassis->mutable_interior_lights_rpt_416()->set_rear_dome_lights_on_is_valid( rear_dome_lights_on_is_valid(bytes, length)); chassis->mutable_interior_lights_rpt_416()->set_front_dome_lights_on_is_valid( front_dome_lights_on_is_valid(bytes, length)); chassis->mutable_interior_lights_rpt_416()->set_dim_level( dim_level(bytes, length)); chassis->mutable_interior_lights_rpt_416()->set_mood_lights_on( mood_lights_on(bytes, length)); chassis->mutable_interior_lights_rpt_416()->set_rear_dome_lights_on( rear_dome_lights_on(bytes, length)); chassis->mutable_interior_lights_rpt_416()->set_front_dome_lights_on( front_dome_lights_on(bytes, length)); } // config detail: {'name': 'dim_level_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 19, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Interiorlightsrpt416::dim_level_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'mood_lights_on_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 18, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Interiorlightsrpt416::mood_lights_on_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'rear_dome_lights_on_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 17, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Interiorlightsrpt416::rear_dome_lights_on_is_valid( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'front_dome_lights_on_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 16, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Interiorlightsrpt416::front_dome_lights_on_is_valid( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'dim_level', 'enum': {0: 'DIM_LEVEL_DIM_LEVEL_MIN', // 1: 'DIM_LEVEL_DIM_LEVEL_1', 2: 'DIM_LEVEL_DIM_LEVEL_2', 3: // 'DIM_LEVEL_DIM_LEVEL_3', 4: 'DIM_LEVEL_DIM_LEVEL_4', 5: // 'DIM_LEVEL_DIM_LEVEL_5', 6: 'DIM_LEVEL_DIM_LEVEL_6', 7: // 'DIM_LEVEL_DIM_LEVEL_7', 8: 'DIM_LEVEL_DIM_LEVEL_8', 9: // 'DIM_LEVEL_DIM_LEVEL_9', 10: 'DIM_LEVEL_DIM_LEVEL_10', 11: // 'DIM_LEVEL_DIM_LEVEL_11', 12: 'DIM_LEVEL_DIM_LEVEL_MAX'}, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|12]', // 'bit': 15, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Interior_lights_rpt_416::Dim_levelType Interiorlightsrpt416::dim_level( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Interior_lights_rpt_416::Dim_levelType ret = static_cast<Interior_lights_rpt_416::Dim_levelType>(x); return ret; } // config detail: {'name': 'mood_lights_on', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Interiorlightsrpt416::mood_lights_on(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'rear_dome_lights_on', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Interiorlightsrpt416::rear_dome_lights_on(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'front_dome_lights_on', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 0, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Interiorlightsrpt416::front_dome_lights_on(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/brake_motor_rpt_3_403.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/brake_motor_rpt_3_403.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Brakemotorrpt3403::Brakemotorrpt3403() {} const int32_t Brakemotorrpt3403::ID = 0x403; void Brakemotorrpt3403::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_brake_motor_rpt_3_403()->set_torque_output( torque_output(bytes, length)); chassis->mutable_brake_motor_rpt_3_403()->set_torque_input( torque_input(bytes, length)); } // config detail: {'name': 'torque_output', 'offset': 0.0, 'precision': 0.001, // 'len': 32, 'is_signed_var': True, 'physical_range': // '[-2147483.648|2147483.647]', 'bit': 7, 'type': 'double', 'order': // 'motorola', 'physical_unit': 'N-m'} double Brakemotorrpt3403::torque_output(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 1); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; Byte t2(bytes + 2); t = t2.get_byte(0, 8); x <<= 8; x |= t; Byte t3(bytes + 3); t = t3.get_byte(0, 8); x <<= 8; x |= t; x <<= 0; x >>= 0; double ret = x * 0.001000; return ret; } // config detail: {'name': 'torque_input', 'offset': 0.0, 'precision': 0.001, // 'len': 32, 'is_signed_var': True, 'physical_range': // '[-2147483.648|2147483.647]', 'bit': 39, 'type': 'double', 'order': // 'motorola', 'physical_unit': 'N-m'} double Brakemotorrpt3403::torque_input(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 5); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; Byte t2(bytes + 6); t = t2.get_byte(0, 8); x <<= 8; x |= t; Byte t3(bytes + 7); t = t3.get_byte(0, 8); x <<= 8; x |= t; x <<= 0; x >>= 0; double ret = x * 0.001000; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/dash_controls_right_rpt_210.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Dashcontrolsrightrpt210 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Dashcontrolsrightrpt210(); uint32_t GetPeriod() const override; void UpdateData(uint8_t* data) override; void Reset() override; // config detail: {'name': 'OUTPUT_VALUE', 'enum': {0: // 'OUTPUT_VALUE_DASH_CONTROL_NONE', 1: 'OUTPUT_VALUE_DASH_CONTROL_OK', 2: // 'OUTPUT_VALUE_DASH_CONTROL_LEFT', 3: 'OUTPUT_VALUE_DASH_CONTROL_RIGHT', 4: // 'OUTPUT_VALUE_DASH_CONTROL_UP', 5: 'OUTPUT_VALUE_DASH_CONTROL_DOWN'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|255]', 'bit': 31, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Dashcontrolsrightrpt210* set_output_value( Dash_controls_right_rpt_210::Output_valueType output_value); // config detail: {'name': 'COMMANDED_VALUE', 'enum': {0: // 'COMMANDED_VALUE_DASH_CONTROL_NONE', 1: 'COMMANDED_VALUE_DASH_CONTROL_OK', // 2: 'COMMANDED_VALUE_DASH_CONTROL_LEFT', 3: // 'COMMANDED_VALUE_DASH_CONTROL_RIGHT', 4: 'COMMANDED_VALUE_DASH_CONTROL_UP', // 5: 'COMMANDED_VALUE_DASH_CONTROL_DOWN'}, 'precision': 1.0, 'len': 8, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|255]', 'bit': // 23, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Dashcontrolsrightrpt210* set_commanded_value( Dash_controls_right_rpt_210::Commanded_valueType commanded_value); // config detail: {'name': 'VEHICLE_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Dashcontrolsrightrpt210* set_vehicle_fault(bool vehicle_fault); // config detail: {'name': 'PACMOD_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Dashcontrolsrightrpt210* set_pacmod_fault(bool pacmod_fault); // config detail: {'name': 'OVERRIDE_ACTIVE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Dashcontrolsrightrpt210* set_override_active(bool override_active); // config detail: {'name': 'OUTPUT_REPORTED_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} Dashcontrolsrightrpt210* set_output_reported_fault( bool output_reported_fault); // config detail: {'name': 'INPUT_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} Dashcontrolsrightrpt210* set_input_output_fault(bool input_output_fault); // config detail: {'name': 'ENABLED', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} Dashcontrolsrightrpt210* set_enabled(bool enabled); // config detail: {'name': 'COMMAND_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} Dashcontrolsrightrpt210* set_command_output_fault(bool command_output_fault); // config detail: {'name': 'MANUAL_INPUT', 'enum': {0: // 'MANUAL_INPUT_DASH_CONTROL_NONE', 1: 'MANUAL_INPUT_DASH_CONTROL_OK', 2: // 'MANUAL_INPUT_DASH_CONTROL_LEFT', 3: 'MANUAL_INPUT_DASH_CONTROL_RIGHT', 4: // 'MANUAL_INPUT_DASH_CONTROL_UP', 5: 'MANUAL_INPUT_DASH_CONTROL_DOWN'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|255]', 'bit': 15, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Dashcontrolsrightrpt210* set_manual_input( Dash_controls_right_rpt_210::Manual_inputType manual_input); private: // config detail: {'name': 'OUTPUT_VALUE', 'enum': {0: // 'OUTPUT_VALUE_DASH_CONTROL_NONE', 1: 'OUTPUT_VALUE_DASH_CONTROL_OK', 2: // 'OUTPUT_VALUE_DASH_CONTROL_LEFT', 3: 'OUTPUT_VALUE_DASH_CONTROL_RIGHT', 4: // 'OUTPUT_VALUE_DASH_CONTROL_UP', 5: 'OUTPUT_VALUE_DASH_CONTROL_DOWN'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|255]', 'bit': 31, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} void set_p_output_value( uint8_t* data, Dash_controls_right_rpt_210::Output_valueType output_value); // config detail: {'name': 'COMMANDED_VALUE', 'enum': {0: // 'COMMANDED_VALUE_DASH_CONTROL_NONE', 1: 'COMMANDED_VALUE_DASH_CONTROL_OK', // 2: 'COMMANDED_VALUE_DASH_CONTROL_LEFT', 3: // 'COMMANDED_VALUE_DASH_CONTROL_RIGHT', 4: 'COMMANDED_VALUE_DASH_CONTROL_UP', // 5: 'COMMANDED_VALUE_DASH_CONTROL_DOWN'}, 'precision': 1.0, 'len': 8, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|255]', 'bit': // 23, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} void set_p_commanded_value( uint8_t* data, Dash_controls_right_rpt_210::Commanded_valueType commanded_value); // config detail: {'name': 'VEHICLE_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_vehicle_fault(uint8_t* data, bool vehicle_fault); // config detail: {'name': 'PACMOD_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_pacmod_fault(uint8_t* data, bool pacmod_fault); // config detail: {'name': 'OVERRIDE_ACTIVE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_override_active(uint8_t* data, bool override_active); // config detail: {'name': 'OUTPUT_REPORTED_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} void set_p_output_reported_fault(uint8_t* data, bool output_reported_fault); // config detail: {'name': 'INPUT_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} void set_p_input_output_fault(uint8_t* data, bool input_output_fault); // config detail: {'name': 'ENABLED', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_enabled(uint8_t* data, bool enabled); // config detail: {'name': 'COMMAND_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} void set_p_command_output_fault(uint8_t* data, bool command_output_fault); // config detail: {'name': 'MANUAL_INPUT', 'enum': {0: // 'MANUAL_INPUT_DASH_CONTROL_NONE', 1: 'MANUAL_INPUT_DASH_CONTROL_OK', 2: // 'MANUAL_INPUT_DASH_CONTROL_LEFT', 3: 'MANUAL_INPUT_DASH_CONTROL_RIGHT', 4: // 'MANUAL_INPUT_DASH_CONTROL_UP', 5: 'MANUAL_INPUT_DASH_CONTROL_DOWN'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|255]', 'bit': 15, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} void set_p_manual_input( uint8_t* data, Dash_controls_right_rpt_210::Manual_inputType manual_input); private: Dash_controls_right_rpt_210::Output_valueType output_value_; Dash_controls_right_rpt_210::Commanded_valueType commanded_value_; bool vehicle_fault_; bool pacmod_fault_; bool override_active_; bool output_reported_fault_; bool input_output_fault_; bool enabled_; bool command_output_fault_; Dash_controls_right_rpt_210::Manual_inputType manual_input_; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/steering_rpt_22c.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/steering_rpt_22c.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Steeringrpt22c::Steeringrpt22c() {} const int32_t Steeringrpt22c::ID = 0x22C; void Steeringrpt22c::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_steering_rpt_22c()->set_vehicle_fault( vehicle_fault(bytes, length)); chassis->mutable_steering_rpt_22c()->set_pacmod_fault( pacmod_fault(bytes, length)); chassis->mutable_steering_rpt_22c()->set_override_active( override_active(bytes, length)); chassis->mutable_steering_rpt_22c()->set_output_reported_fault( output_reported_fault(bytes, length)); chassis->mutable_steering_rpt_22c()->set_input_output_fault( input_output_fault(bytes, length)); chassis->mutable_steering_rpt_22c()->set_enabled( enabled(bytes, length)); chassis->mutable_steering_rpt_22c()->set_command_output_fault( command_output_fault(bytes, length)); chassis->mutable_steering_rpt_22c()->set_manual_input( manual_input(bytes, length)); chassis->mutable_steering_rpt_22c()->set_commanded_value( commanded_value(bytes, length)); chassis->mutable_steering_rpt_22c()->set_output_value( output_value(bytes, length)); } // config detail: {'name': 'vehicle_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Steeringrpt22c::vehicle_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(6, 1); bool ret = x; return ret; } // config detail: {'name': 'pacmod_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Steeringrpt22c::pacmod_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'override_active', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Steeringrpt22c::override_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'output_reported_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Steeringrpt22c::output_reported_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'input_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Steeringrpt22c::input_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'enabled', 'offset': 0.0, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', // 'order': 'motorola', 'physical_unit': ''} bool Steeringrpt22c::enabled(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'command_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Steeringrpt22c::command_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'manual_input', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 15, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad'} double Steeringrpt22c::manual_input(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 2); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x * 0.001000; return ret; } // config detail: {'name': 'commanded_value', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 31, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad'} double Steeringrpt22c::commanded_value(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 4); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x * 0.001000; return ret; } // config detail: {'name': 'output_value', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 47, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad'} double Steeringrpt22c::output_value(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 5); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 6); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x * 0.001000; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/BUILD
load("@rules_cc//cc:defs.bzl", "cc_library") load("//tools:cpplint.bzl", "cpplint") package(default_visibility = ["//visibility:public"]) CANBUS_COPTS = ["-DMODULE_NAME=\\\"canbus\\\""] cc_library( name = "canbus_lexus_protocol", srcs = glob([ "*.cc", ]), hdrs = glob([ "*.h", ]), copts = CANBUS_COPTS, deps = [ "//modules/canbus_vehicle/lexus/proto:lexus_cc_proto", "//modules/drivers/canbus/can_comm:message_manager_base", "//modules/drivers/canbus/common:canbus_common", ], ) cpplint()
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/accel_cmd_100.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/accel_cmd_100.h" #include <algorithm> #include "modules/drivers/canbus/common/byte.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; const int32_t Accelcmd100::ID = 0x100; // public Accelcmd100::Accelcmd100() { Reset(); } uint32_t Accelcmd100::GetPeriod() const { // TODO(QiL) modify every protocol's period manually static const uint32_t PERIOD = 20 * 1000; return PERIOD; } void Accelcmd100::UpdateData(uint8_t* data) { set_p_ignore_overrides(data, ignore_overrides_); set_p_enable(data, enable_); set_p_clear_override(data, clear_override_); set_p_clear_faults(data, clear_faults_); set_p_accel_cmd(data, accel_cmd_); } void Accelcmd100::Reset() { // TODO(QiL) you should check this manually ignore_overrides_ = false; enable_ = false; clear_override_ = false; clear_faults_ = false; accel_cmd_ = 0.0; } Accelcmd100* Accelcmd100::set_ignore_overrides(bool ignore_overrides) { ignore_overrides_ = ignore_overrides; return this; } // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Accelcmd100::set_p_ignore_overrides(uint8_t* data, bool ignore_overrides) { uint8_t x = ignore_overrides; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 1, 1); } Accelcmd100* Accelcmd100::set_enable(bool enable) { enable_ = enable; return this; } // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', // 'order': 'motorola', 'physical_unit': ''} void Accelcmd100::set_p_enable(uint8_t* data, bool enable) { uint8_t x = enable; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 0, 1); } Accelcmd100* Accelcmd100::set_clear_override(bool clear_override) { clear_override_ = clear_override; return this; } // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Accelcmd100::set_p_clear_override(uint8_t* data, bool clear_override) { uint8_t x = clear_override; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 2, 1); } Accelcmd100* Accelcmd100::set_clear_faults(bool clear_faults) { clear_faults_ = clear_faults; return this; } // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Accelcmd100::set_p_clear_faults(uint8_t* data, bool clear_faults) { uint8_t x = clear_faults; Byte to_set(data + 0); to_set.set_value(static_cast<uint8_t>(x), 3, 1); } Accelcmd100* Accelcmd100::set_accel_cmd(double accel_cmd) { accel_cmd_ = accel_cmd; return this; } // config detail: {'name': 'ACCEL_CMD', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 15, // 'type': 'double', 'order': 'motorola', 'physical_unit': ''} void Accelcmd100::set_p_accel_cmd(uint8_t* data, double accel_cmd) { const double scaling_bias = 0.0; // estimated from the garage test data const double scaling_gain = 1.20; // estimated from the garage test data accel_cmd = std::max(0.0, (accel_cmd - scaling_bias) / (scaling_gain * 100)); accel_cmd = ProtocolData::BoundedValue(0.0, 1.0, accel_cmd); // TODO(AS): fix this scaling. int x = static_cast<int>(accel_cmd / 0.001000); uint8_t t = 0; t = static_cast<uint8_t>(x & 0xFF); Byte to_set0(data + 2); to_set0.set_value(t, 0, 8); x >>= 8; t = static_cast<uint8_t>(x & 0xFF); Byte to_set1(data + 1); to_set1.set_value(t, 0, 8); } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/global_rpt_10.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Globalrpt10 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Globalrpt10(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'CONFIG_FAULT_ACTIVE', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 15, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool config_fault_active(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PACMOD_SUBSYSTEM_TIMEOUT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 5, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool pacmod_subsystem_timeout(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PACMOD_SYSTEM_ENABLED', 'enum': {0: // 'PACMOD_SYSTEM_ENABLED_CONTROL_DISABLED', 1: // 'PACMOD_SYSTEM_ENABLED_CONTROL_ENABLED'}, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0, // 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Global_rpt_10::Pacmod_system_enabledType pacmod_system_enabled( const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PACMOD_SYSTEM_OVERRIDE_ACTIVE', 'enum': {0: // 'PACMOD_SYSTEM_OVERRIDE_ACTIVE_NOT_OVERRIDDEN', 1: // 'PACMOD_SYSTEM_OVERRIDE_ACTIVE_OVERRIDDEN'}, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Global_rpt_10::Pacmod_system_override_activeType pacmod_system_override_active(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PACMOD_SYSTEM_FAULT_ACTIVE', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 7, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool pacmod_system_fault_active(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'VEH_CAN_TIMEOUT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool veh_can_timeout(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'STR_CAN_TIMEOUT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool str_can_timeout(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'BRK_CAN_TIMEOUT', 'enum': {0: // 'BRK_CAN_TIMEOUT_NO_ACTIVE_CAN_TIMEOUT', 1: // 'BRK_CAN_TIMEOUT_ACTIVE_CAN_TIMEOUT'}, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 4, // 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Global_rpt_10::Brk_can_timeoutType brk_can_timeout( const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'USR_CAN_TIMEOUT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool usr_can_timeout(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'USR_CAN_READ_ERRORS', 'offset': 0.0, // 'precision': 1.0, 'len': 16, 'is_signed_var': False, 'physical_range': // '[0|65535]', 'bit': 55, 'type': 'int', 'order': 'motorola', // 'physical_unit': ''} int usr_can_read_errors(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/headlight_rpt_218.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/headlight_rpt_218.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Headlightrpt218::Headlightrpt218() {} const int32_t Headlightrpt218::ID = 0x218; void Headlightrpt218::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_headlight_rpt_218()->set_vehicle_fault( vehicle_fault(bytes, length)); chassis->mutable_headlight_rpt_218()->set_pacmod_fault( pacmod_fault(bytes, length)); chassis->mutable_headlight_rpt_218()->set_override_active( override_active(bytes, length)); chassis->mutable_headlight_rpt_218()->set_output_reported_fault( output_reported_fault(bytes, length)); chassis->mutable_headlight_rpt_218()->set_input_output_fault( input_output_fault(bytes, length)); chassis->mutable_headlight_rpt_218()->set_enabled( enabled(bytes, length)); chassis->mutable_headlight_rpt_218()->set_command_output_fault( command_output_fault(bytes, length)); chassis->mutable_headlight_rpt_218()->set_output_value( output_value(bytes, length)); chassis->mutable_headlight_rpt_218()->set_manual_input( manual_input(bytes, length)); chassis->mutable_headlight_rpt_218()->set_commanded_value( commanded_value(bytes, length)); } // config detail: {'name': 'vehicle_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Headlightrpt218::vehicle_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(6, 1); bool ret = x; return ret; } // config detail: {'name': 'pacmod_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Headlightrpt218::pacmod_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'override_active', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Headlightrpt218::override_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'output_reported_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Headlightrpt218::output_reported_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'input_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Headlightrpt218::input_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'enabled', 'offset': 0.0, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', // 'order': 'motorola', 'physical_unit': ''} bool Headlightrpt218::enabled(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'command_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Headlightrpt218::command_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'output_value', 'enum': {0: // 'OUTPUT_VALUE_HEADLIGHTS_OFF', 1: 'OUTPUT_VALUE_LOW_BEAMS', 2: // 'OUTPUT_VALUE_HIGH_BEAMS'}, 'precision': 1.0, 'len': 8, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit': 31, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Headlight_rpt_218::Output_valueType Headlightrpt218::output_value( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Headlight_rpt_218::Output_valueType ret = static_cast<Headlight_rpt_218::Output_valueType>(x); return ret; } // config detail: {'name': 'manual_input', 'enum': {0: // 'MANUAL_INPUT_HEADLIGHTS_OFF', 1: 'MANUAL_INPUT_LOW_BEAMS', 2: // 'MANUAL_INPUT_HIGH_BEAMS'}, 'precision': 1.0, 'len': 8, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit': 15, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Headlight_rpt_218::Manual_inputType Headlightrpt218::manual_input( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Headlight_rpt_218::Manual_inputType ret = static_cast<Headlight_rpt_218::Manual_inputType>(x); return ret; } // config detail: {'name': 'commanded_value', 'enum': {0: // 'COMMANDED_VALUE_HEADLIGHTS_OFF', 1: 'COMMANDED_VALUE_LOW_BEAMS', 2: // 'COMMANDED_VALUE_HIGH_BEAMS'}, 'precision': 1.0, 'len': 8, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit': 23, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Headlight_rpt_218::Commanded_valueType Headlightrpt218::commanded_value( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Headlight_rpt_218::Commanded_valueType ret = static_cast<Headlight_rpt_218::Commanded_valueType>(x); return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/cruise_control_buttons_rpt_208.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/cruise_control_buttons_rpt_208.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Cruisecontrolbuttonsrpt208::Cruisecontrolbuttonsrpt208() {} const int32_t Cruisecontrolbuttonsrpt208::ID = 0x208; void Cruisecontrolbuttonsrpt208::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_cruise_control_buttons_rpt_208()->set_output_value( output_value(bytes, length)); chassis->mutable_cruise_control_buttons_rpt_208()->set_manual_input( manual_input(bytes, length)); chassis->mutable_cruise_control_buttons_rpt_208()->set_commanded_value( commanded_value(bytes, length)); chassis->mutable_cruise_control_buttons_rpt_208()->set_vehicle_fault( vehicle_fault(bytes, length)); chassis->mutable_cruise_control_buttons_rpt_208()->set_pacmod_fault( pacmod_fault(bytes, length)); chassis->mutable_cruise_control_buttons_rpt_208()->set_override_active( override_active(bytes, length)); chassis->mutable_cruise_control_buttons_rpt_208()->set_output_reported_fault( output_reported_fault(bytes, length)); chassis->mutable_cruise_control_buttons_rpt_208()->set_input_output_fault( input_output_fault(bytes, length)); chassis->mutable_cruise_control_buttons_rpt_208()->set_enabled( enabled(bytes, length)); chassis->mutable_cruise_control_buttons_rpt_208()->set_command_output_fault( command_output_fault(bytes, length)); } // config detail: {'name': 'output_value', 'enum': {0: // 'OUTPUT_VALUE_CRUISE_CONTROL_NONE', 1: 'OUTPUT_VALUE_CRUISE_CONTROL_CNCL', 2: // 'OUTPUT_VALUE_CRUISE_CONTROL_ACC_FURTHER', 3: // 'OUTPUT_VALUE_CRUISE_CONTROL_ACC_CLOSER', 4: // 'OUTPUT_VALUE_CRUISE_CONTROL_SET_DEC', 5: // 'OUTPUT_VALUE_CRUISE_CONTROL_RES_INC', 6: // 'OUTPUT_VALUE_CRUISE_CONTROL_ON_OFF'}, 'precision': 1.0, 'len': 8, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|255]', 'bit': // 31, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Cruise_control_buttons_rpt_208::Output_valueType Cruisecontrolbuttonsrpt208::output_value(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Cruise_control_buttons_rpt_208::Output_valueType ret = static_cast<Cruise_control_buttons_rpt_208::Output_valueType>(x); return ret; } // config detail: {'name': 'manual_input', 'enum': {0: // 'MANUAL_INPUT_CRUISE_CONTROL_NONE', 1: 'MANUAL_INPUT_CRUISE_CONTROL_CNCL', 2: // 'MANUAL_INPUT_CRUISE_CONTROL_ACC_FURTHER', 3: // 'MANUAL_INPUT_CRUISE_CONTROL_ACC_CLOSER', 4: // 'MANUAL_INPUT_CRUISE_CONTROL_SET_DEC', 5: // 'MANUAL_INPUT_CRUISE_CONTROL_RES_INC', 6: // 'MANUAL_INPUT_CRUISE_CONTROL_ON_OFF'}, 'precision': 1.0, 'len': 8, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|255]', 'bit': // 15, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Cruise_control_buttons_rpt_208::Manual_inputType Cruisecontrolbuttonsrpt208::manual_input(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Cruise_control_buttons_rpt_208::Manual_inputType ret = static_cast<Cruise_control_buttons_rpt_208::Manual_inputType>(x); return ret; } // config detail: {'name': 'commanded_value', 'enum': {0: // 'COMMANDED_VALUE_CRUISE_CONTROL_NONE', 1: // 'COMMANDED_VALUE_CRUISE_CONTROL_CNCL', 2: // 'COMMANDED_VALUE_CRUISE_CONTROL_ACC_FURTHER', 3: // 'COMMANDED_VALUE_CRUISE_CONTROL_ACC_CLOSER', 4: // 'COMMANDED_VALUE_CRUISE_CONTROL_SET_DEC', 5: // 'COMMANDED_VALUE_CRUISE_CONTROL_RES_INC', 6: // 'COMMANDED_VALUE_CRUISE_CONTROL_ON_OFF'}, 'precision': 1.0, 'len': 8, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|255]', 'bit': // 23, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Cruise_control_buttons_rpt_208::Commanded_valueType Cruisecontrolbuttonsrpt208::commanded_value(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Cruise_control_buttons_rpt_208::Commanded_valueType ret = static_cast<Cruise_control_buttons_rpt_208::Commanded_valueType>(x); return ret; } // config detail: {'name': 'vehicle_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Cruisecontrolbuttonsrpt208::vehicle_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(6, 1); bool ret = x; return ret; } // config detail: {'name': 'pacmod_fault', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Cruisecontrolbuttonsrpt208::pacmod_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'override_active', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Cruisecontrolbuttonsrpt208::override_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'output_reported_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Cruisecontrolbuttonsrpt208::output_reported_fault( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'input_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Cruisecontrolbuttonsrpt208::input_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'enabled', 'offset': 0.0, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', // 'order': 'motorola', 'physical_unit': ''} bool Cruisecontrolbuttonsrpt208::enabled(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'command_output_fault', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Cruisecontrolbuttonsrpt208::command_output_fault(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/accel_aux_rpt_300.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/accel_aux_rpt_300.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Accelauxrpt300::Accelauxrpt300() {} const int32_t Accelauxrpt300::ID = 0x300; void Accelauxrpt300::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_accel_aux_rpt_300()->set_user_interaction_is_valid( user_interaction_is_valid(bytes, length)); chassis->mutable_accel_aux_rpt_300()->set_user_interaction( user_interaction(bytes, length)); chassis->mutable_accel_aux_rpt_300()->set_raw_pedal_force_is_valid( raw_pedal_force_is_valid(bytes, length)); chassis->mutable_accel_aux_rpt_300()->set_raw_pedal_force( raw_pedal_force(bytes, length)); chassis->mutable_accel_aux_rpt_300()->set_raw_pedal_pos_is_valid( raw_pedal_pos_is_valid(bytes, length)); chassis->mutable_accel_aux_rpt_300()->set_raw_pedal_pos( raw_pedal_pos(bytes, length)); } // config detail: {'name': 'user_interaction_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 42, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Accelauxrpt300::user_interaction_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 5); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'user_interaction', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 32, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Accelauxrpt300::user_interaction(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'raw_pedal_force_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 41, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Accelauxrpt300::raw_pedal_force_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 5); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'raw_pedal_force', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double Accelauxrpt300::raw_pedal_force(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 3); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x * 0.001000; return ret; } // config detail: {'name': 'raw_pedal_pos_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 40, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Accelauxrpt300::raw_pedal_pos_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 5); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'raw_pedal_pos', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double Accelauxrpt300::raw_pedal_pos(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 1); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x * 0.001000; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/vin_rpt_414.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Vinrpt414 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Vinrpt414(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'VEH_SERIAL', 'offset': 0.0, 'precision': 1.0, // 'len': 24, 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 39, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} int veh_serial(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'VEH_MY_CODE', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 31, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} int veh_my_code(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'VEH_MFG_CODE', 'offset': 0.0, 'precision': 1.0, // 'len': 24, 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 7, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} int veh_mfg_code(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/hazard_lights_rpt_214.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Hazardlightsrpt214 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Hazardlightsrpt214(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'OUTPUT_VALUE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 24, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool output_value(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'COMMANDED_VALUE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 16, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool commanded_value(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'MANUAL_INPUT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 8, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool manual_input(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'VEHICLE_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool vehicle_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PACMOD_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool pacmod_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OVERRIDE_ACTIVE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool override_active(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OUTPUT_REPORTED_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool output_reported_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'INPUT_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool input_output_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'ENABLED', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} bool enabled(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'COMMAND_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool command_output_fault(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/headlight_cmd_118.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Headlightcmd118 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Headlightcmd118(); uint32_t GetPeriod() const override; void UpdateData(uint8_t* data) override; void Reset() override; // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} Headlightcmd118* set_ignore_overrides(bool ignore_overrides); // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} Headlightcmd118* set_enable(bool enable); // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Headlightcmd118* set_clear_override(bool clear_override); // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Headlightcmd118* set_clear_faults(bool clear_faults); // config detail: {'name': 'HEADLIGHT_CMD', 'enum': {0: // 'HEADLIGHT_CMD_HEADLIGHTS_OFF', 1: 'HEADLIGHT_CMD_LOW_BEAMS', 2: // 'HEADLIGHT_CMD_HIGH_BEAMS'}, 'precision': 1.0, 'len': 8, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit': 15, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Headlightcmd118* set_headlight_cmd( Headlight_cmd_118::Headlight_cmdType headlight_cmd); private: // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} void set_p_ignore_overrides(uint8_t* data, bool ignore_overrides); // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_enable(uint8_t* data, bool enable); // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_clear_override(uint8_t* data, bool clear_override); // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_clear_faults(uint8_t* data, bool clear_faults); // config detail: {'name': 'HEADLIGHT_CMD', 'enum': {0: // 'HEADLIGHT_CMD_HEADLIGHTS_OFF', 1: 'HEADLIGHT_CMD_LOW_BEAMS', 2: // 'HEADLIGHT_CMD_HIGH_BEAMS'}, 'precision': 1.0, 'len': 8, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit': 15, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} void set_p_headlight_cmd(uint8_t* data, Headlight_cmd_118::Headlight_cmdType headlight_cmd); private: bool ignore_overrides_; bool enable_; bool clear_override_; bool clear_faults_; Headlight_cmd_118::Headlight_cmdType headlight_cmd_; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/global_rpt_10.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/global_rpt_10.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Globalrpt10::Globalrpt10() {} const int32_t Globalrpt10::ID = 0x10; void Globalrpt10::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_global_rpt_10()->set_config_fault_active( config_fault_active(bytes, length)); chassis->mutable_global_rpt_10()->set_pacmod_subsystem_timeout( pacmod_subsystem_timeout(bytes, length)); chassis->mutable_global_rpt_10()->set_pacmod_system_enabled( pacmod_system_enabled(bytes, length)); chassis->mutable_global_rpt_10()->set_pacmod_system_override_active( pacmod_system_override_active(bytes, length)); chassis->mutable_global_rpt_10()->set_pacmod_system_fault_active( pacmod_system_fault_active(bytes, length)); chassis->mutable_global_rpt_10()->set_veh_can_timeout( veh_can_timeout(bytes, length)); chassis->mutable_global_rpt_10()->set_str_can_timeout( str_can_timeout(bytes, length)); chassis->mutable_global_rpt_10()->set_brk_can_timeout( brk_can_timeout(bytes, length)); chassis->mutable_global_rpt_10()->set_usr_can_timeout( usr_can_timeout(bytes, length)); chassis->mutable_global_rpt_10()->set_usr_can_read_errors( usr_can_read_errors(bytes, length)); } // config detail: {'name': 'config_fault_active', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 15, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Globalrpt10::config_fault_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(7, 1); bool ret = x; return ret; } // config detail: {'name': 'pacmod_subsystem_timeout', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 5, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Globalrpt10::pacmod_subsystem_timeout(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'pacmod_system_enabled', 'enum': {0: // 'PACMOD_SYSTEM_ENABLED_CONTROL_DISABLED', 1: // 'PACMOD_SYSTEM_ENABLED_CONTROL_ENABLED'}, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0, // 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Global_rpt_10::Pacmod_system_enabledType Globalrpt10::pacmod_system_enabled( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); Global_rpt_10::Pacmod_system_enabledType ret = static_cast<Global_rpt_10::Pacmod_system_enabledType>(x); return ret; } // config detail: {'name': 'pacmod_system_override_active', 'enum': {0: // 'PACMOD_SYSTEM_OVERRIDE_ACTIVE_NOT_OVERRIDDEN', 1: // 'PACMOD_SYSTEM_OVERRIDE_ACTIVE_OVERRIDDEN'}, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Global_rpt_10::Pacmod_system_override_activeType Globalrpt10::pacmod_system_override_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); Global_rpt_10::Pacmod_system_override_activeType ret = static_cast<Global_rpt_10::Pacmod_system_override_activeType>(x); return ret; } // config detail: {'name': 'pacmod_system_fault_active', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 7, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Globalrpt10::pacmod_system_fault_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(7, 1); bool ret = x; return ret; } // config detail: {'name': 'veh_can_timeout', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Globalrpt10::veh_can_timeout(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(6, 1); bool ret = x; return ret; } // config detail: {'name': 'str_can_timeout', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Globalrpt10::str_can_timeout(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'brk_can_timeout', 'enum': {0: // 'BRK_CAN_TIMEOUT_NO_ACTIVE_CAN_TIMEOUT', 1: // 'BRK_CAN_TIMEOUT_ACTIVE_CAN_TIMEOUT'}, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 4, // 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Global_rpt_10::Brk_can_timeoutType Globalrpt10::brk_can_timeout( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(4, 1); Global_rpt_10::Brk_can_timeoutType ret = static_cast<Global_rpt_10::Brk_can_timeoutType>(x); return ret; } // config detail: {'name': 'usr_can_timeout', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Globalrpt10::usr_can_timeout(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'usr_can_read_errors', 'offset': 0.0, // 'precision': 1.0, 'len': 16, 'is_signed_var': False, 'physical_range': // '[0|65535]', 'bit': 55, 'type': 'int', 'order': 'motorola', 'physical_unit': // ''} int Globalrpt10::usr_can_read_errors(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 7); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; int ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/turn_rpt_230.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Turnrpt230 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Turnrpt230(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'VEHICLE_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool vehicle_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PACMOD_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool pacmod_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OVERRIDE_ACTIVE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool override_active(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OUTPUT_REPORTED_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool output_reported_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'INPUT_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool input_output_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'ENABLED', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} bool enabled(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'COMMAND_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool command_output_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'MANUAL_INPUT', 'enum': {0: 'MANUAL_INPUT_RIGHT', // 1: 'MANUAL_INPUT_NONE', 2: 'MANUAL_INPUT_LEFT', 3: 'MANUAL_INPUT_HAZARD'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|3]', 'bit': 15, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Turn_rpt_230::Manual_inputType manual_input(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'COMMANDED_VALUE', 'enum': {0: // 'COMMANDED_VALUE_RIGHT', 1: 'COMMANDED_VALUE_NONE', 2: // 'COMMANDED_VALUE_LEFT', 3: 'COMMANDED_VALUE_HAZARD'}, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]', // 'bit': 23, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Turn_rpt_230::Commanded_valueType commanded_value(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OUTPUT_VALUE', 'enum': {0: 'OUTPUT_VALUE_RIGHT', // 1: 'OUTPUT_VALUE_NONE', 2: 'OUTPUT_VALUE_LEFT', 3: 'OUTPUT_VALUE_HAZARD'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|3]', 'bit': 31, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Turn_rpt_230::Output_valueType output_value(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/hazard_lights_cmd_114.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/hazard_lights_cmd_114.h" #include "modules/drivers/canbus/common/byte.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; const int32_t Hazardlightscmd114::ID = 0x114; // public Hazardlightscmd114::Hazardlightscmd114() { Reset(); } uint32_t Hazardlightscmd114::GetPeriod() const { // TODO(QiL) modify every protocol's period manually static const uint32_t PERIOD = 20 * 1000; return PERIOD; } void Hazardlightscmd114::UpdateData(uint8_t* data) { set_p_hazard_lights_cmd(data, hazard_lights_cmd_); set_p_ignore_overrides(data, ignore_overrides_); set_p_clear_override(data, clear_override_); set_p_enable(data, enable_); set_p_clear_faults(data, clear_faults_); } void Hazardlightscmd114::Reset() { // TODO(QiL) you should check this manually hazard_lights_cmd_ = false; ignore_overrides_ = false; clear_override_ = false; enable_ = false; clear_faults_ = false; } Hazardlightscmd114* Hazardlightscmd114::set_hazard_lights_cmd( bool hazard_lights_cmd) { hazard_lights_cmd_ = hazard_lights_cmd; return this; } // config detail: {'name': 'HAZARD_LIGHTS_CMD', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 8, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Hazardlightscmd114::set_p_hazard_lights_cmd(uint8_t* data, bool hazard_lights_cmd) { uint8_t x = hazard_lights_cmd; Byte to_set(data + 1); to_set.set_value(x, 0, 1); } Hazardlightscmd114* Hazardlightscmd114::set_ignore_overrides( bool ignore_overrides) { ignore_overrides_ = ignore_overrides; return this; } // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Hazardlightscmd114::set_p_ignore_overrides(uint8_t* data, bool ignore_overrides) { uint8_t x = ignore_overrides; Byte to_set(data + 0); to_set.set_value(x, 1, 1); } Hazardlightscmd114* Hazardlightscmd114::set_clear_override( bool clear_override) { clear_override_ = clear_override; return this; } // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Hazardlightscmd114::set_p_clear_override(uint8_t* data, bool clear_override) { uint8_t x = clear_override; Byte to_set(data + 0); to_set.set_value(x, 2, 1); } Hazardlightscmd114* Hazardlightscmd114::set_enable(bool enable) { enable_ = enable; return this; } // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': 1, // 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool', // 'order': 'motorola', 'physical_unit': ''} void Hazardlightscmd114::set_p_enable(uint8_t* data, bool enable) { uint8_t x = enable; Byte to_set(data + 0); to_set.set_value(x, 0, 1); } Hazardlightscmd114* Hazardlightscmd114::set_clear_faults(bool clear_faults) { clear_faults_ = clear_faults; return this; } // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void Hazardlightscmd114::set_p_clear_faults(uint8_t* data, bool clear_faults) { uint8_t x = clear_faults; Byte to_set(data + 0); to_set.set_value(x, 3, 1); } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/wiper_cmd_134.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Wipercmd134 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Wipercmd134(); uint32_t GetPeriod() const override; void UpdateData(uint8_t* data) override; void Reset() override; // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} Wipercmd134* set_ignore_overrides(bool ignore_overrides); // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} Wipercmd134* set_enable(bool enable); // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Wipercmd134* set_clear_override(bool clear_override); // config detail: {'name': 'WIPER_CMD', 'enum': {0: 'WIPER_CMD_WIPERS_OFF', 1: // 'WIPER_CMD_INTERMITTENT_1', 2: 'WIPER_CMD_INTERMITTENT_2', 3: // 'WIPER_CMD_INTERMITTENT_3', 4: 'WIPER_CMD_INTERMITTENT_4', 5: // 'WIPER_CMD_INTERMITTENT_5', 6: 'WIPER_CMD_LOW', 7: 'WIPER_CMD_HIGH'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|7]', 'bit': 15, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Wipercmd134* set_wiper_cmd(Wiper_cmd_134::Wiper_cmdType wiper_cmd); // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Wipercmd134* set_clear_faults(bool clear_faults); private: // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} void set_p_ignore_overrides(uint8_t* data, bool ignore_overrides); // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_enable(uint8_t* data, bool enable); // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_clear_override(uint8_t* data, bool clear_override); // config detail: {'name': 'WIPER_CMD', 'enum': {0: 'WIPER_CMD_WIPERS_OFF', 1: // 'WIPER_CMD_INTERMITTENT_1', 2: 'WIPER_CMD_INTERMITTENT_2', 3: // 'WIPER_CMD_INTERMITTENT_3', 4: 'WIPER_CMD_INTERMITTENT_4', 5: // 'WIPER_CMD_INTERMITTENT_5', 6: 'WIPER_CMD_LOW', 7: 'WIPER_CMD_HIGH'}, // 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|7]', 'bit': 15, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} void set_p_wiper_cmd(uint8_t* data, Wiper_cmd_134::Wiper_cmdType wiper_cmd); // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_clear_faults(uint8_t* data, bool clear_faults); private: bool ignore_overrides_; bool enable_; bool clear_override_; Wiper_cmd_134::Wiper_cmdType wiper_cmd_; bool clear_faults_; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/shift_cmd_128.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Shiftcmd128 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Shiftcmd128(); uint32_t GetPeriod() const override; void UpdateData(uint8_t* data) override; void Reset() override; // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} Shiftcmd128* set_ignore_overrides(bool ignore_overrides); // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} Shiftcmd128* set_enable(bool enable); // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Shiftcmd128* set_clear_override(bool clear_override); // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Shiftcmd128* set_clear_faults(bool clear_faults); // config detail: {'description': 'FORWARD is also HIGH on vehicles with // LOW/HIGH, PARK and LOW only available on certain Vehicles.', 'enum': {0: // 'SHIFT_CMD_PARK', 1: 'SHIFT_CMD_REVERSE', 2: 'SHIFT_CMD_NEUTRAL', 3: // 'SHIFT_CMD_FORWARD_HIGH', 4: 'SHIFT_CMD_LOW', 7: 'SHIFT_CMD_NONE'}, // 'precision': 1.0, 'len': 8, 'name': 'SHIFT_CMD', 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 15, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Shiftcmd128* set_shift_cmd(Shift_cmd_128::Shift_cmdType shift_cmd); private: // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} void set_p_ignore_overrides(uint8_t* data, bool ignore_overrides); // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_enable(uint8_t* data, bool enable); // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_clear_override(uint8_t* data, bool clear_override); // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_clear_faults(uint8_t* data, bool clear_faults); // config detail: {'description': 'FORWARD is also HIGH on vehicles with // LOW/HIGH, PARK and LOW only available on certain Vehicles.', 'enum': {0: // 'SHIFT_CMD_PARK', 1: 'SHIFT_CMD_REVERSE', 2: 'SHIFT_CMD_NEUTRAL', 3: // 'SHIFT_CMD_FORWARD_HIGH', 4: 'SHIFT_CMD_LOW', 7: 'SHIFT_CMD_NONE'}, // 'precision': 1.0, 'len': 8, 'name': 'SHIFT_CMD', 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 15, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} void set_p_shift_cmd(uint8_t* data, Shift_cmd_128::Shift_cmdType shift_cmd); private: bool ignore_overrides_; bool enable_; bool clear_override_; bool clear_faults_; Shift_cmd_128::Shift_cmdType shift_cmd_; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/headlight_aux_rpt_318.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Headlightauxrpt318 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Headlightauxrpt318(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'HEADLIGHTS_MODE_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 19, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool headlights_mode_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'HEADLIGHTS_MODE', 'enum': {0: // 'HEADLIGHTS_MODE_HEADLIGHTS_OFF', 1: 'HEADLIGHTS_MODE_PARKING_LIGHTS_ONLY', // 2: 'HEADLIGHTS_MODE_HEADLIGHTS_ON_MANUAL_MODE', 3: // 'HEADLIGHTS_MODE_HEADLIGHTS_ON_AUTO_MODE'}, 'precision': 1.0, 'len': 8, // 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]', 'bit': // 15, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Headlight_aux_rpt_318::Headlights_modeType headlights_mode( const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'FOG_LIGHTS_ON_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 18, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool fog_lights_on_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'FOG_LIGHTS_ON', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool fog_lights_on(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'HEADLIGHTS_ON_BRIGHT_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 17, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool headlights_on_bright_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'HEADLIGHTS_ON_BRIGHT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool headlights_on_bright(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'HEADLIGHTS_ON_IS_VALID', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 16, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool headlights_on_is_valid(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'HEADLIGHTS_ON', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool headlights_on(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/steering_motor_rpt_3_406.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/steering_motor_rpt_3_406.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Steeringmotorrpt3406::Steeringmotorrpt3406() {} const int32_t Steeringmotorrpt3406::ID = 0x406; void Steeringmotorrpt3406::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_steering_motor_rpt_3_406()->set_torque_output( torque_output(bytes, length)); chassis->mutable_steering_motor_rpt_3_406()->set_torque_input( torque_input(bytes, length)); } // config detail: {'name': 'torque_output', 'offset': 0.0, 'precision': 0.001, // 'len': 32, 'is_signed_var': True, 'physical_range': // '[-2147483.648|2147483.647]', 'bit': 7, 'type': 'double', 'order': // 'motorola', 'physical_unit': 'N-m'} double Steeringmotorrpt3406::torque_output(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 1); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; Byte t2(bytes + 2); t = t2.get_byte(0, 8); x <<= 8; x |= t; Byte t3(bytes + 3); t = t3.get_byte(0, 8); x <<= 8; x |= t; x <<= 0; x >>= 0; double ret = x * 0.001000; return ret; } // config detail: {'name': 'torque_input', 'offset': 0.0, 'precision': 0.001, // 'len': 32, 'is_signed_var': True, 'physical_range': // '[-2147483.648|2147483.647]', 'bit': 39, 'type': 'double', 'order': // 'motorola', 'physical_unit': 'N-m'} double Steeringmotorrpt3406::torque_input(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 5); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; Byte t2(bytes + 6); t = t2.get_byte(0, 8); x <<= 8; x |= t; Byte t3(bytes + 7); t = t3.get_byte(0, 8); x <<= 8; x |= t; x <<= 0; x >>= 0; double ret = x * 0.001000; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/veh_specific_rpt_1_412.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/veh_specific_rpt_1_412.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Vehspecificrpt1412::Vehspecificrpt1412() {} const int32_t Vehspecificrpt1412::ID = 0x412; void Vehspecificrpt1412::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_veh_specific_rpt_1_412()->set_shift_pos_2( shift_pos_2(bytes, length)); chassis->mutable_veh_specific_rpt_1_412()->set_shift_pos_1( shift_pos_1(bytes, length)); } // config detail: {'name': 'shift_pos_2', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 15, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} int Vehspecificrpt1412::shift_pos_2(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); int ret = x; return ret; } // config detail: {'name': 'shift_pos_1', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 7, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} int Vehspecificrpt1412::shift_pos_1(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); int ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/wheel_speed_rpt_407.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/wheel_speed_rpt_407.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Wheelspeedrpt407::Wheelspeedrpt407() {} const int32_t Wheelspeedrpt407::ID = 0x407; void Wheelspeedrpt407::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_wheel_speed_rpt_407()->set_wheel_spd_rear_right( wheel_spd_rear_right(bytes, length)); chassis->mutable_wheel_speed_rpt_407()->set_wheel_spd_rear_left( wheel_spd_rear_left(bytes, length)); chassis->mutable_wheel_speed_rpt_407()->set_wheel_spd_front_right( wheel_spd_front_right(bytes, length)); chassis->mutable_wheel_speed_rpt_407()->set_wheel_spd_front_left( wheel_spd_front_left(bytes, length)); } // config detail: {'name': 'wheel_spd_rear_right', 'offset': 0.0, 'precision': // 0.01, 'len': 16, 'is_signed_var': True, 'physical_range': '[-327.68|327.67]', // 'bit': 55, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'} double Wheelspeedrpt407::wheel_spd_rear_right(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 7); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x * 0.010000; return ret; } // config detail: {'name': 'wheel_spd_rear_left', 'offset': 0.0, 'precision': // 0.01, 'len': 16, 'is_signed_var': True, 'physical_range': '[-327.68|327.67]', // 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'} double Wheelspeedrpt407::wheel_spd_rear_left(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 5); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x * 0.010000; return ret; } // config detail: {'name': 'wheel_spd_front_right', 'offset': 0.0, 'precision': // 0.01, 'len': 16, 'is_signed_var': True, 'physical_range': '[-327.68|327.67]', // 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'} double Wheelspeedrpt407::wheel_spd_front_right(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 3); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x * 0.010000; return ret; } // config detail: {'name': 'wheel_spd_front_left', 'offset': 0.0, 'precision': // 0.01, 'len': 16, 'is_signed_var': False, 'physical_range': // '[-327.68|327.67]', 'bit': 7, 'type': 'double', 'order': 'motorola', // 'physical_unit': 'rad/s'} double Wheelspeedrpt407::wheel_spd_front_left(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 1); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x * 0.010000; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/brake_rpt_204.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Brakerpt204 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Brakerpt204(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'COMMAND_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool command_output_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'VEHICLE_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool vehicle_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PACMOD_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool pacmod_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OVERRIDE_ACTIVE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool override_active(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OUTPUT_REPORTED_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool output_reported_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'INPUT_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool input_output_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'ENABLED', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} bool enabled(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'MANUAL_INPUT', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 15, // 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double manual_input(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'COMMANDED_VALUE', 'offset': 0.0, 'precision': // 0.001, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': // 31, 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double commanded_value(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OUTPUT_VALUE', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 47, // 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double output_value(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/occupancy_rpt_415.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/occupancy_rpt_415.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Occupancyrpt415::Occupancyrpt415() {} const int32_t Occupancyrpt415::ID = 0x415; void Occupancyrpt415::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_occupancy_rpt_415()->set_rear_seatbelt_buckled_is_valid( rear_seatbelt_buckled_is_valid(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_pass_seatbelt_buckled_is_valid( pass_seatbelt_buckled_is_valid(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_driver_seatbelt_buckled_is_valid( driver_seatbelt_buckled_is_valid(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_rear_seat_occupied_is_valid( rear_seat_occupied_is_valid(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_pass_seat_occupied_is_valid( pass_seat_occupied_is_valid(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_driver_seat_occupied_is_valid( driver_seat_occupied_is_valid(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_rear_seatbelt_buckled( rear_seatbelt_buckled(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_pass_seatbelt_buckled( pass_seatbelt_buckled(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_driver_seatbelt_buckled( driver_seatbelt_buckled(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_rear_seat_occupied( rear_seat_occupied(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_pass_seat_occupied( pass_seat_occupied(bytes, length)); chassis->mutable_occupancy_rpt_415()->set_driver_seat_occupied( driver_seat_occupied(bytes, length)); } // config detail: {'name': 'rear_seatbelt_buckled_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 13, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::rear_seatbelt_buckled_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'pass_seatbelt_buckled_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 12, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::pass_seatbelt_buckled_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'driver_seatbelt_buckled_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 11, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::driver_seatbelt_buckled_is_valid( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'rear_seat_occupied_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 10, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::rear_seat_occupied_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'pass_seat_occupied_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 9, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::pass_seat_occupied_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'driver_seat_occupied_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 8, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::driver_seat_occupied_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'rear_seatbelt_buckled', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 5, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::rear_seatbelt_buckled(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(5, 1); bool ret = x; return ret; } // config detail: {'name': 'pass_seatbelt_buckled', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::pass_seatbelt_buckled(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(4, 1); bool ret = x; return ret; } // config detail: {'name': 'driver_seatbelt_buckled', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::driver_seatbelt_buckled(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'rear_seat_occupied', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::rear_seat_occupied(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'pass_seat_occupied', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::pass_seat_occupied(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'driver_seat_occupied', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 0, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Occupancyrpt415::driver_seat_occupied(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/accel_rpt_200.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Accelrpt200 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Accelrpt200(); void Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const override; private: // config detail: {'name': 'VEHICLE_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 6, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool vehicle_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'PACMOD_FAULT', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 5, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool pacmod_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OUTPUT_REPORTED_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 4, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool output_reported_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'INPUT_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool input_output_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'COMMAND_OUTPUT_FAULT', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} bool command_output_fault(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OVERRIDE_ACTIVE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool override_active(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'ENABLED', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} bool enabled(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'MANUAL_INPUT', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 15, // 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double manual_input(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'COMMANDED_VALUE', 'offset': 0.0, 'precision': // 0.001, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': // 31, 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double commanded_value(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'OUTPUT_VALUE', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 47, // 'type': 'double', 'order': 'motorola', 'physical_unit': ''} double output_value(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/lat_lon_heading_rpt_40e.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/lat_lon_heading_rpt_40e.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Latlonheadingrpt40e::Latlonheadingrpt40e() {} const int32_t Latlonheadingrpt40e::ID = 0x40E; void Latlonheadingrpt40e::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_lat_lon_heading_rpt_40e()->set_heading( heading(bytes, length)); chassis->mutable_lat_lon_heading_rpt_40e()->set_longitude_seconds( longitude_seconds(bytes, length)); chassis->mutable_lat_lon_heading_rpt_40e()->set_longitude_minutes( longitude_minutes(bytes, length)); chassis->mutable_lat_lon_heading_rpt_40e()->set_longitude_degrees( longitude_degrees(bytes, length)); chassis->mutable_lat_lon_heading_rpt_40e()->set_latitude_seconds( latitude_seconds(bytes, length)); chassis->mutable_lat_lon_heading_rpt_40e()->set_latitude_minutes( latitude_minutes(bytes, length)); chassis->mutable_lat_lon_heading_rpt_40e()->set_latitude_degrees( latitude_degrees(bytes, length)); } // config detail: {'name': 'heading', 'offset': 0.0, 'precision': 0.01, 'len': // 16, 'is_signed_var': True, 'physical_range': '[-327.68|327.67]', 'bit': 55, // 'type': 'double', 'order': 'motorola', 'physical_unit': 'deg'} double Latlonheadingrpt40e::heading(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 7); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x * 0.010000; return ret; } // config detail: {'name': 'longitude_seconds', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': True, 'physical_range': '[-128|127]', 'bit': 47, // 'type': 'int', 'order': 'motorola', 'physical_unit': 'sec'} int Latlonheadingrpt40e::longitude_seconds(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 5); int32_t x = t0.get_byte(0, 8); x <<= 24; x >>= 24; int ret = x; return ret; } // config detail: {'name': 'longitude_minutes', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': True, 'physical_range': '[-128|127]', 'bit': 39, // 'type': 'int', 'order': 'motorola', 'physical_unit': 'min'} int Latlonheadingrpt40e::longitude_minutes(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); x <<= 24; x >>= 24; int ret = x; return ret; } // config detail: {'name': 'longitude_degrees', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': True, 'physical_range': '[-128|127]', 'bit': 31, // 'type': 'int', 'order': 'motorola', 'physical_unit': 'deg'} int Latlonheadingrpt40e::longitude_degrees(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); x <<= 24; x >>= 24; int ret = x; return ret; } // config detail: {'name': 'latitude_seconds', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': True, 'physical_range': '[-128|127]', 'bit': 23, // 'type': 'int', 'order': 'motorola', 'physical_unit': 'sec'} int Latlonheadingrpt40e::latitude_seconds(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); x <<= 24; x >>= 24; int ret = x; return ret; } // config detail: {'name': 'latitude_minutes', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': True, 'physical_range': '[-128|127]', 'bit': 15, // 'type': 'int', 'order': 'motorola', 'physical_unit': 'min'} int Latlonheadingrpt40e::latitude_minutes(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); x <<= 24; x >>= 24; int ret = x; return ret; } // config detail: {'name': 'latitude_degrees', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': True, 'physical_range': '[-128|127]', 'bit': 7, // 'type': 'int', 'order': 'motorola', 'physical_unit': 'deg'} int Latlonheadingrpt40e::latitude_degrees(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); x <<= 24; x >>= 24; int ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/shift_aux_rpt_328.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/shift_aux_rpt_328.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Shiftauxrpt328::Shiftauxrpt328() {} const int32_t Shiftauxrpt328::ID = 0x328; void Shiftauxrpt328::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_shift_aux_rpt_328()->set_speed_interlock_active_is_valid( speed_interlock_active_is_valid(bytes, length)); chassis->mutable_shift_aux_rpt_328()->set_speed_interlock_active( speed_interlock_active(bytes, length)); chassis->mutable_shift_aux_rpt_328()->set_brake_interlock_active_is_valid( brake_interlock_active_is_valid(bytes, length)); chassis->mutable_shift_aux_rpt_328()->set_brake_interlock_active( brake_interlock_active(bytes, length)); chassis->mutable_shift_aux_rpt_328()->set_stay_in_neutral_mode_is_valid( stay_in_neutral_mode_is_valid(bytes, length)); chassis->mutable_shift_aux_rpt_328()->set_stay_in_neutral_mode( stay_in_neutral_mode(bytes, length)); chassis->mutable_shift_aux_rpt_328()->set_between_gears_is_valid( between_gears_is_valid(bytes, length)); chassis->mutable_shift_aux_rpt_328()->set_between_gears( between_gears(bytes, length)); } // config detail: {'name': 'speed_interlock_active_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 11, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Shiftauxrpt328::speed_interlock_active_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'speed_interlock_active', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 3, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Shiftauxrpt328::speed_interlock_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(3, 1); bool ret = x; return ret; } // config detail: {'name': 'brake_interlock_active_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 10, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Shiftauxrpt328::brake_interlock_active_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'brake_interlock_active', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 2, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Shiftauxrpt328::brake_interlock_active(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(2, 1); bool ret = x; return ret; } // config detail: {'name': 'stay_in_neutral_mode_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 9, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Shiftauxrpt328::stay_in_neutral_mode_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'stay_in_neutral_mode', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Shiftauxrpt328::stay_in_neutral_mode(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); bool ret = x; return ret; } // config detail: {'name': 'between_gears_is_valid', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 8, 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Shiftauxrpt328::between_gears_is_valid(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } // config detail: {'name': 'between_gears', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} bool Shiftauxrpt328::between_gears(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); bool ret = x; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/steering_cmd_12c.h
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/lexus/proto/lexus.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace lexus { class Steeringcmd12c : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lexus> { public: static const int32_t ID; Steeringcmd12c(); uint32_t GetPeriod() const override; void UpdateData(uint8_t* data) override; void Reset() override; // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} Steeringcmd12c* set_ignore_overrides(bool ignore_overrides); // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} Steeringcmd12c* set_enable(bool enable); // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Steeringcmd12c* set_clear_override(bool clear_override); // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} Steeringcmd12c* set_clear_faults(bool clear_faults); // config detail: {'name': 'POSITION', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 15, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad'} Steeringcmd12c* set_position(double position); // config detail: {'name': 'ROTATION_RATE', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': // 31, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'} Steeringcmd12c* set_rotation_rate(double rotation_rate); private: // config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'physical_range': // '[0|1]', 'bit': 1, 'type': 'bool', 'order': 'motorola', 'physical_unit': // ''} void set_p_ignore_overrides(uint8_t* data, bool ignore_overrides); // config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': // 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': // 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_enable(uint8_t* data, bool enable); // config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_clear_override(uint8_t* data, bool clear_override); // config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3, // 'type': 'bool', 'order': 'motorola', 'physical_unit': ''} void set_p_clear_faults(uint8_t* data, bool clear_faults); // config detail: {'name': 'POSITION', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]', // 'bit': 15, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad'} void set_p_position(uint8_t* data, double position); // config detail: {'name': 'ROTATION_RATE', 'offset': 0.0, 'precision': 0.001, // 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': // 31, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'} void set_p_rotation_rate(uint8_t* data, double rotation_rate); private: bool ignore_overrides_; bool enable_; bool clear_override_; bool clear_faults_; double position_; double rotation_rate_; }; } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/lexus
apollo_public_repos/apollo/modules/canbus_vehicle/lexus/protocol/yaw_rate_rpt_40d.cc
/****************************************************************************** * Copyright 2018 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/lexus/protocol/yaw_rate_rpt_40d.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace lexus { using ::apollo::drivers::canbus::Byte; Yawraterpt40d::Yawraterpt40d() {} const int32_t Yawraterpt40d::ID = 0x40D; void Yawraterpt40d::Parse(const std::uint8_t* bytes, int32_t length, Lexus* chassis) const { chassis->mutable_yaw_rate_rpt_40d()->set_yaw_rate( yaw_rate(bytes, length)); } // config detail: {'name': 'yaw_rate', 'offset': 0.0, 'precision': 0.01, 'len': // 16, 'is_signed_var': True, 'physical_range': '[-327.68|327.67]', 'bit': 7, // 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'} double Yawraterpt40d::yaw_rate(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 1); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; x <<= 16; x >>= 16; double ret = x * 0.010000; return ret; } } // namespace lexus } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/devkit_vehicle_factory.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ /** * @file devkit_vehicle_factory.h */ #pragma once #include <memory> #include "modules/canbus/proto/canbus_conf.pb.h" #include "modules/canbus/proto/vehicle_parameter.pb.h" #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/common_msgs/control_msgs/control_cmd.pb.h" #include "cyber/cyber.h" #include "modules/canbus/vehicle/abstract_vehicle_factory.h" #include "modules/canbus/vehicle/vehicle_controller.h" #include "modules/common/status/status.h" #include "modules/drivers/canbus/can_client/can_client.h" #include "modules/drivers/canbus/can_comm/can_receiver.h" #include "modules/drivers/canbus/can_comm/can_sender.h" #include "modules/drivers/canbus/can_comm/message_manager.h" /** * @namespace apollo::canbus * @brief apollo::canbus */ namespace apollo { namespace canbus { /** * @class DevkitVehicleFactory * * @brief this class is inherited from AbstractVehicleFactory. It can be used to * create controller and message manager for devkit vehicle. */ class DevkitVehicleFactory : public AbstractVehicleFactory { public: /** * @brief destructor */ virtual ~DevkitVehicleFactory() = default; /** * @brief init vehicle factory * @returns true if successfully initialized */ bool Init(const CanbusConf *canbus_conf) override; /** * @brief start canclient, cansender, canreceiver, vehicle controller * @returns true if successfully started */ bool Start() override; /** * @brief create ch vehicle controller * @returns a unique_ptr that points to the created controller */ void Stop() override; /** * @brief update control command */ void UpdateCommand( const apollo::control::ControlCommand *control_command) override; /** * @brief publish chassis messages */ Chassis publish_chassis() override; /** * @brief publish chassis for vehicle messages */ void PublishChassisDetail() override; private: /** * @brief create devkit vehicle controller * @returns a unique_ptr that points to the created controller */ std::unique_ptr<VehicleController<::apollo::canbus::Devkit>> CreateVehicleController(); /** * @brief create devkit message manager * @returns a unique_ptr that points to the created message manager */ std::unique_ptr<MessageManager<::apollo::canbus::Devkit>> CreateMessageManager(); std::unique_ptr<::apollo::cyber::Node> node_ = nullptr; std::unique_ptr<apollo::drivers::canbus::CanClient> can_client_; CanSender<::apollo::canbus::Devkit> can_sender_; apollo::drivers::canbus::CanReceiver<::apollo::canbus::Devkit> can_receiver_; std::unique_ptr<MessageManager<::apollo::canbus::Devkit>> message_manager_; std::unique_ptr<VehicleController<::apollo::canbus::Devkit>> vehicle_controller_; std::shared_ptr<::apollo::cyber::Writer<::apollo::canbus::Devkit>> chassis_detail_writer_; }; CYBER_REGISTER_VEHICLEFACTORY(DevkitVehicleFactory) } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/devkit_controller_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/devkit_controller.h" #include "cyber/common/file.h" #include "gtest/gtest.h" #include "modules/canbus/proto/canbus_conf.pb.h" #include "modules/common_msgs/chassis_msgs/chassis.pb.h" #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/canbus_vehicle/devkit/devkit_message_manager.h" #include "modules/common_msgs/basic_msgs/vehicle_signal.pb.h" #include "modules/common_msgs/control_msgs/control_cmd.pb.h" #include "modules/drivers/canbus/can_comm/can_sender.h" namespace apollo { namespace canbus { namespace devkit { using apollo::common::ErrorCode; using apollo::common::VehicleSignal; using apollo::control::ControlCommand; class DevkitControllerTest : public ::testing::Test { public: virtual void SetUp() { std::string canbus_conf_file = "modules/canbus/testdata/conf/devkit_canbus_conf_test.pb.txt"; cyber::common::GetProtoFromFile(canbus_conf_file, &canbus_conf_); params_ = canbus_conf_.vehicle_parameter(); control_cmd_.set_throttle(20.0); control_cmd_.set_brake(0.0); control_cmd_.set_steering_target(10.0); control_cmd_.set_steering_rate(100.0); } protected: DevkitController controller_; ControlCommand control_cmd_; VehicleSignal vehicle_signal_; CanSender<::apollo::canbus::Devkit> sender_; DevkitMessageManager msg_manager_; CanbusConf canbus_conf_; VehicleParameter params_; }; TEST_F(DevkitControllerTest, Init) { ErrorCode ret = controller_.Init(params_, &sender_, &msg_manager_); EXPECT_EQ(ret, ErrorCode::OK); } TEST_F(DevkitControllerTest, SetDrivingMode) { Chassis chassis; chassis.set_driving_mode(Chassis::COMPLETE_AUTO_DRIVE); controller_.Init(params_, &sender_, &msg_manager_); controller_.set_driving_mode(chassis.driving_mode()); EXPECT_EQ(controller_.driving_mode(), chassis.driving_mode()); EXPECT_EQ(controller_.SetDrivingMode(chassis.driving_mode()), ErrorCode::OK); } TEST_F(DevkitControllerTest, Status) { controller_.Init(params_, &sender_, &msg_manager_); controller_.set_driving_mode(Chassis::COMPLETE_AUTO_DRIVE); EXPECT_EQ(controller_.Update(control_cmd_), ErrorCode::OK); controller_.SetHorn(control_cmd_); controller_.SetBeam(control_cmd_); controller_.SetTurningSignal(control_cmd_); EXPECT_FALSE(controller_.CheckChassisError()); } TEST_F(DevkitControllerTest, UpdateDrivingMode) { controller_.Init(params_, &sender_, &msg_manager_); controller_.set_driving_mode(Chassis::COMPLETE_AUTO_DRIVE); EXPECT_EQ(controller_.SetDrivingMode(Chassis::COMPLETE_MANUAL), ErrorCode::OK); EXPECT_EQ(controller_.SetDrivingMode(Chassis::COMPLETE_AUTO_DRIVE), ErrorCode::CANBUS_ERROR); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/devkit_controller.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include <memory> #include <thread> #include "modules/canbus/proto/canbus_conf.pb.h" #include "modules/canbus/proto/vehicle_parameter.pb.h" #include "modules/common_msgs/basic_msgs/error_code.pb.h" #include "modules/common_msgs/chassis_msgs/chassis.pb.h" #include "modules/common_msgs/control_msgs/control_cmd.pb.h" #include "modules/canbus_vehicle/devkit/protocol/brake_command_101.h" #include "modules/canbus_vehicle/devkit/protocol/gear_command_103.h" #include "modules/canbus_vehicle/devkit/protocol/park_command_104.h" #include "modules/canbus_vehicle/devkit/protocol/steering_command_102.h" #include "modules/canbus_vehicle/devkit/protocol/throttle_command_100.h" #include "modules/canbus_vehicle/devkit/protocol/vehicle_mode_command_105.h" #include "modules/canbus/vehicle/vehicle_controller.h" namespace apollo { namespace canbus { namespace devkit { class DevkitController final : public VehicleController<::apollo::canbus::Devkit> { public: DevkitController() {} virtual ~DevkitController(); ::apollo::common::ErrorCode Init( const VehicleParameter& params, CanSender<::apollo::canbus::Devkit>* const can_sender, MessageManager<::apollo::canbus::Devkit>* const message_manager) override; bool Start() override; /** * @brief stop the vehicle controller. */ void Stop() override; /** * @brief calculate and return the chassis. * @returns a copy of chassis. Use copy here to avoid multi-thread issues. */ Chassis chassis() override; /** * for test */ FRIEND_TEST(DevkitControllerTest, SetDrivingMode); FRIEND_TEST(DevkitControllerTest, Status); FRIEND_TEST(DevkitControllerTest, UpdateDrivingMode); private: // main logical function for operation the car enter or exit the auto driving void Emergency() override; ::apollo::common::ErrorCode EnableAutoMode() override; ::apollo::common::ErrorCode DisableAutoMode() override; ::apollo::common::ErrorCode EnableSteeringOnlyMode() override; ::apollo::common::ErrorCode EnableSpeedOnlyMode() override; // NEUTRAL, REVERSE, DRIVE void Gear(Chassis::GearPosition state) override; // brake with new acceleration // acceleration:0.00~99.99, unit: // acceleration_spd: 60 ~ 100, suggest: 90 void Brake(double acceleration) override; // drive with old acceleration // gas:0.00~99.99 unit: void Throttle(double throttle) override; // drive with acceleration/deceleration // acc:-7.0~5.0 unit:m/s^2 void Acceleration(double acc) override; // steering with old angle speed // angle:-99.99~0.00~99.99, unit:, left:+, right:- void Steer(double angle) override; // steering with new angle speed // angle:-99.99~0.00~99.99, unit:, left:+, right:- // angle_spd:0.00~99.99, unit:deg/s void Steer(double angle, double angle_spd) override; // set Electrical Park Brake void SetEpbBreak(const ::apollo::control::ControlCommand& command) override; void SetBeam(const ::apollo::control::ControlCommand& command) override; void SetHorn(const ::apollo::control::ControlCommand& command) override; void SetTurningSignal( const ::apollo::control::ControlCommand& command) override; // response vid bool VerifyID() override; void ResetProtocol(); bool CheckChassisError(); bool CheckVin(); void GetVin(); void ResetVin(); private: void SecurityDogThreadFunc(); virtual bool CheckResponse(const int32_t flags, bool need_wait); void set_chassis_error_mask(const int32_t mask); int32_t chassis_error_mask(); Chassis::ErrorCode chassis_error_code(); void set_chassis_error_code(const Chassis::ErrorCode& error_code); private: // control protocol Brakecommand101* brake_command_101_ = nullptr; Gearcommand103* gear_command_103_ = nullptr; Parkcommand104* park_command_104_ = nullptr; Steeringcommand102* steering_command_102_ = nullptr; Throttlecommand100* throttle_command_100_ = nullptr; Vehiclemodecommand105* vehicle_mode_command_105_ = nullptr; Chassis chassis_; std::unique_ptr<std::thread> thread_; bool is_chassis_error_ = false; std::mutex chassis_error_code_mutex_; Chassis::ErrorCode chassis_error_code_ = Chassis::NO_ERROR; std::mutex chassis_mask_mutex_; int32_t chassis_error_mask_ = 0; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/devkit_vehicle_factory.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/devkit_vehicle_factory.h" #include "cyber/common/log.h" #include "modules/canbus/common/canbus_gflags.h" #include "modules/canbus_vehicle/devkit/devkit_controller.h" #include "modules/canbus_vehicle/devkit/devkit_message_manager.h" #include "modules/common/adapters/adapter_gflags.h" #include "modules/common/util/util.h" #include "modules/drivers/canbus/can_client/can_client_factory.h" using apollo::common::ErrorCode; using apollo::control::ControlCommand; using apollo::drivers::canbus::CanClientFactory; namespace apollo { namespace canbus { bool DevkitVehicleFactory::Init(const CanbusConf *canbus_conf) { // Init can client auto can_factory = CanClientFactory::Instance(); can_factory->RegisterCanClients(); can_client_ = can_factory->CreateCANClient(canbus_conf->can_card_parameter()); if (!can_client_) { AERROR << "Failed to create can client."; return false; } AINFO << "Can client is successfully created."; message_manager_ = this->CreateMessageManager(); if (message_manager_ == nullptr) { AERROR << "Failed to create message manager."; return false; } AINFO << "Message manager is successfully created."; if (can_receiver_.Init(can_client_.get(), message_manager_.get(), canbus_conf->enable_receiver_log()) != ErrorCode::OK) { AERROR << "Failed to init can receiver."; return false; } AINFO << "The can receiver is successfully initialized."; if (can_sender_.Init(can_client_.get(), message_manager_.get(), canbus_conf->enable_sender_log()) != ErrorCode::OK) { AERROR << "Failed to init can sender."; return false; } AINFO << "The can sender is successfully initialized."; vehicle_controller_ = CreateVehicleController(); if (vehicle_controller_ == nullptr) { AERROR << "Failed to create vehicle controller."; return false; } AINFO << "The vehicle controller is successfully created."; if (vehicle_controller_->Init(canbus_conf->vehicle_parameter(), &can_sender_, message_manager_.get()) != ErrorCode::OK) { AERROR << "Failed to init vehicle controller."; return false; } AINFO << "The vehicle controller is successfully" << " initialized with canbus conf as : " << canbus_conf->vehicle_parameter().ShortDebugString(); node_ = ::apollo::cyber::CreateNode("chassis_detail"); chassis_detail_writer_ = node_->CreateWriter<::apollo::canbus::Devkit>(FLAGS_chassis_detail_topic); return true; } bool DevkitVehicleFactory::Start() { // 1. init and start the can card hardware if (can_client_->Start() != ErrorCode::OK) { AERROR << "Failed to start can client"; return false; } AINFO << "Can client is started."; // 2. start receive first then send if (can_receiver_.Start() != ErrorCode::OK) { AERROR << "Failed to start can receiver."; return false; } AINFO << "Can receiver is started."; // 3. start send if (can_sender_.Start() != ErrorCode::OK) { AERROR << "Failed to start can sender."; return false; } // 4. start controller if (!vehicle_controller_->Start()) { AERROR << "Failed to start vehicle controller."; return false; } return true; } void DevkitVehicleFactory::Stop() { can_sender_.Stop(); can_receiver_.Stop(); can_client_->Stop(); vehicle_controller_->Stop(); AINFO << "Cleanup cansender, canreceiver, canclient, vehicle controller."; } void DevkitVehicleFactory::UpdateCommand( const apollo::control::ControlCommand *control_command) { if (vehicle_controller_->Update(*control_command) != ErrorCode::OK) { AERROR << "Failed to process callback function OnControlCommand because " "vehicle_controller_->Update error."; return; } can_sender_.Update(); } Chassis DevkitVehicleFactory::publish_chassis() { Chassis chassis = vehicle_controller_->chassis(); ADEBUG << chassis.ShortDebugString(); return chassis; } void DevkitVehicleFactory::PublishChassisDetail() { Devkit chassis_detail; message_manager_->GetSensorData(&chassis_detail); ADEBUG << chassis_detail.ShortDebugString(); chassis_detail_writer_->Write(chassis_detail); } std::unique_ptr<VehicleController<::apollo::canbus::Devkit>> DevkitVehicleFactory::CreateVehicleController() { return std::unique_ptr<VehicleController<::apollo::canbus::Devkit>>( new devkit::DevkitController()); } std::unique_ptr<MessageManager<::apollo::canbus::Devkit>> DevkitVehicleFactory::CreateMessageManager() { return std::unique_ptr<MessageManager<::apollo::canbus::Devkit>>( new devkit::DevkitMessageManager()); } } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/devkit_vehicle_factory_test.cc
/****************************************************************************** * Copyright 2019 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/devkit_vehicle_factory.h" #include "gtest/gtest.h" #include "modules/canbus/proto/canbus_conf.pb.h" #include "modules/canbus/proto/vehicle_parameter.pb.h" #include "cyber/common/file.h" namespace apollo { namespace canbus { class DevkitVehicleFactoryTest : public ::testing::Test { public: virtual void SetUp() { std::string canbus_conf_file = "/apollo/modules/canbus_vehicle/devkit/testdata/" "devkit_canbus_conf_test.pb.txt"; cyber::common::GetProtoFromFile(canbus_conf_file, &canbus_conf_); params_ = canbus_conf_.vehicle_parameter(); params_.set_brand(apollo::common::DKIT); devkit_factory_.SetVehicleParameter(params_); } virtual void TearDown() {} protected: DevkitVehicleFactory devkit_factory_; CanbusConf canbus_conf_; VehicleParameter params_; }; TEST_F(DevkitVehicleFactoryTest, Init) { apollo::cyber::Init("vehicle_factory_test"); EXPECT_EQ(devkit_factory_.Init(&canbus_conf_), true); } } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/cyberfile.xml
<package format="2"> <name>canbus-vehicle-devkit</name> <version>local</version> <description> Dynamic loading for canbus devkit vehicle module </description> <maintainer email="apollo-support@baidu.com">Apollo</maintainer> <license>Apache License 2.0</license> <url type="website">https://www.apollo.auto/</url> <url type="repository">https://github.com/ApolloAuto/apollo</url> <url type="bugtracker">https://github.com/ApolloAuto/apollo/issues</url> <type>module</type> <src_path url="https://github.com/ApolloAuto/apollo">//modules/canbus_vehicle/devkit</src_path> <depend type="binary" repo_name="cyber">cyber-dev</depend> <depend type="binary" repo_name="common" lib_names="common">common-dev</depend> <depend type="binary" repo_name="canbus" lib_names="canbus">canbus-dev</depend> <depend repo_name="common-msgs" lib_names="common-msgs">common-msgs-dev</depend> <depend type="binary" repo_name="drivers">drivers-dev</depend> <depend repo_name="com_google_googletest" lib_names="gtest,gtest_main">3rd-gtest-dev</depend> </package>
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/devkit_message_manager.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/message_manager.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::MessageManager; class DevkitMessageManager : public MessageManager<::apollo::canbus::Devkit> { public: DevkitMessageManager(); virtual ~DevkitMessageManager(); }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/devkit_message_manager_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/devkit_message_manager.h" #include "gtest/gtest.h" #include "modules/canbus_vehicle/devkit/protocol/bms_report_512.h" #include "modules/canbus_vehicle/devkit/protocol/brake_command_101.h" #include "modules/canbus_vehicle/devkit/protocol/brake_report_501.h" #include "modules/canbus_vehicle/devkit/protocol/gear_command_103.h" #include "modules/canbus_vehicle/devkit/protocol/gear_report_503.h" #include "modules/canbus_vehicle/devkit/protocol/park_command_104.h" #include "modules/canbus_vehicle/devkit/protocol/park_report_504.h" #include "modules/canbus_vehicle/devkit/protocol/steering_command_102.h" #include "modules/canbus_vehicle/devkit/protocol/steering_report_502.h" #include "modules/canbus_vehicle/devkit/protocol/throttle_command_100.h" #include "modules/canbus_vehicle/devkit/protocol/throttle_report_500.h" #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_1_507.h" #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_2_508.h" #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_3_509.h" #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_4_510.h" #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_5_511.h" #include "modules/canbus_vehicle/devkit/protocol/vcu_report_505.h" #include "modules/canbus_vehicle/devkit/protocol/wheelspeed_report_506.h" namespace apollo { namespace canbus { namespace devkit { class DevkitMessageManagerTest : public ::testing::Test { public: virtual void SetUp() {} protected: DevkitMessageManager manager_; }; TEST_F(DevkitMessageManagerTest, GetSendProtocols) { EXPECT_NE(manager_.GetMutableProtocolDataById(Brakecommand101::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Gearcommand103::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Parkcommand104::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Steeringcommand102::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Throttlecommand100::ID), nullptr); } TEST_F(DevkitMessageManagerTest, GetRecvProtocols) { EXPECT_NE(manager_.GetMutableProtocolDataById(Bmsreport512::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Brakereport501::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Gearreport503::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Parkreport504::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Steeringreport502::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Throttlereport500::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Ultrsensor1507::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Ultrsensor2508::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Ultrsensor3509::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Ultrsensor4510::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Ultrsensor5511::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Vcureport505::ID), nullptr); EXPECT_NE(manager_.GetMutableProtocolDataById(Wheelspeedreport506::ID), nullptr); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/devkit_message_manager.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/devkit_message_manager.h" #include "modules/canbus_vehicle/devkit/protocol/brake_command_101.h" #include "modules/canbus_vehicle/devkit/protocol/gear_command_103.h" #include "modules/canbus_vehicle/devkit/protocol/park_command_104.h" #include "modules/canbus_vehicle/devkit/protocol/steering_command_102.h" #include "modules/canbus_vehicle/devkit/protocol/throttle_command_100.h" #include "modules/canbus_vehicle/devkit/protocol/vehicle_mode_command_105.h" #include "modules/canbus_vehicle/devkit/protocol/bms_report_512.h" #include "modules/canbus_vehicle/devkit/protocol/brake_report_501.h" #include "modules/canbus_vehicle/devkit/protocol/gear_report_503.h" #include "modules/canbus_vehicle/devkit/protocol/park_report_504.h" #include "modules/canbus_vehicle/devkit/protocol/steering_report_502.h" #include "modules/canbus_vehicle/devkit/protocol/throttle_report_500.h" #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_1_507.h" #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_2_508.h" #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_3_509.h" #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_4_510.h" #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_5_511.h" #include "modules/canbus_vehicle/devkit/protocol/vcu_report_505.h" #include "modules/canbus_vehicle/devkit/protocol/vin_resp1_514.h" #include "modules/canbus_vehicle/devkit/protocol/vin_resp2_515.h" #include "modules/canbus_vehicle/devkit/protocol/vin_resp3_516.h" #include "modules/canbus_vehicle/devkit/protocol/wheelspeed_report_506.h" namespace apollo { namespace canbus { namespace devkit { DevkitMessageManager::DevkitMessageManager() { // Control Messages AddSendProtocolData<Brakecommand101, true>(); AddSendProtocolData<Gearcommand103, true>(); AddSendProtocolData<Parkcommand104, true>(); AddSendProtocolData<Steeringcommand102, true>(); AddSendProtocolData<Throttlecommand100, true>(); AddSendProtocolData<Vehiclemodecommand105, true>(); // Report Messages AddRecvProtocolData<Bmsreport512, true>(); AddRecvProtocolData<Brakereport501, true>(); AddRecvProtocolData<Gearreport503, true>(); AddRecvProtocolData<Parkreport504, true>(); AddRecvProtocolData<Steeringreport502, true>(); AddRecvProtocolData<Throttlereport500, true>(); AddRecvProtocolData<Ultrsensor1507, true>(); AddRecvProtocolData<Ultrsensor2508, true>(); AddRecvProtocolData<Ultrsensor3509, true>(); AddRecvProtocolData<Ultrsensor4510, true>(); AddRecvProtocolData<Ultrsensor5511, true>(); AddRecvProtocolData<Vcureport505, true>(); AddRecvProtocolData<Vinresp1514, true>(); AddRecvProtocolData<Vinresp2515, true>(); AddRecvProtocolData<Vinresp3516, true>(); AddRecvProtocolData<Wheelspeedreport506, true>(); } DevkitMessageManager::~DevkitMessageManager() {} } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/BUILD
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") load("//tools/install:install.bzl", "install", "install_files", "install_src_files") load("//tools:cpplint.bzl", "cpplint") package(default_visibility = ["//visibility:public"]) CANBUS_COPTS = ["-DMODULE_NAME=\\\"canbus\\\""] cc_library( name = "devkit_vehicle_factory", srcs = [ "devkit_vehicle_factory.cc", ], hdrs = [ "devkit_vehicle_factory.h", ], copts = CANBUS_COPTS, alwayslink = True, deps = [ ":devkit_controller", ":devkit_message_manager", "//modules/canbus/common:canbus_gflags", "//modules/common/adapters:adapter_gflags", "//modules/common/status", "//modules/canbus/vehicle:abstract_vehicle_factory", "//modules/drivers/canbus:sensor_canbus_lib", ], ) cc_binary( name = "libdevkit_vehicle_factory_lib.so", linkshared = True, linkstatic = True, deps = [":devkit_vehicle_factory"], ) cc_test( name = "devkit_vehicle_factory_test", size = "small", srcs = ["devkit_vehicle_factory_test.cc"], linkstatic = True, deps = [ ":devkit_vehicle_factory", "@com_google_googletest//:gtest_main", ], ) cc_library( name = "devkit_message_manager", srcs = ["devkit_message_manager.cc"], hdrs = ["devkit_message_manager.h"], copts = CANBUS_COPTS, deps = [ "//modules/canbus_vehicle/devkit/proto:devkit_cc_proto", "//modules/canbus_vehicle/devkit/protocol:canbus_devkit_protocol", "//modules/drivers/canbus/can_comm:message_manager_base", "//modules/drivers/canbus/common:canbus_common", ], ) cc_test( name = "devkit_message_manager_test", size = "small", srcs = ["devkit_message_manager_test.cc"], deps = [ ":devkit_message_manager", "@com_google_googletest//:gtest_main", ], ) cc_library( name = "devkit_controller", srcs = ["devkit_controller.cc"], hdrs = ["devkit_controller.h"], copts = CANBUS_COPTS, deps = [ ":devkit_message_manager", "//modules/canbus/common:canbus_gflags", "//modules/canbus/proto:canbus_conf_cc_proto", "//modules/common_msgs/chassis_msgs:chassis_cc_proto", "//modules/canbus_vehicle/devkit/proto:devkit_cc_proto", "//modules/canbus/proto:vehicle_parameter_cc_proto", "//modules/canbus/vehicle:vehicle_controller_base", "//modules/canbus_vehicle/devkit/protocol:canbus_devkit_protocol", "//modules/common_msgs/basic_msgs:error_code_cc_proto", "//modules/common_msgs/control_msgs:control_cmd_cc_proto", ], ) cc_test( name = "devkit_controller_test", size = "small", srcs = ["devkit_controller_test.cc"], data = ["//modules/canbus:test_data"], deps = [ ":devkit_controller", "@com_google_googletest//:gtest_main", ], ) install( name = "install", library_dest = "canbus-vehicle-devkit/lib", data_dest = "canbus-vehicle-devkit", data = [ ":runtime_data", ":cyberfile.xml", ":canbus-vehicle-devkit.BUILD", ], targets = [ ":libdevkit_vehicle_factory_lib.so", ], deps = [ ":pb_devkit", ":pb_hdrs", ], ) install( name = "pb_hdrs", data_dest = "canbus-vehicle-devkit/include", data = [ "//modules/canbus_vehicle/devkit/proto:devkit_cc_proto", ], ) install_files( name = "pb_devkit", dest = "canbus-vehicle-devkit", files = [ "//modules/canbus_vehicle/devkit/proto:devkit_py_pb2", ], ) filegroup( name = "runtime_data", srcs = glob([ "testdata/**", ]), ) install_src_files( name = "install_src", deps = [ ":install_devkit_src", ":install_devkit_hdrs" ], ) install_src_files( name = "install_devkit_src", src_dir = ["."], dest = "canbus-vehicle-devkit/src", filter = "*", ) install_src_files( name = "install_devkit_hdrs", src_dir = ["."], dest = "canbus-vehicle-devkit/include", filter = "*.h", ) cpplint()
0
apollo_public_repos/apollo/modules/canbus_vehicle
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/devkit_controller.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/devkit_controller.h" #include <string> #include "modules/common_msgs/basic_msgs/vehicle_signal.pb.h" #include "cyber/common/log.h" #include "cyber/time/time.h" #include "modules/canbus/common/canbus_gflags.h" #include "modules/canbus/vehicle/vehicle_controller.h" #include "modules/canbus_vehicle/devkit/devkit_message_manager.h" #include "modules/drivers/canbus/can_comm/can_sender.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::common::ErrorCode; using ::apollo::control::ControlCommand; using ::apollo::drivers::canbus::ProtocolData; namespace { const int32_t kMaxFailAttempt = 10; const int32_t CHECK_RESPONSE_STEER_UNIT_FLAG = 1; const int32_t CHECK_RESPONSE_SPEED_UNIT_FLAG = 2; bool emergency_brake = false; } // namespace ErrorCode DevkitController::Init( const VehicleParameter& params, CanSender<::apollo::canbus::Devkit>* const can_sender, MessageManager<::apollo::canbus::Devkit>* const message_manager) { if (is_initialized_) { AINFO << "DevkitController has already been initiated."; return ErrorCode::CANBUS_ERROR; } vehicle_params_.CopyFrom( common::VehicleConfigHelper::Instance()->GetConfig().vehicle_param()); params_.CopyFrom(params); if (!params_.has_driving_mode()) { AERROR << "Vehicle conf pb not set driving_mode."; return ErrorCode::CANBUS_ERROR; } if (can_sender == nullptr) { return ErrorCode::CANBUS_ERROR; } can_sender_ = can_sender; if (message_manager == nullptr) { AERROR << "protocol manager is null."; return ErrorCode::CANBUS_ERROR; } message_manager_ = message_manager; // sender part brake_command_101_ = dynamic_cast<Brakecommand101*>( message_manager_->GetMutableProtocolDataById(Brakecommand101::ID)); if (brake_command_101_ == nullptr) { AERROR << "Brakecommand101 does not exist in the DevkitMessageManager!"; return ErrorCode::CANBUS_ERROR; } gear_command_103_ = dynamic_cast<Gearcommand103*>( message_manager_->GetMutableProtocolDataById(Gearcommand103::ID)); if (gear_command_103_ == nullptr) { AERROR << "Gearcommand103 does not exist in the DevkitMessageManager!"; return ErrorCode::CANBUS_ERROR; } park_command_104_ = dynamic_cast<Parkcommand104*>( message_manager_->GetMutableProtocolDataById(Parkcommand104::ID)); if (park_command_104_ == nullptr) { AERROR << "Parkcommand104 does not exist in the DevkitMessageManager!"; return ErrorCode::CANBUS_ERROR; } steering_command_102_ = dynamic_cast<Steeringcommand102*>( message_manager_->GetMutableProtocolDataById(Steeringcommand102::ID)); if (steering_command_102_ == nullptr) { AERROR << "Steeringcommand102 does not exist in the DevkitMessageManager!"; return ErrorCode::CANBUS_ERROR; } throttle_command_100_ = dynamic_cast<Throttlecommand100*>( message_manager_->GetMutableProtocolDataById(Throttlecommand100::ID)); if (throttle_command_100_ == nullptr) { AERROR << "Throttlecommand100 does not exist in the DevkitMessageManager!"; return ErrorCode::CANBUS_ERROR; } vehicle_mode_command_105_ = dynamic_cast<Vehiclemodecommand105*>( message_manager_->GetMutableProtocolDataById(Vehiclemodecommand105::ID)); if (vehicle_mode_command_105_ == nullptr) { AERROR << "Vehiclemodecommand105 does not exist in the DevkitMessageManager!"; return ErrorCode::CANBUS_ERROR; } can_sender_->AddMessage(Throttlecommand100::ID, throttle_command_100_, false); can_sender_->AddMessage(Brakecommand101::ID, brake_command_101_, false); can_sender_->AddMessage(Gearcommand103::ID, gear_command_103_, false); can_sender_->AddMessage(Parkcommand104::ID, park_command_104_, false); can_sender_->AddMessage(Steeringcommand102::ID, steering_command_102_, false); can_sender_->AddMessage(Vehiclemodecommand105::ID, vehicle_mode_command_105_, false); // need sleep to ensure all messages received AINFO << "DevkitController is initialized."; is_initialized_ = true; return ErrorCode::OK; } DevkitController::~DevkitController() {} bool DevkitController::Start() { if (!is_initialized_) { AERROR << "DevkitController has NOT been initiated."; return false; } const auto& update_func = [this] { SecurityDogThreadFunc(); }; thread_.reset(new std::thread(update_func)); return true; } void DevkitController::Stop() { if (!is_initialized_) { AERROR << "DevkitController stops or starts improperly!"; return; } if (thread_ != nullptr && thread_->joinable()) { thread_->join(); thread_.reset(); AINFO << "DevkitController stopped."; } } Chassis DevkitController::chassis() { chassis_.Clear(); Devkit chassis_detail; message_manager_->GetSensorData(&chassis_detail); // 21, 22, previously 1, 2 // if (driving_mode() == Chassis::EMERGENCY_MODE) { // set_chassis_error_code(Chassis::NO_ERROR); // } chassis_.set_driving_mode(driving_mode()); chassis_.set_error_code(chassis_error_code()); // 3 chassis_.set_engine_started(true); // 4 engine rpm ch has no engine rpm // chassis_.set_engine_rpm(0); // 5 wheel spd if (chassis_detail.has_wheelspeed_report_506()) { if (chassis_detail.wheelspeed_report_506().has_rr()) { chassis_.mutable_wheel_speed()->set_wheel_spd_rr( chassis_detail.wheelspeed_report_506().rr()); } if (chassis_detail.wheelspeed_report_506().has_rl()) { chassis_.mutable_wheel_speed()->set_wheel_spd_rl( chassis_detail.wheelspeed_report_506().rl()); } if (chassis_detail.wheelspeed_report_506().has_fr()) { chassis_.mutable_wheel_speed()->set_wheel_spd_fr( chassis_detail.wheelspeed_report_506().fr()); } if (chassis_detail.wheelspeed_report_506().has_fl()) { chassis_.mutable_wheel_speed()->set_wheel_spd_fl( chassis_detail.wheelspeed_report_506().fl()); } } // 6 speed_mps if (chassis_detail.has_vcu_report_505() && chassis_detail.vcu_report_505().has_speed()) { chassis_.set_speed_mps( std::abs(static_cast<float>(chassis_detail.vcu_report_505().speed()))); } else { chassis_.set_speed_mps(0); } // 7 no odometer // chassis_.set_odometer_m(0); // 8 no fuel. do not set; // chassis_.set_fuel_range_m(0); // 9 throttle if (chassis_detail.has_throttle_report_500() && chassis_detail.throttle_report_500().has_throttle_pedal_actual()) { chassis_.set_throttle_percentage(static_cast<float>( chassis_detail.throttle_report_500().throttle_pedal_actual())); } else { chassis_.set_throttle_percentage(0); } // throttle sender cmd if (chassis_detail.has_throttle_command_100() && chassis_detail.throttle_command_100().has_throttle_pedal_target()) { chassis_.set_throttle_percentage_cmd(static_cast<float>( chassis_detail.throttle_command_100().throttle_pedal_target())); } else { chassis_.set_throttle_percentage_cmd(0); } // 10 brake if (chassis_detail.has_brake_report_501() && chassis_detail.brake_report_501().has_brake_pedal_actual()) { chassis_.set_brake_percentage(static_cast<float>( chassis_detail.brake_report_501().brake_pedal_actual())); } else { chassis_.set_brake_percentage(0); } // brake sender cmd if (chassis_detail.has_brake_command_101() && chassis_detail.brake_command_101().has_brake_pedal_target()) { chassis_.set_brake_percentage_cmd(static_cast<float>( chassis_detail.brake_command_101().brake_pedal_target())); } else { chassis_.set_brake_percentage_cmd(0); } // 23, previously 11 gear if (chassis_detail.has_gear_report_503() && chassis_detail.gear_report_503().has_gear_actual()) { Chassis::GearPosition gear_pos = Chassis::GEAR_INVALID; if (chassis_detail.gear_report_503().gear_actual() == Gear_report_503::GEAR_ACTUAL_INVALID) { gear_pos = Chassis::GEAR_INVALID; } if (chassis_detail.gear_report_503().gear_actual() == Gear_report_503::GEAR_ACTUAL_NEUTRAL) { gear_pos = Chassis::GEAR_NEUTRAL; } if (chassis_detail.gear_report_503().gear_actual() == Gear_report_503::GEAR_ACTUAL_REVERSE) { gear_pos = Chassis::GEAR_REVERSE; } if (chassis_detail.gear_report_503().gear_actual() == Gear_report_503::GEAR_ACTUAL_DRIVE) { gear_pos = Chassis::GEAR_DRIVE; } if (chassis_detail.gear_report_503().gear_actual() == Gear_report_503::GEAR_ACTUAL_PARK) { gear_pos = Chassis::GEAR_PARKING; } chassis_.set_gear_location(gear_pos); } else { chassis_.set_gear_location(Chassis::GEAR_NONE); } // 12 steering if (chassis_detail.has_steering_report_502() && chassis_detail.steering_report_502().has_steer_angle_actual()) { chassis_.set_steering_percentage(static_cast<float>( chassis_detail.steering_report_502().steer_angle_actual() * 100.0 / vehicle_params_.max_steer_angle() * M_PI / 180)); } else { chassis_.set_steering_percentage(0); } // steering sender cmd if (chassis_detail.has_steering_command_102() && chassis_detail.steering_command_102().has_steer_angle_target()) { chassis_.set_steering_percentage_cmd(static_cast<float>( chassis_detail.steering_command_102().steer_angle_target())); } else { chassis_.set_steering_percentage_cmd(0); } // 13 parking brake if (chassis_detail.has_park_report_504() && chassis_detail.park_report_504().has_parking_actual()) { if (chassis_detail.park_report_504().parking_actual() == Park_report_504::PARKING_ACTUAL_PARKING_TRIGGER) { chassis_.set_parking_brake(true); } else { chassis_.set_parking_brake(false); } } else { chassis_.set_parking_brake(false); } // 14 battery soc if (chassis_detail.has_bms_report_512() && chassis_detail.bms_report_512().has_battery_soc_percentage()) { chassis_.set_battery_soc_percentage( chassis_detail.bms_report_512().battery_soc_percentage()); } else { chassis_.set_battery_soc_percentage(0); } // 15 give engage_advice based on battery low soc warn if (chassis_.battery_soc_percentage() <= 15) { chassis_.mutable_engage_advice()->set_advice( apollo::common::EngageAdvice::DISALLOW_ENGAGE); chassis_.mutable_engage_advice()->set_reason( "Battery soc percentage is lower than 15%, please charge it quickly!"); } // 16 sonor list // to do(ALL):check your vehicle type, confirm your sonar position because of // every vhechle has different sonars assembly. // 08 09 10 11 if (chassis_detail.has_ultr_sensor_1_507()) { chassis_.mutable_surround()->set_sonar08( chassis_detail.ultr_sensor_1_507().uiuss8_tof_direct()); chassis_.mutable_surround()->set_sonar09( chassis_detail.ultr_sensor_1_507().uiuss9_tof_direct()); chassis_.mutable_surround()->set_sonar10( chassis_detail.ultr_sensor_1_507().uiuss10_tof_direct()); chassis_.mutable_surround()->set_sonar11( chassis_detail.ultr_sensor_1_507().uiuss11_tof_direct()); } else { chassis_.mutable_surround()->set_sonar08(0); chassis_.mutable_surround()->set_sonar09(0); chassis_.mutable_surround()->set_sonar10(0); chassis_.mutable_surround()->set_sonar11(0); } // 2 3 4 5 if (chassis_detail.has_ultr_sensor_3_509()) { chassis_.mutable_surround()->set_sonar02( chassis_detail.ultr_sensor_3_509().uiuss2_tof_direct()); chassis_.mutable_surround()->set_sonar03( chassis_detail.ultr_sensor_3_509().uiuss3_tof_direct()); chassis_.mutable_surround()->set_sonar04( chassis_detail.ultr_sensor_3_509().uiuss4_tof_direct()); chassis_.mutable_surround()->set_sonar05( chassis_detail.ultr_sensor_3_509().uiuss5_tof_direct()); } else { chassis_.mutable_surround()->set_sonar02(0); chassis_.mutable_surround()->set_sonar03(0); chassis_.mutable_surround()->set_sonar04(0); chassis_.mutable_surround()->set_sonar05(0); } // 0 1 6 7 if (chassis_detail.has_ultr_sensor_5_511()) { chassis_.mutable_surround()->set_sonar00( chassis_detail.ultr_sensor_5_511().uiuss0_tof_direct()); chassis_.mutable_surround()->set_sonar01( chassis_detail.ultr_sensor_5_511().uiuss1_tof_direct()); chassis_.mutable_surround()->set_sonar06( chassis_detail.ultr_sensor_5_511().uiuss6_tof_direct()); chassis_.mutable_surround()->set_sonar07( chassis_detail.ultr_sensor_5_511().uiuss7_tof_direct()); } else { chassis_.mutable_surround()->set_sonar00(0); chassis_.mutable_surround()->set_sonar01(0); chassis_.mutable_surround()->set_sonar06(0); chassis_.mutable_surround()->set_sonar07(0); } // 17 set vin // vin set 17 bits, like LSBN1234567890123 is prased as // vin17(L),vin16(S),vin15(B),......,vin03(1),vin02(2),vin01(3) std::string vin = ""; if (chassis_detail.has_vin_resp1_514()) { Vin_resp1_514 vin_resp1_514 = chassis_detail.vin_resp1_514(); vin += vin_resp1_514.vin00(); vin += vin_resp1_514.vin01(); vin += vin_resp1_514.vin02(); vin += vin_resp1_514.vin03(); vin += vin_resp1_514.vin04(); vin += vin_resp1_514.vin05(); vin += vin_resp1_514.vin06(); vin += vin_resp1_514.vin07(); } if (chassis_detail.has_vin_resp2_515()) { Vin_resp2_515 vin_resp2_515 = chassis_detail.vin_resp2_515(); vin += vin_resp2_515.vin08(); vin += vin_resp2_515.vin09(); vin += vin_resp2_515.vin10(); vin += vin_resp2_515.vin11(); vin += vin_resp2_515.vin12(); vin += vin_resp2_515.vin13(); vin += vin_resp2_515.vin14(); vin += vin_resp2_515.vin15(); } if (chassis_detail.has_vin_resp3_516()) { Vin_resp3_516 vin_resp3_516 = chassis_detail.vin_resp3_516(); vin += vin_resp3_516.vin16(); } std::reverse(vin.begin(), vin.end()); chassis_.mutable_vehicle_id()->set_vin(vin); // 18 front bumper event if (chassis_detail.has_vcu_report_505() && chassis_detail.vcu_report_505().has_frontcrash_state()) { if (chassis_detail.vcu_report_505().frontcrash_state() == Vcu_report_505::FRONTCRASH_STATE_CRASH_EVENT) { chassis_.set_front_bumper_event(Chassis::BUMPER_PRESSED); } else { chassis_.set_front_bumper_event(Chassis::BUMPER_NORMAL); } } else { chassis_.set_front_bumper_event(Chassis::BUMPER_INVALID); } // 19 back bumper event if (chassis_detail.has_vcu_report_505() && chassis_detail.vcu_report_505().has_backcrash_state()) { if (chassis_detail.vcu_report_505().backcrash_state() == Vcu_report_505::BACKCRASH_STATE_CRASH_EVENT) { chassis_.set_back_bumper_event(Chassis::BUMPER_PRESSED); } else { chassis_.set_back_bumper_event(Chassis::BUMPER_NORMAL); } } else { chassis_.set_back_bumper_event(Chassis::BUMPER_INVALID); } // 20 add checkresponse signal if (chassis_detail.has_brake_report_501() && chassis_detail.brake_report_501().has_brake_en_state()) { chassis_.mutable_check_response()->set_is_esp_online( chassis_detail.brake_report_501().brake_en_state() == 1); } if (chassis_detail.has_steering_report_502() && chassis_detail.steering_report_502().has_steer_en_state()) { chassis_.mutable_check_response()->set_is_eps_online( chassis_detail.steering_report_502().steer_en_state() == 1); } if (chassis_detail.has_throttle_report_500() && chassis_detail.throttle_report_500().has_throttle_en_state()) { chassis_.mutable_check_response()->set_is_vcu_online( chassis_detail.throttle_report_500().throttle_en_state() == 1); } return chassis_; } bool DevkitController::VerifyID() { if (!CheckVin()) { AERROR << "Failed to get the vin."; GetVin(); return false; } else { ResetVin(); return true; } } void DevkitController::Emergency() { set_driving_mode(Chassis::EMERGENCY_MODE); ResetProtocol(); } ErrorCode DevkitController::EnableAutoMode() { if (driving_mode() == Chassis::COMPLETE_AUTO_DRIVE) { AINFO << "already in COMPLETE_AUTO_DRIVE mode"; return ErrorCode::OK; } // set enable brake_command_101_->set_brake_en_ctrl( Brake_command_101::BRAKE_EN_CTRL_ENABLE); throttle_command_100_->set_throttle_en_ctrl( Throttle_command_100::THROTTLE_EN_CTRL_ENABLE); steering_command_102_->set_steer_en_ctrl( Steering_command_102::STEER_EN_CTRL_ENABLE); gear_command_103_->set_gear_en_ctrl(Gear_command_103::GEAR_EN_CTRL_ENABLE); park_command_104_->set_park_en_ctrl(Park_command_104::PARK_EN_CTRL_ENABLE); // set AEB enable if (FLAGS_enable_aeb) { brake_command_101_->set_aeb_en_ctrl( Brake_command_101::AEB_EN_CTRL_ENABLE_AEB); AINFO << "Set AEB enable"; } can_sender_->Update(); const int32_t flag = CHECK_RESPONSE_STEER_UNIT_FLAG | CHECK_RESPONSE_SPEED_UNIT_FLAG; if (!CheckResponse(flag, true)) { AERROR << "Failed to switch to COMPLETE_AUTO_DRIVE mode. Please check the " "emergency button or chassis."; Emergency(); set_chassis_error_code(Chassis::CHASSIS_ERROR); return ErrorCode::CANBUS_ERROR; } set_driving_mode(Chassis::COMPLETE_AUTO_DRIVE); AINFO << "Switch to COMPLETE_AUTO_DRIVE mode ok."; return ErrorCode::OK; } ErrorCode DevkitController::DisableAutoMode() { ResetProtocol(); can_sender_->Update(); set_driving_mode(Chassis::COMPLETE_MANUAL); set_chassis_error_code(Chassis::NO_ERROR); AINFO << "Switch to COMPLETE_MANUAL ok."; return ErrorCode::OK; } ErrorCode DevkitController::EnableSteeringOnlyMode() { if (driving_mode() == Chassis::COMPLETE_AUTO_DRIVE || driving_mode() == Chassis::AUTO_STEER_ONLY) { set_driving_mode(Chassis::AUTO_STEER_ONLY); AINFO << "Already in AUTO_STEER_ONLY mode."; return ErrorCode::OK; } AFATAL << "SpeedOnlyMode is not supported in devkit!"; return ErrorCode::CANBUS_ERROR; } ErrorCode DevkitController::EnableSpeedOnlyMode() { if (driving_mode() == Chassis::COMPLETE_AUTO_DRIVE || driving_mode() == Chassis::AUTO_SPEED_ONLY) { set_driving_mode(Chassis::AUTO_SPEED_ONLY); AINFO << "Already in AUTO_SPEED_ONLY mode"; return ErrorCode::OK; } AFATAL << "SpeedOnlyMode is not supported in devkit!"; return ErrorCode::CANBUS_ERROR; } // NEUTRAL, REVERSE, DRIVE void DevkitController::Gear(Chassis::GearPosition gear_position) { if (driving_mode() != Chassis::COMPLETE_AUTO_DRIVE && driving_mode() != Chassis::AUTO_SPEED_ONLY) { AINFO << "This drive mode no need to set gear."; return; } switch (gear_position) { case Chassis::GEAR_NEUTRAL: { gear_command_103_->set_gear_target(Gear_command_103::GEAR_TARGET_NEUTRAL); break; } case Chassis::GEAR_REVERSE: { gear_command_103_->set_gear_target(Gear_command_103::GEAR_TARGET_REVERSE); break; } case Chassis::GEAR_DRIVE: { gear_command_103_->set_gear_target(Gear_command_103::GEAR_TARGET_DRIVE); break; } case Chassis::GEAR_PARKING: { gear_command_103_->set_gear_target(Gear_command_103::GEAR_TARGET_PARK); break; } case Chassis::GEAR_INVALID: { gear_command_103_->set_gear_target(Gear_command_103::GEAR_TARGET_NEUTRAL); break; } default: { gear_command_103_->set_gear_target(Gear_command_103::GEAR_TARGET_NEUTRAL); break; } } } // brake with pedal // pedal:0.00~99.99, unit:% void DevkitController::Brake(double pedal) { // double real_value = params_.max_acc() * acceleration / 100; // TODO(All) : Update brake value based on mode if (driving_mode() != Chassis::COMPLETE_AUTO_DRIVE && driving_mode() != Chassis::AUTO_SPEED_ONLY) { AINFO << "The current drive mode does not need to set brake pedal."; return; } if (!emergency_brake) { brake_command_101_->set_brake_pedal_target(pedal); } // brake_command_101_->set_brake_pedal_target(pedal); } // drive with pedal // pedal:0.0~99.9 unit:%s void DevkitController::Throttle(double pedal) { if (driving_mode() != Chassis::COMPLETE_AUTO_DRIVE && driving_mode() != Chassis::AUTO_SPEED_ONLY) { AINFO << "The current drive mode does not need to set throttle pedal."; return; } if (!emergency_brake) { throttle_command_100_->set_throttle_pedal_target(pedal); } // throttle_command_100_->set_throttle_pedal_target(pedal); } // confirm the car is driven by acceleration command instead of // throttle/brake pedal drive with acceleration/deceleration acc:-7.0 ~ 5.0, // unit:m/s^2 void DevkitController::Acceleration(double acc) { if (driving_mode() != Chassis::COMPLETE_AUTO_DRIVE && driving_mode() != Chassis::AUTO_SPEED_ONLY) { AINFO << "The current drive mode does not need to set acceleration."; return; } // None } // devkit default, left:+, right:- // need to be compatible with control module, so reverse // steering with default angle speed, 25-250 (default:250) // angle:-99.99~0.00~99.99, unit:, left:+, right:- void DevkitController::Steer(double angle) { if (driving_mode() != Chassis::COMPLETE_AUTO_DRIVE && driving_mode() != Chassis::AUTO_STEER_ONLY) { AINFO << "The current driving mode does not need to set steer."; return; } const double real_angle = vehicle_params_.max_steer_angle() / M_PI * 180 * angle / 100.0; if (!emergency_brake) { steering_command_102_->set_steer_angle_target(real_angle) ->set_steer_angle_spd_target(250); } } // steering with new angle speed // angle:-99.99~0.00~99.99, unit:, left:+, right:- // angle_spd:25~250(default:250), unit:deg/s void DevkitController::Steer(double angle, double angle_spd) { if (driving_mode() != Chassis::COMPLETE_AUTO_DRIVE && driving_mode() != Chassis::AUTO_STEER_ONLY) { AINFO << "The current driving mode does not need to set steer."; return; } const double real_angle = vehicle_params_.max_steer_angle() / M_PI * 180 * angle / 100.0; if (!emergency_brake) { steering_command_102_->set_steer_angle_target(real_angle) ->set_steer_angle_spd_target(250); } } void DevkitController::SetEpbBreak(const ControlCommand& command) { if (command.parking_brake()) { park_command_104_->set_park_target( Park_command_104::PARK_TARGET_PARKING_TRIGGER); } else { park_command_104_->set_park_target(Park_command_104::PARK_TARGET_RELEASE); } } void DevkitController::SetBeam(const ControlCommand& command) { if (command.signal().high_beam()) { // None } else if (command.signal().low_beam()) { // None } else { // None } } void DevkitController::SetHorn(const ControlCommand& command) { if (command.signal().horn()) { // None } else { // None } } void DevkitController::SetTurningSignal(const ControlCommand& command) { // Set Turn Signal auto signal = command.signal().turn_signal(); if (signal == common::VehicleSignal::TURN_LEFT) { vehicle_mode_command_105_->set_turn_light_ctrl( Vehicle_mode_command_105::TURN_LIGHT_CTRL_LEFT_TURNLAMP_ON); } else if (signal == common::VehicleSignal::TURN_RIGHT) { vehicle_mode_command_105_->set_turn_light_ctrl( Vehicle_mode_command_105::TURN_LIGHT_CTRL_RIGHT_TURNLAMP_ON); } else if (signal == common::VehicleSignal::TURN_HAZARD_WARNING) { vehicle_mode_command_105_->set_turn_light_ctrl( Vehicle_mode_command_105::TURN_LIGHT_CTRL_HAZARD_WARNING_LAMPSTS_ON); } else { vehicle_mode_command_105_->set_turn_light_ctrl( Vehicle_mode_command_105::TURN_LIGHT_CTRL_TURNLAMP_OFF); } } bool DevkitController::CheckVin() { if (chassis_.vehicle_id().vin().size() == 17) { AINFO << "Vin check success! Vehicel vin is " << chassis_.vehicle_id().vin(); return true; } else { AINFO << "Vin check failed! Current vin size is " << chassis_.vehicle_id().vin().size(); return false; } } void DevkitController::GetVin() { vehicle_mode_command_105_->set_vin_req( Vehicle_mode_command_105::VIN_REQ_VIN_REQ_ENABLE); AINFO << "Get vin"; can_sender_->Update(); } void DevkitController::ResetVin() { vehicle_mode_command_105_->set_vin_req( Vehicle_mode_command_105::VIN_REQ_VIN_REQ_DISABLE); AINFO << "Reset vin"; can_sender_->Update(); } void DevkitController::ResetProtocol() { message_manager_->ResetSendMessages(); } bool DevkitController::CheckChassisError() { Devkit chassis_detail; message_manager_->GetSensorData(&chassis_detail); if (!chassis_detail.has_check_response()) { AERROR_EVERY(100) << "ChassisDetail has no devkit vehicle info." << chassis_detail.DebugString(); return false; } // steer fault if (chassis_detail.has_steering_report_502()) { if (Steering_report_502::STEER_FLT1_STEER_SYSTEM_HARDWARE_FAULT == chassis_detail.steering_report_502().steer_flt1()) { AERROR_EVERY(100) << "Chassis has steer system fault."; return true; } } // drive fault if (chassis_detail.has_throttle_report_500()) { if (Throttle_report_500::THROTTLE_FLT1_DRIVE_SYSTEM_HARDWARE_FAULT == chassis_detail.throttle_report_500().throttle_flt1()) { AERROR_EVERY(100) << "Chassis has drive system fault."; return true; } } // brake fault if (chassis_detail.has_brake_report_501()) { if (Brake_report_501::BRAKE_FLT1_BRAKE_SYSTEM_HARDWARE_FAULT == chassis_detail.brake_report_501().brake_flt1()) { AERROR_EVERY(100) << "Chassis has brake system fault."; return true; } } // battery soc low if (chassis_detail.has_bms_report_512()) { if (chassis_detail.bms_report_512().is_battery_soc_low()) { AERROR_EVERY(100) << "Chassis battery has low soc, please charge."; return true; } } // battery over emperature fault if (chassis_detail.has_bms_report_512()) { if (Bms_report_512::BATTERY_FLT_OVER_TEMP_FAULT == chassis_detail.bms_report_512().battery_flt_over_temp()) { AERROR_EVERY(100) << "Chassis battery has over temperature fault."; return true; } } // battery low temperature fault if (chassis_detail.has_bms_report_512()) { if (Bms_report_512::BATTERY_FLT_LOW_TEMP_FAULT == chassis_detail.bms_report_512().battery_flt_low_temp()) { AERROR_EVERY(100) << "Chassis battery has below low temperature fault."; return true; } } return false; } void DevkitController::SecurityDogThreadFunc() { int32_t vertical_ctrl_fail = 0; int32_t horizontal_ctrl_fail = 0; if (can_sender_ == nullptr) { AERROR << "Failed to run SecurityDogThreadFunc() because can_sender_ is " "nullptr."; return; } while (!can_sender_->IsRunning()) { std::this_thread::yield(); } std::chrono::duration<double, std::micro> default_period{50000}; int64_t start = 0; int64_t end = 0; while (can_sender_->IsRunning()) { start = ::apollo::cyber::Time::Now().ToMicrosecond(); const Chassis::DrivingMode mode = driving_mode(); bool emergency_mode = false; emergency_brake = false; // 1. horizontal control check if ((mode == Chassis::COMPLETE_AUTO_DRIVE || mode == Chassis::AUTO_STEER_ONLY) && CheckResponse(CHECK_RESPONSE_STEER_UNIT_FLAG, false) == false) { ++horizontal_ctrl_fail; if (horizontal_ctrl_fail >= kMaxFailAttempt) { emergency_mode = true; AINFO << "Driving_mode is into emergency by steer manual intervention"; set_chassis_error_code(Chassis::MANUAL_INTERVENTION); } } else { horizontal_ctrl_fail = 0; } // 2. vertical control check if ((mode == Chassis::COMPLETE_AUTO_DRIVE || mode == Chassis::AUTO_SPEED_ONLY) && !CheckResponse(CHECK_RESPONSE_SPEED_UNIT_FLAG, false)) { ++vertical_ctrl_fail; if (vertical_ctrl_fail >= kMaxFailAttempt) { emergency_mode = true; AINFO << "Driving_mode is into emergency by speed manual intervention"; set_chassis_error_code(Chassis::MANUAL_INTERVENTION); } } else { vertical_ctrl_fail = 0; } if (CheckChassisError()) { set_chassis_error_code(Chassis::CHASSIS_ERROR); emergency_mode = true; if (chassis_.speed_mps() > 0.3) { emergency_brake = true; } } if (emergency_mode && mode != Chassis::EMERGENCY_MODE) { set_driving_mode(Chassis::EMERGENCY_MODE); if (emergency_brake) { throttle_command_100_->set_throttle_pedal_target(0); brake_command_101_->set_brake_pedal_target(40); steering_command_102_->set_steer_angle_target(0); std::this_thread::sleep_for( std::chrono::duration<double, std::milli>(3000)); } message_manager_->ResetSendMessages(); can_sender_->Update(); emergency_brake = false; } end = ::apollo::cyber::Time::Now().ToMicrosecond(); std::chrono::duration<double, std::micro> elapsed{end - start}; if (elapsed < default_period) { std::this_thread::sleep_for(default_period - elapsed); } else { AERROR << "Too much time consumption in DevkitController looping " "process:" << elapsed.count(); } } } bool DevkitController::CheckResponse(const int32_t flags, bool need_wait) { int32_t retry_num = 20; Devkit chassis_detail; bool is_eps_online = false; bool is_vcu_online = false; bool is_esp_online = false; do { if (message_manager_->GetSensorData(&chassis_detail) != ErrorCode::OK) { AERROR_EVERY(100) << "get chassis detail failed."; return false; } bool check_ok = true; if (flags & CHECK_RESPONSE_STEER_UNIT_FLAG) { is_eps_online = chassis_detail.has_check_response() && chassis_detail.check_response().has_is_eps_online() && chassis_detail.check_response().is_eps_online(); check_ok = check_ok && is_eps_online; } if (flags & CHECK_RESPONSE_SPEED_UNIT_FLAG) { is_vcu_online = chassis_detail.has_check_response() && chassis_detail.check_response().has_is_vcu_online() && chassis_detail.check_response().is_vcu_online(); is_esp_online = chassis_detail.has_check_response() && chassis_detail.check_response().has_is_esp_online() && chassis_detail.check_response().is_esp_online(); check_ok = check_ok && is_vcu_online && is_esp_online; } if (check_ok) { return true; } else { AINFO << "Need to check response again."; } if (need_wait) { --retry_num; std::this_thread::sleep_for( std::chrono::duration<double, std::milli>(20)); } } while (need_wait && retry_num); AINFO << "check_response fail: is_eps_online:" << is_eps_online << ", is_vcu_online:" << is_vcu_online << ", is_esp_online:" << is_esp_online; return false; } void DevkitController::set_chassis_error_mask(const int32_t mask) { std::lock_guard<std::mutex> lock(chassis_mask_mutex_); chassis_error_mask_ = mask; } int32_t DevkitController::chassis_error_mask() { std::lock_guard<std::mutex> lock(chassis_mask_mutex_); return chassis_error_mask_; } Chassis::ErrorCode DevkitController::chassis_error_code() { std::lock_guard<std::mutex> lock(chassis_error_code_mutex_); return chassis_error_code_; } void DevkitController::set_chassis_error_code( const Chassis::ErrorCode& error_code) { std::lock_guard<std::mutex> lock(chassis_error_code_mutex_); chassis_error_code_ = error_code; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/testdata/devkit_canbus_conf_test.pb.txt
vehicle_parameter { brand: DKIT max_enable_fail_attempt: 5 driving_mode: COMPLETE_AUTO_DRIVE } can_card_parameter { brand:SOCKET_CAN_RAW type: PCI_CARD channel_id: CHANNEL_ID_ZERO } enable_debug_mode: false
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/proto/devkit.proto
syntax = "proto2"; package apollo.canbus; message Throttle_command_100 { // Control Message enum Throttle_en_ctrlType { THROTTLE_EN_CTRL_DISABLE = 0; THROTTLE_EN_CTRL_ENABLE = 1; } // [m/s^2] [0|10] optional double throttle_acc = 1; // [] [0|255] optional int32 checksum_100 = 2; // [%] [0|100] optional double throttle_pedal_target = 3; // [] [0|1] optional Throttle_en_ctrlType throttle_en_ctrl = 4; // [m/s] [0|10.23] optional double speed_target = 5; } message Brake_command_101 { // Control Message enum Aeb_en_ctrlType { AEB_EN_CTRL_DISABLE_AEB = 0; AEB_EN_CTRL_ENABLE_AEB = 1; } enum Brake_en_ctrlType { BRAKE_EN_CTRL_DISABLE = 0; BRAKE_EN_CTRL_ENABLE = 1; } // [m/s^2] [0|10] optional double brake_dec = 1; // [] [0|255] optional int32 checksum_101 = 2; // [%] [0|100] optional double brake_pedal_target = 3; // [] [0|1] optional Brake_en_ctrlType brake_en_ctrl = 4; // [] [0|0] optional Aeb_en_ctrlType aeb_en_ctrl = 5; } message Steering_command_102 { // Control Message enum Steer_en_ctrlType { STEER_EN_CTRL_DISABLE = 0; STEER_EN_CTRL_ENABLE = 1; } // [] [0|1] optional Steer_en_ctrlType steer_en_ctrl = 1; // [deg] [-500|500] optional int32 steer_angle_target = 2; // [deg/s] [0|250] optional int32 steer_angle_spd_target = 3; // [] [0|255] optional int32 checksum_102 = 4; } message Gear_command_103 { // Control Message enum Gear_targetType { GEAR_TARGET_INVALID = 0; GEAR_TARGET_PARK = 1; GEAR_TARGET_REVERSE = 2; GEAR_TARGET_NEUTRAL = 3; GEAR_TARGET_DRIVE = 4; } enum Gear_en_ctrlType { GEAR_EN_CTRL_DISABLE = 0; GEAR_EN_CTRL_ENABLE = 1; } // [] [0|4] optional Gear_targetType gear_target = 1; // [] [0|1] optional Gear_en_ctrlType gear_en_ctrl = 2; // [] [0|255] optional int32 checksum_103 = 3; } message Park_command_104 { // Control Message enum Park_targetType { PARK_TARGET_RELEASE = 0; PARK_TARGET_PARKING_TRIGGER = 1; } enum Park_en_ctrlType { PARK_EN_CTRL_DISABLE = 0; PARK_EN_CTRL_ENABLE = 1; } // [] [0|255] optional int32 checksum_104 = 1; // [] [0|1] optional Park_targetType park_target = 2; // [] [0|1] optional Park_en_ctrlType park_en_ctrl = 3; } message Vehicle_mode_command_105 { // Control Message enum Turn_light_ctrlType { TURN_LIGHT_CTRL_TURNLAMP_OFF = 0; TURN_LIGHT_CTRL_LEFT_TURNLAMP_ON = 1; TURN_LIGHT_CTRL_RIGHT_TURNLAMP_ON = 2; TURN_LIGHT_CTRL_HAZARD_WARNING_LAMPSTS_ON = 3; } enum Vin_reqType { VIN_REQ_VIN_REQ_DISABLE = 0; VIN_REQ_VIN_REQ_ENABLE = 1; } enum Drive_mode_ctrlType { DRIVE_MODE_CTRL_THROTTLE_PADDLE_DRIVE = 0; DRIVE_MODE_CTRL_SPEED_DRIVE = 1; } enum Steer_mode_ctrlType { STEER_MODE_CTRL_STANDARD_STEER = 0; STEER_MODE_CTRL_NON_DIRECTION_STEER = 1; STEER_MODE_CTRL_SYNC_DIRECTION_STEER = 2; } // [] [0|255] optional int32 checksum_105 = 1; // [] [0|7] optional Turn_light_ctrlType turn_light_ctrl = 2; // [] [0|1] optional Vin_reqType vin_req = 3; // [] [0|7] optional Drive_mode_ctrlType drive_mode_ctrl = 4; // [] [0|7] optional Steer_mode_ctrlType steer_mode_ctrl = 5; } message Throttle_report_500 { // Report Message enum Throttle_flt2Type { THROTTLE_FLT2_NO_FAULT = 0; THROTTLE_FLT2_DRIVE_SYSTEM_COMUNICATION_FAULT = 1; } enum Throttle_flt1Type { THROTTLE_FLT1_NO_FAULT = 0; THROTTLE_FLT1_DRIVE_SYSTEM_HARDWARE_FAULT = 1; } enum Throttle_en_stateType { THROTTLE_EN_STATE_MANUAL = 0; THROTTLE_EN_STATE_AUTO = 1; THROTTLE_EN_STATE_TAKEOVER = 2; THROTTLE_EN_STATE_STANDBY = 3; } // [%] [0|100] optional double throttle_pedal_actual = 1; // Drive system communication fault [] [0|1] optional Throttle_flt2Type throttle_flt2 = 2; // Drive system hardware fault [] [0|1] optional Throttle_flt1Type throttle_flt1 = 3; // [] [0|2] optional Throttle_en_stateType throttle_en_state = 4; } message Brake_report_501 { // Report Message enum Brake_flt2Type { BRAKE_FLT2_NO_FAULT = 0; BRAKE_FLT2_BRAKE_SYSTEM_COMUNICATION_FAULT = 1; } enum Brake_flt1Type { BRAKE_FLT1_NO_FAULT = 0; BRAKE_FLT1_BRAKE_SYSTEM_HARDWARE_FAULT = 1; } enum Brake_en_stateType { BRAKE_EN_STATE_MANUAL = 0; BRAKE_EN_STATE_AUTO = 1; BRAKE_EN_STATE_TAKEOVER = 2; BRAKE_EN_STATE_STANDBY = 3; } // [%] [0|100] optional double brake_pedal_actual = 1; // Brake system communication fault [] [0|1] optional Brake_flt2Type brake_flt2 = 2; // Brake system hardware fault [] [0|1] optional Brake_flt1Type brake_flt1 = 3; // [] [0|2] optional Brake_en_stateType brake_en_state = 4; } message Steering_report_502 { // Report Message enum Steer_flt2Type { STEER_FLT2_NO_FAULT = 0; STEER_FLT2_STEER_SYSTEM_COMUNICATION_FAULT = 1; } enum Steer_flt1Type { STEER_FLT1_NO_FAULT = 0; STEER_FLT1_STEER_SYSTEM_HARDWARE_FAULT = 1; } enum Steer_en_stateType { STEER_EN_STATE_MANUAL = 0; STEER_EN_STATE_AUTO = 1; STEER_EN_STATE_TAKEOVER = 2; STEER_EN_STATE_STANDBY = 3; } // [deg/s] [0|0] optional int32 steer_angle_spd_actual = 1; // Steer system communication fault [] [0|255] optional Steer_flt2Type steer_flt2 = 2; // Steer system hardware fault [] [0|255] optional Steer_flt1Type steer_flt1 = 3; // [] [0|2] optional Steer_en_stateType steer_en_state = 4; // [deg] [-500|500] optional int32 steer_angle_actual = 5; // [deg] [-500|500] optional int32 steer_angle_rear_actual = 6; } message Gear_report_503 { // Report Message enum Gear_fltType { GEAR_FLT_NO_FAULT = 0; GEAR_FLT_FAULT = 1; } enum Gear_actualType { GEAR_ACTUAL_INVALID = 0; GEAR_ACTUAL_PARK = 1; GEAR_ACTUAL_REVERSE = 2; GEAR_ACTUAL_NEUTRAL = 3; GEAR_ACTUAL_DRIVE = 4; } // [] [0|1] optional Gear_fltType gear_flt = 1; // [] [0|4] optional Gear_actualType gear_actual = 2; } message Park_report_504 { // Report Message enum Parking_actualType { PARKING_ACTUAL_RELEASE = 0; PARKING_ACTUAL_PARKING_TRIGGER = 1; } enum Park_fltType { PARK_FLT_NO_FAULT = 0; PARK_FLT_FAULT = 1; } // [] [0|1] optional Parking_actualType parking_actual = 1; // [] [0|1] optional Park_fltType park_flt = 2; } message Vcu_report_505 { // Report Message enum Vehicle_mode_stateType { VEHICLE_MODE_STATE_MANUAL_REMOTE_MODE = 0; VEHICLE_MODE_STATE_AUTO_MODE = 1; VEHICLE_MODE_STATE_EMERGENCY_MODE = 2; VEHICLE_MODE_STATE_STANDBY_MODE = 3; } enum Aeb_modeType { AEB_MODE_DISABLE = 0; AEB_MODE_ENABLE = 1; } enum Brake_light_actualType { BRAKE_LIGHT_ACTUAL_BRAKELIGHT_OFF = 0; BRAKE_LIGHT_ACTUAL_BRAKELIGHT_ON = 1; } enum Turn_light_actualType { TURN_LIGHT_ACTUAL_TURNLAMPSTS_OFF = 0; TURN_LIGHT_ACTUAL_LEFT_TURNLAMPSTS_ON = 1; TURN_LIGHT_ACTUAL_RIGHT_TURNLAMPSTS_ON = 2; TURN_LIGHT_ACTUAL_HAZARD_WARNING_LAMPSTS_ON = 3; } enum Drive_mode_stsType { DRIVE_MODE_STS_THROTTLE_PADDLE_DRIVE_MODE = 0; DRIVE_MODE_STS_SPEED_DRIVE_MODE = 1; } enum Steer_mode_stsType { STEER_MODE_STS_STANDARD_STEER_MODE = 0; STEER_MODE_STS_NON_DIRECTION_STEER_MODE = 1; STEER_MODE_STS_SYNC_DIRECTION_STEER_MODE = 2; } enum Frontcrash_stateType { FRONTCRASH_STATE_NO_EVENT = 0; FRONTCRASH_STATE_CRASH_EVENT = 1; } enum Backcrash_stateType { BACKCRASH_STATE_NO_EVENT = 0; BACKCRASH_STATE_CRASH_EVENT = 1; } enum Aeb_brake_stateType { AEB_BRAKE_STATE_INACTIVE = 0; AEB_BRAKE_STATE_ACTIVE = 1; } // [] [0|0] optional Vehicle_mode_stateType vehicle_mode_state = 1; // describle the vehicle AEB mode whether was set [] [0|1] optional Aeb_modeType aeb_mode = 2; // [] [0|1] optional Brake_light_actualType brake_light_actual = 3; // [] [0|0] optional Turn_light_actualType turn_light_actual = 4; // [] [0|255] optional int32 chassis_errcode = 5; // [] [0|7] optional Drive_mode_stsType drive_mode_sts = 6; // [] [0|7] optional Steer_mode_stsType steer_mode_sts = 7; // [] [0|0] optional Frontcrash_stateType frontcrash_state = 8; // [] [0|0] optional Backcrash_stateType backcrash_state = 9; // describe the vehicle e-brake command whether was triggered by AEB [] [0|0] optional Aeb_brake_stateType aeb_brake_state = 10; // [m/s^2] [-10|10] optional double acc = 11; // [m/s] [-32.768|32.767] optional double speed = 12; } message Wheelspeed_report_506 { // Report Message // [m/s] [0|65.535] optional double rr = 1; // [m/s] [0|65.535] optional double rl = 2; // [m/s] [0|65.535] optional double fr = 3; // [m/s] [0|65.535] optional double fl = 4; } message Ultr_sensor_1_507 { // Report Message // [cm] [0|65535] optional double uiuss9_tof_direct = 1; // [cm] [0|65535] optional double uiuss8_tof_direct = 2; // [cm] [0|65535] optional double uiuss11_tof_direct = 3; // [cm] [0|65535] optional double uiuss10_tof_direct = 4; } message Ultr_sensor_2_508 { // Report Message // [cm] [0|65535] optional double uiuss9_tof_indirect = 1; // [cm] [0|65535] optional double uiuss8_tof_indirect = 2; // [cm] [0|65535] optional double uiuss11_tof_indirect = 3; // [cm] [0|65535] optional double uiuss10_tof_indirect = 4; } message Ultr_sensor_3_509 { // Report Message // [cm] [0|65535] optional double uiuss5_tof_direct = 1; // [cm] [0|65535] optional double uiuss4_tof_direct = 2; // [cm] [0|65535] optional double uiuss3_tof_direct = 3; // [cm] [0|65535] optional double uiuss2_tof_direct = 4; } message Ultr_sensor_4_510 { // Report Message // [cm] [0|65535] optional double uiuss5_tof_indirect = 1; // [cm] [0|65535] optional double uiuss4_tof_indirect = 2; // [cm] [0|65535] optional double uiuss3_tof_indirect = 3; // [cm] [0|65535] optional double uiuss2_tof_indirect = 4; } message Ultr_sensor_5_511 { // Report Message // [cm] [0|65535] optional double uiuss7_tof_direct = 1; // [cm] [0|65535] optional double uiuss6_tof_direct = 2; // [cm] [0|65535] optional double uiuss1_tof_direct = 3; // [cm] [0|65535] optional double uiuss0_tof_direct = 4; } message Bms_report_512 { // Report Message enum Battery_flt_lowtempType { BATTERY_FLT_LOW_TEMP_NO_FAULT = 0; BATTERY_FLT_LOW_TEMP_FAULT = 1; } enum Battery_flt_overtempType { BATTERY_FLT_OVER_TEMP_NO_FAULT = 0; BATTERY_FLT_OVER_TEMP_FAULT = 1; } // Battery Total Current [A] [-3200|3200] optional double battery_current = 1; // Battery Total Voltage [V] [0|300] optional double battery_voltage = 2; // Battery State of Charge percentage [%] [0|100] optional int32 battery_soc_percentage = 3; // Battery Low Soc Warn optional bool is_battery_soc_low = 4; // Battery inside temperature optional double battery_inside_temperature = 5; // Battery Below Low temp fault optional Battery_flt_lowtempType battery_flt_low_temp = 6; // Battery Over High Temp fault optional Battery_flt_overtempType battery_flt_over_temp = 7; } message Vin_resp1_514 { // Report Message // [] [0|255] to char optional string vin07 = 1; // [] [0|255] to char optional string vin06 = 2; // [] [0|255] to char optional string vin05 = 3; // [] [0|255] to char optional string vin04 = 4; // [] [0|255] to char optional string vin03 = 5; // [] [0|255] to char optional string vin02 = 6; // [] [0|255] to char optional string vin01 = 7; // [] [0|255] to char optional string vin00 = 8; } message Vin_resp2_515 { // Report Message // [] [0|255] to char optional string vin15 = 1; // [] [0|255] to char optional string vin14 = 2; // [] [0|255] to char optional string vin13 = 3; // [] [0|255] to char optional string vin12 = 4; // [] [0|255] to char optional string vin11 = 5; // [] [0|255] to char optional string vin10 = 6; // [] [0|255] to char optional string vin09 = 7; // [] [0|255] to char optional string vin08 = 8; } message Vin_resp3_516 { // Report Message // [] [0|255] to char optional string vin16 = 1; } // CheckResponseSignal message CheckResponseSignal { optional bool is_eps_online = 1 [default = false]; optional bool is_epb_online = 2 [default = false]; optional bool is_esp_online = 3 [default = false]; optional bool is_vtog_online = 4 [default = false]; optional bool is_scu_online = 5 [default = false]; optional bool is_switch_online = 6 [default = false]; optional bool is_vcu_online = 7 [default = false]; } message Devkit { optional Throttle_command_100 throttle_command_100 = 1; // control message optional Brake_command_101 brake_command_101 = 2; // control message optional Steering_command_102 steering_command_102 = 3; // control message optional Gear_command_103 gear_command_103 = 4; // control message optional Park_command_104 park_command_104 = 5; // control message optional Throttle_report_500 throttle_report_500 = 6; // report message optional Brake_report_501 brake_report_501 = 7; // report message optional Steering_report_502 steering_report_502 = 8; // report message optional Gear_report_503 gear_report_503 = 9; // report message optional Park_report_504 park_report_504 = 10; // report message optional Vcu_report_505 vcu_report_505 = 11; // report message optional Wheelspeed_report_506 wheelspeed_report_506 = 12; // report message optional Ultr_sensor_1_507 ultr_sensor_1_507 = 13; // report message optional Ultr_sensor_2_508 ultr_sensor_2_508 = 14; // report message optional Ultr_sensor_3_509 ultr_sensor_3_509 = 15; // report message optional Ultr_sensor_4_510 ultr_sensor_4_510 = 16; // report message optional Ultr_sensor_5_511 ultr_sensor_5_511 = 17; // report message optional Bms_report_512 bms_report_512 = 18; // report message optional Vehicle_mode_command_105 vehicle_mode_command_105 = 19; // control message optional Vin_resp1_514 vin_resp1_514 = 20; // report message optional Vin_resp2_515 vin_resp2_515 = 21; // report message optional Vin_resp3_516 vin_resp3_516 = 22; // report message optional CheckResponseSignal check_response = 100; }
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/proto/BUILD
## Auto generated by `proto_build_generator.py` load("@rules_proto//proto:defs.bzl", "proto_library") load("@rules_cc//cc:defs.bzl", "cc_proto_library") load("//tools:python_rules.bzl", "py_proto_library") package(default_visibility = ["//visibility:public"]) cc_proto_library( name = "devkit_cc_proto", deps = [ ":devkit_proto", ], ) proto_library( name = "devkit_proto", srcs = ["devkit.proto"], ) py_proto_library( name = "devkit_py_pb2", deps = [ ":devkit_proto", ], )
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/park_command_104.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/park_command_104.h" #include "modules/drivers/canbus/common/byte.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; const int32_t Parkcommand104::ID = 0x104; // public Parkcommand104::Parkcommand104() { Reset(); } uint32_t Parkcommand104::GetPeriod() const { // TODO(All) : modify every protocol's period manually static const uint32_t PERIOD = 20 * 1000; return PERIOD; } void Parkcommand104::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_park_command_104()->set_park_target( park_target(bytes, length)); chassis->mutable_park_command_104()->set_park_en_ctrl( park_en_ctrl(bytes, length)); chassis->mutable_park_command_104()->set_checksum_104( checksum_104(bytes, length)); } void Parkcommand104::UpdateData(uint8_t* data) { set_p_park_target(data, park_target_); set_p_park_en_ctrl(data, park_en_ctrl_); checksum_104_ = data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6]; set_p_checksum_104(data, checksum_104_); } void Parkcommand104::Reset() { // TODO(All) : you should check this manually checksum_104_ = 0; park_target_ = Park_command_104::PARK_TARGET_RELEASE; park_en_ctrl_ = Park_command_104::PARK_EN_CTRL_DISABLE; } Parkcommand104* Parkcommand104::set_checksum_104(int checksum_104) { checksum_104_ = checksum_104; return this; } // config detail: {'name': 'CheckSum_104', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'physical_range': '[0|255]', 'bit': 63, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} void Parkcommand104::set_p_checksum_104(uint8_t* data, int checksum_104) { checksum_104 = ProtocolData::BoundedValue(0, 255, checksum_104); int x = checksum_104; Byte to_set(data + 7); to_set.set_value(x, 0, 8); } Parkcommand104* Parkcommand104::set_park_target( Park_command_104::Park_targetType park_target) { park_target_ = park_target; return this; } // config detail: {'name': 'Park_Target', 'enum': {0: 'PARK_TARGET_RELEASE', 1: // 'PARK_TARGET_PARKING_TRIGGER'}, 'precision': 1.0, 'len': 1, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 8, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} void Parkcommand104::set_p_park_target( uint8_t* data, Park_command_104::Park_targetType park_target) { int x = park_target; Byte to_set(data + 1); to_set.set_value(x, 0, 1); } Parkcommand104* Parkcommand104::set_park_en_ctrl( Park_command_104::Park_en_ctrlType park_en_ctrl) { park_en_ctrl_ = park_en_ctrl; return this; } // config detail: {'name': 'Park_EN_CTRL', 'enum': {0: 'PARK_EN_CTRL_DISABLE', // 1: 'PARK_EN_CTRL_ENABLE'}, 'precision': 1.0, 'len': 1, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} void Parkcommand104::set_p_park_en_ctrl( uint8_t* data, Park_command_104::Park_en_ctrlType park_en_ctrl) { int x = park_en_ctrl; Byte to_set(data + 0); to_set.set_value(x, 0, 1); } Park_command_104::Park_targetType Parkcommand104::park_target( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 3); Park_command_104::Park_targetType ret = static_cast<Park_command_104::Park_targetType>(x); return ret; } Park_command_104::Park_en_ctrlType Parkcommand104::park_en_ctrl( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); Park_command_104::Park_en_ctrlType ret = static_cast<Park_command_104::Park_en_ctrlType>(x); return ret; } int Parkcommand104::checksum_104(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(0, 8); int ret = x; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/ultr_sensor_3_509.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_3_509.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Ultrsensor3509::Ultrsensor3509() {} const int32_t Ultrsensor3509::ID = 0x509; void Ultrsensor3509::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_ultr_sensor_3_509()->set_uiuss5_tof_direct( uiuss5_tof_direct(bytes, length)); chassis->mutable_ultr_sensor_3_509()->set_uiuss4_tof_direct( uiuss4_tof_direct(bytes, length)); chassis->mutable_ultr_sensor_3_509()->set_uiuss3_tof_direct( uiuss3_tof_direct(bytes, length)); chassis->mutable_ultr_sensor_3_509()->set_uiuss2_tof_direct( uiuss2_tof_direct(bytes, length)); } // config detail: {'name': 'uiuss5_tof_direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 55, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor3509::uiuss5_tof_direct(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 7); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } // config detail: {'name': 'uiuss4_tof_direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor3509::uiuss4_tof_direct(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 5); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } // config detail: {'name': 'uiuss3_tof_direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor3509::uiuss3_tof_direct(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 3); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } // config detail: {'name': 'uiuss2_tof_direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor3509::uiuss2_tof_direct(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 1); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/ultr_sensor_3_509_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_3_509.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Ultrsensor3509Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Ultrsensor3509Test, General) { uint8_t data[8] = {0xE2, 0x95, 0x06, 0x58, 0x08, 0xD6, 0x02, 0x44}; int32_t length = 8; Devkit cd; Ultrsensor3509 ultrsensor3; ultrsensor3.Parse(data, length, &cd); EXPECT_EQ(data[0], 0b11100010); EXPECT_EQ(data[1], 0b10010101); EXPECT_EQ(data[2], 0b00000110); EXPECT_EQ(data[3], 0b01011000); EXPECT_EQ(data[4], 0b00001000); EXPECT_EQ(data[5], 0b11010110); EXPECT_EQ(data[6], 0b00000010); EXPECT_EQ(data[7], 0b01000100); EXPECT_EQ(cd.ultr_sensor_3_509().uiuss5_tof_direct(), 10); EXPECT_EQ(cd.ultr_sensor_3_509().uiuss4_tof_direct(), 39); EXPECT_EQ(cd.ultr_sensor_3_509().uiuss3_tof_direct(), 28); EXPECT_EQ(cd.ultr_sensor_3_509().uiuss2_tof_direct(), 1000); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/park_report_504.h
/****************************************************************************** * Copyright 2019 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Parkreport504 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Parkreport504(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'name': 'Parking_actual', 'enum': {0: // 'PARKING_ACTUAL_RELEASE', 1: 'PARKING_ACTUAL_PARKING_TRIGGER'}, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Park_report_504::Parking_actualType parking_actual( const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'Park_FLT', 'enum': {0: 'PARK_FLT_NO_FAULT', 1: // 'PARK_FLT_FAULT'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Park_report_504::Park_fltType park_flt(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/brake_report_501_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/brake_report_501.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Brakereport501Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Brakereport501Test, General) { uint8_t data[8] = {0x01, 0x00, 0x01, 0x03, 0x52, 0x01, 0x00, 0x01}; int32_t length = 8; Devkit cd; Brakereport501 brakereport; brakereport.Parse(data, length, &cd); EXPECT_EQ(data[0], 0b00000001); EXPECT_EQ(data[1], 0b00000000); EXPECT_EQ(data[2], 0b00000001); EXPECT_EQ(data[3], 0b00000011); EXPECT_EQ(data[4], 0b01010010); EXPECT_EQ(data[5], 0b00000001); EXPECT_EQ(data[6], 0b00000000); EXPECT_EQ(data[7], 0b00000001); EXPECT_EQ(cd.brake_report_501().brake_pedal_actual(), 85); EXPECT_EQ(cd.brake_report_501().brake_flt2(), 1); EXPECT_EQ(cd.brake_report_501().brake_flt1(), 0); EXPECT_EQ(cd.brake_report_501().brake_en_state(), 1); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/bms_report_512.h
/****************************************************************************** * Copyright 2019 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Bmsreport512 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Bmsreport512(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'bit': 23, 'description': 'Battery Total Current', // 'is_signed_var': False, 'len': 16, 'name': 'Battery_Current', 'offset': // -3200.0, 'order': 'motorola', 'physical_range': '[-3200|3200]', // 'physical_unit': 'A', 'precision': 0.1, 'type': 'double'} double battery_current(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 7, 'description': 'Battery Total Voltage', // 'is_signed_var': False, 'len': 16, 'name': 'Battery_Voltage', 'offset': // 0.0, 'order': 'motorola', 'physical_range': '[0|300]', 'physical_unit': // 'V', 'precision': 0.01, 'type': 'double'} double battery_voltage(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 39, 'description': 'Battery Soc percentage', // 'is_signed_var': False, 'len': 8, 'name': 'Battery_Soc', 'offset': 0.0, // 'order': 'motorola', 'physical_range': '[0|100]', 'physical_unit': '%', // 'precision': 1.0, 'type': 'int'} int battery_soc_percentage(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 40, 'description': 'Battery Inside temperature', // 'is_signed_var': False, 'len': 1, 'name': 'Battery_Inside_Temperature', // 'offset': -40, 'order': 'motorola', 'physical_range': '[-40|215]', // 'physical_unit': 'C', 'precision': 1.0, 'type': 'int'} int battery_inside_temperature(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'description': 'Battery Below Low temp fault', 'enum': // {0: 'BATTERY_FLT_LOW_TEMP_NO_FAULT', 1: // 'BATTERY_FLT_LOW_TEMP_FAULT'}, 'precision': 1.0, 'len': 1, // 'name': 'Brake_FLT2', 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|1]', 'bit': 48, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Bms_report_512::Battery_flt_lowtempType battery_flt_low_temp( const std::uint8_t* bytes, const int32_t length) const; // config detail: {'description': 'Battery Over High Temp fault', 'enum': // {0: 'BATTERY_FLT_OVER_TEMP_NO_FAULT', 1: // 'BATTERY_FLT_OVER_TEMP_FAULT'}, 'precision': 1.0, 'len': 1, // 'name': 'Brake_FLT2', 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|1]', 'bit': 49, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Bms_report_512::Battery_flt_overtempType battery_flt_over_temp( const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/gear_command_103_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/gear_command_103.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Gearcommand103Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Gearcommand103Test, simple) { Gearcommand103 gear; EXPECT_EQ(gear.GetPeriod(), 20 * 1000); uint8_t data[8] = {0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78}; gear.UpdateData(data); EXPECT_EQ(data[0], 0b01110000); EXPECT_EQ(data[1], 0b01110011); EXPECT_EQ(data[2], 0b01110011); EXPECT_EQ(data[3], 0b01110100); EXPECT_EQ(data[4], 0b01110101); EXPECT_EQ(data[5], 0b01110110); EXPECT_EQ(data[6], 0b01110111); EXPECT_EQ(data[7], 0b01110000); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/gear_report_503.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Gearreport503 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Gearreport503(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'name': 'Gear_FLT', 'enum': {0: 'GEAR_FLT_NO_FAULT', 1: // 'GEAR_FLT_FAULT'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Gear_report_503::Gear_fltType gear_flt(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'Gear_Actual', 'enum': {0: 'GEAR_ACTUAL_INVALID', // 1: 'GEAR_ACTUAL_PARK', 2: 'GEAR_ACTUAL_REVERSE', 3: 'GEAR_ACTUAL_NEUTRAL', // 4: 'GEAR_ACTUAL_DRIVE'}, 'precision': 1.0, 'len': 3, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 2, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Gear_report_503::Gear_actualType gear_actual(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/throttle_command_100.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/throttle_command_100.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; const int32_t Throttlecommand100::ID = 0x100; // public Throttlecommand100::Throttlecommand100() { Reset(); } uint32_t Throttlecommand100::GetPeriod() const { // TODO(All) : modify every protocol's period manually static const uint32_t PERIOD = 20 * 1000; return PERIOD; } void Throttlecommand100::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_throttle_command_100()->set_throttle_en_ctrl( throttle_en_ctrl(bytes, length)); chassis->mutable_throttle_command_100()->set_throttle_acc( throttle_acc(bytes, length)); chassis->mutable_throttle_command_100()->set_throttle_pedal_target( throttle_pedal_target(bytes, length)); chassis->mutable_throttle_command_100()->set_speed_target( speed_target(bytes, length)); chassis->mutable_throttle_command_100()->set_checksum_100( checksum_100(bytes, length)); } void Throttlecommand100::UpdateData(uint8_t* data) { set_p_speed_target(data, speed_target_); set_p_throttle_acc(data, throttle_acc_); set_p_throttle_pedal_target(data, throttle_pedal_target_); set_p_throttle_en_ctrl(data, throttle_en_ctrl_); checksum_100_ = data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6]; set_p_checksum_100(data, checksum_100_); } void Throttlecommand100::Reset() { // TODO(All) : you should check this manually throttle_en_ctrl_ = Throttle_command_100::THROTTLE_EN_CTRL_DISABLE; throttle_acc_ = 0.0; throttle_pedal_target_ = 0.0; speed_target_ = 0.0; checksum_100_ = 0; } Throttlecommand100* Throttlecommand100::set_throttle_en_ctrl( Throttle_command_100::Throttle_en_ctrlType throttle_en_ctrl) { throttle_en_ctrl_ = throttle_en_ctrl; return this; } // config detail: {'name': 'Throttle_EN_CTRL', 'enum': {0: // 'THROTTLE_EN_CTRL_DISABLE', 1: 'THROTTLE_EN_CTRL_ENABLE'}, 'precision': 1.0, // 'len': 1, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', // 'bit': 0, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} void Throttlecommand100::set_p_throttle_en_ctrl( uint8_t* data, Throttle_command_100::Throttle_en_ctrlType throttle_en_ctrl) { int x = throttle_en_ctrl; Byte to_set(data + 0); to_set.set_value(x, 0, 1); } Throttlecommand100* Throttlecommand100::set_throttle_acc(double throttle_acc) { throttle_acc_ = throttle_acc; return this; } // config detail: {'name': 'Throttle_Acc', 'offset': 0.0, 'precision': 0.01, // 'len': 10, 'is_signed_var': False, 'physical_range': '[0|10]', 'bit': 15, // 'type': 'double', 'order': 'motorola', 'physical_unit': 'm/s^2'} void Throttlecommand100::set_p_throttle_acc(uint8_t* data, double throttle_acc) { throttle_acc = ProtocolData::BoundedValue(0.0, 10.0, throttle_acc); int x = throttle_acc / 0.010000; uint8_t t = 0; t = x & 0x3; Byte to_set0(data + 2); to_set0.set_value(t, 6, 2); x >>= 2; t = x & 0xFF; Byte to_set1(data + 1); to_set1.set_value(t, 0, 8); } Throttlecommand100* Throttlecommand100::set_throttle_pedal_target( double throttle_pedal_target) { throttle_pedal_target_ = throttle_pedal_target; return this; } // config detail: {'name': 'Throttle_Pedal_Target', 'offset': 0.0, 'precision': // 0.1, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': // 31, 'type': 'double', 'order': 'motorola', 'physical_unit': '%'} void Throttlecommand100::set_p_throttle_pedal_target( uint8_t* data, double throttle_pedal_target) { throttle_pedal_target = ProtocolData::BoundedValue(0.0, 100.0, throttle_pedal_target); int x = throttle_pedal_target / 0.100000; uint8_t t = 0; t = x & 0xFF; Byte to_set0(data + 4); to_set0.set_value(t, 0, 8); x >>= 8; t = x & 0xFF; Byte to_set1(data + 3); to_set1.set_value(t, 0, 8); } Throttlecommand100* Throttlecommand100::set_speed_target(double speed_target) { speed_target_ = speed_target; return this; } // config detail: {'bit': 47, 'is_signed_var': False, 'len': 10, 'name': // 'Speed_Target', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|10.23]', 'physical_unit': 'm/s', 'precision': 0.01, 'type': 'double'} void Throttlecommand100::set_p_speed_target(uint8_t* data, double speed_target) { speed_target = ProtocolData::BoundedValue(0.0, 10.23, speed_target); int x = speed_target / 0.010000; uint8_t t = 0; t = x & 0x3; Byte to_set0(data + 6); to_set0.set_value(t, 6, 2); x >>= 2; t = x & 0xFF; Byte to_set1(data + 5); to_set1.set_value(t, 0, 8); } Throttlecommand100* Throttlecommand100::set_checksum_100(int checksum_100) { checksum_100_ = checksum_100; return this; } // config detail: {'name': 'CheckSum_100', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'physical_range': '[0|255]', 'bit': 63, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} void Throttlecommand100::set_p_checksum_100(uint8_t* data, int checksum_100) { checksum_100 = ProtocolData::BoundedValue(0, 255, checksum_100); int x = checksum_100; Byte to_set(data + 7); to_set.set_value(x, 0, 8); } Throttle_command_100::Throttle_en_ctrlType Throttlecommand100::throttle_en_ctrl( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); Throttle_command_100::Throttle_en_ctrlType ret = static_cast<Throttle_command_100::Throttle_en_ctrlType>(x); return ret; } double Throttlecommand100::throttle_acc(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 2); int32_t t = t1.get_byte(6, 2); x <<= 8; x |= t; double ret = x * 0.01; return ret; } double Throttlecommand100::throttle_pedal_target(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 4); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x * 0.100000; return ret; } double Throttlecommand100::speed_target(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 5); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 6); int32_t t = t1.get_byte(6, 2); x <<= 8; x |= t; double ret = x * 0.100000; return ret; } int Throttlecommand100::checksum_100(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(0, 8); int ret = x; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/vin_resp1_514.cc
/****************************************************************************** * Copyright 2019 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/vin_resp1_514.h" #include <string> #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Vinresp1514::Vinresp1514() {} const int32_t Vinresp1514::ID = 0x514; void Vinresp1514::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_vin_resp1_514()->set_vin07( vin07(bytes, length)); chassis->mutable_vin_resp1_514()->set_vin06( vin06(bytes, length)); chassis->mutable_vin_resp1_514()->set_vin05( vin05(bytes, length)); chassis->mutable_vin_resp1_514()->set_vin04( vin04(bytes, length)); chassis->mutable_vin_resp1_514()->set_vin03( vin03(bytes, length)); chassis->mutable_vin_resp1_514()->set_vin02( vin02(bytes, length)); chassis->mutable_vin_resp1_514()->set_vin01( vin01(bytes, length)); chassis->mutable_vin_resp1_514()->set_vin00( vin00(bytes, length)); } // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': 'vin07', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp1514::vin07(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 55, 'is_signed_var': False, 'len': 8, 'name': 'vin06', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp1514::vin06(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 47, 'is_signed_var': False, 'len': 8, 'name': 'vin05', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp1514::vin05(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 5); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 39, 'is_signed_var': False, 'len': 8, 'name': 'vin04', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp1514::vin04(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 31, 'is_signed_var': False, 'len': 8, 'name': 'vin03', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp1514::vin03(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 23, 'is_signed_var': False, 'len': 8, 'name': 'vin02', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp1514::vin02(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 15, 'is_signed_var': False, 'len': 8, 'name': 'vin01', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp1514::vin01(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 7, 'is_signed_var': False, 'len': 8, 'name': 'vin00', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp1514::vin00(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/throttle_command_100_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/throttle_command_100.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Throttlecommand100Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Throttlecommand100Test, simple) { Throttlecommand100 throttle; EXPECT_EQ(throttle.GetPeriod(), 20 * 1000); uint8_t data[8] = {0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78}; throttle.UpdateData(data); EXPECT_EQ(data[0], 0b01110000); EXPECT_EQ(data[1], 0b00000000); EXPECT_EQ(data[2], 0b00110011); EXPECT_EQ(data[3], 0b00000000); EXPECT_EQ(data[4], 0b00000000); EXPECT_EQ(data[5], 0b00000000); EXPECT_EQ(data[6], 0b00110111); EXPECT_EQ(data[7], 0b01110100); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/throttle_report_500.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/throttle_report_500.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Throttlereport500::Throttlereport500() {} const int32_t Throttlereport500::ID = 0x500; void Throttlereport500::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_throttle_report_500()->set_throttle_pedal_actual( throttle_pedal_actual(bytes, length)); chassis->mutable_throttle_report_500()->set_throttle_flt2( throttle_flt2(bytes, length)); chassis->mutable_throttle_report_500()->set_throttle_flt1( throttle_flt1(bytes, length)); chassis->mutable_throttle_report_500()->set_throttle_en_state( throttle_en_state(bytes, length)); chassis->mutable_check_response()->set_is_vcu_online( throttle_en_state(bytes, length) == 1); } // config detail: {'name': 'throttle_pedal_actual', 'offset': 0.0, 'precision': // 0.1, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': // 31, 'type': 'double', 'order': 'motorola', 'physical_unit': '%'} double Throttlereport500::throttle_pedal_actual(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 4); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x * 0.100000; return ret; } // config detail: {'description': 'Drive system communication fault', 'enum': // {0: 'THROTTLE_FLT2_NO_FAULT', 1: // 'THROTTLE_FLT2_DRIVE_SYSTEM_COMUNICATION_FAULT'}, 'precision': 1.0, 'len': 8, // 'name': 'throttle_flt2', 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|1]', 'bit': 23, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Throttle_report_500::Throttle_flt2Type Throttlereport500::throttle_flt2( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Throttle_report_500::Throttle_flt2Type ret = static_cast<Throttle_report_500::Throttle_flt2Type>(x); return ret; } // config detail: {'description': 'Drive system hardware fault', 'enum': {0: // 'THROTTLE_FLT1_NO_FAULT', 1: 'THROTTLE_FLT1_DRIVE_SYSTEM_HARDWARE_FAULT'}, // 'precision': 1.0, 'len': 8, 'name': 'throttle_flt1', 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Throttle_report_500::Throttle_flt1Type Throttlereport500::throttle_flt1( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Throttle_report_500::Throttle_flt1Type ret = static_cast<Throttle_report_500::Throttle_flt1Type>(x); return ret; } // config detail: {'name': 'throttle_en_state', 'enum': {0: // 'THROTTLE_EN_STATE_MANUAL', 1: 'THROTTLE_EN_STATE_AUTO', 2: // 'THROTTLE_EN_STATE_TAKEOVER', 3: 'THROTTLE_EN_STATE_STANDBY'}, // 'precision': 1.0, 'len': 2, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|2]', 'bit': 1, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Throttle_report_500::Throttle_en_stateType Throttlereport500::throttle_en_state( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 2); Throttle_report_500::Throttle_en_stateType ret = static_cast<Throttle_report_500::Throttle_en_stateType>(x); return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/vehicle_mode_command_105.cc
/****************************************************************************** * Copyright 2019 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/vehicle_mode_command_105.h" #include "modules/drivers/canbus/common/byte.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; const int32_t Vehiclemodecommand105::ID = 0x105; // public Vehiclemodecommand105::Vehiclemodecommand105() { Reset(); } uint32_t Vehiclemodecommand105::GetPeriod() const { // TODO(All) : modify every protocol's period manually static const uint32_t PERIOD = 20 * 1000; return PERIOD; } void Vehiclemodecommand105::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_vehicle_mode_command_105()->set_turn_light_ctrl( turn_light_ctrl(bytes, length)); chassis->mutable_vehicle_mode_command_105()->set_vin_req( vin_req(bytes, length)); chassis->mutable_vehicle_mode_command_105()->set_drive_mode_ctrl( drive_mode_ctrl(bytes, length)); chassis->mutable_vehicle_mode_command_105()->set_steer_mode_ctrl( steer_mode_ctrl(bytes, length)); chassis->mutable_vehicle_mode_command_105()->set_checksum_105( checksum_105(bytes, length)); } void Vehiclemodecommand105::UpdateData(uint8_t* data) { set_p_turn_light_ctrl(data, turn_light_ctrl_); set_p_vin_req(data, vin_req_); set_p_drive_mode_ctrl(data, drive_mode_ctrl_); set_p_steer_mode_ctrl(data, steer_mode_ctrl_); checksum_105_ = data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6]; set_p_checksum_105(data, checksum_105_); } void Vehiclemodecommand105::Reset() { // TODO(All) : you should check this manually checksum_105_ = 0; turn_light_ctrl_ = Vehicle_mode_command_105::TURN_LIGHT_CTRL_TURNLAMP_OFF; vin_req_ = Vehicle_mode_command_105::VIN_REQ_VIN_REQ_DISABLE; drive_mode_ctrl_ = Vehicle_mode_command_105::DRIVE_MODE_CTRL_THROTTLE_PADDLE_DRIVE; steer_mode_ctrl_ = Vehicle_mode_command_105::STEER_MODE_CTRL_STANDARD_STEER; } Vehiclemodecommand105* Vehiclemodecommand105::set_checksum_105( int checksum_105) { checksum_105_ = checksum_105; return this; } // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': // 'CheckSum_105', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'} void Vehiclemodecommand105::set_p_checksum_105(uint8_t* data, int checksum_105) { checksum_105 = ProtocolData::BoundedValue(0, 255, checksum_105); int x = checksum_105; Byte to_set(data + 7); to_set.set_value(x, 0, 8); } Vehiclemodecommand105* Vehiclemodecommand105::set_turn_light_ctrl( Vehicle_mode_command_105::Turn_light_ctrlType turn_light_ctrl) { turn_light_ctrl_ = turn_light_ctrl; return this; } // config detail: {'bit': 17, 'enum': {0: 'TURN_LIGHT_CTRL_TURNLAMP_OFF', 1: // 'TURN_LIGHT_CTRL_LEFT_TURNLAMP_ON', 2: 'TURN_LIGHT_CTRL_RIGHT_TURNLAMP_ON', // 3: 'TURN_LIGHT_CTRL_HAZARD_WARNING_LAMPSTS_ON'}, 'is_signed_var': False, // 'len': 2, 'name': 'Turn_Light_CTRL', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type': // 'enum'} void Vehiclemodecommand105::set_p_turn_light_ctrl( uint8_t* data, Vehicle_mode_command_105::Turn_light_ctrlType turn_light_ctrl) { int x = turn_light_ctrl; Byte to_set(data + 2); to_set.set_value(x, 0, 2); } Vehiclemodecommand105* Vehiclemodecommand105::set_vin_req( Vehicle_mode_command_105::Vin_reqType vin_req) { vin_req_ = vin_req; return this; } // config detail: {'bit': 24, 'enum': {0: 'VIN_REQ_VIN_REQ_DISABLE', 1: // 'VIN_REQ_VIN_REQ_ENABLE'}, 'is_signed_var': False, 'len': 1, 'name': // 'VIN_Req', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|1]', // 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} void Vehiclemodecommand105::set_p_vin_req( uint8_t* data, Vehicle_mode_command_105::Vin_reqType vin_req) { int x = vin_req; Byte to_set(data + 3); to_set.set_value(x, 0, 1); } Vehiclemodecommand105* Vehiclemodecommand105::set_drive_mode_ctrl( Vehicle_mode_command_105::Drive_mode_ctrlType drive_mode_ctrl) { drive_mode_ctrl_ = drive_mode_ctrl; return this; } // config detail: {'bit': 10, 'enum': {0: // 'DRIVE_MODE_CTRL_THROTTLE_PADDLE_DRIVE', 1: 'DRIVE_MODE_CTRL_SPEED_DRIVE'}, // 'is_signed_var': False, 'len': 3, 'name': 'Drive_Mode_CTRL', 'offset': 0.0, // 'order': 'motorola', 'physical_range': '[0|7]', 'physical_unit': '', // 'precision': 1.0, 'type': 'enum'} void Vehiclemodecommand105::set_p_drive_mode_ctrl( uint8_t* data, Vehicle_mode_command_105::Drive_mode_ctrlType drive_mode_ctrl) { int x = drive_mode_ctrl; Byte to_set(data + 1); to_set.set_value(x, 0, 3); } Vehiclemodecommand105* Vehiclemodecommand105::set_steer_mode_ctrl( Vehicle_mode_command_105::Steer_mode_ctrlType steer_mode_ctrl) { steer_mode_ctrl_ = steer_mode_ctrl; return this; } // config detail: {'bit': 2, 'enum': {0: 'STEER_MODE_CTRL_STANDARD_STEER', 1: // 'STEER_MODE_CTRL_NON_DIRECTION_STEER', 2: // 'STEER_MODE_CTRL_SYNC_DIRECTION_STEER'}, 'is_signed_var': False, 'len': 3, // 'name': 'Steer_Mode_CTRL', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type': // 'enum'} void Vehiclemodecommand105::set_p_steer_mode_ctrl( uint8_t* data, Vehicle_mode_command_105::Steer_mode_ctrlType steer_mode_ctrl) { int x = steer_mode_ctrl; Byte to_set(data + 0); to_set.set_value(x, 0, 3); } Vehicle_mode_command_105::Turn_light_ctrlType Vehiclemodecommand105::turn_light_ctrl(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 2); Vehicle_mode_command_105::Turn_light_ctrlType ret = static_cast<Vehicle_mode_command_105::Turn_light_ctrlType>(x); return ret; } Vehicle_mode_command_105::Vin_reqType Vehiclemodecommand105::vin_req( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 1); Vehicle_mode_command_105::Vin_reqType ret = static_cast<Vehicle_mode_command_105::Vin_reqType>(x); return ret; } Vehicle_mode_command_105::Drive_mode_ctrlType Vehiclemodecommand105::drive_mode_ctrl(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 3); Vehicle_mode_command_105::Drive_mode_ctrlType ret = static_cast<Vehicle_mode_command_105::Drive_mode_ctrlType>(x); return ret; } Vehicle_mode_command_105::Steer_mode_ctrlType Vehiclemodecommand105::steer_mode_ctrl(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 3); Vehicle_mode_command_105::Steer_mode_ctrlType ret = static_cast<Vehicle_mode_command_105::Steer_mode_ctrlType>(x); return ret; } int Vehiclemodecommand105::checksum_105(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(0, 8); int ret = x; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/throttle_command_100.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Throttlecommand100 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Throttlecommand100(); uint32_t GetPeriod() const override; void UpdateData(uint8_t* data) override; void Reset() override; void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; // config detail: {'name': 'Throttle_EN_CTRL', 'enum': {0: // 'THROTTLE_EN_CTRL_DISABLE', 1: 'THROTTLE_EN_CTRL_ENABLE'}, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Throttlecommand100* set_throttle_en_ctrl( Throttle_command_100::Throttle_en_ctrlType throttle_en_ctrl); // config detail: {'name': 'Throttle_Acc', 'offset': 0.0, 'precision': 0.01, // 'len': 10, 'is_signed_var': False, 'physical_range': '[0|10]', 'bit': 15, // 'type': 'double', 'order': 'motorola', 'physical_unit': 'm/s^2'} Throttlecommand100* set_throttle_acc(double throttle_acc); // config detail: {'name': 'Throttle_Pedal_Target', 'offset': 0.0, // 'precision': 0.1, 'len': 16, 'is_signed_var': False, 'physical_range': // '[0|100]', 'bit': 31, 'type': 'double', 'order': 'motorola', // 'physical_unit': '%'} Throttlecommand100* set_throttle_pedal_target(double throttle_pedal_target); // config detail: {'bit': 47, 'is_signed_var': False, 'len': 10, 'name': // 'Speed_Target', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|10.23]', 'physical_unit': 'm/s', 'precision': 0.01, 'type': 'double'} Throttlecommand100* set_speed_target(double speed_target); // config detail: {'name': 'CheckSum_100', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'physical_range': '[0|255]', 'bit': 63, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} Throttlecommand100* set_checksum_100(int checksum_100); private: // config detail: {'name': 'Throttle_EN_CTRL', 'enum': {0: // 'THROTTLE_EN_CTRL_DISABLE', 1: 'THROTTLE_EN_CTRL_ENABLE'}, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} void set_p_throttle_en_ctrl( uint8_t* data, Throttle_command_100::Throttle_en_ctrlType throttle_en_ctrl); // config detail: {'name': 'Throttle_Acc', 'offset': 0.0, 'precision': 0.01, // 'len': 10, 'is_signed_var': False, 'physical_range': '[0|10]', 'bit': 15, // 'type': 'double', 'order': 'motorola', 'physical_unit': 'm/s^2'} void set_p_throttle_acc(uint8_t* data, double throttle_acc); // config detail: {'name': 'Throttle_Pedal_Target', 'offset': 0.0, // 'precision': 0.1, 'len': 16, 'is_signed_var': False, 'physical_range': // '[0|100]', 'bit': 31, 'type': 'double', 'order': 'motorola', // 'physical_unit': '%'} void set_p_throttle_pedal_target(uint8_t* data, double throttle_pedal_target); // config detail: {'bit': 47, 'is_signed_var': False, 'len': 10, 'name': // 'Speed_Target', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|10.23]', 'physical_unit': 'm/s', 'precision': 0.01, 'type': 'double'} void set_p_speed_target(uint8_t* data, double speed_target); // config detail: {'name': 'CheckSum_100', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'physical_range': '[0|255]', 'bit': 63, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} void set_p_checksum_100(uint8_t* data, int checksum_100); Throttle_command_100::Throttle_en_ctrlType throttle_en_ctrl( const std::uint8_t* bytes, const int32_t length) const; double throttle_acc(const std::uint8_t* bytes, const int32_t length) const; double throttle_pedal_target(const std::uint8_t* bytes, const int32_t length) const; double speed_target(const std::uint8_t* bytes, const int32_t length) const; int checksum_100(const std::uint8_t* bytes, const int32_t length) const; private: Throttle_command_100::Throttle_en_ctrlType throttle_en_ctrl_; double throttle_acc_; double throttle_pedal_target_; double speed_target_; int checksum_100_; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/steering_report_502.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Steeringreport502 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Steeringreport502(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'bit': 47, 'is_signed_var': False, 'len': 16, 'name': // 'Steer_ANGLE_Rear_Actual', 'offset': -500.0, 'order': 'motorola', // 'physical_range': '[-500|500]', 'physical_unit': 'deg', 'precision': 1.0, // 'type': 'int'} int steer_angle_rear_actual(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': // 'Steer_ANGLE_SPD_Actual', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|0]', 'physical_unit': 'deg/s', 'precision': 1.0, // 'type': 'int'} int steer_angle_spd_actual(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 23, 'description': 'Steer system communication // fault', 'enum': {0: 'STEER_FLT2_NO_FAULT', 1: // 'STEER_FLT2_STEER_SYSTEM_COMUNICATION_FAULT'}, 'is_signed_var': False, // 'len': 8, 'name': 'Steer_FLT2', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': // 'enum'} Steering_report_502::Steer_flt2Type steer_flt2(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 15, 'description': 'Steer system hardware fault', // 'enum': {0: 'STEER_FLT1_NO_FAULT', 1: // 'STEER_FLT1_STEER_SYSTEM_HARDWARE_FAULT'}, 'is_signed_var': False, 'len': // 8, 'name': 'Steer_FLT1', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': // 'enum'} Steering_report_502::Steer_flt1Type steer_flt1(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 1, 'enum': {0: 'STEER_EN_STATE_MANUAL', 1: // 'STEER_EN_STATE_AUTO', 2: 'STEER_EN_STATE_TAKEOVER', 3: // 'STEER_EN_STATE_STANDBY'}, 'is_signed_var': False, 'len': 2, 'name': // 'Steer_EN_state', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|2]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} Steering_report_502::Steer_en_stateType steer_en_state( const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 31, 'is_signed_var': False, 'len': 16, 'name': // 'Steer_ANGLE_Actual', 'offset': -500.0, 'order': 'motorola', // 'physical_range': '[-500|500]', 'physical_unit': 'deg', 'precision': 1.0, // 'type': 'int'} int steer_angle_actual(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/steering_report_502_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/steering_report_502.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Steeringreport502Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Steeringreport502Test, General) { uint8_t data[8] = {0x04, 0x01, 0x01, 0x14, 0x1E, 0x03, 0x04, 0x05}; int32_t length = 8; Devkit cd; Steeringreport502 steeringreport; steeringreport.Parse(data, length, &cd); EXPECT_EQ(data[0], 0b00000100); EXPECT_EQ(data[1], 0b00000001); EXPECT_EQ(data[2], 0b00000001); EXPECT_EQ(data[3], 0b00010100); EXPECT_EQ(data[4], 0b00011110); EXPECT_EQ(data[5], 0b00000011); EXPECT_EQ(data[6], 0b00000100); EXPECT_EQ(data[7], 0b00000101); EXPECT_EQ(cd.steering_report_502().steer_angle_spd_actual(), 5); EXPECT_EQ(cd.steering_report_502().steer_flt2(), 1); EXPECT_EQ(cd.steering_report_502().steer_flt1(), 1); EXPECT_EQ(cd.steering_report_502().steer_en_state(), 0); EXPECT_EQ(cd.steering_report_502().steer_angle_actual(), 4650); EXPECT_EQ(cd.steering_report_502().steer_angle_rear_actual(), 272); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/ultr_sensor_4_510.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Ultrsensor4510 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Ultrsensor4510(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'name': 'uiUSS5_ToF_Indirect', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 55, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss5_tof_indirect(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'uiUSS4_ToF_Indirect', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss4_tof_indirect(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'uiUSS3_ToF_Indirect', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss3_tof_indirect(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'uiUSS2_ToF_Indirect', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss2_tof_indirect(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/brake_report_501.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/brake_report_501.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Brakereport501::Brakereport501() {} const int32_t Brakereport501::ID = 0x501; void Brakereport501::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_brake_report_501()->set_brake_pedal_actual( brake_pedal_actual(bytes, length)); chassis->mutable_brake_report_501()->set_brake_flt2( brake_flt2(bytes, length)); chassis->mutable_brake_report_501()->set_brake_flt1( brake_flt1(bytes, length)); chassis->mutable_brake_report_501()->set_brake_en_state( brake_en_state(bytes, length)); chassis->mutable_check_response()->set_is_esp_online( brake_en_state(bytes, length) == 1); } // config detail: {'name': 'brake_pedal_actual', 'offset': 0.0, 'precision': // 0.1, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': // 31, 'type': 'double', 'order': 'motorola', 'physical_unit': '%'} double Brakereport501::brake_pedal_actual(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 4); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x * 0.100000; return ret; } // config detail: {'description': 'Brake system communication fault', 'enum': // {0: 'BRAKE_FLT2_NO_FAULT', 1: 'BRAKE_FLT2_BRAKE_SYSTEM_COMUNICATION_FAULT'}, // 'precision': 1.0, 'len': 8, 'name': 'brake_flt2', 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 23, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Brake_report_501::Brake_flt2Type Brakereport501::brake_flt2( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Brake_report_501::Brake_flt2Type ret = static_cast<Brake_report_501::Brake_flt2Type>(x); return ret; } // config detail: {'description': 'Brake system hardware fault', 'enum': {0: // 'BRAKE_FLT1_NO_FAULT', 1: 'BRAKE_FLT1_BRAKE_SYSTEM_HARDWARE_FAULT'}, // 'precision': 1.0, 'len': 8, 'name': 'brake_flt1', 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Brake_report_501::Brake_flt1Type Brakereport501::brake_flt1( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Brake_report_501::Brake_flt1Type ret = static_cast<Brake_report_501::Brake_flt1Type>(x); return ret; } // config detail: {'name': 'brake_en_state', 'enum': {0: // 'BRAKE_EN_STATE_MANUAL', 1: 'BRAKE_EN_STATE_AUTO', 2: // 'BRAKE_EN_STATE_TAKEOVER', 3: 'BRAKE_EN_STATE_STANDBY'}, 'precision': 1.0, // 'len': 2, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]', // 'bit': 1, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Brake_report_501::Brake_en_stateType Brakereport501::brake_en_state( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 2); Brake_report_501::Brake_en_stateType ret = static_cast<Brake_report_501::Brake_en_stateType>(x); return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/ultr_sensor_3_509.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Ultrsensor3509 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Ultrsensor3509(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'name': 'uiUSS5_ToF_Direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 55, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss5_tof_direct(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'uiUSS4_ToF_Direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss4_tof_direct(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'uiUSS3_ToF_Direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss3_tof_direct(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'uiUSS2_ToF_Direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss2_tof_direct(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/ultr_sensor_1_507_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_1_507.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Ultrsensor1507Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Ultrsensor1507Test, General) { uint8_t data[8] = {0xE2, 0x95, 0x06, 0x58, 0x08, 0xD6, 0x02, 0x44}; int32_t length = 8; Devkit cd; Ultrsensor1507 ultrsensor1; ultrsensor1.Parse(data, length, &cd); EXPECT_EQ(data[0], 0b11100010); EXPECT_EQ(data[1], 0b10010101); EXPECT_EQ(data[2], 0b00000110); EXPECT_EQ(data[3], 0b01011000); EXPECT_EQ(data[4], 0b00001000); EXPECT_EQ(data[5], 0b11010110); EXPECT_EQ(data[6], 0b00000010); EXPECT_EQ(data[7], 0b01000100); EXPECT_EQ(cd.ultr_sensor_1_507().uiuss9_tof_direct(), 28); EXPECT_EQ(cd.ultr_sensor_1_507().uiuss8_tof_direct(), 1000); EXPECT_EQ(cd.ultr_sensor_1_507().uiuss11_tof_direct(), 10); EXPECT_EQ(cd.ultr_sensor_1_507().uiuss10_tof_direct(), 39); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/ultr_sensor_1_507.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Ultrsensor1507 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Ultrsensor1507(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'name': 'uiUSS9_ToF_Direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss9_tof_direct(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'uiUSS8_ToF_Direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss8_tof_direct(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'uiUSS11_ToF_Direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 55, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss11_tof_direct(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'uiUSS10_ToF_Direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double uiuss10_tof_direct(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/bms_report_512_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/bms_report_512.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Bmsreport512Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Bmsreport512Test, General) { uint8_t data[8] = {0x01, 0x00, 0x01, 0x03, 0x52, 0x01, 0x00, 0x01}; int32_t length = 8; Devkit cd; Bmsreport512 bmsreport; bmsreport.Parse(data, length, &cd); EXPECT_EQ(data[0], 0b00000001); EXPECT_EQ(data[1], 0b00000000); EXPECT_EQ(data[2], 0b00000001); EXPECT_EQ(data[3], 0b00000011); EXPECT_EQ(data[4], 0b01010010); EXPECT_EQ(data[5], 0b00000001); EXPECT_EQ(data[6], 0b00000000); EXPECT_EQ(data[7], 0b00000001); EXPECT_EQ(cd.bms_report_512().battery_current(), -3174.1); EXPECT_EQ(cd.bms_report_512().battery_voltage(), 2.56); EXPECT_EQ(cd.bms_report_512().battery_soc_percentage(), 82); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/wheelspeed_report_506.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Wheelspeedreport506 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Wheelspeedreport506(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'name': 'RR', 'offset': 0.0, 'precision': 0.001, 'len': 16, // 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': 55, 'type': // 'double', 'order': 'motorola', 'physical_unit': 'm/s'} double rr(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'RL', 'offset': 0.0, 'precision': 0.001, 'len': 16, // 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': 39, 'type': // 'double', 'order': 'motorola', 'physical_unit': 'm/s'} double rl(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'FR', 'offset': 0.0, 'precision': 0.001, 'len': 16, // 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': 23, 'type': // 'double', 'order': 'motorola', 'physical_unit': 'm/s'} double fr(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'FL', 'offset': 0.0, 'precision': 0.001, 'len': 16, // 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': 7, 'type': // 'double', 'order': 'motorola', 'physical_unit': 'm/s'} double fl(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/wheelspeed_report_506.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/wheelspeed_report_506.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Wheelspeedreport506::Wheelspeedreport506() {} const int32_t Wheelspeedreport506::ID = 0x506; void Wheelspeedreport506::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_wheelspeed_report_506()->set_rr( rr(bytes, length)); chassis->mutable_wheelspeed_report_506()->set_rl( rl(bytes, length)); chassis->mutable_wheelspeed_report_506()->set_fr( fr(bytes, length)); chassis->mutable_wheelspeed_report_506()->set_fl( fl(bytes, length)); } // config detail: {'name': 'rr', 'offset': 0.0, 'precision': 0.001, 'len': 16, // 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': 55, 'type': // 'double', 'order': 'motorola', 'physical_unit': 'm/s'} double Wheelspeedreport506::rr(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 7); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x * 0.001000; return ret; } // config detail: {'name': 'rl', 'offset': 0.0, 'precision': 0.001, 'len': 16, // 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': 39, 'type': // 'double', 'order': 'motorola', 'physical_unit': 'm/s'} double Wheelspeedreport506::rl(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 5); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x * 0.001000; return ret; } // config detail: {'name': 'fr', 'offset': 0.0, 'precision': 0.001, 'len': 16, // 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': 23, 'type': // 'double', 'order': 'motorola', 'physical_unit': 'm/s'} double Wheelspeedreport506::fr(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 3); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x * 0.001000; return ret; } // config detail: {'name': 'fl', 'offset': 0.0, 'precision': 0.001, 'len': 16, // 'is_signed_var': False, 'physical_range': '[0|65.535]', 'bit': 7, 'type': // 'double', 'order': 'motorola', 'physical_unit': 'm/s'} double Wheelspeedreport506::fl(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 1); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x * 0.001000; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/gear_report_503.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/gear_report_503.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Gearreport503::Gearreport503() {} const int32_t Gearreport503::ID = 0x503; void Gearreport503::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_gear_report_503()->set_gear_flt( gear_flt(bytes, length)); chassis->mutable_gear_report_503()->set_gear_actual( gear_actual(bytes, length)); } // config detail: {'name': 'gear_flt', 'enum': {0: 'GEAR_FLT_NO_FAULT', 1: // 'GEAR_FLT_FAULT'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Gear_report_503::Gear_fltType Gearreport503::gear_flt(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Gear_report_503::Gear_fltType ret = static_cast<Gear_report_503::Gear_fltType>(x); return ret; } // config detail: {'name': 'gear_actual', 'enum': {0: 'GEAR_ACTUAL_INVALID', 1: // 'GEAR_ACTUAL_PARK', 2: 'GEAR_ACTUAL_REVERSE', 3: 'GEAR_ACTUAL_NEUTRAL', 4: // 'GEAR_ACTUAL_DRIVE'}, 'precision': 1.0, 'len': 3, 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 2, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Gear_report_503::Gear_actualType Gearreport503::gear_actual( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 3); Gear_report_503::Gear_actualType ret = static_cast<Gear_report_503::Gear_actualType>(x); return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/steering_command_102.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/steering_command_102.h" #include "modules/drivers/canbus/common/byte.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; const int32_t Steeringcommand102::ID = 0x102; // public Steeringcommand102::Steeringcommand102() { Reset(); } uint32_t Steeringcommand102::GetPeriod() const { // TODO(All) : modify every protocol's period manually static const uint32_t PERIOD = 20 * 1000; return PERIOD; } void Steeringcommand102::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_steering_command_102()->set_steer_en_ctrl( steer_en_ctrl(bytes, length)); chassis->mutable_steering_command_102() ->set_steer_angle_target( steer_angle_target(bytes, length)); chassis->mutable_steering_command_102()->set_steer_angle_spd_target( steer_angle_spd_target(bytes, length)); chassis->mutable_steering_command_102()->set_checksum_102( checksum_102(bytes, length)); } void Steeringcommand102::UpdateData(uint8_t* data) { set_p_steer_en_ctrl(data, steer_en_ctrl_); set_p_steer_angle_target(data, steer_angle_target_); set_p_steer_angle_spd_target(data, steer_angle_spd_target_); checksum_102_ = data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6]; set_p_checksum_102(data, checksum_102_); } void Steeringcommand102::Reset() { // TODO(All) : you should check this manually steer_en_ctrl_ = Steering_command_102::STEER_EN_CTRL_DISABLE; steer_angle_target_ = 0; steer_angle_spd_target_ = 0; checksum_102_ = 0; } Steeringcommand102* Steeringcommand102::set_steer_en_ctrl( Steering_command_102::Steer_en_ctrlType steer_en_ctrl) { steer_en_ctrl_ = steer_en_ctrl; return this; } // config detail: {'bit': 0, 'enum': {0: 'STEER_EN_CTRL_DISABLE', 1: // 'STEER_EN_CTRL_ENABLE'}, 'is_signed_var': False, 'len': 1, 'name': // 'Steer_EN_CTRL', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} void Steeringcommand102::set_p_steer_en_ctrl( uint8_t* data, Steering_command_102::Steer_en_ctrlType steer_en_ctrl) { int x = steer_en_ctrl; Byte to_set(data + 0); to_set.set_value(x, 0, 1); } Steeringcommand102* Steeringcommand102::set_steer_angle_target( int steer_angle_target) { steer_angle_target_ = steer_angle_target; return this; } // config detail: {'bit': 31, 'is_signed_var': False, 'len': 16, 'name': // 'Steer_ANGLE_Target', 'offset': -500.0, 'order': 'motorola', // 'physical_range': '[-500|500]''right -, left +', 'physical_unit': 'deg', // 'precision': 1.0, 'type': 'int'} void Steeringcommand102::set_p_steer_angle_target(uint8_t* data, int steer_angle_target) { steer_angle_target = ProtocolData::BoundedValue(-500, 500, steer_angle_target); int x = (steer_angle_target - -500.000000); uint8_t t = 0; t = x & 0xFF; Byte to_set0(data + 4); to_set0.set_value(t, 0, 8); x >>= 8; t = x & 0xFF; Byte to_set1(data + 3); to_set1.set_value(t, 0, 8); } Steeringcommand102* Steeringcommand102::set_steer_angle_spd_target( int steer_angle_spd_target) { steer_angle_spd_target_ = steer_angle_spd_target; return this; } // config detail: {'bit': 15, 'is_signed_var': False, 'len': 8, 'name': // 'Steer_ANGLE_SPD_Target', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|250]', 'physical_unit': 'deg/s', 'precision': 1.0, // 'type': 'int'} void Steeringcommand102::set_p_steer_angle_spd_target( uint8_t* data, int steer_angle_spd_target) { steer_angle_spd_target = ProtocolData::BoundedValue(0, 250, steer_angle_spd_target); int x = steer_angle_spd_target; Byte to_set(data + 1); to_set.set_value(x, 0, 8); } Steeringcommand102* Steeringcommand102::set_checksum_102(int checksum_102) { checksum_102_ = checksum_102; return this; } // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': // 'CheckSum_102', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'} void Steeringcommand102::set_p_checksum_102(uint8_t* data, int checksum_102) { checksum_102 = ProtocolData::BoundedValue(0, 255, checksum_102); int x = checksum_102; Byte to_set(data + 7); to_set.set_value(x, 0, 8); } Steering_command_102::Steer_en_ctrlType Steeringcommand102::steer_en_ctrl( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); Steering_command_102::Steer_en_ctrlType ret = static_cast<Steering_command_102::Steer_en_ctrlType>(x); return ret; } double Steeringcommand102::steer_angle_target(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 4); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x * 1 + -500.000000; return ret; } double Steeringcommand102::steer_angle_spd_target(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); double ret = x * 1; return ret; } int Steeringcommand102::checksum_102(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(0, 8); int ret = x; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/vin_resp2_515.h
/****************************************************************************** * Copyright 2019 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include <string> #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Vinresp2515 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Vinresp2515(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': // 'VIN15', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string vin15(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 55, 'is_signed_var': False, 'len': 8, 'name': // 'VIN14', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string vin14(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 47, 'is_signed_var': False, 'len': 8, 'name': // 'VIN13', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string vin13(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 39, 'is_signed_var': False, 'len': 8, 'name': // 'VIN12', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string vin12(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 31, 'is_signed_var': False, 'len': 8, 'name': // 'VIN11', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string vin11(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 23, 'is_signed_var': False, 'len': 8, 'name': // 'VIN10', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string vin10(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 15, 'is_signed_var': False, 'len': 8, 'name': // 'VIN09', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string vin09(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'bit': 7, 'is_signed_var': False, 'len': 8, 'name': // 'VIN08', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string vin08(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/vin_resp3_516.h
/****************************************************************************** * Copyright 2019 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include <string> #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Vinresp3516 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Vinresp3516(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'bit': 7, 'is_signed_var': False, 'len': 8, 'name': // 'VIN16', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string vin16(const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/ultr_sensor_1_507.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_1_507.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Ultrsensor1507::Ultrsensor1507() {} const int32_t Ultrsensor1507::ID = 0x507; void Ultrsensor1507::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_ultr_sensor_1_507()->set_uiuss9_tof_direct( uiuss9_tof_direct(bytes, length)); chassis->mutable_ultr_sensor_1_507()->set_uiuss8_tof_direct( uiuss8_tof_direct(bytes, length)); chassis->mutable_ultr_sensor_1_507()->set_uiuss11_tof_direct( uiuss11_tof_direct(bytes, length)); chassis->mutable_ultr_sensor_1_507()->set_uiuss10_tof_direct( uiuss10_tof_direct(bytes, length)); } // config detail: {'name': 'uiuss9_tof_direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor1507::uiuss9_tof_direct(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 3); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } // config detail: {'name': 'uiuss8_tof_direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor1507::uiuss8_tof_direct(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 1); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } // config detail: {'name': 'uiuss11_tof_direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 55, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor1507::uiuss11_tof_direct(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 7); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } // config detail: {'name': 'uiuss10_tof_direct', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor1507::uiuss10_tof_direct(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 5); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/park_report_504_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/park_report_504.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Parkreport504Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Parkreport504Test, General) { uint8_t data[8] = {0x04, 0x01, 0x01, 0x10, 0x90, 0x01, 0x00, 0x01}; int32_t length = 8; Devkit cd; Parkreport504 parkreport; parkreport.Parse(data, length, &cd); EXPECT_EQ(data[0], 0b00000100); EXPECT_EQ(data[1], 0b00000001); EXPECT_EQ(data[2], 0b00000001); EXPECT_EQ(data[3], 0b00010000); EXPECT_EQ(data[4], 0b10010000); EXPECT_EQ(data[5], 0b00000001); EXPECT_EQ(data[6], 0b00000000); EXPECT_EQ(data[7], 0b00000001); EXPECT_EQ(cd.park_report_504().parking_actual(), 0); EXPECT_EQ(cd.park_report_504().park_flt(), 1); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/ultr_sensor_5_511_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_5_511.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Ultrsensor5511Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Ultrsensor5511Test, General) { uint8_t data[8] = {0xE2, 0x95, 0x06, 0x58, 0x08, 0xD6, 0x02, 0x44}; int32_t length = 8; Devkit cd; Ultrsensor5511 ultrsensor5; ultrsensor5.Parse(data, length, &cd); EXPECT_EQ(data[0], 0b11100010); EXPECT_EQ(data[1], 0b10010101); EXPECT_EQ(data[2], 0b00000110); EXPECT_EQ(data[3], 0b01011000); EXPECT_EQ(data[4], 0b00001000); EXPECT_EQ(data[5], 0b11010110); EXPECT_EQ(data[6], 0b00000010); EXPECT_EQ(data[7], 0b01000100); EXPECT_EQ(cd.ultr_sensor_5_511().uiuss7_tof_direct(), 10); EXPECT_EQ(cd.ultr_sensor_5_511().uiuss6_tof_direct(), 39); EXPECT_EQ(cd.ultr_sensor_5_511().uiuss1_tof_direct(), 28); EXPECT_EQ(cd.ultr_sensor_5_511().uiuss0_tof_direct(), 1000); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/ultr_sensor_4_510.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_4_510.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Ultrsensor4510::Ultrsensor4510() {} const int32_t Ultrsensor4510::ID = 0x510; void Ultrsensor4510::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_ultr_sensor_4_510()->set_uiuss5_tof_indirect( uiuss5_tof_indirect(bytes, length)); chassis->mutable_ultr_sensor_4_510()->set_uiuss4_tof_indirect( uiuss4_tof_indirect(bytes, length)); chassis->mutable_ultr_sensor_4_510()->set_uiuss3_tof_indirect( uiuss3_tof_indirect(bytes, length)); chassis->mutable_ultr_sensor_4_510()->set_uiuss2_tof_indirect( uiuss2_tof_indirect(bytes, length)); } // config detail: {'name': 'uiuss5_tof_indirect', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 55, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor4510::uiuss5_tof_indirect(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 7); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } // config detail: {'name': 'uiuss4_tof_indirect', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor4510::uiuss4_tof_indirect(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 5); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } // config detail: {'name': 'uiuss3_tof_indirect', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 23, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor4510::uiuss3_tof_indirect(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 3); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } // config detail: {'name': 'uiuss2_tof_indirect', 'offset': 0.0, 'precision': // 0.01724, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|65535]', // 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'cm'} double Ultrsensor4510::uiuss2_tof_indirect(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 1); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x / 58; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/brake_report_501.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Brakereport501 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Brakereport501(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'name': 'Brake_Pedal_Actual', 'offset': 0.0, 'precision': // 0.1, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': // 31, 'type': 'double', 'order': 'motorola', 'physical_unit': '%'} double brake_pedal_actual(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'description': 'Brake system communication fault', 'enum': // {0: 'BRAKE_FLT2_NO_FAULT', 1: // 'BRAKE_FLT2_BRAKE_SYSTEM_COMUNICATION_FAULT'}, 'precision': 1.0, 'len': 8, // 'name': 'Brake_FLT2', 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|1]', 'bit': 23, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Brake_report_501::Brake_flt2Type brake_flt2(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'description': 'Brake system hardware fault', 'enum': {0: // 'BRAKE_FLT1_NO_FAULT', 1: 'BRAKE_FLT1_BRAKE_SYSTEM_HARDWARE_FAULT'}, // 'precision': 1.0, 'len': 8, 'name': 'Brake_FLT1', 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Brake_report_501::Brake_flt1Type brake_flt1(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'Brake_EN_state', 'enum': {0: // 'BRAKE_EN_STATE_MANUAL', 1: 'BRAKE_EN_STATE_AUTO', 2: // 'BRAKE_EN_STATE_TAKEOVER', 3: 'BRAKE_EN_STATE_STANDBY'}, 'precision': 1.0, // 'len': 2, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]', // 'bit': 1, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''} Brake_report_501::Brake_en_stateType brake_en_state( const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/steering_report_502.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/steering_report_502.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Steeringreport502::Steeringreport502() {} const int32_t Steeringreport502::ID = 0x502; void Steeringreport502::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_steering_report_502()->set_steer_angle_rear_actual( steer_angle_rear_actual(bytes, length)); chassis->mutable_steering_report_502()->set_steer_angle_spd_actual( steer_angle_spd_actual(bytes, length)); chassis->mutable_steering_report_502()->set_steer_flt2( steer_flt2(bytes, length)); chassis->mutable_steering_report_502()->set_steer_flt1( steer_flt1(bytes, length)); chassis->mutable_steering_report_502()->set_steer_en_state( steer_en_state(bytes, length)); chassis->mutable_steering_report_502()->set_steer_angle_actual( steer_angle_actual(bytes, length)); chassis->mutable_check_response()->set_is_eps_online( steer_en_state(bytes, length) == 1); } // config detail: {'bit': 47, 'is_signed_var': False, 'len': 16, 'name': // 'steer_angle_rear_actual', 'offset': -500.0, 'order': 'motorola', // 'physical_range': '[-500|500]', 'physical_unit': 'deg', 'precision': 1.0, // 'type': 'int'} int Steeringreport502::steer_angle_rear_actual(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 5); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 6); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; int ret = x + -500.000000; return ret; } // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': // 'steer_angle_spd_actual', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|0]', 'physical_unit': 'deg/s', 'precision': 1.0, // 'type': 'int'} int Steeringreport502::steer_angle_spd_actual(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(0, 8); int ret = x; return ret; } // config detail: {'bit': 23, 'description': 'Steer system communication fault', // 'enum': {0: 'STEER_FLT2_NO_FAULT', 1: // 'STEER_FLT2_STEER_SYSTEM_COMUNICATION_FAULT'}, 'is_signed_var': False, 'len': // 8, 'name': 'steer_flt2', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': // 'enum'} Steering_report_502::Steer_flt2Type Steeringreport502::steer_flt2( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); Steering_report_502::Steer_flt2Type ret = static_cast<Steering_report_502::Steer_flt2Type>(x); return ret; } // config detail: {'bit': 15, 'description': 'Steer system hardware fault', // 'enum': {0: 'STEER_FLT1_NO_FAULT', 1: // 'STEER_FLT1_STEER_SYSTEM_HARDWARE_FAULT'}, 'is_signed_var': False, 'len': 8, // 'name': 'steer_flt1', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} Steering_report_502::Steer_flt1Type Steeringreport502::steer_flt1( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Steering_report_502::Steer_flt1Type ret = static_cast<Steering_report_502::Steer_flt1Type>(x); return ret; } // config detail: {'bit': 1, 'enum': {0: 'STEER_EN_STATE_MANUAL', 1: // 'STEER_EN_STATE_AUTO', 2: 'STEER_EN_STATE_TAKEOVER', 3: // 'STEER_EN_STATE_STANDBY'}, 'is_signed_var': False, 'len': 2, 'name': // 'steer_en_state', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|2]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} Steering_report_502::Steer_en_stateType Steeringreport502::steer_en_state( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 2); Steering_report_502::Steer_en_stateType ret = static_cast<Steering_report_502::Steer_en_stateType>(x); return ret; } // config detail: {'bit': 31, 'is_signed_var': False, 'len': 16, 'name': // 'steer_angle_actual', 'offset': -500.0, 'order': 'motorola', // 'physical_range': '[-500|500]', 'physical_unit': 'deg', 'precision': 1.0, // 'type': 'int'} int Steeringreport502::steer_angle_actual(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 4); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; int ret = x + -500.000000; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/park_report_504.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/park_report_504.h" #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Parkreport504::Parkreport504() {} const int32_t Parkreport504::ID = 0x504; void Parkreport504::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_park_report_504()->set_parking_actual( parking_actual(bytes, length)); chassis->mutable_park_report_504()->set_park_flt( park_flt(bytes, length)); } // config detail: {'name': 'parking_actual', 'enum': {0: // 'PARKING_ACTUAL_RELEASE', 1: 'PARKING_ACTUAL_PARKING_TRIGGER'}, // 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Park_report_504::Parking_actualType Parkreport504::parking_actual( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); Park_report_504::Parking_actualType ret = static_cast<Park_report_504::Parking_actualType>(x); return ret; } // config detail: {'name': 'park_flt', 'enum': {0: 'PARK_FLT_NO_FAULT', 1: // 'PARK_FLT_FAULT'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False, // 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', 'order': // 'motorola', 'physical_unit': ''} Park_report_504::Park_fltType Parkreport504::park_flt(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Park_report_504::Park_fltType ret = static_cast<Park_report_504::Park_fltType>(x); return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/park_command_104_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/park_command_104.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Parkcommand104Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Parkcommand104Test, simple) { Parkcommand104 park; EXPECT_EQ(park.GetPeriod(), 20 * 1000); uint8_t data[8] = {0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78}; park.UpdateData(data); EXPECT_EQ(data[0], 0b01110000); EXPECT_EQ(data[1], 0b01110010); EXPECT_EQ(data[2], 0b01110011); EXPECT_EQ(data[3], 0b01110100); EXPECT_EQ(data[4], 0b01110101); EXPECT_EQ(data[5], 0b01110110); EXPECT_EQ(data[6], 0b01110111); EXPECT_EQ(data[7], 0b01110001); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/throttle_report_500.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Throttlereport500 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Throttlereport500(); void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; private: // config detail: {'name': 'Throttle_Pedal_Actual', 'offset': 0.0, // 'precision': 0.1, 'len': 16, 'is_signed_var': False, 'physical_range': // '[0|100]', 'bit': 31, 'type': 'double', 'order': 'motorola', // 'physical_unit': '%'} double throttle_pedal_actual(const std::uint8_t* bytes, const int32_t length) const; // config detail: {'description': 'Drive system communication fault', 'enum': // {0: 'THROTTLE_FLT2_NO_FAULT', 1: // 'THROTTLE_FLT2_DRIVE_SYSTEM_COMUNICATION_FAULT'}, 'precision': 1.0, 'len': // 8, 'name': 'Throttle_FLT2', 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|1]', 'bit': 23, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Throttle_report_500::Throttle_flt2Type throttle_flt2( const std::uint8_t* bytes, const int32_t length) const; // config detail: {'description': 'Drive system hardware fault', 'enum': {0: // 'THROTTLE_FLT1_NO_FAULT', 1: 'THROTTLE_FLT1_DRIVE_SYSTEM_HARDWARE_FAULT'}, // 'precision': 1.0, 'len': 8, 'name': 'Throttle_FLT1', 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 15, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Throttle_report_500::Throttle_flt1Type throttle_flt1( const std::uint8_t* bytes, const int32_t length) const; // config detail: {'name': 'Throttle_EN_state', 'enum': {0: // 'THROTTLE_EN_STATE_MANUAL', 1: 'THROTTLE_EN_STATE_AUTO', 2: // 'THROTTLE_EN_STATE_TAKEOVER', 3: 'THROTTLE_EN_STATE_STANDBY'}, // 'precision': 1.0, 'len': 2, 'is_signed_var': False, 'offset': 0.0, // 'physical_range': '[0|2]', 'bit': 1, 'type': 'enum', 'order': 'motorola', // 'physical_unit': ''} Throttle_report_500::Throttle_en_stateType throttle_en_state( const std::uint8_t* bytes, const int32_t length) const; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/ultr_sensor_2_508_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/ultr_sensor_2_508.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Ultrsensor2508Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Ultrsensor2508Test, General) { uint8_t data[8] = {0xE2, 0x95, 0x06, 0x58, 0x08, 0xD6, 0x02, 0x44}; int32_t length = 8; Devkit cd; Ultrsensor2508 ultrsensor2; ultrsensor2.Parse(data, length, &cd); EXPECT_EQ(data[0], 0b11100010); EXPECT_EQ(data[1], 0b10010101); EXPECT_EQ(data[2], 0b00000110); EXPECT_EQ(data[3], 0b01011000); EXPECT_EQ(data[4], 0b00001000); EXPECT_EQ(data[5], 0b11010110); EXPECT_EQ(data[6], 0b00000010); EXPECT_EQ(data[7], 0b01000100); EXPECT_EQ(cd.ultr_sensor_2_508().uiuss9_tof_indirect(), 28); EXPECT_EQ(cd.ultr_sensor_2_508().uiuss8_tof_indirect(), 1000); EXPECT_EQ(cd.ultr_sensor_2_508().uiuss11_tof_indirect(), 10); EXPECT_EQ(cd.ultr_sensor_2_508().uiuss10_tof_indirect(), 39); } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/steering_command_102.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Steeringcommand102 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Steeringcommand102(); uint32_t GetPeriod() const override; void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; void UpdateData(uint8_t* data) override; void Reset() override; // config detail: {'bit': 0, 'enum': {0: 'STEER_EN_CTRL_DISABLE', 1: // 'STEER_EN_CTRL_ENABLE'}, 'is_signed_var': False, 'len': 1, 'name': // 'Steer_EN_CTRL', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} Steeringcommand102* set_steer_en_ctrl( Steering_command_102::Steer_en_ctrlType steer_en_ctrl); // config detail: {'bit': 31, 'is_signed_var': False, 'len': 16, 'name': // 'Steer_ANGLE_Target', 'offset': -500.0, 'order': 'motorola', // 'physical_range': '[-500|500]''right -, left +', 'physical_unit': 'deg', // 'precision': 1.0, 'type': 'int'} Steeringcommand102* set_steer_angle_target(int steer_angle_target); // config detail: {'bit': 15, 'is_signed_var': False, 'len': 8, 'name': // 'Steer_ANGLE_SPD_Target', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|250]', 'physical_unit': 'deg/s', 'precision': 1.0, // 'type': 'int'} Steeringcommand102* set_steer_angle_spd_target(int steer_angle_spd_target); // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': // 'CheckSum_102', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'} Steeringcommand102* set_checksum_102(int checksum_102); private: // config detail: {'bit': 0, 'enum': {0: 'STEER_EN_CTRL_DISABLE', 1: // 'STEER_EN_CTRL_ENABLE'}, 'is_signed_var': False, 'len': 1, 'name': // 'Steer_EN_CTRL', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} void set_p_steer_en_ctrl( uint8_t* data, Steering_command_102::Steer_en_ctrlType steer_en_ctrl); // config detail: {'bit': 31, 'is_signed_var': False, 'len': 16, 'name': // 'Steer_ANGLE_Target', 'offset': -500.0, 'order': 'motorola', // 'physical_range': '[-500|500]', 'physical_unit': 'deg', 'precision': 1.0, // 'type': 'int'} void set_p_steer_angle_target(uint8_t* data, int steer_angle_target); // config detail: {'bit': 15, 'is_signed_var': False, 'len': 8, 'name': // 'Steer_ANGLE_SPD_Target', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|250]', 'physical_unit': 'deg/s', 'precision': 1.0, // 'type': 'int'} void set_p_steer_angle_spd_target(uint8_t* data, int steer_angle_spd_target); // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': // 'CheckSum_102', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'} void set_p_checksum_102(uint8_t* data, int checksum_102); // report the command Steering_command_102::Steer_en_ctrlType steer_en_ctrl( const std::uint8_t* bytes, const int32_t length) const; double steer_angle_target(const std::uint8_t* bytes, const int32_t length) const; double steer_angle_spd_target(const std::uint8_t* bytes, const int32_t length) const; int checksum_102(const std::uint8_t* bytes, const int32_t length) const; private: Steering_command_102::Steer_en_ctrlType steer_en_ctrl_; int steer_angle_target_; int steer_angle_spd_target_; int checksum_102_; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/vin_resp2_515.cc
/****************************************************************************** * Copyright 2019 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/vin_resp2_515.h" #include <string> #include "glog/logging.h" #include "modules/drivers/canbus/common/byte.h" #include "modules/drivers/canbus/common/canbus_consts.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; Vinresp2515::Vinresp2515() {} const int32_t Vinresp2515::ID = 0x515; void Vinresp2515::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_vin_resp2_515()->set_vin15( vin15(bytes, length)); chassis->mutable_vin_resp2_515()->set_vin14( vin14(bytes, length)); chassis->mutable_vin_resp2_515()->set_vin13( vin13(bytes, length)); chassis->mutable_vin_resp2_515()->set_vin12( vin12(bytes, length)); chassis->mutable_vin_resp2_515()->set_vin11( vin11(bytes, length)); chassis->mutable_vin_resp2_515()->set_vin10( vin10(bytes, length)); chassis->mutable_vin_resp2_515()->set_vin09( vin09(bytes, length)); chassis->mutable_vin_resp2_515()->set_vin08( vin08(bytes, length)); } // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': 'vin15', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp2515::vin15(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 55, 'is_signed_var': False, 'len': 8, 'name': 'vin14', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp2515::vin14(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 6); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 47, 'is_signed_var': False, 'len': 8, 'name': 'vin13', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp2515::vin13(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 5); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 39, 'is_signed_var': False, 'len': 8, 'name': 'vin12', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp2515::vin12(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 4); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 31, 'is_signed_var': False, 'len': 8, 'name': 'vin11', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp2515::vin11(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 23, 'is_signed_var': False, 'len': 8, 'name': 'vin10', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp2515::vin10(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 2); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 15, 'is_signed_var': False, 'len': 8, 'name': 'vin09', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp2515::vin09(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } // config detail: {'bit': 7, 'is_signed_var': False, 'len': 8, 'name': 'vin08', // 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|255]', // 'physical_unit': '', 'precision': 1.0, 'type': 'int'} std::string Vinresp2515::vin08(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 8); std::string ret = ""; ret += x; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/vehicle_mode_command_105.h
/****************************************************************************** * Copyright 2019 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Vehiclemodecommand105 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Vehiclemodecommand105(); uint32_t GetPeriod() const override; void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; void UpdateData(uint8_t* data) override; void Reset() override; // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': // 'CheckSum_105', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'} Vehiclemodecommand105* set_checksum_105(int checksum_105); // config detail: {'bit': 17, 'enum': {0: 'TURN_LIGHT_CTRL_TURNLAMP_OFF', 1: // 'TURN_LIGHT_CTRL_LEFT_TURNLAMP_ON', 2: 'TURN_LIGHT_CTRL_RIGHT_TURNLAMP_ON', // 3: 'TURN_LIGHT_CTRL_HAZARD_WARNING_LAMPSTS_ON'}, 'is_signed_var': False, // 'len': 2, 'name': 'Turn_Light_CTRL', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type': // 'enum'} Vehiclemodecommand105* set_turn_light_ctrl( Vehicle_mode_command_105::Turn_light_ctrlType turn_light_ctrl); // config detail: {'bit': 24, 'enum': {0: 'VIN_REQ_VIN_REQ_DISABLE', 1: // 'VIN_REQ_VIN_REQ_ENABLE'}, 'is_signed_var': False, 'len': 1, 'name': // 'VIN_Req', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|1]', // 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} Vehiclemodecommand105* set_vin_req( Vehicle_mode_command_105::Vin_reqType vin_req); // config detail: {'bit': 10, 'enum': {0: // 'DRIVE_MODE_CTRL_THROTTLE_PADDLE_DRIVE', 1: 'DRIVE_MODE_CTRL_SPEED_DRIVE'}, // 'is_signed_var': False, 'len': 3, 'name': 'Drive_Mode_CTRL', 'offset': 0.0, // 'order': 'motorola', 'physical_range': '[0|7]', 'physical_unit': '', // 'precision': 1.0, 'type': 'enum'} Vehiclemodecommand105* set_drive_mode_ctrl( Vehicle_mode_command_105::Drive_mode_ctrlType drive_mode_ctrl); // config detail: {'bit': 2, 'enum': {0: 'STEER_MODE_CTRL_STANDARD_STEER', 1: // 'STEER_MODE_CTRL_NON_DIRECTION_STEER', 2: // 'STEER_MODE_CTRL_SYNC_DIRECTION_STEER'}, 'is_signed_var': False, 'len': 3, // 'name': 'Steer_Mode_CTRL', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type': // 'enum'} Vehiclemodecommand105* set_steer_mode_ctrl( Vehicle_mode_command_105::Steer_mode_ctrlType steer_mode_ctrl); private: // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': // 'CheckSum_105', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'} void set_p_checksum_105(uint8_t* data, int checksum_105); // config detail: {'bit': 17, 'enum': {0: 'TURN_LIGHT_CTRL_TURNLAMP_OFF', 1: // 'TURN_LIGHT_CTRL_LEFT_TURNLAMP_ON', 2: 'TURN_LIGHT_CTRL_RIGHT_TURNLAMP_ON', // 3: 'TURN_LIGHT_CTRL_HAZARD_WARNING_LAMPSTS_ON'}, 'is_signed_var': False, // 'len': 2, 'name': 'Turn_Light_CTRL', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type': // 'enum'} void set_p_turn_light_ctrl( uint8_t* data, Vehicle_mode_command_105::Turn_light_ctrlType turn_light_ctrl); // config detail: {'bit': 24, 'enum': {0: 'VIN_REQ_VIN_REQ_DISABLE', 1: // 'VIN_REQ_VIN_REQ_ENABLE'}, 'is_signed_var': False, 'len': 1, 'name': // 'VIN_Req', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|1]', // 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} void set_p_vin_req(uint8_t* data, Vehicle_mode_command_105::Vin_reqType vin_req); // config detail: {'bit': 10, 'enum': {0: // 'DRIVE_MODE_CTRL_THROTTLE_PADDLE_DRIVE', 1: 'DRIVE_MODE_CTRL_SPEED_DRIVE'}, // 'is_signed_var': False, 'len': 3, 'name': 'Drive_Mode_CTRL', 'offset': 0.0, // 'order': 'motorola', 'physical_range': '[0|7]', 'physical_unit': '', // 'precision': 1.0, 'type': 'enum'} void set_p_drive_mode_ctrl( uint8_t* data, Vehicle_mode_command_105::Drive_mode_ctrlType drive_mode_ctrl); // config detail: {'bit': 2, 'enum': {0: 'STEER_MODE_CTRL_STANDARD_STEER', 1: // 'STEER_MODE_CTRL_NON_DIRECTION_STEER', 2: // 'STEER_MODE_CTRL_SYNC_DIRECTION_STEER'}, 'is_signed_var': False, 'len': 3, // 'name': 'Steer_Mode_CTRL', 'offset': 0.0, 'order': 'motorola', // 'physical_range': '[0|7]', 'physical_unit': '', 'precision': 1.0, 'type': // 'enum'} void set_p_steer_mode_ctrl( uint8_t* data, Vehicle_mode_command_105::Steer_mode_ctrlType steer_mode_ctrl); // report the command Vehicle_mode_command_105::Turn_light_ctrlType turn_light_ctrl( const std::uint8_t* bytes, const int32_t length) const; Vehicle_mode_command_105::Vin_reqType vin_req(const std::uint8_t* bytes, const int32_t length) const; Vehicle_mode_command_105::Drive_mode_ctrlType drive_mode_ctrl( const std::uint8_t* bytes, const int32_t length) const; Vehicle_mode_command_105::Steer_mode_ctrlType steer_mode_ctrl( const std::uint8_t* bytes, const int32_t length) const; int checksum_105(const std::uint8_t* bytes, const int32_t length) const; private: int checksum_105_; Vehicle_mode_command_105::Turn_light_ctrlType turn_light_ctrl_; Vehicle_mode_command_105::Vin_reqType vin_req_; Vehicle_mode_command_105::Drive_mode_ctrlType drive_mode_ctrl_; Vehicle_mode_command_105::Steer_mode_ctrlType steer_mode_ctrl_; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/gear_command_103.h
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #pragma once #include "modules/canbus_vehicle/devkit/proto/devkit.pb.h" #include "modules/drivers/canbus/can_comm/protocol_data.h" namespace apollo { namespace canbus { namespace devkit { class Gearcommand103 : public ::apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Devkit> { public: static const int32_t ID; Gearcommand103(); uint32_t GetPeriod() const override; void Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const override; void UpdateData(uint8_t* data) override; void Reset() override; // config detail: {'name': 'Gear_Target', 'enum': {0: 'GEAR_TARGET_INVALID', // 1: 'GEAR_TARGET_PARK', 2: 'GEAR_TARGET_REVERSE', 3: 'GEAR_TARGET_NEUTRAL', // 4: 'GEAR_TARGET_DRIVE'}, 'precision': 1.0, 'len': 3, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 10, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Gearcommand103* set_gear_target( Gear_command_103::Gear_targetType gear_target); // config detail: {'name': 'Gear_EN_CTRL', 'enum': {0: 'GEAR_EN_CTRL_DISABLE', // 1: 'GEAR_EN_CTRL_ENABLE'}, 'precision': 1.0, 'len': 1, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} Gearcommand103* set_gear_en_ctrl( Gear_command_103::Gear_en_ctrlType gear_en_ctrl); // config detail: {'name': 'CheckSum_103', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'physical_range': '[0|255]', 'bit': 63, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} Gearcommand103* set_checksum_103(int checksum_103); private: // config detail: {'name': 'Gear_Target', 'enum': {0: 'GEAR_TARGET_INVALID', // 1: 'GEAR_TARGET_PARK', 2: 'GEAR_TARGET_REVERSE', 3: 'GEAR_TARGET_NEUTRAL', // 4: 'GEAR_TARGET_DRIVE'}, 'precision': 1.0, 'len': 3, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 10, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} void set_p_gear_target(uint8_t* data, Gear_command_103::Gear_targetType gear_target); // config detail: {'name': 'Gear_EN_CTRL', 'enum': {0: 'GEAR_EN_CTRL_DISABLE', // 1: 'GEAR_EN_CTRL_ENABLE'}, 'precision': 1.0, 'len': 1, 'is_signed_var': // False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', // 'order': 'motorola', 'physical_unit': ''} void set_p_gear_en_ctrl(uint8_t* data, Gear_command_103::Gear_en_ctrlType gear_en_ctrl); // config detail: {'name': 'CheckSum_103', 'offset': 0.0, 'precision': 1.0, // 'len': 8, 'is_signed_var': False, 'physical_range': '[0|255]', 'bit': 63, // 'type': 'int', 'order': 'motorola', 'physical_unit': ''} void set_p_checksum_103(uint8_t* data, int checksum_103); // report the command Gear_command_103::Gear_targetType gear_target(const std::uint8_t* bytes, const int32_t length) const; Gear_command_103::Gear_en_ctrlType gear_en_ctrl(const std::uint8_t* bytes, const int32_t length) const; int checksum_103(const std::uint8_t* bytes, const int32_t length) const; private: Gear_command_103::Gear_targetType gear_target_; Gear_command_103::Gear_en_ctrlType gear_en_ctrl_; int checksum_103_; }; } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/brake_command_101.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/brake_command_101.h" #include "modules/drivers/canbus/common/byte.h" namespace apollo { namespace canbus { namespace devkit { using ::apollo::drivers::canbus::Byte; const int32_t Brakecommand101::ID = 0x101; // public Brakecommand101::Brakecommand101() { Reset(); } uint32_t Brakecommand101::GetPeriod() const { // TODO(All) : modify every protocol's period manually static const uint32_t PERIOD = 20 * 1000; return PERIOD; } void Brakecommand101::Parse(const std::uint8_t* bytes, int32_t length, Devkit* chassis) const { chassis->mutable_brake_command_101()->set_brake_en_ctrl( brake_en_ctrl(bytes, length)); chassis->mutable_brake_command_101()->set_aeb_en_ctrl( aeb_en_ctrl(bytes, length)); chassis->mutable_brake_command_101()->set_brake_dec( brake_dec(bytes, length)); chassis->mutable_brake_command_101()->set_brake_pedal_target( brake_pedal_target(bytes, length)); chassis->mutable_brake_command_101()->set_checksum_101( checksum_101(bytes, length)); } void Brakecommand101::UpdateData(uint8_t* data) { set_p_aeb_en_ctrl(data, aeb_en_ctrl_); set_p_brake_dec(data, brake_dec_); set_p_brake_pedal_target(data, brake_pedal_target_); set_p_brake_en_ctrl(data, brake_en_ctrl_); checksum_101_ = data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6]; set_p_checksum_101(data, checksum_101_); } void Brakecommand101::Reset() { // TODO(All) : you should check this manually aeb_en_ctrl_ = Brake_command_101::AEB_EN_CTRL_DISABLE_AEB; brake_dec_ = 0.0; checksum_101_ = 0; brake_pedal_target_ = 0.0; brake_en_ctrl_ = Brake_command_101::BRAKE_EN_CTRL_DISABLE; } Brakecommand101* Brakecommand101::set_brake_en_ctrl( Brake_command_101::Brake_en_ctrlType brake_en_ctrl) { brake_en_ctrl_ = brake_en_ctrl; return this; } // config detail: {'bit': 0, 'enum': {0: 'BRAKE_EN_CTRL_DISABLE', 1: // 'BRAKE_EN_CTRL_ENABLE'}, 'is_signed_var': False, 'len': 1, 'name': // 'Brake_EN_CTRL', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|1]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} void Brakecommand101::set_p_brake_en_ctrl( uint8_t* data, Brake_command_101::Brake_en_ctrlType brake_en_ctrl) { int x = brake_en_ctrl; Byte to_set(data + 0); to_set.set_value(x, 0, 1); } Brakecommand101* Brakecommand101::set_aeb_en_ctrl( Brake_command_101::Aeb_en_ctrlType aeb_en_ctrl) { aeb_en_ctrl_ = aeb_en_ctrl; return this; } // config detail: {'bit': 1, 'enum': {0: 'AEB_EN_CTRL_DISABLE_AEB', 1: // 'AEB_EN_CTRL_ENABLE_AEB'}, 'is_signed_var': False, 'len': 1, 'name': // 'AEB_EN_CTRL', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|0]', // 'physical_unit': '', 'precision': 1.0, 'type': 'enum'} void Brakecommand101::set_p_aeb_en_ctrl( uint8_t* data, Brake_command_101::Aeb_en_ctrlType aeb_en_ctrl) { int x = aeb_en_ctrl; Byte to_set(data + 0); to_set.set_value(x, 1, 1); } Brakecommand101* Brakecommand101::set_brake_dec(double brake_dec) { brake_dec_ = brake_dec; return this; } // config detail: {'bit': 15, 'is_signed_var': False, 'len': 10, 'name': // 'Brake_Dec', 'offset': 0.0, 'order': 'motorola', 'physical_range': '[0|10]', // 'physical_unit': 'm/s^2', 'precision': 0.01, 'type': 'double'} void Brakecommand101::set_p_brake_dec(uint8_t* data, double brake_dec) { brake_dec = ProtocolData::BoundedValue(0.0, 10.0, brake_dec); int x = brake_dec / 0.010000; uint8_t t = 0; t = x & 0x3; Byte to_set0(data + 2); to_set0.set_value(t, 6, 2); x >>= 2; t = x & 0xFF; Byte to_set1(data + 1); to_set1.set_value(t, 0, 8); } Brakecommand101* Brakecommand101::set_brake_pedal_target( double brake_pedal_target) { brake_pedal_target_ = brake_pedal_target; return this; } // config detail: {'bit': 31, 'is_signed_var': False, 'len': 16, 'name': // 'Brake_Pedal_Target', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|100]', 'physical_unit': '%', 'precision': 0.1, 'type': 'double'} void Brakecommand101::set_p_brake_pedal_target(uint8_t* data, double brake_pedal_target) { brake_pedal_target = ProtocolData::BoundedValue(0.0, 100.0, brake_pedal_target); int x = brake_pedal_target / 0.100000; uint8_t t = 0; t = x & 0xFF; Byte to_set0(data + 4); to_set0.set_value(t, 0, 8); x >>= 8; t = x & 0xFF; Byte to_set1(data + 3); to_set1.set_value(t, 0, 8); } Brakecommand101* Brakecommand101::set_checksum_101(int checksum_101) { checksum_101_ = checksum_101; return this; } // config detail: {'bit': 63, 'is_signed_var': False, 'len': 8, 'name': // 'CheckSum_101', 'offset': 0.0, 'order': 'motorola', 'physical_range': // '[0|255]', 'physical_unit': '', 'precision': 1.0, 'type': 'int'} void Brakecommand101::set_p_checksum_101(uint8_t* data, int checksum_101) { checksum_101 = ProtocolData::BoundedValue(0, 255, checksum_101); int x = checksum_101; Byte to_set(data + 7); to_set.set_value(x, 0, 8); } Brake_command_101::Brake_en_ctrlType Brakecommand101::brake_en_ctrl( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(0, 1); Brake_command_101::Brake_en_ctrlType ret = static_cast<Brake_command_101::Brake_en_ctrlType>(x); return ret; } Brake_command_101::Aeb_en_ctrlType Brakecommand101::aeb_en_ctrl( const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 0); int32_t x = t0.get_byte(1, 1); Brake_command_101::Aeb_en_ctrlType ret = static_cast<Brake_command_101::Aeb_en_ctrlType>(x); return ret; } double Brakecommand101::brake_dec(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 1); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 2); int32_t t = t1.get_byte(6, 2); x <<= 8; x |= t; double ret = x * 0.01; return ret; } double Brakecommand101::brake_pedal_target(const std::uint8_t* bytes, const int32_t length) const { Byte t0(bytes + 3); int32_t x = t0.get_byte(0, 8); Byte t1(bytes + 4); int32_t t = t1.get_byte(0, 8); x <<= 8; x |= t; double ret = x * 0.1; return ret; } int Brakecommand101::checksum_101(const std::uint8_t* bytes, int32_t length) const { Byte t0(bytes + 7); int32_t x = t0.get_byte(0, 8); int ret = x; return ret; } } // namespace devkit } // namespace canbus } // namespace apollo
0
apollo_public_repos/apollo/modules/canbus_vehicle/devkit
apollo_public_repos/apollo/modules/canbus_vehicle/devkit/protocol/throttle_report_500_test.cc
/****************************************************************************** * Copyright 2020 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/canbus_vehicle/devkit/protocol/throttle_report_500.h" #include "gtest/gtest.h" namespace apollo { namespace canbus { namespace devkit { class Throttlereport500Test : public ::testing::Test { public: virtual void SetUp() {} }; TEST_F(Throttlereport500Test, General) { uint8_t data[8] = {0x07, 0x01, 0x01, 0x02, 0x8A, 0x03, 0x04, 0x05}; int32_t length = 8; Devkit cd; Throttlereport500 throttlereport; throttlereport.Parse(data, length, &cd); EXPECT_EQ(data[0], 0b00000111); EXPECT_EQ(data[1], 0b00000001); EXPECT_EQ(data[2], 0b00000001); EXPECT_EQ(data[3], 0b00000010); EXPECT_EQ(data[4], 0b10001010); EXPECT_EQ(data[5], 0b00000011); EXPECT_EQ(data[6], 0b00000100); EXPECT_EQ(data[7], 0b00000101); EXPECT_EQ(cd.throttle_report_500().throttle_pedal_actual(), 65); EXPECT_EQ(cd.throttle_report_500().throttle_flt2(), 1); EXPECT_EQ(cd.throttle_report_500().throttle_flt1(), 1); EXPECT_EQ(cd.throttle_report_500().throttle_en_state(), 3); } } // namespace devkit } // namespace canbus } // namespace apollo
0