MCPcopy Create free account
hub / github.com/CopterExpress/clover / main

Function main

clover/src/led.cpp:297–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297int main(int argc, char **argv)
298{
299 ros::init(argc, argv, "led");
300 ros::NodeHandle nh, nh_priv("~");
301
302 nh_priv.param("blink_rate", blink_rate, 2.0);
303 nh_priv.param("blink_fast_rate", blink_fast_rate, blink_rate * 2);
304 nh_priv.param("fade_period", fade_period, 0.5);
305 nh_priv.param("wipe_period", wipe_period, 0.5);
306 nh_priv.param("flash_delay", flash_delay, 0.1);
307 nh_priv.param("rainbow_period", rainbow_period, 5.0);
308
309 nh_priv.param("notify/low_battery/threshold", low_battery_threshold, 3.7);
310 nh_priv.param("notify/error/ignore", error_ignore, {});
311
312 std::string led; // led namespace
313 nh_priv.param("led", led, std::string("led"));
314 if (!led.empty()) led += "/";
315
316 ros::service::waitForService(led + "set_leds"); // cannot work without set_leds service
317 set_leds_srv = nh.serviceClient<led_msgs::SetLEDs>(led + "set_leds", true);
318
319 // wait for leds count info
320 handleState(*ros::topic::waitForMessage<led_msgs::LEDStateArray>(led + "state", nh));
321
322 auto state_sub = nh.subscribe(led + "state", 1, &handleState);
323
324 auto set_effect = nh.advertiseService(led + "set_effect", &setEffect);
325
326 auto mavros_state_sub = nh.subscribe("mavros/state", 1, &handleMavrosState);
327 auto battery_sub = nh.subscribe("mavros/battery", 1, &handleBattery);
328 auto rosout_sub = nh.subscribe("/rosout_agg", 1, &handleLog);
329
330 timer = nh.createTimer(ros::Duration(0), &proceed, false, false);
331
332 ROS_INFO("ready");
333 notify("startup");
334 ros::spin();
335}

Callers

nothing calls this directly

Calls 4

handleStateFunction · 0.70
notifyFunction · 0.70
initFunction · 0.50
subscribeMethod · 0.45

Tested by

no test coverage detected