25using ::apollo::drivers::canbus::Byte;
34 static const uint32_t PERIOD = 20 * 1000;
40 chassis->mutable_ads_drive_command_50()->set_drive_enable(
41 drive_enable(bytes, length));
42 chassis->mutable_ads_drive_command_50()->set_auto_shift_command(
43 auto_shift_command(bytes, length));
44 chassis->mutable_ads_drive_command_50()->set_auto_drive_torque(
45 auto_drive_torque(bytes, length));
49 set_p_drive_enable(data, drive_enable_);
50 set_p_auto_shift_command(data, auto_shift_command_);
51 set_p_auto_drive_torque(data, auto_drive_torque_);
52 ++auto_drivercmd_alivecounter_;
53 auto_drivercmd_alivecounter_ = (auto_drivercmd_alivecounter_) % 16;
54 set_p_auto_drivercmd_alivecounter(data, auto_drivercmd_alivecounter_);
55 auto_drivercmd_checksum_ =
56 data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6];
57 set_p_auto_drivercmd_checksum(data, auto_drivercmd_checksum_);
62 drive_enable_ =
false;
64 auto_drive_torque_ = 0.0;
65 auto_drivercmd_alivecounter_ = 0;
66 auto_drivercmd_checksum_ = 0;
70 drive_enable_ = drive_enable;
78void Adsdrivecommand50::set_p_drive_enable(uint8_t* data,
bool drive_enable) {
81 Byte to_set(data + 0);
82 to_set.set_value(x, 0, 1);
85bool Adsdrivecommand50::drive_enable(
const std::uint8_t* bytes,
86 int32_t length)
const {
88 int32_t x = t0.get_byte(0, 1);
96 auto_shift_command_ = auto_shift_command;
106void Adsdrivecommand50::set_p_auto_shift_command(
109 int x = auto_shift_command;
111 Byte to_set(data + 1);
112 to_set.set_value(x, 0, 2);
116Adsdrivecommand50::auto_shift_command(
const std::uint8_t* bytes,
117 int32_t length)
const {
119 int32_t x = t0.get_byte(0, 2);
127 double auto_drive_torque) {
128 auto_drive_torque_ = auto_drive_torque;
135void Adsdrivecommand50::set_p_auto_drive_torque(uint8_t* data,
136 double auto_drive_torque) {
137 auto_drive_torque = ProtocolData::BoundedValue(0.0, 50.0, auto_drive_torque);
138 int x = (auto_drive_torque - -665.000000) / 0.020000;
142 Byte to_set0(data + 3);
143 to_set0.set_value(t, 0, 8);
147 Byte to_set1(data + 2);
148 to_set1.set_value(t, 0, 8);
151double Adsdrivecommand50::auto_drive_torque(
const std::uint8_t* bytes,
152 int32_t length)
const {
154 int32_t x = t0.get_byte(0, 8);
157 int32_t t = t1.get_byte(0, 8);
161 double ret = (x * 0.020000) + -665.000000;
166 int auto_drivercmd_alivecounter) {
167 auto_drivercmd_alivecounter_ = auto_drivercmd_alivecounter;
174void Adsdrivecommand50::set_p_auto_drivercmd_alivecounter(
175 uint8_t* data,
int auto_drivercmd_alivecounter) {
176 auto_drivercmd_alivecounter =
177 ProtocolData::BoundedValue(0, 15, auto_drivercmd_alivecounter);
178 int x = auto_drivercmd_alivecounter;
180 Byte to_set(data + 6);
181 to_set.set_value(x, 0, 4);
185 int auto_drivercmd_checksum) {
186 auto_drivercmd_checksum_ = auto_drivercmd_checksum;
193void Adsdrivecommand50::set_p_auto_drivercmd_checksum(
194 uint8_t* data,
int auto_drivercmd_checksum) {
195 auto_drivercmd_checksum =
196 ProtocolData::BoundedValue(0, 255, auto_drivercmd_checksum);
197 int x = auto_drivercmd_checksum;
199 Byte to_set(data + 7);
200 to_set.set_value(x, 0, 8);
void UpdateData(uint8_t *data) override
Adsdrivecommand50 * set_auto_drive_torque(double auto_drive_torque)
Adsdrivecommand50 * set_auto_drivercmd_alivecounter(int auto_drivercmd_alivecounter)
Adsdrivecommand50 * set_auto_shift_command(Ads_drive_command_50::Auto_shift_commandType auto_shift_command)
void Parse(const std::uint8_t *bytes, int32_t length, Neolix_edu *chassis) const override
Adsdrivecommand50 * set_drive_enable(bool drive_enable)
uint32_t GetPeriod() const override
Adsdrivecommand50 * set_auto_drivercmd_checksum(int auto_drivercmd_checksum)