25using ::apollo::drivers::canbus::Byte;
34 static const uint32_t PERIOD = 20 * 1000;
39 Demo* chassis)
const {
40 chassis->mutable_throttle_command_100()->set_heartbeat_100(
41 heartbeat_100(bytes, length));
42 chassis->mutable_throttle_command_100()->set_speed_target(
43 speed_target(bytes, length));
44 chassis->mutable_throttle_command_100()->set_throttle_acc(
45 throttle_acc(bytes, length));
46 chassis->mutable_throttle_command_100()->set_checksum_100(
47 checksum_100(bytes, length));
48 chassis->mutable_throttle_command_100()->set_throttle_pedal_target(
49 throttle_pedal_target(bytes, length));
50 chassis->mutable_throttle_command_100()->set_throttle_en_ctrl(
51 throttle_en_ctrl(bytes, length));
57 heartbeat_100_ = (heartbeat_100_) % 16;
58 set_p_heartbeat_100(data, heartbeat_100_);
60 data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6];
61 set_p_checksum_100(data, checksum_100_);
65 set_p_heartbeat_100(data, heartbeat_100_);
66 set_p_throttle_acc(data, throttle_acc_);
67 set_p_throttle_pedal_target(data, throttle_pedal_target_);
68 set_p_throttle_en_ctrl(data, throttle_en_ctrl_);
77 throttle_pedal_target_ = 0.0;
82 heartbeat_100_ = heartbeat_100;
89void Throttlecommand100::set_p_heartbeat_100(uint8_t* data,
int heartbeat_100) {
90 heartbeat_100 = ProtocolData::BoundedValue(0, 15, heartbeat_100);
91 int x = heartbeat_100;
93 Byte to_set(data + 0);
94 to_set.set_value(x, 4, 4);
98 speed_target_ = speed_target;
105void Throttlecommand100::set_p_speed_target(uint8_t* data,
106 double speed_target) {
107 speed_target = ProtocolData::BoundedValue(0.0, 40.95, speed_target);
108 int x = speed_target / 0.010000;
112 Byte to_set0(data + 6);
113 to_set0.set_value(t, 4, 4);
117 Byte to_set1(data + 5);
118 to_set1.set_value(t, 0, 8);
122 throttle_acc_ = throttle_acc;
129void Throttlecommand100::set_p_throttle_acc(uint8_t* data,
130 double throttle_acc) {
131 throttle_acc = ProtocolData::BoundedValue(0.0, 10.0, throttle_acc);
132 int x = throttle_acc / 0.010000;
136 Byte to_set0(data + 2);
137 to_set0.set_value(t, 6, 2);
141 Byte to_set1(data + 1);
142 to_set1.set_value(t, 0, 8);
146 checksum_100_ = checksum_100;
153void Throttlecommand100::set_p_checksum_100(uint8_t* data,
int checksum_100) {
154 checksum_100 = ProtocolData::BoundedValue(0, 255, checksum_100);
155 int x = checksum_100;
157 Byte to_set(data + 7);
158 to_set.set_value(x, 0, 8);
162 double throttle_pedal_target) {
163 throttle_pedal_target_ = throttle_pedal_target;
171void Throttlecommand100::set_p_throttle_pedal_target(
172 uint8_t* data,
double throttle_pedal_target) {
173 throttle_pedal_target =
174 ProtocolData::BoundedValue(0.0, 100.0, throttle_pedal_target);
175 int x = throttle_pedal_target / 0.100000;
179 Byte to_set0(data + 4);
180 to_set0.set_value(t, 0, 8);
184 Byte to_set1(data + 3);
185 to_set1.set_value(t, 0, 8);
190 throttle_en_ctrl_ = throttle_en_ctrl;
199void Throttlecommand100::set_p_throttle_en_ctrl(
202 int x = throttle_en_ctrl;
204 Byte to_set(data + 0);
205 to_set.set_value(x, 0, 1);
208int Throttlecommand100::heartbeat_100(
const std::uint8_t* bytes,
209 int32_t length)
const {
211 int32_t x = t0.get_byte(4, 4);
217double Throttlecommand100::speed_target(
const std::uint8_t* bytes,
218 int32_t length)
const {
220 int32_t x = t0.get_byte(0, 8);
223 int32_t t = t1.get_byte(4, 4);
227 double ret = x * 0.010000;
231double Throttlecommand100::throttle_acc(
const std::uint8_t* bytes,
232 int32_t length)
const {
234 int32_t x = t0.get_byte(0, 8);
237 int32_t t = t1.get_byte(6, 2);
241 double ret = x * 0.010000;
245int Throttlecommand100::checksum_100(
const std::uint8_t* bytes,
246 int32_t length)
const {
248 int32_t x = t0.get_byte(0, 8);
254double Throttlecommand100::throttle_pedal_target(
const std::uint8_t* bytes,
255 int32_t length)
const {
257 int32_t x = t0.get_byte(0, 8);
260 int32_t t = t1.get_byte(0, 8);
264 double ret = x * 0.100000;
269 const std::uint8_t* bytes, int32_t length)
const {
271 int32_t x = t0.get_byte(0, 1);
void UpdateData_Heartbeat(uint8_t *data) override
Throttlecommand100 * set_heartbeat_100(int heartbeat_100)
Throttlecommand100 * set_throttle_en_ctrl(Throttle_command_100::Throttle_en_ctrlType throttle_en_ctrl)
void Parse(const std::uint8_t *bytes, int32_t length, Demo *chassis) const override
void UpdateData(uint8_t *data) override
uint32_t GetPeriod() const override
Throttlecommand100 * set_throttle_pedal_target(double throttle_pedal_target)
Throttlecommand100 * set_checksum_100(int checksum_100)
Throttlecommand100 * set_speed_target(double speed_target)
Throttlecommand100 * set_throttle_acc(double throttle_acc)
@ THROTTLE_EN_CTRL_DISABLE