25using ::apollo::drivers::canbus::Byte;
34 static const uint32_t PERIOD = 20 * 1000;
40 chassis->mutable_ads_eps_command_56()->set_drive_enable(
41 drive_enable(bytes, length));
42 chassis->mutable_ads_eps_command_56()->set_auto_target_angle(
43 auto_target_angle(bytes, length));
47 set_p_drive_enable(data, drive_enable_);
48 set_p_auto_target_angle(data, auto_target_angle_);
49 ++auto_drivercmd_alivecounter_;
50 auto_drivercmd_alivecounter_ = (auto_drivercmd_alivecounter_) % 16;
51 set_p_auto_drivercmd_alivecounter(data, auto_drivercmd_alivecounter_);
52 auto_drivercmd_checksum_ =
53 data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6];
54 set_p_auto_drivercmd_checksum(data, auto_drivercmd_checksum_);
59 drive_enable_ =
false;
60 auto_target_angle_ = 0.0;
61 auto_drivercmd_alivecounter_ = 0;
62 auto_drivercmd_checksum_ = 0;
66 drive_enable_ = drive_enable;
74void Adsepscommand56::set_p_drive_enable(uint8_t* data,
bool drive_enable) {
77 Byte to_set(data + 0);
78 to_set.set_value(x, 0, 1);
81bool Adsepscommand56::drive_enable(
const std::uint8_t* bytes,
82 int32_t length)
const {
84 int32_t x = t0.get_byte(0, 1);
91 double auto_target_angle) {
92 auto_target_angle_ = -auto_target_angle;
99void Adsepscommand56::set_p_auto_target_angle(uint8_t* data,
100 double auto_target_angle) {
102 ProtocolData::BoundedValue(-380.0, 380.0, auto_target_angle);
103 int x = (auto_target_angle - -2048.000000) / 0.062500;
107 Byte to_set0(data + 3);
108 to_set0.set_value(t, 0, 8);
112 Byte to_set1(data + 2);
113 to_set1.set_value(t, 0, 8);
116double Adsepscommand56::auto_target_angle(
const std::uint8_t* bytes,
117 int32_t length)
const {
119 int32_t x = t0.get_byte(0, 8);
122 int32_t t = t1.get_byte(0, 8);
126 double ret = 0.0625 * x + -2048;
131 int auto_drivercmd_alivecounter) {
132 auto_drivercmd_alivecounter_ = auto_drivercmd_alivecounter;
139void Adsepscommand56::set_p_auto_drivercmd_alivecounter(
140 uint8_t* data,
int auto_drivercmd_alivecounter) {
141 auto_drivercmd_alivecounter =
142 ProtocolData::BoundedValue(0, 15, auto_drivercmd_alivecounter);
143 int x = auto_drivercmd_alivecounter;
145 Byte to_set(data + 6);
146 to_set.set_value(x, 0, 4);
150 int auto_drivercmd_checksum) {
151 auto_drivercmd_checksum_ = auto_drivercmd_checksum;
158void Adsepscommand56::set_p_auto_drivercmd_checksum(
159 uint8_t* data,
int auto_drivercmd_checksum) {
160 auto_drivercmd_checksum =
161 ProtocolData::BoundedValue(0, 255, auto_drivercmd_checksum);
162 int x = auto_drivercmd_checksum;
164 Byte to_set(data + 7);
165 to_set.set_value(x, 0, 8);
Adsepscommand56 * set_auto_drivercmd_alivecounter(int auto_drivercmd_alivecounter)
uint32_t GetPeriod() const override
void UpdateData(uint8_t *data) override
void Parse(const std::uint8_t *bytes, int32_t length, Neolix_edu *chassis) const override
Adsepscommand56 * set_auto_drivercmd_checksum(int auto_drivercmd_checksum)
Adsepscommand56 * set_drive_enable(bool drive_enable)
Adsepscommand56 * set_auto_target_angle(double auto_target_angle)