1- // neural_telemetry_receiver.cpp
21#include < memory>
32#include < string>
3+ #include < utility>
44
55#include " rclcpp/rclcpp.hpp"
6- #include " std_msgs /msg/float32_multi_array .hpp"
6+ #include " argus_core /msg/neural_frame .hpp"
77
88class NeuralTelemetryReceiver : public rclcpp ::Node
99{
@@ -12,17 +12,17 @@ class NeuralTelemetryReceiver : public rclcpp::Node
1212 : Node(" neural_telemetry_receiver" )
1313 {
1414 input_topic_ = this ->declare_parameter <std::string>(
15- " input_topic" , " /argus/neural_interface/telemetry " );
15+ " input_topic" , " /argus/neural_interface_bridge/neural_data " );
1616
1717 output_topic_ = this ->declare_parameter <std::string>(
1818 " output_topic" , " /argus/sensors/neural_telemetry" );
1919
2020 auto qos = rclcpp::SensorDataQoS ();
2121
22- publisher_ = this ->create_publisher <std_msgs ::msg::Float32MultiArray >(
22+ publisher_ = this ->create_publisher <argus_core ::msg::NeuralFrame >(
2323 output_topic_, qos);
2424
25- subscription_ = this ->create_subscription <std_msgs ::msg::Float32MultiArray >(
25+ subscription_ = this ->create_subscription <argus_core ::msg::NeuralFrame >(
2626 input_topic_,
2727 qos,
2828 std::bind (
@@ -38,9 +38,9 @@ class NeuralTelemetryReceiver : public rclcpp::Node
3838 }
3939
4040private:
41- void telemetry_callback (const std_msgs ::msg::Float32MultiArray ::SharedPtr msg)
41+ void telemetry_callback (const argus_core ::msg::NeuralFrame ::SharedPtr msg)
4242 {
43- if (msg->data . empty () ) {
43+ if (msg->channel_count == 0 ) {
4444 RCLCPP_WARN_THROTTLE (
4545 this ->get_logger (),
4646 *this ->get_clock (),
@@ -49,23 +49,30 @@ class NeuralTelemetryReceiver : public rclcpp::Node
4949 return ;
5050 }
5151
52- auto out_msg = std_msgs::msg::Float32MultiArray ();
53- out_msg.layout = msg->layout ;
54- out_msg.data = msg->data ;
52+ if (msg->channel_count > 96 ) {
53+ RCLCPP_WARN_THROTTLE (
54+ this ->get_logger (),
55+ *this ->get_clock (),
56+ 5000 ,
57+ " Received invalid neural telemetry frame: channel_count=%u" ,
58+ msg->channel_count );
59+ return ;
60+ }
5561
56- publisher_->publish (out_msg );
62+ publisher_->publish (*msg );
5763
5864 RCLCPP_DEBUG (
5965 this ->get_logger (),
60- " Republished neural telemetry fram with %zu values" ,
61- out_msg.data .size ());
66+ " Republished neural telemetry frame sample=%u with %u channels" ,
67+ msg->sample ,
68+ msg->channel_count );
6269 }
6370
6471 std::string input_topic_;
6572 std::string output_topic_;
6673
67- rclcpp::Publisher<std_msgs ::msg::Float32MultiArray >::SharedPtr publisher_;
68- rclcpp::Subscription<std_msgs ::msg::Float32MultiArray >::SharedPtr subscription_;
74+ rclcpp::Publisher<argus_core ::msg::NeuralFrame >::SharedPtr publisher_;
75+ rclcpp::Subscription<argus_core ::msg::NeuralFrame >::SharedPtr subscription_;
6976};
7077
7178int main (int argc, char ** argv)
@@ -74,4 +81,4 @@ int main(int argc, char ** argv)
7481 rclcpp::spin (std::make_shared<NeuralTelemetryReceiver>());
7582 rclcpp::shutdown ();
7683 return 0 ;
77- }
84+ }
0 commit comments