File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed
src/network_systems/projects/can_transceiver Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,9 @@ enum class CanId : canid_t {
111111 PRESSURE_14 = 0x13E ,
112112 PRESSURE_SENSOR_END = 0x13F ,
113113 GENERIC_SENSOR_START = 0x140 ,
114- GENERIC_SENSOR_END = 0x1FF
114+ GENERIC_SENSOR_END = 0x1FF ,
115+ DEBUG_START = 0x200 ,
116+ DEBUG_END = 0x2FF
115117};
116118
117119inline bool isValidCanId (canid_t id)
@@ -135,7 +137,9 @@ inline bool isValidCanId(canid_t id)
135137 id <= static_cast <canid_t >(CanId::PRESSURE_SENSOR_END)) ||
136138
137139 (id >= static_cast <canid_t >(CanId::GENERIC_SENSOR_START) &&
138- id <= static_cast <canid_t >(CanId::GENERIC_SENSOR_END));
140+ id <= static_cast <canid_t >(CanId::GENERIC_SENSOR_END)) ||
141+
142+ (id >= static_cast <canid_t >(CanId::DEBUG_START) && id <= static_cast <canid_t >(CanId::DEBUG_END));
139143}
140144
141145/* *
Original file line number Diff line number Diff line change @@ -27,13 +27,21 @@ void CanTransceiver::onNewCanData(const CanFrame & frame) const
2727 return ;
2828 }
2929 CanId id{frame.can_id };
30- if (read_callbacks_.contains (id)) {
31- read_callbacks_.at (id)(frame); // invoke the callback function mapped to id
30+
31+ if (id >= CanId::DEBUG_START && id <= CanId::DEBUG_END) {
32+ // ELEC debug frame, do nothing
33+ return ;
3234 }
3335
3436 // 0x100 - 0x1FF: Generic sensor data frame range
3537 if (id >= CanId::GENERIC_SENSOR_START && id <= CanId::GENERIC_SENSOR_END) {
3638 read_callbacks_.at (CanId::GENERIC_SENSOR_START)(frame);
39+ return ;
40+ }
41+
42+ if (read_callbacks_.contains (id)) {
43+ read_callbacks_.at (id)(frame); // invoke the callback function mapped to id
44+ return ;
3745 }
3846}
3947
Original file line number Diff line number Diff line change @@ -368,9 +368,8 @@ class CanTransceiverIntf : public NetNode
368368 wind_sensor_msg = wind_sensor.toRosMsg ();
369369 wind_sensors_pub_->publish (wind_sensors_);
370370
371- // NUM_WIND_SENSORS is a placeholder,
372- // replace with number of data points wanted in the moving average
373- double k = NUM_WIND_SENSORS;
371+ // Arbitrary number of data points for moving average
372+ double k = 20 ; // NOLINT(readability-magic-numbers)
374373 // convert deg to rad
375374 double angle = wind_sensor_msg.direction * (M_PI / 180.0 ); // NOLINT(readability-magic-numbers)
376375 double y = wind_sensor_msg.speed .speed * sin (angle);
You can’t perform that action at this time.
0 commit comments