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/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/steering_control_a2_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/zhongyun/protocol/steering_control_a2.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Steeringcontrola2Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Steeringcontrola2Test, reset) {
uint8_t data[8] = {0x67, 0x62, 0x63, 0x64, 0x51, 0x52, 0x53, 0x54};
Steeringcontrola2 steer;
EXPECT_EQ(steer.GetPeriod(), 20 * 1000);
steer.UpdateData(data);
EXPECT_EQ(data[0], 0b00000000);
EXPECT_EQ(data[1], 0b11111110);
EXPECT_EQ(data[2], 0b01111111);
EXPECT_EQ(data[3], 0b01100100);
EXPECT_EQ(data[4], 0b01010001);
EXPECT_EQ(data[5], 0b01010010);
EXPECT_EQ(data[6], 0b01010011);
EXPECT_EQ(data[7], 0b01010100);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/parking_control_a5.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/zhongyun/protocol/parking_control_a5.h"
#include "modules/drivers/canbus/common/byte.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
using ::apollo::drivers::canbus::Byte;
const int32_t Parkingcontrola5::ID = 0xA5;
// public
Parkingcontrola5::Parkingcontrola5() { Reset(); }
uint32_t Parkingcontrola5::GetPeriod() const {
// TODO(ChaoM) : modify every protocol's period manually
static const uint32_t PERIOD = 20 * 1000;
return PERIOD;
}
void Parkingcontrola5::UpdateData(uint8_t* data) {
set_p_parking_target(data, parking_target_);
set_p_parking_enable_control(data, parking_enable_control_);
}
void Parkingcontrola5::Reset() {
// TODO(ChaoM) : you should check this manually
parking_target_ = Parking_control_a5::PARKING_TARGET_RELEASE;
parking_enable_control_ =
Parking_control_a5::PARKING_ENABLE_CONTROL_PARKING_MANUALCONTROL;
}
Parkingcontrola5* Parkingcontrola5::set_parking_target(
Parking_control_a5::Parking_targetType parking_target) {
parking_target_ = parking_target;
return this;
}
// config detail: {'name': 'Parking_target', 'enum': {0:
// 'PARKING_TARGET_RELEASE', 1: 'PARKING_TARGET_PARKING_TRIGGER'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 8, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
void Parkingcontrola5::set_p_parking_target(
uint8_t* data, Parking_control_a5::Parking_targetType parking_target) {
int x = parking_target;
Byte to_set(data + 1);
to_set.set_value(static_cast<uint8_t>(x), 0, 8);
}
Parkingcontrola5* Parkingcontrola5::set_parking_enable_control(
Parking_control_a5::Parking_enable_controlType parking_enable_control) {
parking_enable_control_ = parking_enable_control;
return this;
}
// config detail: {'name': 'Parking_Enable_control', 'enum': {0:
// 'PARKING_ENABLE_CONTROL_PARKING_MANUALCONTROL', 1:
// 'PARKING_ENABLE_CONTROL_PARKING_AUTOCONTROL'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
void Parkingcontrola5::set_p_parking_enable_control(
uint8_t* data,
Parking_control_a5::Parking_enable_controlType parking_enable_control) {
int x = parking_enable_control;
Byte to_set(data + 0);
to_set.set_value(static_cast<uint8_t>(x), 0, 8);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/error_state_e1.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/zhongyun/proto/zhongyun.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Errorstatee1 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Zhongyun> {
public:
static const int32_t ID;
Errorstatee1();
void Parse(const std::uint8_t* bytes, int32_t length,
Zhongyun* chassis) const override;
private:
// config detail: {'name': 'brake_error_code', 'enum': {0:
// 'BRAKE_ERROR_CODE_NO_ERROR', 1: 'BRAKE_ERROR_CODE_ERROR'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 32, 'type': 'enum', 'order': 'intel',
// 'physical_unit': 'bit'}
Error_state_e1::Brake_error_codeType brake_error_code(
const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'Driven_error_code', 'enum': {0:
// 'DRIVEN_ERROR_CODE_NO_ERROR', 1: 'DRIVEN_ERROR_CODE_ERROR'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 24, 'type': 'enum', 'order': 'intel',
// 'physical_unit': 'bit'}
Error_state_e1::Driven_error_codeType driven_error_code(
const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'steering_error_code', 'enum': {0:
// 'STEERING_ERROR_CODE_NO_ERROR', 1: 'STEERING_ERROR_CODE_ERROR'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 16, 'type': 'enum', 'order': 'intel',
// 'physical_unit': 'bit'}
Error_state_e1::Steering_error_codeType steering_error_code(
const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'Parking_error_code', 'enum': {0:
// 'PARKING_ERROR_CODE_NO_ERROR', 1: 'PARKING_ERROR_CODE_ERROR'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 8, 'type': 'enum', 'order': 'intel',
// 'physical_unit': 'bit'}
Error_state_e1::Parking_error_codeType parking_error_code(
const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'Gear_error_msg', 'enum': {0:
// 'GEAR_ERROR_MSG_NO_ERROR', 1: 'GEAR_ERROR_MSG_ERROR'}, 'precision': 1.0,
// 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]',
// 'bit': 0, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Error_state_e1::Gear_error_msgType gear_error_msg(const std::uint8_t* bytes,
const int32_t length) const;
};
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/steering_control_a2.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/zhongyun/proto/zhongyun.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Steeringcontrola2 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Zhongyun> {
public:
static const int32_t ID;
Steeringcontrola2();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'name': 'Steering_target', 'offset': -1638.35, 'precision':
// 0.05, 'len': 16, 'is_signed_var': False, 'physical_range': '[-32|32]',
// 'bit': 8, 'type': 'double', 'order': 'intel', 'physical_unit': 'deg'}
Steeringcontrola2* set_steering_target(double steering_target);
// config detail: {'name': 'Steering_Enable_control', 'enum': {0:
// 'STEERING_ENABLE_CONTROL_STEERING_MANUALCONTROL', 1:
// 'STEERING_ENABLE_CONTROL_STEERING_AUTOCONTROL'}, 'precision': 1.0, 'len':
// 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit':
// 0, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Steeringcontrola2* set_steering_enable_control(
Steering_control_a2::Steering_enable_controlType steering_enable_control);
private:
// config detail: {'name': 'Steering_target', 'offset': -1638.35, 'precision':
// 0.05, 'len': 16, 'is_signed_var': False, 'physical_range': '[-32|32]',
// 'bit': 8, 'type': 'double', 'order': 'intel', 'physical_unit': 'deg'}
void set_p_steering_target(uint8_t* data, double steering_target);
// config detail: {'name': 'Steering_Enable_control', 'enum': {0:
// 'STEERING_ENABLE_CONTROL_STEERING_MANUALCONTROL', 1:
// 'STEERING_ENABLE_CONTROL_STEERING_AUTOCONTROL'}, 'precision': 1.0, 'len':
// 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit':
// 0, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
void set_p_steering_enable_control(
uint8_t* data,
Steering_control_a2::Steering_enable_controlType steering_enable_control);
private:
double steering_target_;
Steering_control_a2::Steering_enable_controlType steering_enable_control_;
};
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/enable_state_feedback_c3.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/zhongyun/proto/zhongyun.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Enablestatefeedbackc3 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Zhongyun> {
public:
static const int32_t ID;
Enablestatefeedbackc3();
void Parse(const std::uint8_t* bytes, int32_t length,
Zhongyun* chassis) const override;
private:
// config detail: {'name': 'Parking_enable_state', 'enum': {0:
// 'PARKING_ENABLE_STATE_PARKING_MANUALCONTROL', 1:
// 'PARKING_ENABLE_STATE_PARKING_AUTOCONTROL', 2:
// 'PARKING_ENABLE_STATE_PARKING_TAKEOVER'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit':
// 32, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Enable_state_feedback_c3::Parking_enable_stateType parking_enable_state(
const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'Steering_enable_state', 'enum': {0:
// 'STEERING_ENABLE_STATE_STEERING_MANUALCONTROL', 1:
// 'STEERING_ENABLE_STATE_STEERING_AUTOCONTROL', 2:
// 'STEERING_ENABLE_STATE_STEERING_MANUAL_TAKEOVER'}, 'precision': 1.0, 'len':
// 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit':
// 8, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Enable_state_feedback_c3::Steering_enable_stateType steering_enable_state(
const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'Gear_enable_actual', 'enum': {0:
// 'GEAR_ENABLE_ACTUAL_GEAR_MANUALCONTROL', 1:
// 'GEAR_ENABLE_ACTUAL_GEAR_AUTOCONTROL', 2:
// 'GEAR_ENABLE_ACTUAL_GEAR_MANUAL_TAKEOVER'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Enable_state_feedback_c3::Gear_enable_actualType gear_enable_actual(
const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'Driven_enable_state', 'enum': {0:
// 'DRIVEN_ENABLE_STATE_DRIVE_MANUAL', 1: 'DRIVEN_ENABLE_STATE_DRIVE_AUTO', 2:
// 'DRIVEN_ENABLE_STATE_DRIVE_TAKEOVER'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit':
// 16, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Enable_state_feedback_c3::Driven_enable_stateType driven_enable_state(
const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'Brake_enable_state', 'enum': {0:
// 'BRAKE_ENABLE_STATE_BRAKE_MANUAL', 1: 'BRAKE_ENABLE_STATE_BRAKE_AUTO', 2:
// 'BRAKE_ENABLE_STATE_BRAKE_TAKEOVER'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit':
// 24, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Enable_state_feedback_c3::Brake_enable_stateType brake_enable_state(
const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/enable_state_feedback_c3.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/zhongyun/protocol/enable_state_feedback_c3.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 zhongyun {
using ::apollo::drivers::canbus::Byte;
Enablestatefeedbackc3::Enablestatefeedbackc3() {}
const int32_t Enablestatefeedbackc3::ID = 0xC3;
void Enablestatefeedbackc3::Parse(const std::uint8_t* bytes, int32_t length,
Zhongyun* chassis) const {
chassis->mutable_enable_state_feedback_c3()->set_parking_enable_state(
parking_enable_state(bytes, length));
chassis->mutable_enable_state_feedback_c3()->set_steering_enable_state(
steering_enable_state(bytes, length));
chassis->mutable_enable_state_feedback_c3()->set_gear_enable_actual(
gear_enable_actual(bytes, length));
chassis->mutable_enable_state_feedback_c3()->set_driven_enable_state(
driven_enable_state(bytes, length));
chassis->mutable_enable_state_feedback_c3()->set_brake_enable_state(
brake_enable_state(bytes, length));
// Added for response check
chassis->mutable_check_response()->set_is_esp_online(
brake_enable_state(bytes, length) == 1);
chassis->mutable_check_response()->set_is_vcu_online(
((driven_enable_state(bytes, length) == 1) &&
(gear_enable_actual(bytes, length) == 1)) == 1);
chassis->mutable_check_response()->set_is_eps_online(
steering_enable_state(bytes, length) == 1);
}
// config detail: {'name': 'parking_enable_state', 'enum': {0:
// 'PARKING_ENABLE_STATE_PARKING_MANUALCONTROL', 1:
// 'PARKING_ENABLE_STATE_PARKING_AUTOCONTROL', 2:
// 'PARKING_ENABLE_STATE_PARKING_TAKEOVER'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 32,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Enable_state_feedback_c3::Parking_enable_stateType
Enablestatefeedbackc3::parking_enable_state(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(0, 8);
Enable_state_feedback_c3::Parking_enable_stateType ret =
static_cast<Enable_state_feedback_c3::Parking_enable_stateType>(x);
return ret;
}
// config detail: {'name': 'steering_enable_state', 'enum': {0:
// 'STEERING_ENABLE_STATE_STEERING_MANUALCONTROL', 1:
// 'STEERING_ENABLE_STATE_STEERING_AUTOCONTROL', 2:
// 'STEERING_ENABLE_STATE_STEERING_MANUAL_TAKEOVER'}, 'precision': 1.0,
// 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]',
// 'bit': 8, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Enable_state_feedback_c3::Steering_enable_stateType
Enablestatefeedbackc3::steering_enable_state(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
Enable_state_feedback_c3::Steering_enable_stateType ret =
static_cast<Enable_state_feedback_c3::Steering_enable_stateType>(x);
return ret;
}
// config detail: {'name': 'gear_enable_actual', 'enum': {0:
// 'GEAR_ENABLE_ACTUAL_GEAR_MANUALCONTROL', 1:
// 'GEAR_ENABLE_ACTUAL_GEAR_AUTOCONTROL', 2:
// 'GEAR_ENABLE_ACTUAL_GEAR_MANUAL_TAKEOVER'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Enable_state_feedback_c3::Gear_enable_actualType
Enablestatefeedbackc3::gear_enable_actual(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(0, 8);
Enable_state_feedback_c3::Gear_enable_actualType ret =
static_cast<Enable_state_feedback_c3::Gear_enable_actualType>(x);
return ret;
}
// config detail: {'name': 'driven_enable_state', 'enum': {0:
// 'DRIVEN_ENABLE_STATE_DRIVE_MANUAL', 1: 'DRIVEN_ENABLE_STATE_DRIVE_AUTO',
// 2: 'DRIVEN_ENABLE_STATE_DRIVE_TAKEOVER'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit': 16,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Enable_state_feedback_c3::Driven_enable_stateType
Enablestatefeedbackc3::driven_enable_state(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 8);
Enable_state_feedback_c3::Driven_enable_stateType ret =
static_cast<Enable_state_feedback_c3::Driven_enable_stateType>(x);
return ret;
}
// config detail: {'name': 'brake_enable_state', 'enum': {0:
// 'BRAKE_ENABLE_STATE_BRAKE_MANUAL', 1: 'BRAKE_ENABLE_STATE_BRAKE_AUTO', 2:
// 'BRAKE_ENABLE_STATE_BRAKE_TAKEOVER'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit': 24,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Enable_state_feedback_c3::Brake_enable_stateType
Enablestatefeedbackc3::brake_enable_state(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 3);
int32_t x = t0.get_byte(0, 8);
Enable_state_feedback_c3::Brake_enable_stateType ret =
static_cast<Enable_state_feedback_c3::Brake_enable_stateType>(x);
return ret;
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/vehicle_state_feedback_2_c4.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/zhongyun/protocol/vehicle_state_feedback_2_c4.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 zhongyun {
using ::apollo::drivers::canbus::Byte;
Vehiclestatefeedback2c4::Vehiclestatefeedback2c4() {}
const int32_t Vehiclestatefeedback2c4::ID = 0xC4;
void Vehiclestatefeedback2c4::Parse(const std::uint8_t* bytes, int32_t length,
Zhongyun* chassis) const {
chassis->mutable_vehicle_state_feedback_2_c4()->set_motor_speed(
motor_speed(bytes, length));
chassis->mutable_vehicle_state_feedback_2_c4()->set_driven_torque_feedback(
driven_torque_feedback(bytes, length));
}
// config detail: {'name': 'motor_speed', 'offset': 0.0, 'precision': 1.0,
// 'len': 16, 'is_signed_var': True, 'physical_range': '[-3000|3000]', 'bit': 0,
// 'type': 'int', 'order': 'intel', 'physical_unit': 'rpm'}
int Vehiclestatefeedback2c4::motor_speed(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
Byte t1(bytes + 0);
int32_t t = t1.get_byte(0, 8);
x <<= 8;
x |= t;
x <<= 16;
x >>= 16;
int ret = x;
return ret;
}
// config detail: {'name': 'driven_torque_feedback', 'offset': 0.0, 'precision':
// 0.05, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit':
// 16, 'type': 'double', 'order': 'intel', 'physical_unit': '%'}
double Vehiclestatefeedback2c4::driven_torque_feedback(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 3);
int32_t x = t0.get_byte(0, 8);
Byte t1(bytes + 2);
int32_t t = t1.get_byte(0, 8);
x <<= 8;
x |= t;
double ret = x * 0.050000;
return ret;
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/torque_control_a3.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/zhongyun/proto/zhongyun.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Torquecontrola3 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Zhongyun> {
public:
static const int32_t ID;
Torquecontrola3();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'name': 'driven_torque', 'offset': 0.0, 'precision': 0.05,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': 8,
// 'type': 'double', 'order': 'intel', 'physical_unit': '%'}
Torquecontrola3* set_driven_torque(double driven_torque);
// config detail: {'name': 'Driven_Enable_control', 'enum': {0:
// 'DRIVEN_ENABLE_CONTROL_DRIVE_MANUAL', 1:
// 'DRIVEN_ENABLE_CONTROL_DRIVE_AUTO'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Torquecontrola3* set_driven_enable_control(
Torque_control_a3::Driven_enable_controlType driven_enable_control);
private:
// config detail: {'name': 'driven_torque', 'offset': 0.0, 'precision': 0.05,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': 8,
// 'type': 'double', 'order': 'intel', 'physical_unit': '%'}
void set_p_driven_torque(uint8_t* data, double driven_torque);
// config detail: {'name': 'Driven_Enable_control', 'enum': {0:
// 'DRIVEN_ENABLE_CONTROL_DRIVE_MANUAL', 1:
// 'DRIVEN_ENABLE_CONTROL_DRIVE_AUTO'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
void set_p_driven_enable_control(
uint8_t* data,
Torque_control_a3::Driven_enable_controlType driven_enable_control);
private:
double driven_torque_;
Torque_control_a3::Driven_enable_controlType driven_enable_control_;
};
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/torque_control_a3_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/zhongyun/protocol/torque_control_a3.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Torquecontrola3Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Torquecontrola3Test, reset) {
uint8_t data[8] = {0x67, 0x62, 0x63, 0x64, 0x51, 0x52, 0x53, 0x54};
Torquecontrola3 torque;
EXPECT_EQ(torque.GetPeriod(), 20 * 1000);
torque.UpdateData(data);
EXPECT_EQ(data[0], 0b00000000);
EXPECT_EQ(data[1], 0b00000000);
EXPECT_EQ(data[2], 0b00000000);
EXPECT_EQ(data[3], 0b01100100);
EXPECT_EQ(data[4], 0b01010001);
EXPECT_EQ(data[5], 0b01010010);
EXPECT_EQ(data[6], 0b01010011);
EXPECT_EQ(data[7], 0b01010100);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/vehicle_state_feedback_c1.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/zhongyun/proto/zhongyun.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Vehiclestatefeedbackc1 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Zhongyun> {
public:
static const int32_t ID;
Vehiclestatefeedbackc1();
void Parse(const std::uint8_t* bytes, int32_t length,
Zhongyun* chassis) const override;
private:
// config detail: {'name': 'Parking_actual', 'enum': {0:
// 'PARKING_ACTUAL_RELEASE', 1: 'PARKING_ACTUAL_PARKING_TRIGGER'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 56, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
Vehicle_state_feedback_c1::Parking_actualType parking_actual(
const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'brake_torque_feedback', 'offset': 0.0,
// 'precision': 0.05, 'len': 16, 'is_signed_var': False, 'physical_range':
// '[0|100]', 'bit': 40, 'type': 'double', 'order': 'intel', 'physical_unit':
// '%'}
double brake_torque_feedback(const std::uint8_t* bytes,
const int32_t length) const;
// config detail: {'name': 'Gear_state_actual', 'enum': {1:
// 'GEAR_STATE_ACTUAL_P', 2: 'GEAR_STATE_ACTUAL_N', 3: 'GEAR_STATE_ACTUAL_D',
// 4: 'GEAR_STATE_ACTUAL_R', 5: 'GEAR_STATE_ACTUAL_INVALID'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|5]', 'bit': 32, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
Vehicle_state_feedback_c1::Gear_state_actualType gear_state_actual(
const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'Steering_actual', 'offset': -1638.35, 'precision':
// 0.05, 'len': 16, 'is_signed_var': False, 'physical_range': '[-40|40]',
// 'bit': 16, 'type': 'double', 'order': 'intel', 'physical_unit': 'deg'}
double steering_actual(const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'speed', 'offset': 0.0, 'precision': 0.01, 'len':
// 16, 'is_signed_var': False, 'physical_range': '[0|35]', 'bit': 0, 'type':
// 'double', 'order': 'intel', 'physical_unit': 'kph'}
double speed(const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/parking_control_a5.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/zhongyun/proto/zhongyun.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Parkingcontrola5 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Zhongyun> {
public:
static const int32_t ID;
Parkingcontrola5();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'name': 'Parking_target', 'enum': {0:
// 'PARKING_TARGET_RELEASE', 1: 'PARKING_TARGET_PARKING_TRIGGER'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 8, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
Parkingcontrola5* set_parking_target(
Parking_control_a5::Parking_targetType parking_target);
// config detail: {'name': 'Parking_Enable_control', 'enum': {0:
// 'PARKING_ENABLE_CONTROL_PARKING_MANUALCONTROL', 1:
// 'PARKING_ENABLE_CONTROL_PARKING_AUTOCONTROL'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Parkingcontrola5* set_parking_enable_control(
Parking_control_a5::Parking_enable_controlType parking_enable_control);
private:
// config detail: {'name': 'Parking_target', 'enum': {0:
// 'PARKING_TARGET_RELEASE', 1: 'PARKING_TARGET_PARKING_TRIGGER'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 8, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
void set_p_parking_target(
uint8_t* data, Parking_control_a5::Parking_targetType parking_target);
// config detail: {'name': 'Parking_Enable_control', 'enum': {0:
// 'PARKING_ENABLE_CONTROL_PARKING_MANUALCONTROL', 1:
// 'PARKING_ENABLE_CONTROL_PARKING_AUTOCONTROL'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
void set_p_parking_enable_control(
uint8_t* data,
Parking_control_a5::Parking_enable_controlType parking_enable_control);
private:
Parking_control_a5::Parking_targetType parking_target_;
Parking_control_a5::Parking_enable_controlType parking_enable_control_;
};
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/vehicle_state_feedback_c1_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/zhongyun/protocol/vehicle_state_feedback_c1.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Vehiclestatefeedbackc1Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Vehiclestatefeedbackc1Test, reset) {
Vehiclestatefeedbackc1 feedback_;
int32_t length = 8;
Zhongyun cd;
uint8_t bytes[8] = {0x88, 0x44, 0x22, 0x11, 0x03, 0x12, 0x13, 0x01};
feedback_.Parse(bytes, length, &cd);
auto &feedbackinfo = cd.vehicle_state_feedback_c1();
EXPECT_DOUBLE_EQ(feedbackinfo.parking_actual(), 1);
EXPECT_DOUBLE_EQ(feedbackinfo.brake_torque_feedback(), 244.1);
EXPECT_DOUBLE_EQ(feedbackinfo.gear_state_actual(), 3);
EXPECT_DOUBLE_EQ(feedbackinfo.steering_actual(), -1419.05);
EXPECT_DOUBLE_EQ(feedbackinfo.speed(), 48.733333333333334);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/enable_state_feedback_c3_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/zhongyun/protocol/enable_state_feedback_c3.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Enablestatefeedbackc3Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Enablestatefeedbackc3Test, reset) {
Enablestatefeedbackc3 feedback_;
int32_t length = 8;
Zhongyun cd;
uint8_t bytes[8] = {0x01, 0x02, 0x01, 0x02, 0x01, 0x12, 0x13, 0x14};
feedback_.Parse(bytes, length, &cd);
auto &feedbackinfo = cd.enable_state_feedback_c3();
EXPECT_DOUBLE_EQ(feedbackinfo.parking_enable_state(), 1);
EXPECT_DOUBLE_EQ(feedbackinfo.steering_enable_state(), 2);
EXPECT_DOUBLE_EQ(feedbackinfo.gear_enable_actual(), 1);
EXPECT_DOUBLE_EQ(feedbackinfo.driven_enable_state(), 1);
EXPECT_DOUBLE_EQ(feedbackinfo.brake_enable_state(), 2);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/error_state_e1_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/zhongyun/protocol/error_state_e1.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Errorstatee1Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Errorstatee1Test, reset) {
Errorstatee1 error_state_;
int32_t length = 8;
Zhongyun cd;
uint8_t bytes[8] = {0x01, 0x01, 0x01, 0x01, 0x01, 0x12, 0x13, 0x14};
error_state_.Parse(bytes, length, &cd);
auto &error_state_info = cd.error_state_e1();
EXPECT_DOUBLE_EQ(error_state_info.brake_error_code(), 1);
EXPECT_DOUBLE_EQ(error_state_info.driven_error_code(), 1);
EXPECT_DOUBLE_EQ(error_state_info.steering_error_code(), 1);
EXPECT_DOUBLE_EQ(error_state_info.parking_error_code(), 1);
EXPECT_DOUBLE_EQ(error_state_info.gear_error_msg(), 1);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/brake_control_a4_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/zhongyun/protocol/brake_control_a4.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Brakecontrola4Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Brakecontrola4Test, reset) {
uint8_t data[8] = {0x67, 0x62, 0x63, 0x64, 0x51, 0x52, 0x53, 0x54};
Brakecontrola4 brk4;
EXPECT_EQ(brk4.GetPeriod(), 20 * 1000);
brk4.UpdateData(data);
EXPECT_EQ(data[0], 0b00000000);
EXPECT_EQ(data[1], 0b00000000);
EXPECT_EQ(data[2], 0b00000000);
EXPECT_EQ(data[3], 0b01100100);
EXPECT_EQ(data[4], 0b01010001);
EXPECT_EQ(data[5], 0b01010010);
EXPECT_EQ(data[6], 0b01010011);
EXPECT_EQ(data[7], 0b01010100);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/brake_control_a4.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/zhongyun/proto/zhongyun.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Brakecontrola4 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Zhongyun> {
public:
static const int32_t ID;
Brakecontrola4();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'name': 'brake_torque', 'offset': 0.0, 'precision': 0.05,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': 8,
// 'type': 'double', 'order': 'intel', 'physical_unit': '%'}
Brakecontrola4* set_brake_torque(double brake_torque);
// config detail: {'name': 'Brake_Enable_control', 'enum': {0:
// 'BRAKE_ENABLE_CONTROL_BRAKE_MANUAL', 1: 'BRAKE_ENABLE_CONTROL_BRAKE_AUTO'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
Brakecontrola4* set_brake_enable_control(
Brake_control_a4::Brake_enable_controlType brake_enable_control);
private:
// config detail: {'name': 'brake_torque', 'offset': 0.0, 'precision': 0.05,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': 8,
// 'type': 'double', 'order': 'intel', 'physical_unit': '%'}
void set_p_brake_torque(uint8_t* data, double brake_torque);
// config detail: {'name': 'Brake_Enable_control', 'enum': {0:
// 'BRAKE_ENABLE_CONTROL_BRAKE_MANUAL', 1: 'BRAKE_ENABLE_CONTROL_BRAKE_AUTO'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
void set_p_brake_enable_control(
uint8_t* data,
Brake_control_a4::Brake_enable_controlType brake_enable_control);
private:
double brake_torque_;
Brake_control_a4::Brake_enable_controlType brake_enable_control_;
};
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/gear_control_a1.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/zhongyun/protocol/gear_control_a1.h"
#include "modules/drivers/canbus/common/byte.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
using ::apollo::drivers::canbus::Byte;
const int32_t Gearcontrola1::ID = 0xA1;
// public
Gearcontrola1::Gearcontrola1() { Reset(); }
uint32_t Gearcontrola1::GetPeriod() const {
// TODO(ChaoM) : modify every protocol's period manually
static const uint32_t PERIOD = 20 * 1000;
return PERIOD;
}
void Gearcontrola1::UpdateData(uint8_t* data) {
set_p_gear_state_target(data, gear_state_target_);
set_p_gear_enable_control(data, gear_enable_control_);
}
void Gearcontrola1::Reset() {
// TODO(ChaoM) : you should check this manually
gear_state_target_ = Gear_control_a1::GEAR_STATE_TARGET_P;
gear_enable_control_ =
Gear_control_a1::GEAR_ENABLE_CONTROL_GEAR_MANUALCONTROL;
}
Gearcontrola1* Gearcontrola1::set_gear_state_target(
Gear_control_a1::Gear_state_targetType gear_state_target) {
gear_state_target_ = gear_state_target;
return this;
}
// config detail: {'name': 'Gear_state_target', 'enum': {1:
// 'GEAR_STATE_TARGET_P', 2: 'GEAR_STATE_TARGET_N', 3: 'GEAR_STATE_TARGET_D', 4:
// 'GEAR_STATE_TARGET_R', 5: 'GEAR_STATE_TARGET_INVALID'}, 'precision': 1.0,
// 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[1|5]',
// 'bit': 8, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
void Gearcontrola1::set_p_gear_state_target(
uint8_t* data, Gear_control_a1::Gear_state_targetType gear_state_target) {
int x = gear_state_target;
Byte to_set(data + 1);
to_set.set_value(static_cast<uint8_t>(x), 0, 8);
}
Gearcontrola1* Gearcontrola1::set_gear_enable_control(
Gear_control_a1::Gear_enable_controlType gear_enable_control) {
gear_enable_control_ = gear_enable_control;
return this;
}
// config detail: {'name': 'Gear_Enable_control', 'enum': {0:
// 'GEAR_ENABLE_CONTROL_GEAR_MANUALCONTROL', 1:
// 'GEAR_ENABLE_CONTROL_GEAR_AUTOCONTROL'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
void Gearcontrola1::set_p_gear_enable_control(
uint8_t* data,
Gear_control_a1::Gear_enable_controlType gear_enable_control) {
int x = gear_enable_control;
Byte to_set(data + 0);
to_set.set_value(static_cast<uint8_t>(x), 0, 8);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
CANBUS_COPTS = ["-DMODULE_NAME=\\\"canbus\\\""]
cc_library(
name = "canbus_zhongyun_protocol",
deps = [
"brake_control_a4",
"enable_state_feedback_c3",
"error_state_e1",
"gear_control_a1",
"parking_control_a5",
"steering_control_a2",
"torque_control_a3",
"vehicle_state_feedback_2_c4",
"vehicle_state_feedback_c1",
],
)
cc_library(
name = "brake_control_a4",
srcs = ["brake_control_a4.cc"],
hdrs = ["brake_control_a4.h"],
copts = CANBUS_COPTS,
deps = [
"//modules/canbus_vehicle/zhongyun/proto:zhongyun_cc_proto",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "brake_control_a4_test",
size = "small",
srcs = ["brake_control_a4_test.cc"],
deps = [
":canbus_zhongyun_protocol",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "enable_state_feedback_c3",
srcs = ["enable_state_feedback_c3.cc"],
hdrs = ["enable_state_feedback_c3.h"],
copts = CANBUS_COPTS,
deps = [
"//modules/canbus_vehicle/zhongyun/proto:zhongyun_cc_proto",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "enable_state_feedback_c3_test",
size = "small",
srcs = ["enable_state_feedback_c3_test.cc"],
deps = [
":canbus_zhongyun_protocol",
"@com_google_googletest//:gtest_main",
],
linkstatic = True,
)
cc_library(
name = "error_state_e1",
srcs = ["error_state_e1.cc"],
hdrs = ["error_state_e1.h"],
copts = CANBUS_COPTS,
deps = [
"//modules/canbus_vehicle/zhongyun/proto:zhongyun_cc_proto",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "error_state_e1_test",
size = "small",
srcs = ["error_state_e1_test.cc"],
deps = [
":canbus_zhongyun_protocol",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "gear_control_a1",
srcs = ["gear_control_a1.cc"],
hdrs = ["gear_control_a1.h"],
copts = CANBUS_COPTS,
deps = [
"//modules/canbus_vehicle/zhongyun/proto:zhongyun_cc_proto",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "gear_control_a1_test",
size = "small",
srcs = ["gear_control_a1_test.cc"],
deps = [
":canbus_zhongyun_protocol",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "parking_control_a5",
srcs = ["parking_control_a5.cc"],
hdrs = ["parking_control_a5.h"],
copts = CANBUS_COPTS,
deps = [
"//modules/canbus_vehicle/zhongyun/proto:zhongyun_cc_proto",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "parking_control_a5_test",
size = "small",
srcs = ["parking_control_a5_test.cc"],
deps = [
":canbus_zhongyun_protocol",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "steering_control_a2",
srcs = ["steering_control_a2.cc"],
hdrs = ["steering_control_a2.h"],
copts = CANBUS_COPTS,
deps = [
"//modules/canbus_vehicle/zhongyun/proto:zhongyun_cc_proto",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "steering_control_a2_test",
size = "small",
srcs = ["steering_control_a2_test.cc"],
deps = [
":canbus_zhongyun_protocol",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "torque_control_a3",
srcs = ["torque_control_a3.cc"],
hdrs = ["torque_control_a3.h"],
copts = CANBUS_COPTS,
deps = [
"//modules/canbus_vehicle/zhongyun/proto:zhongyun_cc_proto",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "torque_control_a3_test",
size = "small",
srcs = ["torque_control_a3_test.cc"],
deps = [
":canbus_zhongyun_protocol",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "vehicle_state_feedback_2_c4",
srcs = ["vehicle_state_feedback_2_c4.cc"],
hdrs = ["vehicle_state_feedback_2_c4.h"],
copts = CANBUS_COPTS,
deps = [
"//modules/canbus_vehicle/zhongyun/proto:zhongyun_cc_proto",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "vehicle_state_feedback_2_c4_test",
size = "small",
srcs = ["vehicle_state_feedback_2_c4_test.cc"],
deps = [
":canbus_zhongyun_protocol",
"@com_google_googletest//:gtest_main",
],
linkstatic = True,
)
cc_library(
name = "vehicle_state_feedback_c1",
srcs = ["vehicle_state_feedback_c1.cc"],
hdrs = ["vehicle_state_feedback_c1.h"],
copts = CANBUS_COPTS,
deps = [
"//modules/canbus_vehicle/zhongyun/proto:zhongyun_cc_proto",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "vehicle_state_feedback_c1_test",
size = "small",
srcs = ["vehicle_state_feedback_c1_test.cc"],
deps = [
":canbus_zhongyun_protocol",
"@com_google_googletest//:gtest_main",
],
linkstatic = True,
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/gear_control_a1.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/zhongyun/proto/zhongyun.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Gearcontrola1 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Zhongyun> {
public:
static const int32_t ID;
Gearcontrola1();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'name': 'Gear_state_target', 'enum': {1:
// 'GEAR_STATE_TARGET_P', 2: 'GEAR_STATE_TARGET_N', 3: 'GEAR_STATE_TARGET_D',
// 4: 'GEAR_STATE_TARGET_R', 5: 'GEAR_STATE_TARGET_INVALID'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[1|5]', 'bit': 8, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
Gearcontrola1* set_gear_state_target(
Gear_control_a1::Gear_state_targetType gear_state_target);
// config detail: {'name': 'Gear_Enable_control', 'enum': {0:
// 'GEAR_ENABLE_CONTROL_GEAR_MANUALCONTROL', 1:
// 'GEAR_ENABLE_CONTROL_GEAR_AUTOCONTROL'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Gearcontrola1* set_gear_enable_control(
Gear_control_a1::Gear_enable_controlType gear_enable_control);
private:
// config detail: {'name': 'Gear_state_target', 'enum': {1:
// 'GEAR_STATE_TARGET_P', 2: 'GEAR_STATE_TARGET_N', 3: 'GEAR_STATE_TARGET_D',
// 4: 'GEAR_STATE_TARGET_R', 5: 'GEAR_STATE_TARGET_INVALID'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[1|5]', 'bit': 8, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
void set_p_gear_state_target(
uint8_t* data, Gear_control_a1::Gear_state_targetType gear_state_target);
// config detail: {'name': 'Gear_Enable_control', 'enum': {0:
// 'GEAR_ENABLE_CONTROL_GEAR_MANUALCONTROL', 1:
// 'GEAR_ENABLE_CONTROL_GEAR_AUTOCONTROL'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
void set_p_gear_enable_control(
uint8_t* data,
Gear_control_a1::Gear_enable_controlType gear_enable_control);
private:
Gear_control_a1::Gear_state_targetType gear_state_target_;
Gear_control_a1::Gear_enable_controlType gear_enable_control_;
};
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/parking_control_a5_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/zhongyun/protocol/parking_control_a5.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Parkingcontrola5Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Parkingcontrola5Test, reset) {
uint8_t data[8] = {0x67, 0x62, 0x63, 0x64, 0x51, 0x52, 0x53, 0x54};
Parkingcontrola5 park;
EXPECT_EQ(park.GetPeriod(), 20 * 1000);
park.UpdateData(data);
EXPECT_EQ(data[0], 0b00000000);
EXPECT_EQ(data[1], 0b00000000);
EXPECT_EQ(data[2], 0b01100011);
EXPECT_EQ(data[3], 0b01100100);
EXPECT_EQ(data[4], 0b01010001);
EXPECT_EQ(data[5], 0b01010010);
EXPECT_EQ(data[6], 0b01010011);
EXPECT_EQ(data[7], 0b01010100);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/vehicle_state_feedback_c1.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/zhongyun/protocol/vehicle_state_feedback_c1.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 zhongyun {
using ::apollo::drivers::canbus::Byte;
Vehiclestatefeedbackc1::Vehiclestatefeedbackc1() {}
const int32_t Vehiclestatefeedbackc1::ID = 0xC1;
void Vehiclestatefeedbackc1::Parse(const std::uint8_t* bytes, int32_t length,
Zhongyun* chassis) const {
chassis->mutable_vehicle_state_feedback_c1()->set_parking_actual(
parking_actual(bytes, length));
chassis->mutable_vehicle_state_feedback_c1()->set_brake_torque_feedback(
brake_torque_feedback(bytes, length));
chassis->mutable_vehicle_state_feedback_c1()->set_gear_state_actual(
gear_state_actual(bytes, length));
chassis->mutable_vehicle_state_feedback_c1()->set_steering_actual(
steering_actual(bytes, length));
chassis->mutable_vehicle_state_feedback_c1()->set_speed(
speed(bytes, length) / 3.6);
}
// config detail: {'name': 'parking_actual', 'enum': {0:
// 'PARKING_ACTUAL_RELEASE', 1: 'PARKING_ACTUAL_PARKING_TRIGGER'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 56, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
Vehicle_state_feedback_c1::Parking_actualType
Vehiclestatefeedbackc1::parking_actual(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 7);
int32_t x = t0.get_byte(0, 8);
Vehicle_state_feedback_c1::Parking_actualType ret =
static_cast<Vehicle_state_feedback_c1::Parking_actualType>(x);
return ret;
}
// config detail: {'name': 'brake_torque_feedback', 'offset': 0.0, 'precision':
// 0.05, 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit':
// 40, 'type': 'double', 'order': 'intel', 'physical_unit': '%'}
double Vehiclestatefeedbackc1::brake_torque_feedback(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 6);
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.050000;
return ret;
}
// config detail: {'name': 'gear_state_actual', 'enum': {1:
// 'GEAR_STATE_ACTUAL_P', 2: 'GEAR_STATE_ACTUAL_N', 3: 'GEAR_STATE_ACTUAL_D', 4:
// 'GEAR_STATE_ACTUAL_R', 5: 'GEAR_STATE_ACTUAL_INVALID'}, 'precision': 1.0,
// 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|5]',
// 'bit': 32, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
Vehicle_state_feedback_c1::Gear_state_actualType
Vehiclestatefeedbackc1::gear_state_actual(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(0, 8);
Vehicle_state_feedback_c1::Gear_state_actualType ret =
static_cast<Vehicle_state_feedback_c1::Gear_state_actualType>(x);
return ret;
}
// config detail: {'name': 'steering_actual', 'offset': -1638.35, 'precision':
// 0.05, 'len': 16, 'is_signed_var': False, 'physical_range': '[-40|40]', 'bit':
// 16, 'type': 'double', 'order': 'intel', 'physical_unit': 'deg'}
double Vehiclestatefeedbackc1::steering_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 + 2);
int32_t t = t1.get_byte(0, 8);
x <<= 8;
x |= t;
double ret = x * 0.050000 + -1638.350000;
return ret;
}
// config detail: {'name': 'speed', 'offset': 0.0, 'precision': 0.01, 'len': 16,
// 'is_signed_var': False, 'physical_range': '[0|35]', 'bit': 0, 'type':
// 'double', 'order': 'intel', 'physical_unit': 'kph'}
double Vehiclestatefeedbackc1::speed(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
Byte t1(bytes + 0);
int32_t t = t1.get_byte(0, 8);
x <<= 8;
x |= t;
double ret = x * 0.010000;
return ret;
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/torque_control_a3.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/zhongyun/protocol/torque_control_a3.h"
#include "modules/drivers/canbus/common/byte.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
using ::apollo::drivers::canbus::Byte;
const int32_t Torquecontrola3::ID = 0xA3;
// public
Torquecontrola3::Torquecontrola3() { Reset(); }
uint32_t Torquecontrola3::GetPeriod() const {
// TODO(ChaoM) : modify every protocol's period manually
static const uint32_t PERIOD = 20 * 1000;
return PERIOD;
}
void Torquecontrola3::UpdateData(uint8_t* data) {
set_p_driven_torque(data, driven_torque_);
set_p_driven_enable_control(data, driven_enable_control_);
}
void Torquecontrola3::Reset() {
// TODO(ChaoM) : you should check this manually
driven_torque_ = 0.0;
driven_enable_control_ =
Torque_control_a3::DRIVEN_ENABLE_CONTROL_DRIVE_MANUAL;
}
Torquecontrola3* Torquecontrola3::set_driven_torque(double driven_torque) {
driven_torque_ = driven_torque;
return this;
}
// config detail: {'name': 'driven_torque', 'offset': 0.0, 'precision': 0.05,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': 8,
// 'type': 'double', 'order': 'intel', 'physical_unit': '%'}
void Torquecontrola3::set_p_driven_torque(uint8_t* data, double driven_torque) {
driven_torque = ProtocolData::BoundedValue(0.0, 100.0, driven_torque);
int x = static_cast<int>(driven_torque / 0.050000);
uint8_t t = 0;
t = static_cast<uint8_t>(x & 0xFF);
Byte to_set0(data + 1);
to_set0.set_value(t, 0, 8);
x >>= 8;
t = static_cast<uint8_t>(x & 0xFF);
Byte to_set1(data + 2);
to_set1.set_value(t, 0, 8);
}
Torquecontrola3* Torquecontrola3::set_driven_enable_control(
Torque_control_a3::Driven_enable_controlType driven_enable_control) {
driven_enable_control_ = driven_enable_control;
return this;
}
// config detail: {'name': 'Driven_Enable_control', 'enum': {0:
// 'DRIVEN_ENABLE_CONTROL_DRIVE_MANUAL', 1: 'DRIVEN_ENABLE_CONTROL_DRIVE_AUTO'},
// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', 'order': 'intel',
// 'physical_unit': ''}
void Torquecontrola3::set_p_driven_enable_control(
uint8_t* data,
Torque_control_a3::Driven_enable_controlType driven_enable_control) {
int x = driven_enable_control;
Byte to_set(data + 0);
to_set.set_value(static_cast<uint8_t>(x), 0, 8);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/steering_control_a2.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/zhongyun/protocol/steering_control_a2.h"
#include "modules/drivers/canbus/common/byte.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
using ::apollo::drivers::canbus::Byte;
const int32_t Steeringcontrola2::ID = 0xA2;
// public
Steeringcontrola2::Steeringcontrola2() { Reset(); }
uint32_t Steeringcontrola2::GetPeriod() const {
// TODO(ChaoM) : modify every protocol's period manually
static const uint32_t PERIOD = 20 * 1000;
return PERIOD;
}
void Steeringcontrola2::UpdateData(uint8_t* data) {
set_p_steering_target(data, steering_target_);
set_p_steering_enable_control(data, steering_enable_control_);
}
void Steeringcontrola2::Reset() {
// TODO(ChaoM) : you should check this manually
steering_target_ = 0.0;
steering_enable_control_ =
Steering_control_a2::STEERING_ENABLE_CONTROL_STEERING_MANUALCONTROL;
}
Steeringcontrola2* Steeringcontrola2::set_steering_target(
double steering_target) {
steering_target_ = steering_target;
return this;
}
// config detail: {'name': 'Steering_target', 'offset': -1638.35, 'precision':
// 0.05, 'len': 16, 'is_signed_var': False, 'physical_range': '[-32|32]', 'bit':
// 8, 'type': 'double', 'order': 'intel', 'physical_unit': 'deg'}
void Steeringcontrola2::set_p_steering_target(uint8_t* data,
double steering_target) {
steering_target = ProtocolData::BoundedValue(-32.0, 32.0, steering_target);
int x = static_cast<int>((steering_target - -1638.350000) / 0.050000);
uint8_t t = 0;
t = static_cast<uint8_t>(x & 0xFF);
Byte to_set0(data + 1);
to_set0.set_value(t, 0, 8);
x >>= 8;
t = static_cast<uint8_t>(x & 0xFF);
Byte to_set1(data + 2);
to_set1.set_value(t, 0, 8);
}
Steeringcontrola2* Steeringcontrola2::set_steering_enable_control(
Steering_control_a2::Steering_enable_controlType steering_enable_control) {
steering_enable_control_ = steering_enable_control;
return this;
}
// config detail: {'name': 'Steering_Enable_control', 'enum': {0:
// 'STEERING_ENABLE_CONTROL_STEERING_MANUALCONTROL', 1:
// 'STEERING_ENABLE_CONTROL_STEERING_AUTOCONTROL'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0,
// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
void Steeringcontrola2::set_p_steering_enable_control(
uint8_t* data,
Steering_control_a2::Steering_enable_controlType steering_enable_control) {
int x = steering_enable_control;
Byte to_set(data + 0);
to_set.set_value(static_cast<uint8_t>(x), 0, 8);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun
|
apollo_public_repos/apollo/modules/canbus_vehicle/zhongyun/protocol/gear_control_a1_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/zhongyun/protocol/gear_control_a1.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace zhongyun {
class Gearcontrola1Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Gearcontrola1Test, reset) {
uint8_t data[8] = {0x67, 0x62, 0x63, 0x64, 0x51, 0x52, 0x53, 0x54};
Gearcontrola1 gear;
EXPECT_EQ(gear.GetPeriod(), 20 * 1000);
gear.UpdateData(data);
EXPECT_EQ(data[0], 0b00000000);
EXPECT_EQ(data[1], 0b00000001);
EXPECT_EQ(data[2], 0b01100011);
EXPECT_EQ(data[3], 0b01100100);
EXPECT_EQ(data[4], 0b01010001);
EXPECT_EQ(data[5], 0b01010010);
EXPECT_EQ(data[6], 0b01010011);
EXPECT_EQ(data[7], 0b01010100);
}
} // namespace zhongyun
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/gem_controller_test.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/gem/gem_controller.h"
#include <string>
#include "gtest/gtest.h"
#include "modules/canbus/proto/canbus_conf.pb.h"
#include "modules/common_msgs/chassis_msgs/chassis.pb.h"
#include "modules/common_msgs/control_msgs/control_cmd.pb.h"
#include "cyber/common/file.h"
#include "modules/canbus_vehicle/gem/gem_message_manager.h"
#include "modules/drivers/canbus/can_comm/can_sender.h"
namespace apollo {
namespace canbus {
namespace gem {
using ::apollo::common::ErrorCode;
using ::apollo::control::ControlCommand;
class GemControllerTest : public ::testing::Test {
public:
virtual void SetUp() {
std::string canbus_conf_file =
"/apollo/modules/canbus/testdata/conf/gem_canbus_conf_test.pb.txt";
cyber::common::GetProtoFromFile(canbus_conf_file, &canbus_conf_);
params_ = canbus_conf_.vehicle_parameter();
}
protected:
GemController controller_;
CanSender<::apollo::canbus::Gem> sender_;
CanbusConf canbus_conf_;
VehicleParameter params_;
GemMessageManager msg_manager_;
ControlCommand control_cmd_;
};
TEST_F(GemControllerTest, Init) {
ErrorCode ret = controller_.Init(params_, &sender_, &msg_manager_);
EXPECT_EQ(ret, ErrorCode::OK);
}
TEST_F(GemControllerTest, 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(GemControllerTest, 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(GemControllerTest, UpdateDrivingMode) {
controller_.Init(params_, &sender_, &msg_manager_);
controller_.set_driving_mode(Chassis::COMPLETE_AUTO_DRIVE);
EXPECT_EQ(controller_.SetDrivingMode(Chassis::COMPLETE_MANUAL),
ErrorCode::OK);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/gem_vehicle_factory.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.
*****************************************************************************/
/**
* @file gem_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/gem/proto/gem.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/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 GemVehicleFactory
*
* @brief this class is inherited from AbstractVehicleFactory. It can be used to
* create controller and message manager for Gem vehicle.
*/
class GemVehicleFactory : public AbstractVehicleFactory {
public:
/**
* @brief destructor
*/
virtual ~GemVehicleFactory() = 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 Gem vehicle controller
* @returns a unique_ptr that points to the created controller
*/
std::unique_ptr<VehicleController<::apollo::canbus::Gem>>
CreateVehicleController();
/**
* @brief create Gem message manager
* @returns a unique_ptr that points to the created message manager
*/
std::unique_ptr<MessageManager<::apollo::canbus::Gem>> CreateMessageManager();
std::unique_ptr<::apollo::cyber::Node> node_ = nullptr;
std::unique_ptr<apollo::drivers::canbus::CanClient> can_client_;
CanSender<::apollo::canbus::Gem> can_sender_;
apollo::drivers::canbus::CanReceiver<::apollo::canbus::Gem> can_receiver_;
std::unique_ptr<MessageManager<::apollo::canbus::Gem>> message_manager_;
std::unique_ptr<VehicleController<::apollo::canbus::Gem>> vehicle_controller_;
std::shared_ptr<::apollo::cyber::Writer<::apollo::canbus::Gem>>
chassis_detail_writer_;
};
CYBER_REGISTER_VEHICLEFACTORY(GemVehicleFactory)
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/gem_message_manager_test.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/gem/gem_message_manager.h"
#include "gtest/gtest.h"
#include "modules/canbus_vehicle/gem/protocol/accel_cmd_67.h"
#include "modules/canbus_vehicle/gem/protocol/accel_rpt_68.h"
#include "modules/canbus_vehicle/gem/protocol/brake_cmd_6b.h"
#include "modules/canbus_vehicle/gem/protocol/brake_motor_rpt_1_70.h"
#include "modules/canbus_vehicle/gem/protocol/brake_motor_rpt_2_71.h"
#include "modules/canbus_vehicle/gem/protocol/brake_motor_rpt_3_72.h"
#include "modules/canbus_vehicle/gem/protocol/brake_rpt_6c.h"
#include "modules/canbus_vehicle/gem/protocol/date_time_rpt_83.h"
#include "modules/canbus_vehicle/gem/protocol/global_cmd_69.h"
#include "modules/canbus_vehicle/gem/protocol/global_rpt_6a.h"
#include "modules/canbus_vehicle/gem/protocol/headlight_cmd_76.h"
#include "modules/canbus_vehicle/gem/protocol/headlight_rpt_77.h"
#include "modules/canbus_vehicle/gem/protocol/horn_cmd_78.h"
#include "modules/canbus_vehicle/gem/protocol/horn_rpt_79.h"
#include "modules/canbus_vehicle/gem/protocol/lat_lon_heading_rpt_82.h"
#include "modules/canbus_vehicle/gem/protocol/parking_brake_status_rpt_80.h"
#include "modules/canbus_vehicle/gem/protocol/shift_cmd_65.h"
#include "modules/canbus_vehicle/gem/protocol/shift_rpt_66.h"
#include "modules/canbus_vehicle/gem/protocol/steering_cmd_6d.h"
#include "modules/canbus_vehicle/gem/protocol/steering_motor_rpt_1_73.h"
#include "modules/canbus_vehicle/gem/protocol/steering_motor_rpt_2_74.h"
#include "modules/canbus_vehicle/gem/protocol/steering_motor_rpt_3_75.h"
#include "modules/canbus_vehicle/gem/protocol/steering_rpt_1_6e.h"
#include "modules/canbus_vehicle/gem/protocol/turn_cmd_63.h"
#include "modules/canbus_vehicle/gem/protocol/turn_rpt_64.h"
#include "modules/canbus_vehicle/gem/protocol/vehicle_speed_rpt_6f.h"
#include "modules/canbus_vehicle/gem/protocol/wheel_speed_rpt_7a.h"
#include "modules/canbus_vehicle/gem/protocol/wiper_cmd_90.h"
#include "modules/canbus_vehicle/gem/protocol/wiper_rpt_91.h"
#include "modules/canbus_vehicle/gem/protocol/yaw_rate_rpt_81.h"
namespace apollo {
namespace canbus {
namespace gem {
class GemMessageManagerTest : public ::testing::Test {
protected:
GemMessageManager manager_;
};
TEST_F(GemMessageManagerTest, GetSendProtocols) {
EXPECT_NE(manager_.GetMutableProtocolDataById(Accelcmd67::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Brakecmd6b::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Globalcmd69::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Headlightcmd76::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Horncmd78::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Shiftcmd65::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Steeringcmd6d::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Turncmd63::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Wipercmd90::ID), nullptr);
}
TEST_F(GemMessageManagerTest, GetRecvProtocols) {
EXPECT_NE(manager_.GetMutableProtocolDataById(Accelrpt68::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Brakemotorrpt170::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Brakemotorrpt271::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Brakemotorrpt372::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Brakerpt6c::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Datetimerpt83::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Globalrpt6a::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Headlightrpt77::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Hornrpt79::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Latlonheadingrpt82::ID),
nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Parkingbrakestatusrpt80::ID),
nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Shiftrpt66::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Steeringmotorrpt173::ID),
nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Steeringmotorrpt274::ID),
nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Steeringmotorrpt375::ID),
nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Steeringrpt16e::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Turnrpt64::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Vehiclespeedrpt6f::ID),
nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Wheelspeedrpt7a::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Wiperrpt91::ID), nullptr);
EXPECT_NE(manager_.GetMutableProtocolDataById(Yawraterpt81::ID), nullptr);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/gem_controller.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/gem/gem_controller.h"
#include <cmath>
#include "modules/canbus_vehicle/gem/proto/gem.pb.h"
#include "modules/common_msgs/basic_msgs/vehicle_signal.pb.h"
#include "cyber/common/log.h"
#include "cyber/time/time.h"
#include "modules/canbus_vehicle/gem/gem_message_manager.h"
#include "modules/canbus/vehicle/vehicle_controller.h"
#include "modules/drivers/canbus/can_comm/can_sender.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
// using ::apollo::canbus::gem;
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;
} // namespace
ErrorCode GemController::Init(
const VehicleParameter& params,
CanSender<::apollo::canbus::Gem>* const can_sender,
MessageManager<::apollo::canbus::Gem>* const message_manager) {
if (is_initialized_) {
AINFO << "GemController has already been initialized.";
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) {
AERROR << "Canbus sender is null.";
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_cmd_6b_ = dynamic_cast<Brakecmd6b*>(
message_manager_->GetMutableProtocolDataById(Brakecmd6b::ID));
if (brake_cmd_6b_ == nullptr) {
AERROR << "Brakecmd6b does not exist in the GemMessageManager!";
return ErrorCode::CANBUS_ERROR;
}
accel_cmd_67_ = dynamic_cast<Accelcmd67*>(
message_manager_->GetMutableProtocolDataById(Accelcmd67::ID));
if (accel_cmd_67_ == nullptr) {
AERROR << "Accelcmd67 does not exist in the GemMessageManager!";
return ErrorCode::CANBUS_ERROR;
}
steering_cmd_6d_ = dynamic_cast<Steeringcmd6d*>(
message_manager_->GetMutableProtocolDataById(Steeringcmd6d::ID));
if (steering_cmd_6d_ == nullptr) {
AERROR << "Steeringcmd6d does not exist in the GemMessageManager!";
return ErrorCode::CANBUS_ERROR;
}
shift_cmd_65_ = dynamic_cast<Shiftcmd65*>(
message_manager_->GetMutableProtocolDataById(Shiftcmd65::ID));
if (shift_cmd_65_ == nullptr) {
AERROR << "Shiftcmd65 does not exist in the GemMessageManager!";
return ErrorCode::CANBUS_ERROR;
}
turn_cmd_63_ = dynamic_cast<Turncmd63*>(
message_manager_->GetMutableProtocolDataById(Turncmd63::ID));
if (turn_cmd_63_ == nullptr) {
AERROR << "Turncmd63 does not exist in the GemMessageManager!";
return ErrorCode::CANBUS_ERROR;
}
global_cmd_69_ = dynamic_cast<Globalcmd69*>(
message_manager_->GetMutableProtocolDataById(Globalcmd69::ID));
if (global_cmd_69_ == nullptr) {
AERROR << "Turncmd63 does not exist in the GemMessageManager!";
return ErrorCode::CANBUS_ERROR;
}
can_sender_->AddMessage(Brakecmd6b::ID, brake_cmd_6b_, false);
can_sender_->AddMessage(Accelcmd67::ID, accel_cmd_67_, false);
can_sender_->AddMessage(Steeringcmd6d::ID, steering_cmd_6d_, false);
can_sender_->AddMessage(Shiftcmd65::ID, shift_cmd_65_, false);
can_sender_->AddMessage(Turncmd63::ID, turn_cmd_63_, false);
can_sender_->AddMessage(Globalcmd69::ID, global_cmd_69_, false);
// Need to sleep to ensure all messages received.
AINFO << "GemController is initialized.";
is_initialized_ = true;
return ErrorCode::OK;
}
GemController::~GemController() {}
bool GemController::Start() {
if (!is_initialized_) {
AERROR << "GemController has NOT been initiated.";
return false;
}
const auto& update_func = [this] { SecurityDogThreadFunc(); };
thread_.reset(new std::thread(update_func));
return true;
}
void GemController::Stop() {
if (!is_initialized_) {
AERROR << "GemController stops or starts improperly!";
return;
}
if (thread_ != nullptr && thread_->joinable()) {
thread_->join();
thread_.reset();
AINFO << "GemController stopped.";
}
}
Chassis GemController::chassis() {
chassis_.Clear();
Gem 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);
// 5
if (chassis_detail.has_vehicle_speed_rpt_6f() &&
chassis_detail.vehicle_speed_rpt_6f().has_vehicle_speed()) {
chassis_.set_speed_mps(static_cast<float>(
chassis_detail.vehicle_speed_rpt_6f().vehicle_speed()));
} else {
chassis_.set_speed_mps(0);
}
// 7
chassis_.set_fuel_range_m(0);
// 8
if (chassis_detail.has_accel_rpt_68() &&
chassis_detail.accel_rpt_68().has_output_value()) {
chassis_.set_throttle_percentage(
static_cast<float>(chassis_detail.accel_rpt_68().output_value()));
} else {
chassis_.set_throttle_percentage(0);
}
// 9
if (chassis_detail.has_brake_rpt_6c() &&
chassis_detail.brake_rpt_6c().has_output_value()) {
chassis_.set_brake_percentage(
static_cast<float>(chassis_detail.brake_rpt_6c().output_value()));
} else {
chassis_.set_brake_percentage(0);
}
// 23, previously 10
if (chassis_detail.has_shift_rpt_66() &&
chassis_detail.shift_rpt_66().has_output_value()) {
Chassis::GearPosition gear_pos = Chassis::GEAR_INVALID;
if (chassis_detail.shift_rpt_66().output_value() ==
Shift_rpt_66::OUTPUT_VALUE_NEUTRAL) {
gear_pos = Chassis::GEAR_NEUTRAL;
}
if (chassis_detail.shift_rpt_66().output_value() ==
Shift_rpt_66::OUTPUT_VALUE_REVERSE) {
gear_pos = Chassis::GEAR_REVERSE;
}
if (chassis_detail.shift_rpt_66().output_value() ==
Shift_rpt_66::OUTPUT_VALUE_FORWARD) {
gear_pos = Chassis::GEAR_DRIVE;
}
chassis_.set_gear_location(gear_pos);
} else {
chassis_.set_gear_location(Chassis::GEAR_NONE);
}
// 11
// TODO(QiL) : verify the unit here.
if (chassis_detail.has_steering_rpt_1_6e() &&
chassis_detail.steering_rpt_1_6e().has_output_value()) {
chassis_.set_steering_percentage(
static_cast<float>(chassis_detail.steering_rpt_1_6e().output_value() *
100.0 / vehicle_params_.max_steer_angle()));
} else {
chassis_.set_steering_percentage(0);
}
if (chassis_detail.has_global_rpt_6a() &&
chassis_detail.global_rpt_6a().has_pacmod_status()) {
if (chassis_detail.global_rpt_6a().pacmod_status() ==
Global_rpt_6a::PACMOD_STATUS_CONTROL_ENABLED) {
chassis_.set_driving_mode(Chassis::COMPLETE_AUTO_DRIVE);
global_cmd_69_->set_clear_override(
Global_cmd_69::CLEAR_OVERRIDE_DON_T_CLEAR_ACTIVE_OVERRIDES);
} else {
chassis_.set_driving_mode(Chassis::COMPLETE_MANUAL);
}
} else {
chassis_.set_driving_mode(Chassis::COMPLETE_MANUAL);
}
// TODO(QiL) : implement the turn light signal here
// 16, 17
if (chassis_detail.has_light() &&
chassis_detail.light().has_turn_light_type() &&
chassis_detail.light().turn_light_type() != Light::TURN_LIGHT_OFF) {
if (chassis_detail.light().turn_light_type() == Light::TURN_LEFT_ON) {
chassis_.mutable_signal()->set_turn_signal(
common::VehicleSignal::TURN_LEFT);
} else if (chassis_detail.light().turn_light_type() ==
Light::TURN_RIGHT_ON) {
chassis_.mutable_signal()->set_turn_signal(
common::VehicleSignal::TURN_RIGHT);
} else {
chassis_.mutable_signal()->set_turn_signal(
common::VehicleSignal::TURN_NONE);
}
} else {
chassis_.mutable_signal()->set_turn_signal(
common::VehicleSignal::TURN_NONE);
}
// TODO(all): implement the rest here/
// 26
if (chassis_error_mask_) {
chassis_.set_chassis_error_mask(chassis_error_mask_);
}
// Give engage_advice based on error_code and canbus feedback
if (!chassis_error_mask_ && !chassis_.parking_brake() &&
chassis_.throttle_percentage() == 0.0 &&
chassis_.brake_percentage() != 0.0) {
chassis_.mutable_engage_advice()->set_advice(
apollo::common::EngageAdvice::READY_TO_ENGAGE);
} else {
chassis_.mutable_engage_advice()->set_advice(
apollo::common::EngageAdvice::DISALLOW_ENGAGE);
chassis_.mutable_engage_advice()->set_reason(
"CANBUS not ready, firmware error or emergency button pressed!");
}
return chassis_;
}
bool GemController::VerifyID() { return true; }
void GemController::Emergency() {
set_driving_mode(Chassis::EMERGENCY_MODE);
ResetProtocol();
set_chassis_error_code(Chassis::CHASSIS_ERROR);
}
ErrorCode GemController::EnableAutoMode() {
if (driving_mode() == Chassis::COMPLETE_AUTO_DRIVE) {
AINFO << "Already in COMPLETE_AUTO_DRIVE mode";
return ErrorCode::OK;
}
global_cmd_69_->set_pacmod_enable(
Global_cmd_69::PACMOD_ENABLE_CONTROL_ENABLED);
global_cmd_69_->set_clear_override(
Global_cmd_69::CLEAR_OVERRIDE_CLEAR_ACTIVE_OVERRIDES);
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.";
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 GemController::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 GemController::EnableSteeringOnlyMode() {
AFATAL << "Not supported!";
return ErrorCode::OK;
}
ErrorCode GemController::EnableSpeedOnlyMode() {
AFATAL << "Not supported!";
return ErrorCode::OK;
}
// NEUTRAL, REVERSE, DRIVE
void GemController::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: {
shift_cmd_65_->set_shift_cmd(Shift_cmd_65::SHIFT_CMD_NEUTRAL);
break;
}
case Chassis::GEAR_REVERSE: {
shift_cmd_65_->set_shift_cmd(Shift_cmd_65::SHIFT_CMD_REVERSE);
break;
}
case Chassis::GEAR_DRIVE: {
shift_cmd_65_->set_shift_cmd(Shift_cmd_65::SHIFT_CMD_FORWARD);
break;
}
case Chassis::GEAR_INVALID: {
AERROR << "Gear command is invalid!";
shift_cmd_65_->set_shift_cmd(Shift_cmd_65::SHIFT_CMD_NEUTRAL);
break;
}
default: {
shift_cmd_65_->set_shift_cmd(Shift_cmd_65::SHIFT_CMD_NEUTRAL);
break;
}
}
}
// brake with new acceleration
// acceleration:0.00~99.99, unit:
// acceleration:0.0 ~ 7.0, unit:m/s^2
// acceleration_spd:60 ~ 100, suggest: 90
// -> pedal
void GemController::Brake(double pedal) {
// double real_value = params_.max_acc() * acceleration / 100;
// TODO(QiL) 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 acceleration.";
return;
}
brake_cmd_6b_->set_brake_cmd(pedal / 100.0);
}
// drive with old acceleration
// gas:0.00~99.99 unit:
void GemController::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 acceleration.";
return;
}
accel_cmd_67_->set_accel_cmd(pedal / 100.0);
}
// drive with acceleration/deceleration
// acc:-7.0 ~ 5.0, unit:m/s^2
void GemController::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
}
// gem default, -470 ~ 470, left:+, right:-
// need to be compatible with control module, so reverse
// steering with old angle speed
// angle:-99.99~0.00~99.99, unit:, left:-, right:+
void GemController::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() * angle / 100.0;
steering_cmd_6d_->set_position_value(real_angle)->set_speed_limit(9.0);
}
// 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 GemController::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() * angle / 100.0;
const double real_angle_spd =
ProtocolData<::apollo::canbus::Gem>::BoundedValue(
vehicle_params_.min_steer_angle_rate(),
vehicle_params_.max_steer_angle_rate(),
vehicle_params_.max_steer_angle_rate() * angle_spd / 100.0);
steering_cmd_6d_->set_position_value(real_angle)
->set_speed_limit(real_angle_spd);
}
void GemController::SetEpbBreak(const ControlCommand& command) {
if (command.parking_brake()) {
// None
} else {
// None
}
}
void GemController::SetBeam(const ControlCommand& command) {
if (command.signal().high_beam()) {
// None
} else if (command.signal().low_beam()) {
// None
} else {
// None
}
}
void GemController::SetHorn(const ControlCommand& command) {
if (command.signal().horn()) {
// None
} else {
// None
}
}
void GemController::SetTurningSignal(const ControlCommand& command) {
// Set Turn Signal
auto signal = command.signal().turn_signal();
if (signal == common::VehicleSignal::TURN_LEFT) {
turn_cmd_63_->set_turn_signal_cmd(Turn_cmd_63::TURN_SIGNAL_CMD_LEFT);
} else if (signal == common::VehicleSignal::TURN_RIGHT) {
turn_cmd_63_->set_turn_signal_cmd(Turn_cmd_63::TURN_SIGNAL_CMD_RIGHT);
} else {
turn_cmd_63_->set_turn_signal_cmd(Turn_cmd_63::TURN_SIGNAL_CMD_NONE);
}
}
void GemController::ResetProtocol() { message_manager_->ResetSendMessages(); }
bool GemController::CheckChassisError() {
// TODO(QiL) : implement it here
return false;
}
void GemController::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;
// 1. horizontal control check
if ((mode == Chassis::COMPLETE_AUTO_DRIVE ||
mode == Chassis::AUTO_STEER_ONLY) &&
!CheckResponse(CHECK_RESPONSE_STEER_UNIT_FLAG, false)) {
++horizontal_ctrl_fail;
if (horizontal_ctrl_fail >= kMaxFailAttempt) {
emergency_mode = true;
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;
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 (emergency_mode && mode != Chassis::EMERGENCY_MODE) {
set_driving_mode(Chassis::EMERGENCY_MODE);
message_manager_->ResetSendMessages();
}
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 GemController looping process:"
<< elapsed.count();
}
}
}
bool GemController::CheckResponse(const int32_t flags, bool need_wait) {
/* ADD YOUR OWN CAR CHASSIS OPERATION
*/
return true;
}
void GemController::set_chassis_error_mask(const int32_t mask) {
std::lock_guard<std::mutex> lock(chassis_mask_mutex_);
chassis_error_mask_ = mask;
}
int32_t GemController::chassis_error_mask() {
std::lock_guard<std::mutex> lock(chassis_mask_mutex_);
return chassis_error_mask_;
}
Chassis::ErrorCode GemController::chassis_error_code() {
std::lock_guard<std::mutex> lock(chassis_error_code_mutex_);
return chassis_error_code_;
}
void GemController::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 gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/cyberfile.xml
|
<package format="2">
<name>canbus-vehicle-gem</name>
<version>local</version>
<description>
Dynamic loading for canbus gem 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/gem</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/gem/gem_controller.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 <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 "cyber/common/macros.h"
#include "modules/canbus_vehicle/gem/protocol/accel_cmd_67.h"
#include "modules/canbus_vehicle/gem/protocol/brake_cmd_6b.h"
#include "modules/canbus_vehicle/gem/protocol/global_cmd_69.h"
#include "modules/canbus_vehicle/gem/protocol/shift_cmd_65.h"
#include "modules/canbus_vehicle/gem/protocol/steering_cmd_6d.h"
#include "modules/canbus_vehicle/gem/protocol/turn_cmd_63.h"
#include "modules/canbus/vehicle/vehicle_controller.h"
namespace apollo {
namespace canbus {
namespace gem {
class GemController final : public VehicleController<::apollo::canbus::Gem> {
public:
GemController() {}
virtual ~GemController();
::apollo::common::ErrorCode Init(
const VehicleParameter& params,
CanSender<::apollo::canbus::Gem>* const can_sender,
MessageManager<::apollo::canbus::Gem>* 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;
FRIEND_TEST(GemControllerTest, SetDrivingMode);
FRIEND_TEST(GemControllerTest, Status);
FRIEND_TEST(GemControllerTest, 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;
bool VerifyID() override;
void ResetProtocol();
bool CheckChassisError();
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
Accelcmd67* accel_cmd_67_ = nullptr;
Brakecmd6b* brake_cmd_6b_ = nullptr;
Shiftcmd65* shift_cmd_65_ = nullptr;
Steeringcmd6d* steering_cmd_6d_ = nullptr;
Turncmd63* turn_cmd_63_ = nullptr;
Globalcmd69* global_cmd_69_ = 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 gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/gem_vehicle_factory.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/gem/gem_vehicle_factory.h"
#include "cyber/common/log.h"
// #include "modules/canbus/common/canbus_gflags.h"
#include "modules/canbus_vehicle/gem/gem_controller.h"
#include "modules/canbus_vehicle/gem/gem_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 GemVehicleFactory::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::Gem>(FLAGS_chassis_detail_topic);
return true;
}
bool GemVehicleFactory::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 GemVehicleFactory::Stop() {
can_sender_.Stop();
can_receiver_.Stop();
can_client_->Stop();
vehicle_controller_->Stop();
AINFO << "Cleanup cansender, canreceiver, canclient, vehicle controller.";
}
void GemVehicleFactory::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 GemVehicleFactory::publish_chassis() {
Chassis chassis = vehicle_controller_->chassis();
ADEBUG << chassis.ShortDebugString();
return chassis;
}
void GemVehicleFactory::PublishChassisDetail() {
Gem chassis_detail;
message_manager_->GetSensorData(&chassis_detail);
ADEBUG << chassis_detail.ShortDebugString();
chassis_detail_writer_->Write(chassis_detail);
}
std::unique_ptr<VehicleController<::apollo::canbus::Gem>>
GemVehicleFactory::CreateVehicleController() {
return std::unique_ptr<VehicleController<::apollo::canbus::Gem>>(
new gem::GemController());
}
std::unique_ptr<MessageManager<::apollo::canbus::Gem>>
GemVehicleFactory::CreateMessageManager() {
return std::unique_ptr<MessageManager<::apollo::canbus::Gem>>(
new gem::GemMessageManager());
}
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/gem_message_manager.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/message_manager.h"
namespace apollo {
namespace canbus {
namespace gem {
using ::apollo::drivers::canbus::MessageManager;
class GemMessageManager : public MessageManager<::apollo::canbus::Gem> {
public:
GemMessageManager();
virtual ~GemMessageManager();
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/gem_message_manager.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/gem/gem_message_manager.h"
#include "modules/canbus_vehicle/gem/protocol/accel_cmd_67.h"
#include "modules/canbus_vehicle/gem/protocol/brake_cmd_6b.h"
#include "modules/canbus_vehicle/gem/protocol/global_cmd_69.h"
#include "modules/canbus_vehicle/gem/protocol/headlight_cmd_76.h"
#include "modules/canbus_vehicle/gem/protocol/horn_cmd_78.h"
#include "modules/canbus_vehicle/gem/protocol/shift_cmd_65.h"
#include "modules/canbus_vehicle/gem/protocol/steering_cmd_6d.h"
#include "modules/canbus_vehicle/gem/protocol/turn_cmd_63.h"
#include "modules/canbus_vehicle/gem/protocol/wiper_cmd_90.h"
#include "modules/canbus_vehicle/gem/protocol/accel_rpt_68.h"
#include "modules/canbus_vehicle/gem/protocol/brake_motor_rpt_1_70.h"
#include "modules/canbus_vehicle/gem/protocol/brake_motor_rpt_2_71.h"
#include "modules/canbus_vehicle/gem/protocol/brake_motor_rpt_3_72.h"
#include "modules/canbus_vehicle/gem/protocol/brake_rpt_6c.h"
#include "modules/canbus_vehicle/gem/protocol/date_time_rpt_83.h"
#include "modules/canbus_vehicle/gem/protocol/global_rpt_6a.h"
#include "modules/canbus_vehicle/gem/protocol/headlight_rpt_77.h"
#include "modules/canbus_vehicle/gem/protocol/horn_rpt_79.h"
#include "modules/canbus_vehicle/gem/protocol/lat_lon_heading_rpt_82.h"
#include "modules/canbus_vehicle/gem/protocol/parking_brake_status_rpt_80.h"
#include "modules/canbus_vehicle/gem/protocol/shift_rpt_66.h"
#include "modules/canbus_vehicle/gem/protocol/steering_motor_rpt_1_73.h"
#include "modules/canbus_vehicle/gem/protocol/steering_motor_rpt_2_74.h"
#include "modules/canbus_vehicle/gem/protocol/steering_motor_rpt_3_75.h"
#include "modules/canbus_vehicle/gem/protocol/steering_rpt_1_6e.h"
#include "modules/canbus_vehicle/gem/protocol/turn_rpt_64.h"
#include "modules/canbus_vehicle/gem/protocol/vehicle_speed_rpt_6f.h"
#include "modules/canbus_vehicle/gem/protocol/wheel_speed_rpt_7a.h"
#include "modules/canbus_vehicle/gem/protocol/wiper_rpt_91.h"
#include "modules/canbus_vehicle/gem/protocol/yaw_rate_rpt_81.h"
namespace apollo {
namespace canbus {
namespace gem {
GemMessageManager::GemMessageManager() {
// Control Messages
AddSendProtocolData<Accelcmd67, true>();
AddSendProtocolData<Brakecmd6b, true>();
AddSendProtocolData<Globalcmd69, true>();
AddSendProtocolData<Headlightcmd76, true>();
AddSendProtocolData<Horncmd78, true>();
AddSendProtocolData<Shiftcmd65, true>();
AddSendProtocolData<Steeringcmd6d, true>();
AddSendProtocolData<Turncmd63, true>();
AddSendProtocolData<Wipercmd90, true>();
// Report Messages
AddRecvProtocolData<Accelrpt68, true>();
AddRecvProtocolData<Brakemotorrpt170, true>();
AddRecvProtocolData<Brakemotorrpt271, true>();
AddRecvProtocolData<Brakemotorrpt372, true>();
AddRecvProtocolData<Brakerpt6c, true>();
AddRecvProtocolData<Datetimerpt83, true>();
AddRecvProtocolData<Globalrpt6a, true>();
AddRecvProtocolData<Headlightrpt77, true>();
AddRecvProtocolData<Hornrpt79, true>();
AddRecvProtocolData<Latlonheadingrpt82, true>();
AddRecvProtocolData<Parkingbrakestatusrpt80, true>();
AddRecvProtocolData<Shiftrpt66, true>();
AddRecvProtocolData<Steeringmotorrpt173, true>();
AddRecvProtocolData<Steeringmotorrpt274, true>();
AddRecvProtocolData<Steeringmotorrpt375, true>();
AddRecvProtocolData<Steeringrpt16e, true>();
AddRecvProtocolData<Turnrpt64, true>();
AddRecvProtocolData<Vehiclespeedrpt6f, true>();
AddRecvProtocolData<Wheelspeedrpt7a, true>();
AddRecvProtocolData<Wiperrpt91, true>();
AddRecvProtocolData<Yawraterpt81, true>();
}
GemMessageManager::~GemMessageManager() {}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/gem_vehicle_factory_test.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/gem/gem_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 GemVehicleFactoryTest : public ::testing::Test {
public:
virtual void SetUp() {
std::string canbus_conf_file =
"modules/canbus/testdata/conf/gem_canbus_conf_test.pb.txt";
cyber::common::GetProtoFromFile(canbus_conf_file, &canbus_conf_);
params_ = canbus_conf_.vehicle_parameter();
params_.set_brand(apollo::common::GEM);
gem_factory_.SetVehicleParameter(params_);
}
virtual void TearDown() {}
protected:
GemVehicleFactory gem_factory_;
CanbusConf canbus_conf_;
VehicleParameter params_;
};
TEST_F(GemVehicleFactoryTest, Init) {
apollo::cyber::Init("vehicle_factory_test");
EXPECT_EQ(gem_factory_.Init(&canbus_conf_), true);
}
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/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 = "gem_vehicle_factory",
srcs = ["gem_vehicle_factory.cc"],
hdrs = ["gem_vehicle_factory.h"],
copts = CANBUS_COPTS,
alwayslink = True,
deps = [
":gem_controller",
":gem_message_manager",
"//modules/common/adapters:adapter_gflags",
"//modules/common/status",
"//modules/canbus/vehicle:abstract_vehicle_factory",
"//modules/drivers/canbus:sensor_canbus_lib",
],
)
cc_binary(
name = "libgem_vehicle_factory_lib.so",
linkshared = True,
linkstatic = True,
deps = [":gem_vehicle_factory"],
)
cc_test(
name = "gem_vehicle_factory_test",
size = "small",
srcs = ["gem_vehicle_factory_test.cc"],
data = ["//modules/canbus:test_data"],
linkstatic = True,
deps = [
":gem_vehicle_factory",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "gem_message_manager",
srcs = ["gem_message_manager.cc"],
hdrs = ["gem_message_manager.h"],
copts = CANBUS_COPTS,
deps = [
"//modules/canbus_vehicle/gem/proto:gem_cc_proto",
"//modules/canbus_vehicle/gem/protocol:canbus_gem_protocol",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "gem_message_manager_test",
size = "small",
srcs = ["gem_message_manager_test.cc"],
deps = [
":gem_message_manager",
"@com_google_googletest//:gtest_main",
],
)
cc_library(
name = "gem_controller",
srcs = ["gem_controller.cc"],
hdrs = ["gem_controller.h"],
copts = CANBUS_COPTS,
deps = [
":gem_message_manager",
"//modules/common_msgs/chassis_msgs:chassis_cc_proto",
"//modules/canbus_vehicle/gem/proto:gem_cc_proto",
"//modules/canbus/vehicle:vehicle_controller_base",
"//modules/canbus_vehicle/gem/protocol:canbus_gem_protocol",
"//modules/drivers/canbus/can_comm:can_sender",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/drivers/canbus/common:canbus_common",
],
)
cc_test(
name = "gem_controller_test",
size = "small",
srcs = ["gem_controller_test.cc"],
data = ["//modules/canbus:test_data"],
deps = [
":gem_controller",
"//modules/common/util",
"@com_google_googletest//:gtest_main",
],
)
install(
name = "install",
library_dest = "canbus-vehicle-gem/lib",
data_dest = "canbus-vehicle-gem",
data = [
":runtime_data",
":cyberfile.xml",
":canbus-vehicle-gem.BUILD",
],
targets = [
":libgem_vehicle_factory_lib.so",
],
deps = [
":pb_gem",
":pb_hdrs",
],
)
install(
name = "pb_hdrs",
data_dest = "canbus-vehicle-gem/include",
data = [
"//modules/canbus_vehicle/gem/proto:gem_cc_proto",
],
)
install_files(
name = "pb_gem",
dest = "canbus-vehicle-gem",
files = [
"//modules/canbus_vehicle/gem/proto:gem_py_pb2",
],
)
filegroup(
name = "runtime_data",
srcs = glob([
"testdata/**",
]),
)
install_src_files(
name = "install_src",
deps = [
":install_gem_src",
":install_gem_hdrs"
],
)
install_src_files(
name = "install_gem_src",
src_dir = ["."],
dest = "canbus-vehicle-gem/src",
filter = "*",
)
install_src_files(
name = "install_gem_hdrs",
src_dir = ["."],
dest = "canbus-vehicle-gem/include",
filter = "*.h",
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/testdata/gem_canbus_conf_test.pb.txt
|
vehicle_parameter {
brand: GEM
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/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/proto/gem.proto
|
syntax = "proto2";
package apollo.canbus;
// Gem vehicle starts from here
// TODO(QiL) : Re-factor needed here
message Global_rpt_6a {
// Report Message
enum Pacmod_statusType {
PACMOD_STATUS_CONTROL_DISABLED = 0;
PACMOD_STATUS_CONTROL_ENABLED = 1;
}
enum Override_statusType {
OVERRIDE_STATUS_NOT_OVERRIDDEN = 0;
OVERRIDE_STATUS_OVERRIDDEN = 1;
}
enum Brk_can_timeoutType {
BRK_CAN_TIMEOUT_NO_ACTIVE_CAN_TIMEOUT = 0;
BRK_CAN_TIMEOUT_ACTIVE_CAN_TIMEOUT = 1;
}
// [] [0|1]
optional Pacmod_statusType pacmod_status = 1;
// [] [0|1]
optional Override_statusType override_status = 2;
// [] [0|1]
optional bool veh_can_timeout = 3;
// [] [0|1]
optional bool str_can_timeout = 4;
// [] [0|1]
optional Brk_can_timeoutType brk_can_timeout = 5;
// [] [0|1]
optional bool usr_can_timeout = 6;
// [] [0|65535]
optional int32 usr_can_read_errors = 7;
}
message Brake_cmd_6b {
// Report Message
// [%] [0|1]
optional double brake_cmd = 1;
}
message Brake_rpt_6c {
// Report Message
enum Brake_on_offType {
BRAKE_ON_OFF_OFF = 0;
BRAKE_ON_OFF_ON = 1;
}
// [%] [0|1]
optional double manual_input = 1;
// [%] [0|1]
optional double commanded_value = 2;
// [%] [0|1]
optional double output_value = 3;
// [] [0|1]
optional Brake_on_offType brake_on_off = 4;
}
message Steering_cmd_6d {
// Report Message
// [radians] [-2147483.648|2147483.647]
optional double position_value = 1;
// [rad/s] [0|65.535]
optional double speed_limit = 2;
}
message Steering_rpt_1_6e {
// Report Message
// [rad/s] [-32.768|32.767]
optional double manual_input = 1;
// [rad/s] [-32.768|32.767]
optional double commanded_value = 2;
// [rad/s] [-32.768|32.767]
optional double output_value = 3;
}
message Wheel_speed_rpt_7a {
// Report Message
// [rad/s] [-32768|32767]
optional int32 wheel_spd_rear_right = 1;
// [rad/s] [-32768|32767]
optional int32 wheel_spd_rear_left = 2;
// [rad/s] [-32768|32767]
optional int32 wheel_spd_front_right = 3;
// [rad/s] [-32768|32767]
optional int32 wheel_spd_front_left = 4;
}
message Date_time_rpt_83 {
// Report Message
// [sec] [0|60]
optional int32 time_second = 1;
// [min] [0|60]
optional int32 time_minute = 2;
// [hr] [0|23]
optional int32 time_hour = 3;
// [dy] [1|31]
optional int32 date_day = 4;
// [mon] [1|12]
optional int32 date_month = 5;
// [yr] [2000|2255]
optional int32 date_year = 6;
}
message Brake_motor_rpt_1_70 {
// Report Message
// [amps] [0|4294967.295]
optional double motor_current = 1;
// [radians] [-2147483.648|2147483.647]
optional double shaft_position = 2;
}
message Headlight_rpt_77 {
// Report Message
enum Output_valueType {
OUTPUT_VALUE_HEADLIGHTS_OFF = 0;
OUTPUT_VALUE_LOW_BEAMS = 1;
OUTPUT_VALUE_HIGH_BEAMS = 2;
}
enum Manual_inputType {
MANUAL_INPUT_HEADLIGHTS_OFF = 0;
MANUAL_INPUT_LOW_BEAMS = 1;
MANUAL_INPUT_HIGH_BEAMS = 2;
}
enum Commanded_valueType {
COMMANDED_VALUE_HEADLIGHTS_OFF = 0;
COMMANDED_VALUE_LOW_BEAMS = 1;
COMMANDED_VALUE_HIGH_BEAMS = 2;
}
// [] [0|2]
optional Output_valueType output_value = 1;
// [] [0|2]
optional Manual_inputType manual_input = 2;
// [] [0|2]
optional Commanded_valueType commanded_value = 3;
}
message Accel_rpt_68 {
// Report Message
// [%] [0|1]
optional double manual_input = 1;
// [%] [0|1]
optional double commanded_value = 2;
// [%] [0|1]
optional double output_value = 3;
}
message Steering_motor_rpt_3_75 {
// Report Message
// [N-m] [-2147483.648|2147483.647]
optional double torque_output = 1;
// [N-m] [-2147483.648|2147483.647]
optional double torque_input = 2;
}
message Turn_cmd_63 {
// Report Message
enum Turn_signal_cmdType {
TURN_SIGNAL_CMD_RIGHT = 0;
TURN_SIGNAL_CMD_NONE = 1;
TURN_SIGNAL_CMD_LEFT = 2;
TURN_SIGNAL_CMD_HAZARD = 3;
}
// [] [0|3]
optional Turn_signal_cmdType turn_signal_cmd = 1;
}
message Turn_rpt_64 {
// Report Message
enum Manual_inputType {
MANUAL_INPUT_RIGHT = 0;
MANUAL_INPUT_NONE = 1;
MANUAL_INPUT_LEFT = 2;
MANUAL_INPUT_HAZARD = 3;
}
enum Commanded_valueType {
COMMANDED_VALUE_RIGHT = 0;
COMMANDED_VALUE_NONE = 1;
COMMANDED_VALUE_LEFT = 2;
COMMANDED_VALUE_HAZARD = 3;
}
enum Output_valueType {
OUTPUT_VALUE_RIGHT = 0;
OUTPUT_VALUE_NONE = 1;
OUTPUT_VALUE_LEFT = 2;
OUTPUT_VALUE_HAZARD = 3;
}
// [] [0|3]
optional Manual_inputType manual_input = 1;
// [] [0|3]
optional Commanded_valueType commanded_value = 2;
// [] [0|3]
optional Output_valueType output_value = 3;
}
message Shift_cmd_65 {
// Report Message
enum Shift_cmdType {
SHIFT_CMD_PARK = 0;
SHIFT_CMD_REVERSE = 1;
SHIFT_CMD_NEUTRAL = 2;
SHIFT_CMD_FORWARD = 3;
SHIFT_CMD_LOW = 4;
}
// FORWARD_is_also_LOW_on_vehicles_with_LOW/HIGH,_PARK_and_HIGH_only_available_on_certain_Vehicles
// [] [0|4]
optional Shift_cmdType shift_cmd = 1;
}
message Shift_rpt_66 {
// Report Message
enum Manual_inputType {
MANUAL_INPUT_PARK = 0;
MANUAL_INPUT_REVERSE = 1;
MANUAL_INPUT_NEUTRAL = 2;
MANUAL_INPUT_FORWARD = 3;
MANUAL_INPUT_HIGH = 4;
}
enum Commanded_valueType {
COMMANDED_VALUE_PARK = 0;
COMMANDED_VALUE_REVERSE = 1;
COMMANDED_VALUE_NEUTRAL = 2;
COMMANDED_VALUE_FORWARD = 3;
COMMANDED_VALUE_HIGH = 4;
}
enum Output_valueType {
OUTPUT_VALUE_PARK = 0;
OUTPUT_VALUE_REVERSE = 1;
OUTPUT_VALUE_NEUTRAL = 2;
OUTPUT_VALUE_FORWARD = 3;
OUTPUT_VALUE_HIGH = 4;
}
// [] [0|4]
optional Manual_inputType manual_input = 1;
// [] [0|4]
optional Commanded_valueType commanded_value = 2;
// [] [0|4]
optional Output_valueType output_value = 3;
}
message Accel_cmd_67 {
// Report Message
// [%] [0|1]
optional double accel_cmd = 1;
}
message Lat_lon_heading_rpt_82 {
// Report Message
// [deg] [-327.68|327.67]
optional double heading = 1;
// [sec] [-128|127]
optional int32 longitude_seconds = 2;
// [min] [-128|127]
optional int32 longitude_minutes = 3;
// [deg] [-128|127]
optional int32 longitude_degrees = 4;
// [sec] [-128|127]
optional int32 latitude_seconds = 5;
// [min] [-128|127]
optional int32 latitude_minutes = 6;
// [deg] [-128|127]
optional int32 latitude_degrees = 7;
}
message Global_cmd_69 {
// Report Message
enum Pacmod_enableType {
PACMOD_ENABLE_CONTROL_DISABLED = 0;
PACMOD_ENABLE_CONTROL_ENABLED = 1;
}
enum Clear_overrideType {
CLEAR_OVERRIDE_DON_T_CLEAR_ACTIVE_OVERRIDES = 0;
CLEAR_OVERRIDE_CLEAR_ACTIVE_OVERRIDES = 1;
}
enum Ignore_overrideType {
IGNORE_OVERRIDE_DON_T_IGNORE_USER_OVERRIDES = 0;
IGNORE_OVERRIDE_IGNORE_USER_OVERRIDES = 1;
}
// [] [0|1]
optional Pacmod_enableType pacmod_enable = 1;
// [] [0|1]
optional Clear_overrideType clear_override = 2;
// [] [0|1]
optional Ignore_overrideType ignore_override = 3;
}
message Parking_brake_status_rpt_80 {
// Report Message
enum Parking_brake_enabledType {
PARKING_BRAKE_ENABLED_OFF = 0;
PARKING_BRAKE_ENABLED_ON = 1;
}
// [] [0|1]
optional Parking_brake_enabledType parking_brake_enabled = 1;
}
message Yaw_rate_rpt_81 {
// Report Message
// [rad/s] [-327.68|327.67]
optional double yaw_rate = 1;
}
message Horn_rpt_79 {
// Report Message
enum Output_valueType {
OUTPUT_VALUE_OFF = 0;
OUTPUT_VALUE_ON = 1;
}
enum Commanded_valueType {
COMMANDED_VALUE_OFF = 0;
COMMANDED_VALUE_ON = 1;
}
enum Manual_inputType {
MANUAL_INPUT_OFF = 0;
MANUAL_INPUT_ON = 1;
}
// [] [0|1]
optional Output_valueType output_value = 1;
// [] [0|1]
optional Commanded_valueType commanded_value = 2;
// [] [0|1]
optional Manual_inputType manual_input = 3;
}
message Horn_cmd_78 {
// Report Message
enum Horn_cmdType {
HORN_CMD_OFF = 0;
HORN_CMD_ON = 1;
}
// [] [0|1]
optional Horn_cmdType horn_cmd = 1;
}
message Wiper_rpt_91 {
// Report Message
enum Output_valueType {
OUTPUT_VALUE_WIPERS_OFF = 0;
OUTPUT_VALUE_INTERMITTENT_1 = 1;
OUTPUT_VALUE_INTERMITTENT_2 = 2;
OUTPUT_VALUE_INTERMITTENT_3 = 3;
OUTPUT_VALUE_INTERMITTENT_4 = 4;
OUTPUT_VALUE_INTERMITTENT_5 = 5;
OUTPUT_VALUE_LOW = 6;
OUTPUT_VALUE_HIGH = 7;
}
enum Commanded_valueType {
COMMANDED_VALUE_WIPERS_OFF = 0;
COMMANDED_VALUE_INTERMITTENT_1 = 1;
COMMANDED_VALUE_INTERMITTENT_2 = 2;
COMMANDED_VALUE_INTERMITTENT_3 = 3;
COMMANDED_VALUE_INTERMITTENT_4 = 4;
COMMANDED_VALUE_INTERMITTENT_5 = 5;
COMMANDED_VALUE_LOW = 6;
COMMANDED_VALUE_HIGH = 7;
}
enum Manual_inputType {
MANUAL_INPUT_WIPERS_OFF = 0;
MANUAL_INPUT_INTERMITTENT_1 = 1;
MANUAL_INPUT_INTERMITTENT_2 = 2;
MANUAL_INPUT_INTERMITTENT_3 = 3;
MANUAL_INPUT_INTERMITTENT_4 = 4;
MANUAL_INPUT_INTERMITTENT_5 = 5;
MANUAL_INPUT_LOW = 6;
MANUAL_INPUT_HIGH = 7;
}
// [] [0|7]
optional Output_valueType output_value = 1;
// [] [0|7]
optional Commanded_valueType commanded_value = 2;
// [] [0|7]
optional Manual_inputType manual_input = 3;
}
message Vehicle_speed_rpt_6f {
// Report Message
enum Vehicle_speed_validType {
VEHICLE_SPEED_VALID_INVALID = 0;
VEHICLE_SPEED_VALID_VALID = 1;
}
// [m/s] [-327.68|327.67]
optional double vehicle_speed = 1;
// [] [0|1]
optional Vehicle_speed_validType vehicle_speed_valid = 2;
}
message Headlight_cmd_76 {
// Report Message
enum Headlight_cmdType {
HEADLIGHT_CMD_HEADLIGHTS_OFF = 0;
HEADLIGHT_CMD_LOW_BEAMS = 1;
HEADLIGHT_CMD_HIGH_BEAMS = 2;
}
// [] [0|2]
optional Headlight_cmdType headlight_cmd = 1;
}
message Steering_motor_rpt_2_74 {
// Report Message
// [deg C] [-32808|32727]
optional int32 encoder_temperature = 1;
// [deg C] [-32808|32727]
optional int32 motor_temperature = 2;
// [rev/s] [-2147483.648|2147483.647]
optional double angular_speed = 3;
}
message Brake_motor_rpt_2_71 {
// Report Message
// [deg C] [-32808|32727]
optional int32 encoder_temperature = 1;
// [deg C] [-32808|32727]
optional int32 motor_temperature = 2;
// [rev/s] [0|4294967.295]
optional double angular_speed = 3;
}
message Steering_motor_rpt_1_73 {
// Report Message
// [amps] [0|4294967.295]
optional double motor_current = 1;
// [amps] [-2147483.648|2147483.647]
optional double shaft_position = 2;
}
message Wiper_cmd_90 {
// Report Message
enum Wiper_cmdType {
WIPER_CMD_WIPERS_OFF = 0;
WIPER_CMD_INTERMITTENT_1 = 1;
WIPER_CMD_INTERMITTENT_2 = 2;
WIPER_CMD_INTERMITTENT_3 = 3;
WIPER_CMD_INTERMITTENT_4 = 4;
WIPER_CMD_INTERMITTENT_5 = 5;
WIPER_CMD_LOW = 6;
WIPER_CMD_HIGH = 7;
}
// [] [0|7]
optional Wiper_cmdType wiper_cmd = 1;
}
message Brake_motor_rpt_3_72 {
// Report Message
// [N-m] [-2147483.648|2147483.647]
optional double torque_output = 1;
// [N-m] [-2147483.648|2147483.647]
optional double torque_input = 2;
}
message Light {
enum TurnLightType {
TURN_LIGHT_OFF = 0;
TURN_LEFT_ON = 1;
TURN_RIGHT_ON = 2;
TURN_LIGHT_ON = 3;
}
enum BeamLampType {
BEAM_OFF = 0;
HIGH_BEAM_ON = 1;
LOW_BEAM_ON = 2;
}
optional TurnLightType turn_light_type = 1;
optional BeamLampType beam_lamp_type = 2;
optional bool is_brake_lamp_on = 3;
}
message Gem {
optional Global_rpt_6a global_rpt_6a = 1; // report message
optional Brake_cmd_6b brake_cmd_6b = 2; // report message
optional Brake_rpt_6c brake_rpt_6c = 3; // report message
optional Steering_cmd_6d steering_cmd_6d = 4; // report message
optional Steering_rpt_1_6e steering_rpt_1_6e = 5; // report message
optional Wheel_speed_rpt_7a wheel_speed_rpt_7a = 6; // report message
optional Date_time_rpt_83 date_time_rpt_83 = 7; // report message
optional Brake_motor_rpt_1_70 brake_motor_rpt_1_70 = 8; // report message
optional Headlight_rpt_77 headlight_rpt_77 = 9; // report message
optional Accel_rpt_68 accel_rpt_68 = 10; // report message
optional Steering_motor_rpt_3_75 steering_motor_rpt_3_75 =
11; // report message
optional Turn_cmd_63 turn_cmd_63 = 12; // report message
optional Turn_rpt_64 turn_rpt_64 = 13; // report message
optional Shift_cmd_65 shift_cmd_65 = 14; // report message
optional Shift_rpt_66 shift_rpt_66 = 15; // report message
optional Accel_cmd_67 accel_cmd_67 = 16; // report message
optional Lat_lon_heading_rpt_82 lat_lon_heading_rpt_82 =
17; // report message
optional Global_cmd_69 global_cmd_69 = 18; // report message
optional Parking_brake_status_rpt_80 parking_brake_status_rpt_80 =
19; // report message
optional Yaw_rate_rpt_81 yaw_rate_rpt_81 = 20; // report message
optional Horn_rpt_79 horn_rpt_79 = 21; // report message
optional Horn_cmd_78 horn_cmd_78 = 22; // report message
optional Wiper_rpt_91 wiper_rpt_91 = 23; // report message
optional Vehicle_speed_rpt_6f vehicle_speed_rpt_6f = 24; // report message
optional Headlight_cmd_76 headlight_cmd_76 = 25; // report message
optional Steering_motor_rpt_2_74 steering_motor_rpt_2_74 =
26; // report message
optional Brake_motor_rpt_2_71 brake_motor_rpt_2_71 = 27; // report message
optional Steering_motor_rpt_1_73 steering_motor_rpt_1_73 =
28; // report message
optional Wiper_cmd_90 wiper_cmd_90 = 29; // report message
optional Brake_motor_rpt_3_72 brake_motor_rpt_3_72 = 30; // report message
optional Light light = 31; // report message
}
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/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 = "gem_cc_proto",
deps = [
":gem_proto",
],
)
proto_library(
name = "gem_proto",
srcs = ["gem.proto"],
)
py_proto_library(
name = "gem_py_pb2",
deps = [
":gem_proto",
],
)
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/parking_brake_status_rpt_80.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Parkingbrakestatusrpt80 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Parkingbrakestatusrpt80();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// config detail: {'name': 'PARKING_BRAKE_ENABLED', 'enum': {0:
// 'PARKING_BRAKE_ENABLED_OFF', 1: 'PARKING_BRAKE_ENABLED_ON'},
// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Parking_brake_status_rpt_80::Parking_brake_enabledType parking_brake_enabled(
const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/steering_cmd_6d.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Steeringcmd6d : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Steeringcmd6d();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'name': 'POSITION_VALUE', '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': 'radians'}
Steeringcmd6d* set_position_value(double position_value);
// config detail: {'name': 'SPEED_LIMIT', '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'}
Steeringcmd6d* set_speed_limit(double speed_limit);
private:
// config detail: {'name': 'POSITION_VALUE', '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': 'radians'}
void set_p_position_value(uint8_t* data, double position_value);
// config detail: {'name': 'SPEED_LIMIT', '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'}
void set_p_speed_limit(uint8_t* data, double speed_limit);
private:
double position_value_;
double speed_limit_;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/steering_motor_rpt_1_73.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/gem/protocol/steering_motor_rpt_1_73.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 gem {
using ::apollo::drivers::canbus::Byte;
Steeringmotorrpt173::Steeringmotorrpt173() {}
const int32_t Steeringmotorrpt173::ID = 0x73;
void Steeringmotorrpt173::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_steering_motor_rpt_1_73()->set_motor_current(
motor_current(bytes, length));
chassis->mutable_steering_motor_rpt_1_73()->set_shaft_position(
shaft_position(bytes, length));
}
// config detail: {'name': 'motor_current', 'offset': 0.0, 'precision': 0.001,
// 'len': 32, 'is_signed_var': False, 'physical_range': '[0|4294967.295]',
// 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'amps'}
double Steeringmotorrpt173::motor_current(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;
double ret = x * 0.001000;
return ret;
}
// config detail: {'name': 'shaft_position', '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': 'amps'}
double Steeringmotorrpt173::shaft_position(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 gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_cmd_6b.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/gem/protocol/brake_cmd_6b.h"
#include "modules/drivers/canbus/common/byte.h"
namespace apollo {
namespace canbus {
namespace gem {
using ::apollo::drivers::canbus::Byte;
const int32_t Brakecmd6b::ID = 0x6B;
// public
Brakecmd6b::Brakecmd6b() { Reset(); }
uint32_t Brakecmd6b::GetPeriod() const {
// TODO(QiL) :modify every protocol's period manually
static const uint32_t PERIOD = 20 * 1000;
return PERIOD;
}
void Brakecmd6b::UpdateData(uint8_t* data) {
set_p_brake_cmd(data, brake_cmd_);
}
void Brakecmd6b::Reset() {
// TODO(QiL) :you should check this manually
brake_cmd_ = 0.0;
}
Brakecmd6b* Brakecmd6b::set_brake_cmd(double brake_cmd) {
brake_cmd_ = brake_cmd;
return this;
}
// config detail: {'name': 'BRAKE_CMD', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 7,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
void Brakecmd6b::set_p_brake_cmd(uint8_t* data, double brake_cmd) {
brake_cmd = ProtocolData::BoundedValue(0.0, 1.0, brake_cmd);
int x = static_cast<int>(brake_cmd / 0.001000);
uint8_t t = 0;
t = static_cast<uint8_t>(x & 0xFF);
Byte to_set0(data + 1);
to_set0.set_value(t, 0, 8);
x >>= 8;
t = static_cast<uint8_t>(x & 0xFF);
Byte to_set1(data + 0);
to_set1.set_value(t, 0, 8);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/accel_rpt_68.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/gem/protocol/accel_rpt_68.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 gem {
using ::apollo::drivers::canbus::Byte;
Accelrpt68::Accelrpt68() {}
const int32_t Accelrpt68::ID = 0x68;
void Accelrpt68::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_accel_rpt_68()->set_manual_input(
manual_input(bytes, length));
chassis->mutable_accel_rpt_68()->set_commanded_value(
commanded_value(bytes, length));
chassis->mutable_accel_rpt_68()->set_output_value(
output_value(bytes, length));
}
// config detail: {'name': 'manual_input', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 7,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
double Accelrpt68::manual_input(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;
}
// config detail: {'name': 'commanded_value', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 23,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
double Accelrpt68::commanded_value(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': 'output_value', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 39,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
double Accelrpt68::output_value(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;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/yaw_rate_rpt_81.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/gem/protocol/yaw_rate_rpt_81.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 gem {
using ::apollo::drivers::canbus::Byte;
Yawraterpt81::Yawraterpt81() {}
const int32_t Yawraterpt81::ID = 0x81;
void Yawraterpt81::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_yaw_rate_rpt_81()->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 Yawraterpt81::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 gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_cmd_6b.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Brakecmd6b : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Brakecmd6b();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'name': 'BRAKE_CMD', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 7,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
Brakecmd6b* set_brake_cmd(double brake_cmd);
private:
// config detail: {'name': 'BRAKE_CMD', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 7,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
void set_p_brake_cmd(uint8_t* data, double brake_cmd);
private:
double brake_cmd_;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/horn_rpt_79.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Hornrpt79 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Hornrpt79();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// 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': 23, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Horn_rpt_79::Output_valueType output_value(const std::uint8_t* bytes,
const int32_t length) const;
// 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':
// 15, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Horn_rpt_79::Commanded_valueType commanded_value(const std::uint8_t* bytes,
const int32_t length) const;
// 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': 7, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Horn_rpt_79::Manual_inputType manual_input(const std::uint8_t* bytes,
const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/shift_rpt_66.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Shiftrpt66 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Shiftrpt66();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// config detail: {'name': 'MANUAL_INPUT', 'enum': {0: 'MANUAL_INPUT_PARK', 1:
// 'MANUAL_INPUT_REVERSE', 2: 'MANUAL_INPUT_NEUTRAL', 3:
// 'MANUAL_INPUT_FORWARD', 4: 'MANUAL_INPUT_HIGH'}, 'precision': 1.0, 'len':
// 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|4]', 'bit':
// 7, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Shift_rpt_66::Manual_inputType manual_input(const std::uint8_t* bytes,
const int32_t length) const;
// config detail: {'name': 'COMMANDED_VALUE', 'enum': {0:
// 'COMMANDED_VALUE_PARK', 1: 'COMMANDED_VALUE_REVERSE', 2:
// 'COMMANDED_VALUE_NEUTRAL', 3: 'COMMANDED_VALUE_FORWARD', 4:
// 'COMMANDED_VALUE_HIGH'}, 'precision': 1.0, 'len': 8, 'is_signed_var':
// False, 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 15, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Shift_rpt_66::Commanded_valueType commanded_value(const std::uint8_t* bytes,
const int32_t length) const;
// config detail: {'name': 'OUTPUT_VALUE', 'enum': {0: 'OUTPUT_VALUE_PARK', 1:
// 'OUTPUT_VALUE_REVERSE', 2: 'OUTPUT_VALUE_NEUTRAL', 3:
// 'OUTPUT_VALUE_FORWARD', 4: 'OUTPUT_VALUE_HIGH'}, 'precision': 1.0, 'len':
// 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|4]', 'bit':
// 23, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Shift_rpt_66::Output_valueType output_value(const std::uint8_t* bytes,
const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/wiper_rpt_91.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/gem/protocol/wiper_rpt_91.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 gem {
using ::apollo::drivers::canbus::Byte;
Wiperrpt91::Wiperrpt91() {}
const int32_t Wiperrpt91::ID = 0x91;
void Wiperrpt91::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_wiper_rpt_91()->set_output_value(
output_value(bytes, length));
chassis->mutable_wiper_rpt_91()->set_commanded_value(
commanded_value(bytes, length));
chassis->mutable_wiper_rpt_91()->set_manual_input(
manual_input(bytes, length));
}
// config detail: {'name': 'output_value', 'enum': {0:
// 'OUTPUT_VALUE_WIPERS_OFF', 1: 'OUTPUT_VALUE_INTERMITTENT_1', 2:
// 'OUTPUT_VALUE_INTERMITTENT_2', 3: 'OUTPUT_VALUE_INTERMITTENT_3', 4:
// 'OUTPUT_VALUE_INTERMITTENT_4', 5: 'OUTPUT_VALUE_INTERMITTENT_5', 6:
// 'OUTPUT_VALUE_LOW', 7: 'OUTPUT_VALUE_HIGH'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|7]', 'bit': 23,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Wiper_rpt_91::Output_valueType Wiperrpt91::output_value(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 8);
Wiper_rpt_91::Output_valueType ret =
static_cast<Wiper_rpt_91::Output_valueType>(x);
return ret;
}
// config detail: {'name': 'commanded_value', 'enum': {0:
// 'COMMANDED_VALUE_WIPERS_OFF', 1: 'COMMANDED_VALUE_INTERMITTENT_1', 2:
// 'COMMANDED_VALUE_INTERMITTENT_2', 3: 'COMMANDED_VALUE_INTERMITTENT_3', 4:
// 'COMMANDED_VALUE_INTERMITTENT_4', 5: 'COMMANDED_VALUE_INTERMITTENT_5', 6:
// 'COMMANDED_VALUE_LOW', 7: 'COMMANDED_VALUE_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': ''}
Wiper_rpt_91::Commanded_valueType Wiperrpt91::commanded_value(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
Wiper_rpt_91::Commanded_valueType ret =
static_cast<Wiper_rpt_91::Commanded_valueType>(x);
return ret;
}
// config detail: {'name': 'manual_input', 'enum': {0:
// 'MANUAL_INPUT_WIPERS_OFF', 1: 'MANUAL_INPUT_INTERMITTENT_1', 2:
// 'MANUAL_INPUT_INTERMITTENT_2', 3: 'MANUAL_INPUT_INTERMITTENT_3', 4:
// 'MANUAL_INPUT_INTERMITTENT_4', 5: 'MANUAL_INPUT_INTERMITTENT_5', 6:
// 'MANUAL_INPUT_LOW', 7: 'MANUAL_INPUT_HIGH'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|7]', 'bit': 7,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Wiper_rpt_91::Manual_inputType Wiperrpt91::manual_input(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(0, 8);
Wiper_rpt_91::Manual_inputType ret =
static_cast<Wiper_rpt_91::Manual_inputType>(x);
return ret;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/global_cmd_69.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Globalcmd69 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Globalcmd69();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'name': 'PACMOD_ENABLE', 'enum': {0:
// 'PACMOD_ENABLE_CONTROL_DISABLED', 1: 'PACMOD_ENABLE_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': ''}
Globalcmd69* set_pacmod_enable(
Global_cmd_69::Pacmod_enableType pacmod_enable);
// config detail: {'name': 'CLEAR_OVERRIDE', 'enum': {0:
// 'CLEAR_OVERRIDE_DON_T_CLEAR_ACTIVE_OVERRIDES', 1:
// 'CLEAR_OVERRIDE_CLEAR_ACTIVE_OVERRIDES'}, 'precision': 1.0, 'len': 1,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 1,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Globalcmd69* set_clear_override(
Global_cmd_69::Clear_overrideType clear_override);
// config detail: {'name': 'IGNORE_OVERRIDE', 'enum': {0:
// 'IGNORE_OVERRIDE_DON_T_IGNORE_USER_OVERRIDES', 1:
// 'IGNORE_OVERRIDE_IGNORE_USER_OVERRIDES'}, 'precision': 1.0, 'len': 1,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 2,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Globalcmd69* set_ignore_override(
Global_cmd_69::Ignore_overrideType ignore_override);
private:
// config detail: {'name': 'PACMOD_ENABLE', 'enum': {0:
// 'PACMOD_ENABLE_CONTROL_DISABLED', 1: 'PACMOD_ENABLE_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': ''}
void set_p_pacmod_enable(uint8_t* data,
Global_cmd_69::Pacmod_enableType pacmod_enable);
// config detail: {'name': 'CLEAR_OVERRIDE', 'enum': {0:
// 'CLEAR_OVERRIDE_DON_T_CLEAR_ACTIVE_OVERRIDES', 1:
// 'CLEAR_OVERRIDE_CLEAR_ACTIVE_OVERRIDES'}, 'precision': 1.0, 'len': 1,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 1,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
void set_p_clear_override(uint8_t* data,
Global_cmd_69::Clear_overrideType clear_override);
// config detail: {'name': 'IGNORE_OVERRIDE', 'enum': {0:
// 'IGNORE_OVERRIDE_DON_T_IGNORE_USER_OVERRIDES', 1:
// 'IGNORE_OVERRIDE_IGNORE_USER_OVERRIDES'}, 'precision': 1.0, 'len': 1,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 2,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
void set_p_ignore_override(
uint8_t* data, Global_cmd_69::Ignore_overrideType ignore_override);
private:
Global_cmd_69::Pacmod_enableType pacmod_enable_;
Global_cmd_69::Clear_overrideType clear_override_;
Global_cmd_69::Ignore_overrideType ignore_override_;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_motor_rpt_1_70.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Brakemotorrpt170 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Brakemotorrpt170();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// config detail: {'name': 'MOTOR_CURRENT', 'offset': 0.0, 'precision': 0.001,
// 'len': 32, 'is_signed_var': False, 'physical_range': '[0|4294967.295]',
// 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'amps'}
double motor_current(const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'SHAFT_POSITION', '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': 'radians'}
double shaft_position(const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/shift_cmd_65.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Shiftcmd65 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Shiftcmd65();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'description':
// 'FORWARD_is_also_LOW_on_vehicles_with_LOW/HIGH,_PARK_and_HIGH_only_available_on_certain_Vehicles',
// 'enum': {0: 'SHIFT_CMD_PARK', 1: 'SHIFT_CMD_REVERSE', 2:
// 'SHIFT_CMD_NEUTRAL', 3: 'SHIFT_CMD_FORWARD', 4: 'SHIFT_CMD_LOW'},
// 'precision': 1.0, 'len': 8, 'name': 'SHIFT_CMD', 'is_signed_var': False,
// 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 7, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Shiftcmd65* set_shift_cmd(Shift_cmd_65::Shift_cmdType shift_cmd);
private:
// config detail: {'description':
// 'FORWARD_is_also_LOW_on_vehicles_with_LOW/HIGH,_PARK_and_HIGH_only_available_on_certain_Vehicles',
// 'enum': {0: 'SHIFT_CMD_PARK', 1: 'SHIFT_CMD_REVERSE', 2:
// 'SHIFT_CMD_NEUTRAL', 3: 'SHIFT_CMD_FORWARD', 4: 'SHIFT_CMD_LOW'},
// 'precision': 1.0, 'len': 8, 'name': 'SHIFT_CMD', 'is_signed_var': False,
// 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 7, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
void set_p_shift_cmd(uint8_t* data, Shift_cmd_65::Shift_cmdType shift_cmd);
private:
Shift_cmd_65::Shift_cmdType shift_cmd_;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/steering_motor_rpt_2_74.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Steeringmotorrpt274 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Steeringmotorrpt274();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// config detail: {'name': 'ENCODER_TEMPERATURE', 'offset': -40.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32808|32727]', 'bit': 7, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'deg C'}
int encoder_temperature(const std::uint8_t* bytes,
const int32_t length) const;
// config detail: {'name': 'MOTOR_TEMPERATURE', 'offset': -40.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32808|32727]', 'bit': 23, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'deg C'}
int motor_temperature(const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'ANGULAR_SPEED', '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': 'rev/s'}
double angular_speed(const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_motor_rpt_2_71.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Brakemotorrpt271 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Brakemotorrpt271();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// config detail: {'name': 'ENCODER_TEMPERATURE', 'offset': -40.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32808|32727]', 'bit': 7, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'deg C'}
int encoder_temperature(const std::uint8_t* bytes,
const int32_t length) const;
// config detail: {'name': 'MOTOR_TEMPERATURE', 'offset': -40.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32808|32727]', 'bit': 23, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'deg C'}
int motor_temperature(const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'ANGULAR_SPEED', 'offset': 0.0, 'precision': 0.001,
// 'len': 32, 'is_signed_var': False, 'physical_range': '[0|4294967.295]',
// 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rev/s'}
double angular_speed(const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/lat_lon_heading_rpt_82_test.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/gem/protocol/lat_lon_heading_rpt_82.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Latlonheadingrpt82Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Latlonheadingrpt82Test, reset) {
Latlonheadingrpt82 Latlonheading;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
Latlonheading.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(chassis_detail.lat_lon_heading_rpt_82().heading(),
48.84);
EXPECT_DOUBLE_EQ(
chassis_detail.lat_lon_heading_rpt_82().longitude_seconds(), 18);
EXPECT_DOUBLE_EQ(
chassis_detail.lat_lon_heading_rpt_82().longitude_minutes(), 17);
EXPECT_DOUBLE_EQ(
chassis_detail.lat_lon_heading_rpt_82().longitude_degrees(), 4);
EXPECT_DOUBLE_EQ(
chassis_detail.lat_lon_heading_rpt_82().latitude_seconds(), 3);
EXPECT_DOUBLE_EQ(
chassis_detail.lat_lon_heading_rpt_82().latitude_minutes(), 2);
EXPECT_DOUBLE_EQ(
chassis_detail.lat_lon_heading_rpt_82().latitude_degrees(), 1);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/turn_cmd_63.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/gem/protocol/turn_cmd_63.h"
#include "modules/drivers/canbus/common/byte.h"
namespace apollo {
namespace canbus {
namespace gem {
using ::apollo::drivers::canbus::Byte;
const int32_t Turncmd63::ID = 0x63;
// public
Turncmd63::Turncmd63() { Reset(); }
uint32_t Turncmd63::GetPeriod() const {
// TODO(QiL) :modify every protocol's period manually
static const uint32_t PERIOD = 20 * 1000;
return PERIOD;
}
void Turncmd63::UpdateData(uint8_t* data) {
set_p_turn_signal_cmd(data, turn_signal_cmd_);
}
void Turncmd63::Reset() {
// TODO(QiL) :you should check this manually
turn_signal_cmd_ = Turn_cmd_63::TURN_SIGNAL_CMD_NONE;
}
Turncmd63* Turncmd63::set_turn_signal_cmd(
Turn_cmd_63::Turn_signal_cmdType turn_signal_cmd) {
turn_signal_cmd_ = turn_signal_cmd;
return this;
}
// config detail: {'name': 'TURN_SIGNAL_CMD', 'enum': {0:
// 'TURN_SIGNAL_CMD_RIGHT', 1: 'TURN_SIGNAL_CMD_NONE', 2:
// 'TURN_SIGNAL_CMD_LEFT', 3: 'TURN_SIGNAL_CMD_HAZARD'}, 'precision': 1.0,
// 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]',
// 'bit': 7, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
void Turncmd63::set_p_turn_signal_cmd(
uint8_t* data, Turn_cmd_63::Turn_signal_cmdType turn_signal_cmd) {
uint8_t x = turn_signal_cmd;
Byte to_set(data + 0);
to_set.set_value(static_cast<uint8_t>(x), 0, 8);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/wiper_cmd_90.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Wipercmd90 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Wipercmd90();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() 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': 7, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Wipercmd90* set_wiper_cmd(Wiper_cmd_90::Wiper_cmdType wiper_cmd);
private:
// 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': 7, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
void set_p_wiper_cmd(uint8_t* data, Wiper_cmd_90::Wiper_cmdType wiper_cmd);
private:
Wiper_cmd_90::Wiper_cmdType wiper_cmd_;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/horn_rpt_79.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/gem/protocol/horn_rpt_79.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 gem {
using ::apollo::drivers::canbus::Byte;
Hornrpt79::Hornrpt79() {}
const int32_t Hornrpt79::ID = 0x79;
void Hornrpt79::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_horn_rpt_79()->set_output_value(
output_value(bytes, length));
chassis->mutable_horn_rpt_79()->set_commanded_value(
commanded_value(bytes, length));
chassis->mutable_horn_rpt_79()->set_manual_input(
manual_input(bytes, length));
}
// 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': 23, 'type': 'enum', 'order':
// 'motorola', 'physical_unit': ''}
Horn_rpt_79::Output_valueType Hornrpt79::output_value(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 8);
Horn_rpt_79::Output_valueType ret =
static_cast<Horn_rpt_79::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': 15, 'type': 'enum', 'order':
// 'motorola', 'physical_unit': ''}
Horn_rpt_79::Commanded_valueType Hornrpt79::commanded_value(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
Horn_rpt_79::Commanded_valueType ret =
static_cast<Horn_rpt_79::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': 7, 'type': 'enum', 'order':
// 'motorola', 'physical_unit': ''}
Horn_rpt_79::Manual_inputType Hornrpt79::manual_input(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(0, 8);
Horn_rpt_79::Manual_inputType ret =
static_cast<Horn_rpt_79::Manual_inputType>(x);
return ret;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/headlight_rpt_77.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Headlightrpt77 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Headlightrpt77();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// 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': 23, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Headlight_rpt_77::Output_valueType output_value(const std::uint8_t* bytes,
const int32_t length) const;
// 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': 7, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Headlight_rpt_77::Manual_inputType manual_input(const std::uint8_t* bytes,
const int32_t length) const;
// 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': 15, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Headlight_rpt_77::Commanded_valueType commanded_value(
const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/global_rpt_6a.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/gem/protocol/global_rpt_6a.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 gem {
using ::apollo::drivers::canbus::Byte;
Globalrpt6a::Globalrpt6a() {}
const int32_t Globalrpt6a::ID = 0x6A;
void Globalrpt6a::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_global_rpt_6a()->set_pacmod_status(
pacmod_status(bytes, length));
chassis->mutable_global_rpt_6a()->set_override_status(
override_status(bytes, length));
chassis->mutable_global_rpt_6a()->set_veh_can_timeout(
veh_can_timeout(bytes, length));
chassis->mutable_global_rpt_6a()->set_str_can_timeout(
str_can_timeout(bytes, length));
chassis->mutable_global_rpt_6a()->set_brk_can_timeout(
brk_can_timeout(bytes, length));
chassis->mutable_global_rpt_6a()->set_usr_can_timeout(
usr_can_timeout(bytes, length));
chassis->mutable_global_rpt_6a()->set_usr_can_read_errors(
usr_can_read_errors(bytes, length));
}
// config detail: {'name': 'pacmod_status', 'enum': {0:
// 'PACMOD_STATUS_CONTROL_DISABLED', 1: 'PACMOD_STATUS_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_6a::Pacmod_statusType Globalrpt6a::pacmod_status(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(0, 1);
Global_rpt_6a::Pacmod_statusType ret =
static_cast<Global_rpt_6a::Pacmod_statusType>(x);
return ret;
}
// config detail: {'name': 'override_status', 'enum': {0:
// 'OVERRIDE_STATUS_NOT_OVERRIDDEN', 1: 'OVERRIDE_STATUS_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_6a::Override_statusType Globalrpt6a::override_status(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(1, 1);
Global_rpt_6a::Override_statusType ret =
static_cast<Global_rpt_6a::Override_statusType>(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': 2,
// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
bool Globalrpt6a::veh_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': '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 Globalrpt6a::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_6a::Brk_can_timeoutType Globalrpt6a::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_6a::Brk_can_timeoutType ret =
static_cast<Global_rpt_6a::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': 5,
// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
bool Globalrpt6a::usr_can_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': '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 Globalrpt6a::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 gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/steering_motor_rpt_2_74_test.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/gem/protocol/steering_motor_rpt_2_74.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Steeringmotorrpt274Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Steeringmotorrpt274Test, reset) {
Steeringmotorrpt274 steeringmotor2;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
steeringmotor2.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(
chassis_detail.steering_motor_rpt_2_74().encoder_temperature(),
218);
EXPECT_DOUBLE_EQ(
chassis_detail.steering_motor_rpt_2_74().motor_temperature(), 732);
EXPECT_DOUBLE_EQ(
chassis_detail.steering_motor_rpt_2_74().angular_speed(),
286397.20400000003);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/headlight_rpt_77.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/gem/protocol/headlight_rpt_77.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 gem {
using ::apollo::drivers::canbus::Byte;
Headlightrpt77::Headlightrpt77() {}
const int32_t Headlightrpt77::ID = 0x77;
void Headlightrpt77::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_headlight_rpt_77()->set_output_value(
output_value(bytes, length));
chassis->mutable_headlight_rpt_77()->set_manual_input(
manual_input(bytes, length));
chassis->mutable_headlight_rpt_77()->set_commanded_value(
commanded_value(bytes, length));
}
// 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': 23, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Headlight_rpt_77::Output_valueType Headlightrpt77::output_value(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 8);
Headlight_rpt_77::Output_valueType ret =
static_cast<Headlight_rpt_77::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': 7, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Headlight_rpt_77::Manual_inputType Headlightrpt77::manual_input(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(0, 8);
Headlight_rpt_77::Manual_inputType ret =
static_cast<Headlight_rpt_77::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': 15, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Headlight_rpt_77::Commanded_valueType Headlightrpt77::commanded_value(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
Headlight_rpt_77::Commanded_valueType ret =
static_cast<Headlight_rpt_77::Commanded_valueType>(x);
return ret;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/accel_rpt_68.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Accelrpt68 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Accelrpt68();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// config detail: {'name': 'MANUAL_INPUT', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 7,
// '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':
// 23, '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': 39,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
double output_value(const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_rpt_6c_test.cc
|
/******************************************************************************
* Copyright 2017 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/gem/protocol/brake_rpt_6c.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
TEST(Brake61Test, General) {
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
Brakerpt6c brake;
brake.Parse(bytes, length, &chassis_detail);
auto &brakerpt = chassis_detail.brake_rpt_6c();
EXPECT_DOUBLE_EQ(brakerpt.manual_input(), 0.258);
EXPECT_DOUBLE_EQ(brakerpt.commanded_value(), 0.772);
EXPECT_DOUBLE_EQ(brakerpt.output_value(), 4.37);
EXPECT_EQ(brakerpt.brake_on_off(), Brake_rpt_6c::BRAKE_ON_OFF_ON);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/steering_motor_rpt_1_73_test.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/gem/protocol/steering_motor_rpt_1_73.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Steeringmotorrpt173Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Steeringmotorrpt173Test, reset) {
Steeringmotorrpt173 steeringmotor1;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
steeringmotor1.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(
chassis_detail.steering_motor_rpt_1_73().motor_current(),
16909.060000000001);
EXPECT_DOUBLE_EQ(
chassis_detail.steering_motor_rpt_1_73().shaft_position(),
286397.20400000003);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_motor_rpt_2_71_test.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/gem/protocol/brake_motor_rpt_2_71.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Brakemotorrpt271Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Brakemotorrpt271Test, reset) {
Brakemotorrpt271 brakermotor2;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
brakermotor2.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(
chassis_detail.brake_motor_rpt_2_71().encoder_temperature(), 218);
EXPECT_DOUBLE_EQ(
chassis_detail.brake_motor_rpt_2_71().motor_temperature(), 732);
EXPECT_DOUBLE_EQ(chassis_detail.brake_motor_rpt_2_71().angular_speed(),
286397.20400000003);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/accel_rpt_68_test.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/gem/protocol/accel_rpt_68.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Accelrpt68Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Accelrpt68Test, reset) {
Accelrpt68 acc;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
acc.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(chassis_detail.accel_rpt_68().manual_input(), 0.258);
EXPECT_DOUBLE_EQ(chassis_detail.accel_rpt_68().commanded_value(), 0.772);
EXPECT_DOUBLE_EQ(chassis_detail.accel_rpt_68().output_value(), 4.37);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/steering_rpt_1_6e_test.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/gem/protocol/steering_rpt_1_6e.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Steeringrpt16eTest : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Steeringrpt16eTest, reset) {
Steeringrpt16e steeringrpt16;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
steeringrpt16.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(chassis_detail.steering_rpt_1_6e().manual_input(),
0.258);
EXPECT_DOUBLE_EQ(chassis_detail.steering_rpt_1_6e().commanded_value(),
0.772);
EXPECT_DOUBLE_EQ(chassis_detail.steering_rpt_1_6e().output_value(),
4.37);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/vehicle_speed_rpt_6f.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Vehiclespeedrpt6f : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Vehiclespeedrpt6f();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* 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_6f::Vehicle_speed_validType vehicle_speed_valid(
const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_motor_rpt_3_72.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Brakemotorrpt372 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Brakemotorrpt372();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// 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 torque_output(const std::uint8_t* bytes, const int32_t length) const;
// 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 torque_input(const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/turn_rpt_64.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/gem/protocol/turn_rpt_64.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 gem {
using ::apollo::drivers::canbus::Byte;
Turnrpt64::Turnrpt64() {}
const int32_t Turnrpt64::ID = 0x64;
void Turnrpt64::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_turn_rpt_64()->set_manual_input(
manual_input(bytes, length));
chassis->mutable_turn_rpt_64()->set_commanded_value(
commanded_value(bytes, length));
chassis->mutable_turn_rpt_64()->set_output_value(
output_value(bytes, length));
}
// 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': 7, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Turn_rpt_64::Manual_inputType Turnrpt64::manual_input(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(0, 8);
Turn_rpt_64::Manual_inputType ret =
static_cast<Turn_rpt_64::Manual_inputType>(x);
return ret;
}
// 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': 15, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Turn_rpt_64::Commanded_valueType Turnrpt64::commanded_value(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
Turn_rpt_64::Commanded_valueType ret =
static_cast<Turn_rpt_64::Commanded_valueType>(x);
return ret;
}
// 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': 23, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Turn_rpt_64::Output_valueType Turnrpt64::output_value(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 8);
Turn_rpt_64::Output_valueType ret =
static_cast<Turn_rpt_64::Output_valueType>(x);
return ret;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_motor_rpt_3_72.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/gem/protocol/brake_motor_rpt_3_72.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 gem {
using ::apollo::drivers::canbus::Byte;
Brakemotorrpt372::Brakemotorrpt372() {}
const int32_t Brakemotorrpt372::ID = 0x72;
void Brakemotorrpt372::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_brake_motor_rpt_3_72()->set_torque_output(
torque_output(bytes, length));
chassis->mutable_brake_motor_rpt_3_72()->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 Brakemotorrpt372::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 Brakemotorrpt372::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 gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/wheel_speed_rpt_7a_test.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/gem/protocol/wheel_speed_rpt_7a.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Wheelspeedrpt7aTest : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Wheelspeedrpt7aTest, reset) {
Wheelspeedrpt7a wheelspeed;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
wheelspeed.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(
chassis_detail.wheel_speed_rpt_7a().wheel_spd_rear_right(), 4884);
EXPECT_DOUBLE_EQ(
chassis_detail.wheel_speed_rpt_7a().wheel_spd_rear_left(), 4370);
EXPECT_DOUBLE_EQ(
chassis_detail.wheel_speed_rpt_7a().wheel_spd_front_right(), 772);
EXPECT_DOUBLE_EQ(
chassis_detail.wheel_speed_rpt_7a().wheel_spd_front_left(), 258);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/accel_cmd_67_test.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/gem/protocol/accel_cmd_67.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Accelcmd67Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Accelcmd67Test, reset) {
uint8_t data[8] = {0x67, 0x62, 0x63, 0x64, 0x51, 0x52, 0x53, 0x54};
Accelcmd67 accel_cmd;
EXPECT_EQ(accel_cmd.GetPeriod(), 20 * 1000);
accel_cmd.UpdateData(data);
EXPECT_EQ(data[0], 0b00000000);
EXPECT_EQ(data[1], 0b00000000);
EXPECT_EQ(data[2], 0b01100011);
EXPECT_EQ(data[3], 0b01100100);
EXPECT_EQ(data[4], 0b01010001);
EXPECT_EQ(data[5], 0b01010010);
EXPECT_EQ(data[6], 0b01010011);
EXPECT_EQ(data[7], 0b01010100);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/parking_brake_status_rpt_80.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/gem/protocol/parking_brake_status_rpt_80.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 gem {
using ::apollo::drivers::canbus::Byte;
Parkingbrakestatusrpt80::Parkingbrakestatusrpt80() {}
const int32_t Parkingbrakestatusrpt80::ID = 0x80;
void Parkingbrakestatusrpt80::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_parking_brake_status_rpt_80()->set_parking_brake_enabled(
parking_brake_enabled(bytes, length));
}
// config detail: {'name': 'parking_brake_enabled', 'enum': {0:
// 'PARKING_BRAKE_ENABLED_OFF', 1: 'PARKING_BRAKE_ENABLED_ON'},
// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'offset': 0.0,
// 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Parking_brake_status_rpt_80::Parking_brake_enabledType
Parkingbrakestatusrpt80::parking_brake_enabled(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(0, 1);
Parking_brake_status_rpt_80::Parking_brake_enabledType ret =
static_cast<Parking_brake_status_rpt_80::Parking_brake_enabledType>(x);
return ret;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/steering_motor_rpt_1_73.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Steeringmotorrpt173 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Steeringmotorrpt173();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// config detail: {'name': 'MOTOR_CURRENT', 'offset': 0.0, 'precision': 0.001,
// 'len': 32, 'is_signed_var': False, 'physical_range': '[0|4294967.295]',
// 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'amps'}
double motor_current(const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'SHAFT_POSITION', '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': 'amps'}
double shaft_position(const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/wiper_rpt_91.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Wiperrpt91 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Wiperrpt91();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// config detail: {'name': 'OUTPUT_VALUE', 'enum': {0:
// 'OUTPUT_VALUE_WIPERS_OFF', 1: 'OUTPUT_VALUE_INTERMITTENT_1', 2:
// 'OUTPUT_VALUE_INTERMITTENT_2', 3: 'OUTPUT_VALUE_INTERMITTENT_3', 4:
// 'OUTPUT_VALUE_INTERMITTENT_4', 5: 'OUTPUT_VALUE_INTERMITTENT_5', 6:
// 'OUTPUT_VALUE_LOW', 7: 'OUTPUT_VALUE_HIGH'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|7]', 'bit':
// 23, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Wiper_rpt_91::Output_valueType output_value(const std::uint8_t* bytes,
const int32_t length) const;
// config detail: {'name': 'COMMANDED_VALUE', 'enum': {0:
// 'COMMANDED_VALUE_WIPERS_OFF', 1: 'COMMANDED_VALUE_INTERMITTENT_1', 2:
// 'COMMANDED_VALUE_INTERMITTENT_2', 3: 'COMMANDED_VALUE_INTERMITTENT_3', 4:
// 'COMMANDED_VALUE_INTERMITTENT_4', 5: 'COMMANDED_VALUE_INTERMITTENT_5', 6:
// 'COMMANDED_VALUE_LOW', 7: 'COMMANDED_VALUE_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': ''}
Wiper_rpt_91::Commanded_valueType commanded_value(const std::uint8_t* bytes,
const int32_t length) const;
// config detail: {'name': 'MANUAL_INPUT', 'enum': {0:
// 'MANUAL_INPUT_WIPERS_OFF', 1: 'MANUAL_INPUT_INTERMITTENT_1', 2:
// 'MANUAL_INPUT_INTERMITTENT_2', 3: 'MANUAL_INPUT_INTERMITTENT_3', 4:
// 'MANUAL_INPUT_INTERMITTENT_4', 5: 'MANUAL_INPUT_INTERMITTENT_5', 6:
// 'MANUAL_INPUT_LOW', 7: 'MANUAL_INPUT_HIGH'}, 'precision': 1.0, 'len': 8,
// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|7]', 'bit': 7,
// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Wiper_rpt_91::Manual_inputType manual_input(const std::uint8_t* bytes,
const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_rpt_6c.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/gem/protocol/brake_rpt_6c.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 gem {
using ::apollo::drivers::canbus::Byte;
Brakerpt6c::Brakerpt6c() {}
const int32_t Brakerpt6c::ID = 0x6C;
void Brakerpt6c::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_brake_rpt_6c()->set_manual_input(
manual_input(bytes, length));
chassis->mutable_brake_rpt_6c()->set_commanded_value(
commanded_value(bytes, length));
chassis->mutable_brake_rpt_6c()->set_output_value(
output_value(bytes, length));
chassis->mutable_brake_rpt_6c()->set_brake_on_off(
brake_on_off(bytes, length));
}
// config detail: {'name': 'manual_input', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 7,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
double Brakerpt6c::manual_input(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;
}
// config detail: {'name': 'commanded_value', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 23,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
double Brakerpt6c::commanded_value(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': 'output_value', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 39,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
double Brakerpt6c::output_value(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': 'brake_on_off', 'enum': {0: 'BRAKE_ON_OFF_OFF', 1:
// 'BRAKE_ON_OFF_ON'}, 'precision': 1.0, 'len': 1, 'is_signed_var': False,
// 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 48, 'type': 'enum', 'order':
// 'motorola', 'physical_unit': ''}
Brake_rpt_6c::Brake_on_offType Brakerpt6c::brake_on_off(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 6);
int32_t x = t0.get_byte(0, 1);
Brake_rpt_6c::Brake_on_offType ret =
static_cast<Brake_rpt_6c::Brake_on_offType>(x);
return ret;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/headlight_cmd_76.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Headlightcmd76 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Headlightcmd76();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// 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': 7, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Headlightcmd76* set_headlight_cmd(
Headlight_cmd_76::Headlight_cmdType headlight_cmd);
private:
// 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': 7, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
void set_p_headlight_cmd(uint8_t* data,
Headlight_cmd_76::Headlight_cmdType headlight_cmd);
private:
Headlight_cmd_76::Headlight_cmdType headlight_cmd_;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_motor_rpt_1_70_test.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/gem/protocol/brake_motor_rpt_1_70.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Brakemotorrpt170Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Brakemotorrpt170Test, reset) {
Brakemotorrpt170 brakermotor1;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
brakermotor1.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(chassis_detail.brake_motor_rpt_1_70().motor_current(),
16909.060000000001);
EXPECT_DOUBLE_EQ(chassis_detail.brake_motor_rpt_1_70().shaft_position(),
286397.20400000003);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/turn_rpt_64.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Turnrpt64 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Turnrpt64();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// 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': 7, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Turn_rpt_64::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': 15, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Turn_rpt_64::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': 23, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
Turn_rpt_64::Output_valueType output_value(const std::uint8_t* bytes,
const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/date_time_rpt_83_test.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/gem/protocol/date_time_rpt_83.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Datetimerpt83Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Datetimerpt83Test, reset) {
Datetimerpt83 datetime;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
datetime.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(chassis_detail.date_time_rpt_83().time_second(), 18);
EXPECT_DOUBLE_EQ(chassis_detail.date_time_rpt_83().time_minute(), 17);
EXPECT_DOUBLE_EQ(chassis_detail.date_time_rpt_83().time_hour(), 4);
EXPECT_DOUBLE_EQ(chassis_detail.date_time_rpt_83().date_day(), 4);
EXPECT_DOUBLE_EQ(chassis_detail.date_time_rpt_83().date_month(), 3);
EXPECT_DOUBLE_EQ(chassis_detail.date_time_rpt_83().date_year(), 2001);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/wiper_cmd_90.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/gem/protocol/wiper_cmd_90.h"
#include "modules/drivers/canbus/common/byte.h"
namespace apollo {
namespace canbus {
namespace gem {
using ::apollo::drivers::canbus::Byte;
const int32_t Wipercmd90::ID = 0x90;
// public
Wipercmd90::Wipercmd90() { Reset(); }
uint32_t Wipercmd90::GetPeriod() const {
// TODO(QiL) :modify every protocol's period manually
static const uint32_t PERIOD = 20 * 1000;
return PERIOD;
}
void Wipercmd90::UpdateData(uint8_t* data) {
set_p_wiper_cmd(data, wiper_cmd_);
}
void Wipercmd90::Reset() {
// TODO(QiL) :you should check this manually
wiper_cmd_ = Wiper_cmd_90::WIPER_CMD_WIPERS_OFF;
}
Wipercmd90* Wipercmd90::set_wiper_cmd(Wiper_cmd_90::Wiper_cmdType wiper_cmd) {
wiper_cmd_ = wiper_cmd;
return this;
}
// 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': 7, 'type': 'enum', 'order': 'motorola',
// 'physical_unit': ''}
void Wipercmd90::set_p_wiper_cmd(uint8_t* data,
Wiper_cmd_90::Wiper_cmdType wiper_cmd) {
uint8_t x = wiper_cmd;
Byte to_set(data + 0);
to_set.set_value(static_cast<uint8_t>(x), 0, 8);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/wiper_rpt_91_test.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/gem/protocol/wiper_rpt_91.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Wiperrpt91Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Wiperrpt91Test, reset) {
Wiperrpt91 wiper;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[3] = {0x01, 0x02, 0x03};
wiper.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(chassis_detail.wiper_rpt_91().manual_input(), 1);
EXPECT_DOUBLE_EQ(chassis_detail.wiper_rpt_91().commanded_value(), 2);
EXPECT_DOUBLE_EQ(chassis_detail.wiper_rpt_91().output_value(), 3);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/yaw_rate_rpt_81.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Yawraterpt81 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Yawraterpt81();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* 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 gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/steering_rpt_1_6e.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/gem/protocol/steering_rpt_1_6e.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 gem {
using ::apollo::drivers::canbus::Byte;
Steeringrpt16e::Steeringrpt16e() {}
const int32_t Steeringrpt16e::ID = 0x6E;
void Steeringrpt16e::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_steering_rpt_1_6e()->set_manual_input(
manual_input(bytes, length));
chassis->mutable_steering_rpt_1_6e()->set_commanded_value(
commanded_value(bytes, length));
chassis->mutable_steering_rpt_1_6e()->set_output_value(
output_value(bytes, length));
}
// config detail: {'name': 'manual_input', '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': 'rad/s'}
double Steeringrpt16e::manual_input(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;
}
// config detail: {'name': 'commanded_value', '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': 'rad/s'}
double Steeringrpt16e::commanded_value(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': 'output_value', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': True, 'physical_range': '[-32.768|32.767]',
// 'bit': 39, 'type': 'double', 'order': 'motorola', 'physical_unit': 'rad/s'}
double Steeringrpt16e::output_value(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.001000;
return ret;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/yaw_rate_rpt_81_test.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/gem/protocol/yaw_rate_rpt_81.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class YawRatePrt81Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(YawRatePrt81Test, reset) {
Yawraterpt81 yaw_rate;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
yaw_rate.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(chassis_detail.yaw_rate_rpt_81().yaw_rate(), 2.58);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/shift_rpt_66.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/gem/protocol/shift_rpt_66.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 gem {
using ::apollo::drivers::canbus::Byte;
Shiftrpt66::Shiftrpt66() {}
const int32_t Shiftrpt66::ID = 0x66;
void Shiftrpt66::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_shift_rpt_66()->set_manual_input(
manual_input(bytes, length));
chassis->mutable_shift_rpt_66()->set_commanded_value(
commanded_value(bytes, length));
chassis->mutable_shift_rpt_66()->set_output_value(
output_value(bytes, length));
}
// config detail: {'name': 'manual_input', 'enum': {0: 'MANUAL_INPUT_PARK', 1:
// 'MANUAL_INPUT_REVERSE', 2: 'MANUAL_INPUT_NEUTRAL', 3: 'MANUAL_INPUT_FORWARD',
// 4: 'MANUAL_INPUT_HIGH'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False,
// 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 7, 'type': 'enum', 'order':
// 'motorola', 'physical_unit': ''}
Shift_rpt_66::Manual_inputType Shiftrpt66::manual_input(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 0);
int32_t x = t0.get_byte(0, 8);
Shift_rpt_66::Manual_inputType ret =
static_cast<Shift_rpt_66::Manual_inputType>(x);
return ret;
}
// config detail: {'name': 'commanded_value', 'enum': {0:
// 'COMMANDED_VALUE_PARK', 1: 'COMMANDED_VALUE_REVERSE', 2:
// 'COMMANDED_VALUE_NEUTRAL', 3: 'COMMANDED_VALUE_FORWARD', 4:
// 'COMMANDED_VALUE_HIGH'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False,
// 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 15, 'type': 'enum', 'order':
// 'motorola', 'physical_unit': ''}
Shift_rpt_66::Commanded_valueType Shiftrpt66::commanded_value(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
Shift_rpt_66::Commanded_valueType ret =
static_cast<Shift_rpt_66::Commanded_valueType>(x);
return ret;
}
// config detail: {'name': 'output_value', 'enum': {0: 'OUTPUT_VALUE_PARK', 1:
// 'OUTPUT_VALUE_REVERSE', 2: 'OUTPUT_VALUE_NEUTRAL', 3: 'OUTPUT_VALUE_FORWARD',
// 4: 'OUTPUT_VALUE_HIGH'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False,
// 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 23, 'type': 'enum', 'order':
// 'motorola', 'physical_unit': ''}
Shift_rpt_66::Output_valueType Shiftrpt66::output_value(
const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 8);
Shift_rpt_66::Output_valueType ret =
static_cast<Shift_rpt_66::Output_valueType>(x);
return ret;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_rpt_6c.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Brakerpt6c : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Brakerpt6c();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// config detail: {'name': 'MANUAL_INPUT', 'offset': 0.0, 'precision': 0.001,
// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 7,
// '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':
// 23, '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': 39,
// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
double output_value(const std::uint8_t* bytes, const int32_t length) const;
// config detail: {'name': 'BRAKE_ON_OFF', 'enum': {0: 'BRAKE_ON_OFF_OFF', 1:
// 'BRAKE_ON_OFF_ON'}, 'precision': 1.0, 'len': 1, 'is_signed_var': False,
// 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 48, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Brake_rpt_6c::Brake_on_offType brake_on_off(const std::uint8_t* bytes,
const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_motor_rpt_1_70.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/gem/protocol/brake_motor_rpt_1_70.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 gem {
using ::apollo::drivers::canbus::Byte;
Brakemotorrpt170::Brakemotorrpt170() {}
const int32_t Brakemotorrpt170::ID = 0x70;
void Brakemotorrpt170::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_brake_motor_rpt_1_70()->set_motor_current(
motor_current(bytes, length));
chassis->mutable_brake_motor_rpt_1_70()->set_shaft_position(
shaft_position(bytes, length));
}
// config detail: {'name': 'motor_current', 'offset': 0.0, 'precision': 0.001,
// 'len': 32, 'is_signed_var': False, 'physical_range': '[0|4294967.295]',
// 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'amps'}
double Brakemotorrpt170::motor_current(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;
double ret = x * 0.001000;
return ret;
}
// config detail: {'name': 'shaft_position', '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': 'radians'}
double Brakemotorrpt170::shaft_position(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 gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/horn_cmd_78.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Horncmd78 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Horncmd78();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'name': 'HORN_CMD', 'enum': {0: 'HORN_CMD_OFF', 1:
// 'HORN_CMD_ON'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False,
// 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 7, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
Horncmd78* set_horn_cmd(Horn_cmd_78::Horn_cmdType horn_cmd);
private:
// config detail: {'name': 'HORN_CMD', 'enum': {0: 'HORN_CMD_OFF', 1:
// 'HORN_CMD_ON'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False,
// 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 7, 'type': 'enum',
// 'order': 'motorola', 'physical_unit': ''}
void set_p_horn_cmd(uint8_t* data, Horn_cmd_78::Horn_cmdType horn_cmd);
private:
Horn_cmd_78::Horn_cmdType horn_cmd_;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/steering_motor_rpt_3_75_test.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/gem/protocol/steering_motor_rpt_3_75.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Steeringmotorrpt375Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Steeringmotorrpt375Test, reset) {
Steeringmotorrpt375 steeringmotor3;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
steeringmotor3.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(
chassis_detail.steering_motor_rpt_3_75().torque_output(),
16909.060000000001);
EXPECT_DOUBLE_EQ(
chassis_detail.steering_motor_rpt_3_75().torque_input(),
286397.20400000003);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/lat_lon_heading_rpt_82.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Latlonheadingrpt82 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Latlonheadingrpt82();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// 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 heading(const std::uint8_t* bytes, const int32_t length) const;
// 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 longitude_seconds(const std::uint8_t* bytes, const int32_t length) const;
// 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 longitude_minutes(const std::uint8_t* bytes, const int32_t length) const;
// 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 longitude_degrees(const std::uint8_t* bytes, const int32_t length) const;
// 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 latitude_seconds(const std::uint8_t* bytes, const int32_t length) const;
// 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 latitude_minutes(const std::uint8_t* bytes, const int32_t length) const;
// 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 latitude_degrees(const std::uint8_t* bytes, const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/vehicle_speed_rpt_6f.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/gem/protocol/vehicle_speed_rpt_6f.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 gem {
using ::apollo::drivers::canbus::Byte;
Vehiclespeedrpt6f::Vehiclespeedrpt6f() {}
const int32_t Vehiclespeedrpt6f::ID = 0x6F;
void Vehiclespeedrpt6f::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_vehicle_speed_rpt_6f()->set_vehicle_speed(
vehicle_speed(bytes, length));
chassis->mutable_vehicle_speed_rpt_6f()->set_vehicle_speed_valid(
vehicle_speed_valid(bytes, length));
}
// 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 Vehiclespeedrpt6f::vehicle_speed(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;
}
// 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_6f::Vehicle_speed_validType
Vehiclespeedrpt6f::vehicle_speed_valid(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 1);
Vehicle_speed_rpt_6f::Vehicle_speed_validType ret =
static_cast<Vehicle_speed_rpt_6f::Vehicle_speed_validType>(x);
return ret;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/turn_cmd_63.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Turncmd63 : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Turncmd63();
uint32_t GetPeriod() const override;
void UpdateData(uint8_t* data) override;
void Reset() override;
// config detail: {'name': 'TURN_SIGNAL_CMD', 'enum': {0:
// 'TURN_SIGNAL_CMD_RIGHT', 1: 'TURN_SIGNAL_CMD_NONE', 2:
// 'TURN_SIGNAL_CMD_LEFT', 3: 'TURN_SIGNAL_CMD_HAZARD'}, 'precision': 1.0,
// 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]',
// 'bit': 7, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
Turncmd63* set_turn_signal_cmd(
Turn_cmd_63::Turn_signal_cmdType turn_signal_cmd);
private:
// config detail: {'name': 'TURN_SIGNAL_CMD', 'enum': {0:
// 'TURN_SIGNAL_CMD_RIGHT', 1: 'TURN_SIGNAL_CMD_NONE', 2:
// 'TURN_SIGNAL_CMD_LEFT', 3: 'TURN_SIGNAL_CMD_HAZARD'}, 'precision': 1.0,
// 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]',
// 'bit': 7, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
void set_p_turn_signal_cmd(uint8_t* data,
Turn_cmd_63::Turn_signal_cmdType turn_signal_cmd);
private:
Turn_cmd_63::Turn_signal_cmdType turn_signal_cmd_;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/horn_cmd_78.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/gem/protocol/horn_cmd_78.h"
#include "modules/drivers/canbus/common/byte.h"
namespace apollo {
namespace canbus {
namespace gem {
using ::apollo::drivers::canbus::Byte;
const int32_t Horncmd78::ID = 0x78;
// public
Horncmd78::Horncmd78() { Reset(); }
uint32_t Horncmd78::GetPeriod() const {
// TODO(QiL) :modify every protocol's period manually
static const uint32_t PERIOD = 20 * 1000;
return PERIOD;
}
void Horncmd78::UpdateData(uint8_t* data) { set_p_horn_cmd(data, horn_cmd_); }
void Horncmd78::Reset() {
// TODO(QiL) :you should check this manually
horn_cmd_ = Horn_cmd_78::HORN_CMD_OFF;
}
Horncmd78* Horncmd78::set_horn_cmd(Horn_cmd_78::Horn_cmdType horn_cmd) {
horn_cmd_ = horn_cmd;
return this;
}
// config detail: {'name': 'HORN_CMD', 'enum': {0: 'HORN_CMD_OFF', 1:
// 'HORN_CMD_ON'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset':
// 0.0, 'physical_range': '[0|1]', 'bit': 7, 'type': 'enum', 'order':
// 'motorola', 'physical_unit': ''}
void Horncmd78::set_p_horn_cmd(uint8_t* data,
Horn_cmd_78::Horn_cmdType horn_cmd) {
uint8_t x = horn_cmd;
Byte to_set(data + 0);
to_set.set_value(static_cast<uint8_t>(x), 0, 8);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/steering_motor_rpt_2_74.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/gem/protocol/steering_motor_rpt_2_74.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 gem {
using ::apollo::drivers::canbus::Byte;
Steeringmotorrpt274::Steeringmotorrpt274() {}
const int32_t Steeringmotorrpt274::ID = 0x74;
void Steeringmotorrpt274::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_steering_motor_rpt_2_74()->set_encoder_temperature(
encoder_temperature(bytes, length));
chassis->mutable_steering_motor_rpt_2_74()->set_motor_temperature(
motor_temperature(bytes, length));
chassis->mutable_steering_motor_rpt_2_74()->set_angular_speed(
angular_speed(bytes, length));
}
// config detail: {'name': 'encoder_temperature', 'offset': -40.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32808|32727]', 'bit': 7, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'deg C'}
int Steeringmotorrpt274::encoder_temperature(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;
int ret = x + -40;
return ret;
}
// config detail: {'name': 'motor_temperature', 'offset': -40.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32808|32727]', 'bit': 23, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'deg C'}
int Steeringmotorrpt274::motor_temperature(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;
int ret = x + -40;
return ret;
}
// config detail: {'name': 'angular_speed', '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': 'rev/s'}
double Steeringmotorrpt274::angular_speed(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 gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/wheel_speed_rpt_7a.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/gem/proto/gem.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
namespace apollo {
namespace canbus {
namespace gem {
class Wheelspeedrpt7a : public ::apollo::drivers::canbus::ProtocolData<
::apollo::canbus::Gem> {
public:
static const int32_t ID;
Wheelspeedrpt7a();
void Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const override;
private:
// config detail: {'name': 'WHEEL_SPD_REAR_RIGHT', 'offset': 0.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32768|32767]', 'bit': 55, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'rad/s'}
int wheel_spd_rear_right(const std::uint8_t* bytes,
const int32_t length) const;
// config detail: {'name': 'WHEEL_SPD_REAR_LEFT', 'offset': 0.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32768|32767]', 'bit': 39, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'rad/s'}
int wheel_spd_rear_left(const std::uint8_t* bytes,
const int32_t length) const;
// config detail: {'name': 'WHEEL_SPD_FRONT_RIGHT', 'offset': 0.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32768|32767]', 'bit': 23, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'rad/s'}
int wheel_spd_front_right(const std::uint8_t* bytes,
const int32_t length) const;
// config detail: {'name': 'WHEEL_SPD_FRONT_LEFT', 'offset': 0.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32768|32767]', 'bit': 7, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'rad/s'}
int wheel_spd_front_left(const std::uint8_t* bytes,
const int32_t length) const;
};
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/global_rpt_6a_test.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/gem/protocol/global_rpt_6a.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Globalrpt6aTest : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Globalrpt6aTest, reset) {
Globalrpt6a globalrpt;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
globalrpt.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(chassis_detail.global_rpt_6a().pacmod_status(), 1);
EXPECT_DOUBLE_EQ(chassis_detail.global_rpt_6a().override_status(), 0);
EXPECT_DOUBLE_EQ(chassis_detail.global_rpt_6a().veh_can_timeout(), 0);
EXPECT_DOUBLE_EQ(chassis_detail.global_rpt_6a().str_can_timeout(), 0);
EXPECT_DOUBLE_EQ(chassis_detail.global_rpt_6a().brk_can_timeout(), 0);
EXPECT_DOUBLE_EQ(chassis_detail.global_rpt_6a().usr_can_timeout(), 0);
EXPECT_DOUBLE_EQ(chassis_detail.global_rpt_6a().usr_can_read_errors(),
4884);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/wheel_speed_rpt_7a.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/gem/protocol/wheel_speed_rpt_7a.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 gem {
using ::apollo::drivers::canbus::Byte;
Wheelspeedrpt7a::Wheelspeedrpt7a() {}
const int32_t Wheelspeedrpt7a::ID = 0x7A;
void Wheelspeedrpt7a::Parse(const std::uint8_t* bytes, int32_t length,
Gem* chassis) const {
chassis->mutable_wheel_speed_rpt_7a()->set_wheel_spd_rear_right(
wheel_spd_rear_right(bytes, length));
chassis->mutable_wheel_speed_rpt_7a()->set_wheel_spd_rear_left(
wheel_spd_rear_left(bytes, length));
chassis->mutable_wheel_speed_rpt_7a()->set_wheel_spd_front_right(
wheel_spd_front_right(bytes, length));
chassis->mutable_wheel_speed_rpt_7a()->set_wheel_spd_front_left(
wheel_spd_front_left(bytes, length));
}
// config detail: {'name': 'wheel_spd_rear_right', 'offset': 0.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32768|32767]', 'bit': 55, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'rad/s'}
int Wheelspeedrpt7a::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;
int ret = x;
return ret;
}
// config detail: {'name': 'wheel_spd_rear_left', 'offset': 0.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32768|32767]', 'bit': 39, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'rad/s'}
int Wheelspeedrpt7a::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;
int ret = x;
return ret;
}
// config detail: {'name': 'wheel_spd_front_right', 'offset': 0.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32768|32767]', 'bit': 23, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'rad/s'}
int Wheelspeedrpt7a::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;
int ret = x;
return ret;
}
// config detail: {'name': 'wheel_spd_front_left', 'offset': 0.0,
// 'precision': 1.0, 'len': 16, 'is_signed_var': True, 'physical_range':
// '[-32768|32767]', 'bit': 7, 'type': 'int', 'order': 'motorola',
// 'physical_unit': 'rad/s'}
int Wheelspeedrpt7a::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;
x <<= 16;
x >>= 16;
int ret = x;
return ret;
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem
|
apollo_public_repos/apollo/modules/canbus_vehicle/gem/protocol/brake_motor_rpt_3_72_test.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/gem/protocol/brake_motor_rpt_3_72.h"
#include "gtest/gtest.h"
namespace apollo {
namespace canbus {
namespace gem {
class Brakemotorrpt372Test : public ::testing::Test {
public:
virtual void SetUp() {}
};
TEST_F(Brakemotorrpt372Test, reset) {
Brakemotorrpt372 brakermotor3;
int32_t length = 8;
Gem chassis_detail;
uint8_t bytes[8] = {0x01, 0x02, 0x03, 0x04, 0x11, 0x12, 0x13, 0x14};
brakermotor3.Parse(bytes, length, &chassis_detail);
EXPECT_DOUBLE_EQ(chassis_detail.brake_motor_rpt_3_72().torque_output(),
16909.060000000001);
EXPECT_DOUBLE_EQ(chassis_detail.brake_motor_rpt_3_72().torque_input(),
286397.20400000003);
}
} // namespace gem
} // namespace canbus
} // namespace apollo
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.