MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / main

Function main

opt_utils/apps/ros2udp_converter_objects.cpp:202–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202int
203main(int argc, char **argv)
204{
205 // Initialization:
206 ros::init(argc, argv, "ros2udp_converter");
207 ros::NodeHandle nh("~");
208
209 // Read input parameters:
210 nh.param("udp/port", udp_port, 21234);
211 nh.param("udp/hostip", hostip, std::string("127.0.0.1"));
212 nh.param("udp/buffer_length", udp_buffer_length, 4096); //temporary fix until we can convert to the other approach
213 nh.param("json/indent_size", json_indent_size, 0);
214 nh.param("json/newline", json_newline, false);
215 nh.param("json/spacing", json_spacing, false);
216 nh.param("json/use_tabs", json_use_tabs, false);
217 nh.param("json/heartbeat_interval", heartbeat_interval, 0.25);
218
219
220 // ROS subscriber:
221 ros::Subscriber tracking_sub = nh.subscribe<opt_msgs::TrackArray>("input_topic", 1, trackingCallback);
222
223 ros::Subscriber alive_ids_sub = nh.subscribe<opt_msgs::IDArray>("alive_ids_topic", 1, aliveIDsCallback);
224
225
226 // Initialize UDP parameters:
227 char buf[0];
228 udp_data.si_port_ = udp_port; // port
229 udp_data.si_retry_ = 1;
230 udp_data.si_num_byte_ = udp_buffer_length; // number of bytes to write (2048 -> about 30 tracks)
231 udp_data.pc_pck_ = buf; // buffer where the message is written
232 udp_data.si_timeout_ = 4;
233 udp_data.sj_addr_ = Inet_AtoN(hostip.c_str());
234
235 /// Create object for UDP messaging:
236 udp_messaging = open_ptrack::opt_utils::UDPMessaging(udp_data);
237
238 /// Create client socket:
239 udp_messaging.createSocketClientUDP(&udp_data);
240
241 // Execute callbacks:
242 ros::spin();
243
244 // Close socket:
245 udp_messaging.closeSocketUDP(&udp_data);
246
247 return 0;
248}
249

Callers

nothing calls this directly

Calls 4

UDPMessagingClass · 0.85
createSocketClientUDPMethod · 0.80
closeSocketUDPMethod · 0.80
Inet_AtoNFunction · 0.70

Tested by

no test coverage detected