main (int argc, char**argv) { /* handling of -b option */ const char* bus = 0; char c; while (c = getopt (argc, argv, "b:") != EOF) { switch (c) { case 'b': bus = optarg; break; } } /* handling of environment variable */ if (!bus) bus = getenv ("IVYBUS"); /* initializations */ IvyInit ("IvyTranslater", "Hello le monde", 0, 0, 0, 0); IvyStart (bus); /* binding of HelloCallback to messages starting with 'Hello' */ IvyBindMsg (HelloCallback, 0, "^Hello(.*)"); /* binding of ByeCallback to 'Bye' */ IvyBindMsg (ByeCallback, 0, "^Bye$"); /* main loop */ IvyMainLoop(); }
int main(int argc, char **argv) { double angular_velocity_covariance, angular_velocity_stdev; double linear_acceleration_covariance, linear_acceleration_stdev; double orientation_covariance, orientation_stdev; std::string frame_id; // Initializing ROS ros::init(argc, argv, "imu"); ros::NodeHandle nh("~"); imu_message = nh.advertise<sensor_msgs::Imu>("data", 10); att_message = nh.advertise<sensor_msgs::Imu>("att", 10); mag_message = nh.advertise<geometry_msgs::Vector3Stamped>("mag", 10); acc_message = nh.advertise<geometry_msgs::Vector3Stamped>("acc", 10); // Getting Parameters nh.param<std::string>("frame_id", frame_id, "imu"); imu_data.header.frame_id = frame_id; mag_data.header.frame_id = frame_id; nh.param("linear_acceleration_stdev", linear_acceleration_stdev, 0.0); nh.param("orientation_stdev", orientation_stdev, 0.0); nh.param("angular_velocity_stdev", angular_velocity_stdev, 0.0); angular_velocity_covariance = pow(angular_velocity_stdev,2); orientation_covariance = pow(orientation_stdev,2); linear_acceleration_covariance = pow(linear_acceleration_stdev,2); // Fill IMU Message with covariances imu_data.linear_acceleration_covariance[0] = linear_acceleration_covariance; imu_data.linear_acceleration_covariance[4] = linear_acceleration_covariance; imu_data.linear_acceleration_covariance[8] = linear_acceleration_covariance; imu_data.angular_velocity_covariance[0] = angular_velocity_covariance; imu_data.angular_velocity_covariance[4] = angular_velocity_covariance; imu_data.angular_velocity_covariance[8] = angular_velocity_covariance; imu_data.orientation_covariance[0] = orientation_covariance; imu_data.orientation_covariance[4] = orientation_covariance; imu_data.orientation_covariance[8] = orientation_covariance; // Initializing Ivy IvyInit ("imu_parser", "'Imu Parser' is READY!", 0, 0, 0, 0); IvyStart("127.255.255.255"); TimerRepeatAfter (TIMER_LOOP, 500, ROSCallback, 0); // Binding Messages IvyBindMsg(ATTCallback, 0, "BOOZ2_AHRS_EULER(.*)"); IvyBindMsg(GYROCallback, 0, "IMU_GYRO_SCALED(.*)"); IvyBindMsg(ACCELCallback, 0, "IMU_ACCEL_SCALED(.*)"); IvyBindMsg(MAGCallback, 0, "IMU_MAG_SCALED(.*)"); ROS_INFO("IMU: Starting Aquisition Loop"); IvyMainLoop(); return 0; }
void nps_ivy_init(void) { const char* agent_name = AIRFRAME_NAME"_NPS"; const char* ready_msg = AIRFRAME_NAME"_NPS Ready"; IvyInit(agent_name, ready_msg, NULL, NULL, NULL, NULL); IvyBindMsg(on_DL_PING, NULL, "^(\\S*) DL_PING"); IvyBindMsg(on_DL_SETTING, NULL, "^(\\S*) DL_SETTING (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_GET_SETTING, NULL, "^(\\S*) DL_GET_SETTING (\\S*) (\\S*)"); IvyBindMsg(on_DL_BLOCK, NULL, "^(\\S*) BLOCK (\\S*) (\\S*)"); IvyBindMsg(on_DL_MOVE_WP, NULL, "^(\\S*) MOVE_WP (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyStart("127.255.255.255"); }
void calibrator_init(void) { IvyInit ("IrCalib", "IrCalib READY", NULL, NULL, NULL, NULL); IvyBindMsg(on_Attitude, NULL, "^(\\S*) ATTITUDE (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_GPS, NULL, "^(\\S*) GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_Wind, NULL, "^(\\S*) WIND (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_IrSensors, NULL, "^(\\S*) IR_SENSORS (\\S*) (\\S*) (\\S*)"); IvyStart("127.255.255.255"); reset_average(); }
void nps_ivy_init(char* ivy_bus) { /* init ivy and bind some messages common to fw and rotorcraft */ nps_ivy_common_init(ivy_bus); IvyBindMsg(on_DL_MOVE_WP, NULL, "^(\\S*) MOVE_WP (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); //Get the commands from the Autopilot for this simulation IvyBindMsg(on_NPS_ATP_CMD, NULL, "^NPS_ATP_CMD(.*)"); //Get the standard commands from the Autopilot for this simulation IvyBindMsg(on_COMMANDS, NULL, "^\\S* COMMANDS (\\S*)"); }
int main (int argc, char** argv) { gtk_init(&argc, &argv); GtkWidget* window = build_gui(); gtk_widget_show_all(window); IvyInit ("AntennaTracker", "AntennaTracker READY", NULL, NULL, NULL, NULL); IvyBindMsg(on_GPS_STATUS, NULL, "^\\S* GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_NAV_STATUS, NULL, "^\\S* NAVIGATION (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyStart("127.255.255.255"); gtk_main(); return 0; }
static int IvyBindCmd(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv) { filter_struct *filter; Tcl_HashEntry *entry; int dummy; char msg[INTEGER_SPACE]; if (argc != 3) { Tcl_AppendResult(interp, "wrong # of args: \"", argv[0], " filter script\"", (char *) NULL); return TCL_ERROR; } filter = (filter_struct *) ckalloc(sizeof(filter_struct)); filter->filter = ckalloc(strlen(argv[1])+1); /* regexp */ strcpy(filter->filter, argv[1]); filter->script = ckalloc(strlen(argv[2])+1); /* callback proc name */ strcpy(filter->script, argv[2]); filter->id = IvyBindMsg(IvyMsgCB, (void *) filter, filter->filter, NULL); /* MsgPtr id */ filter->interp = interp; entry = Tcl_CreateHashEntry(&filter_table, (char *) (long) filter_id, &dummy); Tcl_SetHashValue(entry, (ClientData) filter); sprintf(msg, "%d", filter_id); filter_id++; Tcl_SetResult(interp, msg, TCL_VOLATILE); return TCL_OK; }
void nps_ivy_init(char* ivy_bus) { /* init ivy and bind some messages common to fw and rotorcraft */ nps_ivy_common_init(ivy_bus); IvyBindMsg(on_DL_MOVE_WP, NULL, "^(\\S*) MOVE_WP (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); }
void nps_ivy_init(char* ivy_bus) { const char* agent_name = AIRFRAME_NAME"_NPS"; const char* ready_msg = AIRFRAME_NAME"_NPS Ready"; IvyInit(agent_name, ready_msg, NULL, NULL, NULL, NULL); IvyBindMsg(on_DL_PING, NULL, "^(\\S*) DL_PING"); IvyBindMsg(on_DL_SETTING, NULL, "^(\\S*) DL_SETTING (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_GET_SETTING, NULL, "^(\\S*) GET_DL_SETTING (\\S*) (\\S*)"); IvyBindMsg(on_DL_BLOCK, NULL, "^(\\S*) BLOCK (\\S*) (\\S*)"); IvyBindMsg(on_DL_MOVE_WP, NULL, "^(\\S*) MOVE_WP (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); #ifdef RADIO_CONTROL_TYPE_DATALINK IvyBindMsg(on_DL_RC_3CH, NULL, "^(\\S*) RC_3CH (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_RC_4CH, NULL, "^(\\S*) RC_4CH (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); #endif #ifdef __APPLE__ const char* default_ivy_bus = "224.255.255.255"; #else const char* default_ivy_bus = "127.255.255.255"; #endif if (ivy_bus == NULL) { IvyStart(default_ivy_bus); } else { IvyStart(ivy_bus); } }
int main (int argc, char** argv) { gtk_init(&argc, &argv); GtkWidget* window = build_gui(); gtk_widget_show_all(window); IvyInit ("MotorBench", "MotorBench READY", NULL, NULL, NULL, NULL); IvyBindMsg(on_MOTOR_BENCH_STATUS, NULL, "^\\S* MOTOR_BENCH_STATUS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_MOTOR_BENCH_STATIC, NULL, "^\\S* MOTOR_BENCH_STATIC (\\S*) (\\S*) (\\S*) (\\S*)"); IvyStart("127.255.255.255"); g_timeout_add(40, timeout_callback, NULL); mb_state.log_channel = NULL; gtk_main(); return 0; }
int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *button; GtkWidget *box1; char *bus=getenv("IVYBUS"); gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(window), 10); gtk_window_set_title (GTK_WINDOW (window), "River Tracking"); box1 = gtk_hbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), box1); //first button... button = gtk_button_new_with_label("(Re)define region of interest"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(init_river_tracking), 0); gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0); gtk_widget_show (button); //second button... button = gtk_button_new_with_label("Quit"); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(destroy), 0); gtk_box_pack_start(GTK_BOX (box1), button, TRUE, TRUE, 0); gtk_widget_show (button); gtk_widget_show(box1); gtk_widget_show(window); IvyInit("river_track", "river_track READY", NULL, NULL, NULL, NULL); IvyBindMsg(textCallback,0,"^river_track hello(.*)"); IvyBindMsg(start_track,0,"(NAV_STATUS 1 1 +.*)"); IvyBindMsg(set_end,0,"(WAYPOINT_MOVED 1 5 +.*)"); IvyStart(bus); gtk_main(); return 0; }
void nps_ivy_init(char *ivy_bus) { const char *agent_name = AIRFRAME_NAME"_NPS"; const char *ready_msg = AIRFRAME_NAME"_NPS Ready"; IvyInit(agent_name, ready_msg, NULL, NULL, NULL, NULL); // bind on a general WORLD_ENV (not a reply to request) IvyBindMsg(on_WORLD_ENV, NULL, "^(\\S*) WORLD_ENV (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); // to be able to change datalink_enabled setting back on IvyBindMsg(on_DL_SETTING, NULL, "^(\\S*) DL_SETTING (\\S*) (\\S*) (\\S*)"); #ifdef __APPLE__ const char *default_ivy_bus = "224.255.255.255"; #else const char *default_ivy_bus = "127.255.255.255"; #endif if (ivy_bus == NULL) { IvyStart(default_ivy_bus); } else { IvyStart(ivy_bus); } }
int main ( int argc, char** argv) { if (argc < 2) { fprintf(stderr, "USE: mavlink-ivy-interface IP \n"); return -1; } fprintf(stderr,"mavlink-ivy-interface forwarding to '%s' \n",argv[1]); udp_init(argv[1]); GMainLoop *ml = g_main_loop_new(NULL, FALSE); IvyInit ("mavlink-ivy-interface", "mavlink-ivy-interface READY", NULL, NULL, NULL, NULL); IvyBindMsg(on_Attitude, NULL, "^(\\S*) ATTITUDE (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_Gps, NULL, "^(\\S*) GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyStart("127.255.255.255"); g_main_loop_run(ml); return 0; }
int main(int argc,char *argv[]){ Widget toplevel,pushb; XtAppContext app_context; Arg myargs[10]; char *bus=getenv("IVYBUS"); char *tosend="foo"; toplevel=XtAppInitialize(&app_context,"Ivy Button",NULL,0,&argc,argv,NULL,myargs,0); pushb=XmCreatePushButton(toplevel,"send message",myargs,1); XtManageChild(pushb); XtAddCallback(pushb,XmNactivateCallback,myMotifCallback,&tosend); XtRealizeWidget(toplevel); IvyXtChannelAppContext(app_context); IvyInit("IvyMotif","IvyMotif connected",NULL,NULL,DieCallback,NULL); IvyBindMsg(textCallback,&tosend,"^Ivy Button text=(.*)"); IvyStart(bus); XtAppMainLoop(app_context); return 0; }
Mav2Ivy::Mav2Ivy(ros::NodeHandle nh, ros::NodeHandle nh_private): nh_(nh), nh_private_(nh_private) { ROS_INFO("Starting Mav2Ivy"); // NodeHandle for mav data ros::NodeHandle nh_data (nh_, mav::ROS_NAMESPACE); // **** get parameters initializeParams(); // **** initialize vaiables //motors_on_ = false; //engaging_ = false; // TODO handle motors on motors_on_ = true; engaging_ = false; ctrl_roll_ = 0; ctrl_pitch_ = 0; ctrl_yaw_ = 0; ctrl_thrust_ = 0; // *** register publishers imu_publisher_ = nh_data.advertise<sensor_msgs::Imu>(mav::IMU_TOPIC, 10); height_publisher_ = nh_data.advertise<mav_msgs::Height>(mav::P_HEIGHT_TOPIC, 10); // **** register subscribers // Replace by IVY stuff IvyBindMsg(ivyFPCallback,this, "^(\\S*) ROTORCRAF_FP (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*"); IvyBindMsg(ivyImuCallback, this, "^(\\S*) AHRS_LKF (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(ivyStatusCallback, this, "^(\\S*) ROTORCRAFT_STATUS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); //imu_calcdata_subscriber_ = nh_rawdata.subscribe( // asctec::IMU_CALCDATA_TOPIC, 10, &Mav2Ivy::imuCalcDataCallback, this); //ll_status_subscriber_ = nh_rawdata.subscribe( // asctec::LL_STATUS_TOPIC, 5, &Mav2Ivy::llStatusCallback, this); cmd_thrust_subscriber_ = nh_data.subscribe( mav::CMD_THRUST_TOPIC, 1, &Mav2Ivy::cmdThrustCallback, this); cmd_roll_subscriber_ = nh_data.subscribe( mav::CMD_ROLL_TOPIC, 1, &Mav2Ivy::cmdRollCallback, this); cmd_pitch_subscriber_ = nh_data.subscribe( mav::CMD_PITCH_TOPIC, 1, &Mav2Ivy::cmdPitchCallback, this); cmd_yaw_subscriber_ = nh_data.subscribe( mav::CMD_YAW_RATE_TOPIC, 5, &Mav2Ivy::cmdYawCallback, this); // **** services //set_motors_on_off_srv_ = nh_data.advertiseService( // "setMotorsOnOff", &Mav2Ivy::setMotorsOnOff, this); get_motors_on_off_srv_ = nh_data.advertiseService( "getMotorsOnOff", &Mav2Ivy::getMotorsOnOff, this); }
int main ( int argc, char** argv) { int s = sizeof(local_uav); gtk_init(&argc, &argv); if (argc < 3) { printf("Use: ivy2serial ac_id serial_device\n"); printf("or\n"); printf("Use: ivy2serial ac_id serial_device xbee_power_level [0-4] to configure the xbee as broadcast, no retries\n"); return -1; } if (argc == 4) { printf("Programming XBee Modem\n"); power_level = (int) (argv[3][0]) - (int) '0'; if (power_level < 0) power_level = 0; else if (power_level > 4) power_level = 4; printf("Set Power Level To: '%d'\n", power_level); } else { power_level = -1; } local_uav.ac_id = atoi(argv[1]); sprintf(status_str, "Listening to AC=%d, Serial Data Size = %d",local_uav.ac_id, s); sprintf(status_ivy_str, "---"); sprintf(status_serial_str, "---"); printf("%s\n",status_str); // Open Serial or Die port = argv[2]; open_port(port); // Init UAV remote_uav.ac_id = 6; remote_uav.phi = 1000; remote_uav.theta = 200; remote_uav.psi = -3140; // Start IVY IvyInit ("IVY <-> Serial", "IVY <-> Serial READY", NULL, NULL, NULL, NULL); IvyBindMsg(on_Desired, NULL, "^%d DESIRED (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id); IvyBindMsg(on_Estimator, NULL, "^%d ESTIMATOR (\\S*) (\\S*)",local_uav.ac_id); IvyBindMsg(on_Navigation, NULL, "^%d NAVIGATION (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id); IvyBindMsg(on_Attitude, NULL, "^%d ATTITUDE (\\S*) (\\S*) (\\S*)", local_uav.ac_id); IvyBindMsg(on_Gps, NULL, "^%d GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)",local_uav.ac_id); IvyStart("127.255.255.255"); // Add Timer gtk_timeout_add(delay / 4, timeout_callback, NULL); // GTK Window GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "IVY_Serial_Bridge"); gtk_signal_connect (GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL); GtkWidget *box = gtk_vbox_new(TRUE, 1); gtk_container_add (GTK_CONTAINER (window), box); GtkWidget *hbox = gtk_hbox_new(FALSE, 1); gtk_container_add (GTK_CONTAINER (box), hbox); status = gtk_label_new( "Status:" ); gtk_box_pack_start(GTK_BOX(hbox), status, FALSE, FALSE, 1); gtk_label_set_justify( (GtkLabel*) status, GTK_JUSTIFY_LEFT ); status = gtk_label_new( status_str ); gtk_box_pack_start(GTK_BOX(hbox), status, FALSE, FALSE, 1); gtk_label_set_justify( (GtkLabel*) status, GTK_JUSTIFY_LEFT ); hbox = gtk_hbox_new(FALSE, 1); gtk_container_add (GTK_CONTAINER (box), hbox); status_ivy = gtk_label_new( "IVY->SERIAL:" ); gtk_box_pack_start(GTK_BOX(hbox), status_ivy, FALSE, FALSE, 1); gtk_label_set_justify( (GtkLabel*) status_ivy, GTK_JUSTIFY_LEFT ); status_ivy = gtk_label_new( status_ivy_str ); gtk_box_pack_start(GTK_BOX(hbox), status_ivy, FALSE, FALSE, 1); gtk_label_set_justify( (GtkLabel*) status_ivy, GTK_JUSTIFY_LEFT ); hbox = gtk_hbox_new(FALSE, 1); gtk_container_add (GTK_CONTAINER (box), hbox); status_serial = gtk_label_new( "SERIAL->IVY:" ); gtk_box_pack_start(GTK_BOX(hbox), status_serial, FALSE, FALSE, 1); gtk_label_set_justify( (GtkLabel*) status_serial, GTK_JUSTIFY_LEFT ); status_serial = gtk_label_new( status_serial_str ); gtk_label_set_justify( GTK_LABEL(status_serial), GTK_JUSTIFY_LEFT ); gtk_box_pack_start(GTK_BOX(hbox), status_serial, FALSE, FALSE, 1); gtk_widget_show_all(window); gtk_main(); // Clean up fprintf(stderr,"Stopping\n"); return 0; }
int main (int argc, char **argv) { GtkWidget *window; GtkWidget *da; GdkGLConfig *glconfig; int xid=-1; /* handling of -b option */ const char* bus = 0; char c; while ((c = getopt (argc, argv, "b:p:")) != EOF) { switch (c) { case 'b': bus = optarg; break; case 'p': xid = strtol(optarg,NULL,0); break; } } printf("xid %d \nbus %s \n",xid,bus); /* handling of environment variable */ if (!bus) bus = getenv ("IVYBUS"); gtk_init (&argc, &argv); gtk_gl_init (&argc, &argv); if (xid==-1){ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 512, 400); } else { window = gtk_window_new(GTK_WINDOW_POPUP); } da = gtk_drawing_area_new (); gtk_container_add (GTK_CONTAINER (window), da); g_signal_connect_swapped (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_widget_set_events (da, GDK_EXPOSURE_MASK); gtk_widget_show (window); if (xid!=-1){ XReparentWindow(GDK_WINDOW_XDISPLAY(window->window), GDK_WINDOW_XWINDOW(window->window), xid, 0,0); gtk_widget_map(window); } /* prepare GL */ glconfig = gdk_gl_config_new_by_mode ( GDK_GL_MODE_RGB | GDK_GL_MODE_DEPTH | GDK_GL_MODE_DOUBLE); if (!glconfig) { g_assert_not_reached (); } if (!gtk_widget_set_gl_capability (da, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE)) { g_assert_not_reached (); } g_signal_connect (da, "configure-event", G_CALLBACK (configure), NULL); g_signal_connect (da, "expose-event", G_CALLBACK (expose), NULL); gtk_widget_show_all (window); g_timeout_add (1000 / 60, update, da); IvyInit ("pprzopengl", "pprzopengl READY", NULL, NULL, NULL, NULL); IvyBindMsg(on_GPS_STATUS, NULL, "^\\S* GPS (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_ATTITUDE, NULL, "^\\S* ATTITUDE (\\S*) (\\S*) (\\S*)"); IvyStart(bus); gtk_main (); return(0); }
int main(int argc, char** argv) { currentPlayingTime = 0.0; startVideoAfter = 0.0; airframeID = 1; currentMode = MODE_REPLAY; replayMode = MANUAL_REPLAY; ml = g_main_loop_new(NULL, FALSE); g_timeout_add(1000 , __timeout_func , ml); IvyInit("Video Synchronizer", "Video Synchronizer READY", NULL, NULL, NULL, NULL); IvyBindMsg(on_Message, NULL, "^time(\\S*) (\\S*)"); IvyBindMsg(on_Message_Video, NULL, "^(\\S*) VIDEO_SYNC(\\S*) (\\S*)"); IvyBindMsg(on_Airframe_ID, NULL, "^replay(\\S*) PONG(\\S*) (\\S*)"); #ifdef __APPLE__ IvyStart("224.255.255.255"); #else IvyStart("127.255.255.255"); #endif /* Ugly because remove every possibility of translation. * But needed to prevent the use of the comma as float separator. */ gtk_disable_setlocale(); gtk_init(&argc, &argv); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Video synchronizer"); g_signal_connect(GTK_OBJECT(window), "destroy", G_CALLBACK(on_quit), NULL); GtkNotebook *tab = (GtkNotebook*)gtk_notebook_new(); g_signal_connect(GTK_OBJECT(tab), "switch-page", G_CALLBACK(on_change_mode), NULL); GtkNotebook *tabReplay = (GtkNotebook*)gtk_notebook_new(); g_signal_connect(GTK_OBJECT(tabReplay), "switch-page", G_CALLBACK(on_change_replay), NULL); //Manual mode //create a box to align the widgets //false -> unheaven sizes; 0 space between widgets GtkWidget *box = gtk_hbox_new(FALSE, 0); //add a label to explain the values to enter GtkWidget *label = gtk_label_new("How long the video must be started \nafter the log file (may be negative) : "); gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); gtk_widget_show(label); //add a spinbutton (to enter the value of the video synchronisation) //startValue, lower, upper, step_increment, page_increment, page_size GtkAdjustment *adj = (GtkAdjustment *) gtk_adjustment_new(0.0, -999999999999.99, 999999999999.99, 0.1, 1.0, 0.0); spinButton = gtk_spin_button_new(adj, 0.1, 1); g_signal_connect(GTK_OBJECT(adj), "value_changed", G_CALLBACK(on_video_sync_changed), NULL); gtk_box_pack_start(GTK_BOX(box), spinButton, TRUE, TRUE, 0); gtk_widget_show(spinButton); //add the unit label at the end of the window label = gtk_label_new("s"); gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); gtk_widget_show(label); gtk_notebook_append_page(tabReplay, box, gtk_label_new("Manual")); //Auto mode //create a box to align the widgets //false -> unheaven sizes; 0 space between widgets GtkWidget *boxAuto = gtk_hbox_new(FALSE, 0); //add a label to explain the values to enter label = gtk_label_new("At what time is the clap in the video : "); gtk_box_pack_start(GTK_BOX(boxAuto), label, FALSE, FALSE, 0); gtk_widget_show(label); //add a spinbutton (to enter the value of the video synchronisation) //startValue, lower, upper, step_increment, page_increment, page_size GtkAdjustment *adjAuto = (GtkAdjustment *) gtk_adjustment_new(0.0, 0.00, 999999999999.99, 0.1, 1.0, 0.0); spinButtonVideo = gtk_spin_button_new(adjAuto, 0.1, 1); g_signal_connect(GTK_OBJECT(adjAuto), "value_changed", G_CALLBACK(on_video_time_tag_changed), NULL); gtk_box_pack_start(GTK_BOX(boxAuto), spinButtonVideo, TRUE, TRUE, 0); gtk_widget_show(spinButtonVideo); //add the unit label at the end of the window label = gtk_label_new("s"); gtk_box_pack_start(GTK_BOX(boxAuto), label, FALSE, FALSE, 0); gtk_widget_show(label); gtk_notebook_append_page(tabReplay, boxAuto, gtk_label_new("Auto")); //create the capture page GtkWidget *captureBox = gtk_hbox_new(FALSE, 0); GtkWidget *button = gtk_button_new_with_label("sync"); gtk_box_pack_start(GTK_BOX(captureBox), button, FALSE, FALSE, 0); g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(on_sync_clicked), NULL); gtk_widget_show(button); gtk_notebook_append_page(tab, (GtkWidget*)tabReplay, gtk_label_new("Replay")); gtk_notebook_append_page(tab, (GtkWidget*)captureBox, gtk_label_new("Capture")); gtk_container_add(GTK_CONTAINER(window), (GtkWidget*)tab); gtk_window_set_icon(GTK_WINDOW(window), create_pixbuf("data/pictures/penguin_icon_vid.png")); gtk_widget_show_all(window); gtk_main(); return 0; }
int main(int argc, char **argv) { int i; //Get process id ProcessID= getpid(); // default password AppPass = defaultAppPass; // try environment variable first, set to default if failed IvyBus = getenv("IVYBUS"); if (IvyBus == NULL) IvyBus = defaultIvyBus; // Parse options for (i = 1; i < argc; ++i) { if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { print_help(); exit(0); } else if (strcmp(argv[i], "-t") == 0) { tcp_port = atoi(argv[++i]); } else if (strcmp(argv[i], "-u") == 0) { udp_port = atoi(argv[++i]); } else if (strcmp(argv[i], "-b") == 0) { IvyBus = argv[++i]; } else if (strcmp(argv[i], "-p") == 0) { AppPass = argv[++i]; } else if (strcmp(argv[i], "-v") == 0) { verbose = 1; } else if (strcmp(argv[i], "-utcp") == 0) { uTCP = 1; } else { printf("App Server: Unknown option\n"); print_help(); exit(0); } } if (verbose) { printf("### Paparazzi App Server ###\n"); printf("Server listen port (TCP) : %d\n", tcp_port); if (uTCP) { printf("Server using TCP communication..\n"); }else{ printf("Server broadcast port (UDP) : %d\n", udp_port); } printf("Control Pass : %s\n", AppPass); printf("Ivy Bus : %s\n", IvyBus); fflush(stdout); } //Create tcp listener #if !GLIB_CHECK_VERSION (2, 35, 1) // init GLib type system (only for older version) g_type_init(); #endif GSocketService *service = g_socket_service_new(); GInetAddress *address = g_inet_address_new_any(G_SOCKET_FAMILY_IPV6); //G_SOCKET_FAMILY_IPV4 could be used GSocketAddress *socket_address = g_inet_socket_address_new(address, tcp_port); //Add listener g_socket_listener_add_address(G_SOCKET_LISTENER(service), socket_address, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_TCP, NULL, NULL, NULL); g_object_unref(socket_address); g_object_unref(address); g_socket_service_start(service); //Connect listening signal g_signal_connect(service, "incoming", G_CALLBACK(new_connection), NULL); //Here comes the ivy bindings IvyInit ("PPRZ_App_Server", "Papparazzi App Server Ready!", NULL, NULL, NULL, NULL); IvyBindMsg(Ivy_All_Msgs, NULL, "(^ground (\\S*) (\\S*) .*)"); IvyBindMsg(on_app_server_NEW_AC, NULL, "ground NEW_AIRCRAFT (\\S*)"); IvyBindMsg(on_app_server_GET_CONFIG, NULL, "(\\S*) ground CONFIG (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_app_server_AIRCRAFTS, NULL, "(\\S*) ground AIRCRAFTS (\\S*)"); IvyStart(IvyBus); GMainLoop *loop = g_main_loop_new(NULL, FALSE); if (verbose) { printf("Starting App Server\n"); fflush(stdout); } IvySendMsg("app_server"); g_timeout_add(100, request_ac_list, NULL); g_main_loop_run(loop); if (verbose) { printf("Stoping App Server\n"); fflush(stdout); } return 0; }
int main ( int argc, char** argv) { //chaines de caracteres pour stocker les messages char bindMsgADC_GENERIC[32]; char bindMsgCAMERA_SNAPSHOT[32]; char bindMsgTOUT[32]; char bindMsgGPS[32]; char bindMsgNAV[32]; char bindMsgATTITUDE[32]; char bindMsgNAVREF[32]; char bindMsgon_Attitude[40]; //int id=1; //id de l'avion a monitorer par défaut, réglé avec GCS char sid[10]="."; //id de l'avion a monitorer par défaut, réglé avec GCS printf("usage: c_ivy_client_alarm id\nid is the identifier of the plane, for instance 3 for N3, . for any 1 caracter id(default)\n "); if (argc>=2) //sscanf(argv[1],"%d",&id); sscanf(argv[1],"%s",sid); printf("binding Ivy frame for id: %s \n",sid); GMainLoop *ml = g_main_loop_new(NULL, FALSE); IvyInit ("c_ivy_client_alarm", "c_ivy_client_alarm READY", NULL, NULL, NULL, NULL); // IvyBindMsg(on_Attitude, NULL,"^(\\S*) ATTITUDE (\\S*) (\\S*) (\\S*)"); /* snprintf(bindMsgon_Attitude,40,"^(\\S*) ATTITUDE (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_Attitude,0,bindMsgon_Attitude); printf(bindMsgon_Attitude); printf("\n"); */ /* snprintf(bindMsgTOUT,32,"(.*)"); IvyBindMsg(readTOUTIvyBus,0,bindMsgTOUT); printf(bindMsgTOUT); printf("\n"); */ snprintf(bindMsgADC_GENERIC,32,"%s%s%s","(",sid," ADC_GENERIC .*)"); IvyBindMsg(readADC_GENERICIvyBus,0,bindMsgADC_GENERIC); printf(bindMsgADC_GENERIC); printf("\n"); snprintf(bindMsgCAMERA_SNAPSHOT,32,"%s%s%s","(",sid," CAMERA_SNAPSHOT .*)"); IvyBindMsg(readCAMERA_SNAPSHOTIvyBus,0,bindMsgCAMERA_SNAPSHOT); printf(bindMsgCAMERA_SNAPSHOT); printf("\n"); /* snprintf(bindMsgGPS,32,"%s%s%s","(",sid," GPS 3.*)"); IvyBindMsg(readGPSIvyBus,0,bindMsgGPS); printf(bindMsgGPS); printf("\n"); */ /* snprintf(bindMsgGPS,32,"%s","(* GPS 3.*)"); IvyBindMsg(readGPSIvyBus,0,bindMsgGPS); printf(bindMsgGPS); printf("\n"); /* snprintf(bindMsgNAV,32,"%s%s%s","(",sid," NAVIGATION .*)"); IvyBindMsg(readNAVIvyBus,0,bindMsgNAV); printf(bindMsgNAV); printf("\n"); snprintf(bindMsgATTITUDE,32,"%s%s%s","(",sid," ATTITUDE .*)"); IvyBindMsg(readATTITUDEIvyBus,0,bindMsgATTITUDE); printf(bindMsgATTITUDE); printf("\n"); snprintf(bindMsgNAVREF,32,"%s%s%s","(",sid," NAVIGATION_REF .*)"); IvyBindMsg(readNAVREFIvyBus,0,bindMsgNAVREF); printf(bindMsgNAVREF); printf("\n"); */ // #ifdef __APPLE__ printf("Mac Os, network submask: 224.255.255.255\n"); IvyStart("224.255.255.255"); #else printf("NO Mac Os, network submask: 127.255.255\n"); IvyStart("127.255.255.255"); #endif // IvyStart("127.0.0.1"); g_main_loop_run(ml); return 0; }
void nps_ivy_mission_commands_init(void) { IvyBindMsg(on_DL_MISSION_GOTO_WP, NULL, "^(\\S*) MISSION_GOTO_WP (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_MISSION_GOTO_WP_LLA, NULL, "^(\\S*) MISSION_GOTO_WP_LLA (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_MISSION_CIRCLE, NULL, "^(\\S*) MISSION_CIRCLE (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_MISSION_CIRCLE_LLA, NULL, "^(\\S*) MISSION_CIRCLE_LLA (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_MISSION_SEGMENT, NULL, "^(\\S*) MISSION_SEGMENT (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_MISSION_SEGMENT_LLA, NULL, "^(\\S*) MISSION_SEGMENT_LLA (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_MISSION_PATH, NULL, "^(\\S*) MISSION_PATH (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_MISSION_PATH_LLA, NULL, "^(\\S*) MISSION_PATH_LLA (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*) (\\S*)"); IvyBindMsg(on_DL_GOTO_MISSION, NULL, "^(\\S*) GOTO_MISSION (\\S*) (\\S*)"); IvyBindMsg(on_DL_NEXT_MISSION, NULL, "^(\\S*) NEXT_MISSION (\\S*)"); IvyBindMsg(on_DL_END_MISSION, NULL, "^(\\S*) END_MISSION (\\S*)"); }
int main(int argc, char **argv) { int i; // default password AppPass = defaultAppPass; // try environment variable first, set to default if failed IvyBus = getenv("IVYBUS"); if (IvyBus == NULL) IvyBus = defaultIvyBus; // Look for paparazzi folder (PAPARAZZI_HOME or assume local path by default) char* PprzFolder = getenv("PAPARAZZI_HOME"); if (PprzFolder == NULL) PprzFolder = defaultPprzFolder; // Parse options for (i = 1; i < argc; ++i) { if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { print_help(); exit(0); } else if (strcmp(argv[i], "-t") == 0) { tcp_port = atoi(argv[++i]); } else if (strcmp(argv[i], "-u") == 0) { udp_port = atoi(argv[++i]); } else if (strcmp(argv[i], "-b") == 0) { IvyBus = argv[++i]; } else if (strcmp(argv[i], "-p") == 0) { AppPass = argv[++i]; } else if (strcmp(argv[i], "-v") == 0) { verbose = 1; } else { printf("App Server: Unknown option\n"); print_help(); exit(0); } } if (verbose) { printf("### Paparazzi App Server ###\n"); printf("Using Paparazzi Folder : %s\n", PprzFolder); printf("Server listen port (TCP) : %d\n", tcp_port); printf("Server broadcast port (UDP) : %d\n", udp_port); printf("Control Pass : %s\n", AppPass); printf("Ivy Bus : %s\n", IvyBus); fflush(stdout); } //Parse conf.xml parse_ac_data(PprzFolder); //Create tcp listener #if !GLIB_CHECK_VERSION (2, 35, 1) // init GLib type system (only for older version) g_type_init(); #endif GSocketService *service = g_socket_service_new(); GInetAddress *address = g_inet_address_new_any(G_SOCKET_FAMILY_IPV6); //G_SOCKET_FAMILY_IPV4 could be used GSocketAddress *socket_address = g_inet_socket_address_new(address, tcp_port); //Add listener g_socket_listener_add_address(G_SOCKET_LISTENER(service), socket_address, G_SOCKET_TYPE_STREAM, G_SOCKET_PROTOCOL_TCP, NULL, NULL, NULL); g_object_unref(socket_address); g_object_unref(address); g_socket_service_start(service); //Connect listening signal g_signal_connect(service, "incoming", G_CALLBACK(new_connection), NULL); //Here comes the ivy bindings IvyInit ("PPRZ_App_Server", "Papparazzi App Server Ready", NULL, NULL, NULL, NULL); IvyBindMsg(Ivy_All_Msgs, NULL, "(^ground .*)"); IvyBindMsg(Ivy_All_Msgs, NULL, "(^\\S* AIRSPEED (\\S*) (\\S*) (\\S*) (\\S*))"); IvyStart(IvyBus); GMainLoop *loop = g_main_loop_new(NULL, FALSE); if (verbose) { printf("Starting App Server\n"); fflush(stdout); } g_main_loop_run(loop); if (verbose) { printf("Stoping App Server\n"); fflush(stdout); } return 0; }