///Initializes the mobile node and prepares it for operation. ///Called when this mobile node is booted up. void reboot_mobile() { // We require each node to have a different stream of random numbers. CNET_srand(nodeinfo.time_of_day.sec + nodeinfo.nodenumber); // Provide the required event handlers. CHECK(CNET_set_handler(EV_PHYSICALREADY, physical_ready, 0)); CHECK(CNET_set_handler(EV_APPLICATIONREADY, application_ready, 0)); // Initialize mobility. init_walking(); start_walking(); // Prepare to talk via our wireless connection. CHECK(CNET_set_wlan_model(my_WLAN_model)); // Setup our data link layer instances. dll_states = calloc(nodeinfo.nlinks + 1, sizeof(struct dll_wifi_state *)); for (int link = 1; link <= nodeinfo.nlinks; ++link) { if (linkinfo[link].linktype == LT_WLAN) { dll_states[link] = dll_wifi_new_state(link, up_from_dll, false /* is_ds */); } } isAss = false; timeAPset = false; //CNET TIMEOUT TIMER CHECK(CNET_set_handler( EV_TIMER2, timeouts, 0)); //CNET PROBE TIMER CHECK(CNET_set_handler(EV_TIMER1, probe, 0)); CHECK(CNET_set_handler(EV_TIMER3, probe, 0)); // Start cnet's default application layer. CHECK(CNET_enable_application(ALLNODES)); printf("reboot_mobile() complete.\n"); printf("\t(%s) My address: %" PRId32 ".\n",nodeinfo.nodename, nodeinfo.address); probe_timer = CNET_start_timer(EV_TIMER1, PROBE_START, 0); toSend = (struct nl_packet *)malloc(sizeof(struct nl_packet)); CNET_start_timer(EV_TIMER1, 0, 0); }
void mode2(void) { action_servo(18, 0); action_servo(19, 60); action_servo(20, 170); set_all_servo(ON); servo_onoff(19, ON); servo_onoff(20, ON); deploy_legs(); wait_servo(2); start_walking(0, 40, 40, 300000, 20); for (unsigned int i = 0; i < 20; i++) walk(0, 40, 40, 300000, 20); delay_s(2); set_all_servo(OFF); servo_onoff(19, OFF); servo_onoff(20, OFF); }