19#include "glog/logging.h"
28using ::apollo::drivers::canbus::Byte;
37 static const uint32_t PERIOD = 20 * 1000;
43 chassis->mutable_throttle_command_100()->set_throttle_en_ctrl(
44 throttle_en_ctrl(bytes, length));
45 chassis->mutable_throttle_command_100()->set_throttle_acc(
46 throttle_acc(bytes, length));
47 chassis->mutable_throttle_command_100()->set_throttle_pedal_target(
48 throttle_pedal_target(bytes, length));
49 chassis->mutable_throttle_command_100()->set_speed_target(
50 speed_target(bytes, length));
51 chassis->mutable_throttle_command_100()->set_checksum_100(
52 checksum_100(bytes, length));
56 set_p_speed_target(data, speed_target_);
57 set_p_throttle_acc(data, throttle_acc_);
58 set_p_throttle_pedal_target(data, throttle_pedal_target_);
59 set_p_throttle_en_ctrl(data, throttle_en_ctrl_);
61 data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6];
62 set_p_checksum_100(data, checksum_100_);
69 throttle_pedal_target_ = 0.0;
76 throttle_en_ctrl_ = throttle_en_ctrl;
84void Throttlecommand100::set_p_throttle_en_ctrl(
87 int x = throttle_en_ctrl;
89 Byte to_set(data + 0);
90 to_set.set_value(x, 0, 1);
94 throttle_acc_ = throttle_acc;
101void Throttlecommand100::set_p_throttle_acc(uint8_t* data,
102 double throttle_acc) {
103 throttle_acc = ProtocolData::BoundedValue(0.0, 10.0, throttle_acc);
104 int x = throttle_acc / 0.010000;
108 Byte to_set0(data + 2);
109 to_set0.set_value(t, 6, 2);
113 Byte to_set1(data + 1);
114 to_set1.set_value(t, 0, 8);
118 double throttle_pedal_target) {
119 throttle_pedal_target_ = throttle_pedal_target;
126void Throttlecommand100::set_p_throttle_pedal_target(
127 uint8_t* data,
double throttle_pedal_target) {
128 throttle_pedal_target =
129 ProtocolData::BoundedValue(0.0, 100.0, throttle_pedal_target);
130 int x = throttle_pedal_target / 0.100000;
134 Byte to_set0(data + 4);
135 to_set0.set_value(t, 0, 8);
139 Byte to_set1(data + 3);
140 to_set1.set_value(t, 0, 8);
144 speed_target_ = speed_target;
151void Throttlecommand100::set_p_speed_target(uint8_t* data,
152 double speed_target) {
153 speed_target = ProtocolData::BoundedValue(0.0, 10.23, speed_target);
154 int x = speed_target / 0.010000;
158 Byte to_set0(data + 6);
159 to_set0.set_value(t, 6, 2);
163 Byte to_set1(data + 5);
164 to_set1.set_value(t, 0, 8);
168 checksum_100_ = checksum_100;
175void Throttlecommand100::set_p_checksum_100(uint8_t* data,
int checksum_100) {
176 checksum_100 = ProtocolData::BoundedValue(0, 255, checksum_100);
177 int x = checksum_100;
179 Byte to_set(data + 7);
180 to_set.set_value(x, 0, 8);
184 const std::uint8_t* bytes, int32_t length)
const {
186 int32_t x = t0.get_byte(0, 1);
193double Throttlecommand100::throttle_acc(
const std::uint8_t* bytes,
194 int32_t length)
const {
196 int32_t x = t0.get_byte(0, 8);
199 int32_t t = t1.get_byte(6, 2);
203 double ret = x * 0.01;
207double Throttlecommand100::throttle_pedal_target(
const std::uint8_t* bytes,
208 int32_t length)
const {
210 int32_t x = t0.get_byte(0, 8);
213 int32_t t = t1.get_byte(0, 8);
217 double ret = x * 0.100000;
221double Throttlecommand100::speed_target(
const std::uint8_t* bytes,
222 int32_t length)
const {
224 int32_t x = t0.get_byte(0, 8);
227 int32_t t = t1.get_byte(6, 2);
231 double ret = x * 0.100000;
235int Throttlecommand100::checksum_100(
const std::uint8_t* bytes,
236 int32_t length)
const {
238 int32_t x = t0.get_byte(0, 8);
Throttlecommand100 * set_speed_target(double speed_target)
void UpdateData(uint8_t *data) override
Throttlecommand100 * set_throttle_en_ctrl(Throttle_command_100::Throttle_en_ctrlType throttle_en_ctrl)
uint32_t GetPeriod() const override
Throttlecommand100 * set_throttle_acc(double throttle_acc)
Throttlecommand100 * set_checksum_100(int checksum_100)
void Parse(const std::uint8_t *bytes, int32_t length, Devkit *chassis) const override
Throttlecommand100 * set_throttle_pedal_target(double throttle_pedal_target)
@ THROTTLE_EN_CTRL_DISABLE