int video_display_init() { com_in = jakopter_com_add_channel(CHANNEL_DISPLAY, DISPLAY_COM_IN_SIZE); if(com_in == NULL) { fprintf(stderr, "Display : couldn't create com channel.\n"); return -1; } return 0; }
int visp_init() { com_in = jakopter_com_add_channel(CHANNEL_DISPLAY, VISP_COM_IN_SIZE); if (com_in == NULL) { fprintf(stderr, "[~][Display] Couldn't create com channel in.\n"); return -1; } com_out = jakopter_com_add_channel(CHANNEL_CALLBACK, VISP_COM_OUT_SIZE); if (com_out == NULL) { fprintf(stderr, "[~][Display] Couldn't create com channel out.\n"); return -1; } jakopter_com_write_float(com_out, 0, 0.0); jakopter_com_write_float(com_out, 4, 0.0); jakopter_com_write_float(com_out, 8, 0.0); prev_update = 0; return 0; }
int video_display_init() { com_in = jakopter_com_add_channel(CHANNEL_DISPLAY, DISPLAY_COM_IN_SIZE); if (com_in == NULL) { fprintf(stderr, "[~][Display] Couldn't create com channel.\n"); return -1; } com_out = jakopter_com_add_channel(CHANNEL_CALLBACK, DISPLAY_COM_OUT_SIZE); if (com_out == NULL) { fprintf(stderr, "[~][Display] Couldn't create com channel out.\n"); return -1; } jakopter_com_write_float(com_out, 0, 0.0); jakopter_com_write_int(com_in, 28, -1); jakopter_com_write_int(com_in, 32, -1); jakopter_com_write_int(com_in, 36, -1); jakopter_com_write_int(com_in, 40, -1); prev_update = 0; return 0; }
/** * \brief Start navdata thread * \return 0 if success, -1 if error */ int navdata_connect() { if (!stopped_navdata) return -1; addr_drone_navdata.sin_family = AF_INET; addr_drone_navdata.sin_addr.s_addr = inet_addr(WIFI_ARDRONE_IP); addr_drone_navdata.sin_port = htons(PORT_NAVDATA); addr_client_navdata.sin_family = AF_INET; addr_client_navdata.sin_addr.s_addr = htonl(INADDR_ANY); addr_client_navdata.sin_port = htons(PORT_NAVDATA); sock_navdata = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sock_navdata < 0) { fprintf(stderr, "[~][navdata] Can't establish socket \n"); return -1; } if (bind(sock_navdata, (struct sockaddr*)&addr_client_navdata, sizeof(addr_client_navdata)) < 0) { fprintf(stderr, "[~][navdata] Can't bind socket to port %d\n", PORT_NAVDATA); return -1; } nav_channel = jakopter_com_add_channel(CHANNEL_NAVDATA, sizeof(data)); if (navdata_init() < 0) { perror("[~][navdata] Init sequence failed"); return -1; } pthread_mutex_lock(&mutex_stopped); stopped_navdata = false; pthread_mutex_unlock(&mutex_stopped); if(pthread_create(&navdata_thread, NULL, navdata_routine, NULL) < 0) { perror("[~][navdata] Can't create thread"); return -1; } return 0; }