コード例 #1
0
void fcuStatusCallback(const asctec_hl_comm::mav_statusConstPtr& status) {
	// Details of this message can found in the source of the implementation at:
	// http://ros.org/rosdoclite/groovy/api/asctec_hl_comm/html/HL__interface_8h.html
	// http://ros.org/rosdoclite/groovy/api/asctec_hl_comm/html/HL__interface_8h_source.html
	// http://ros.org/rosdoclite/groovy/api/asctec_hl_interface/html/hl__interface_8cpp_source.html

	std::ostringstream label;
	int min, sec;

	// **** get GTK thread lock
	gdk_threads_enter();

	// **** update gauge1: battery voltage [mV]
	// UPDATE: After testing with the Pelican+fcu, it turns out the unit is [V]
	if (IS_GTK_GAUGE (data->gauge1))
		gtk_gauge_set_value(GTK_GAUGE (data->gauge1), status->battery_voltage); // * 0.001);

	// possible flight modes are: "Acc", "Height", "GPS" and "unknown"
	gtk_label_set_text(GTK_LABEL (data->flightMode_label), status->flight_mode_ll.c_str());

	// flight time [s]
	// format time to 00:00 (min:sec)
	min = int(status->flight_time) / 60;
	sec = int(status->flight_time) % 60;
	if (min < 10)
		label << "0" << min << ":";
	else
		label << min << ":";
	if (sec < 10)
		label << "0" << sec;
	else
		label << sec;

	gtk_label_set_text(GTK_LABEL (data->upTime_label), label.str().c_str());
	// remember to empty ostringstream
	label.str("");

	// CPU load in % of the time of one SDK loop
	label << status->cpu_load << "%";
	gtk_label_set_text(GTK_LABEL (data->cpuLoad_label), label.str().c_str());
	label.str("");

	// Number of GPS Satellites (int32)
	label << int(status->gps_num_satellites);
	gtk_label_set_text(GTK_LABEL (data->numSats_label), label.str().c_str());


	// possible modes are: "off", "stopping", "starting" and "running"
	if (status->motor_status.compare("off") == 0) {
		gtk_container_remove(GTK_CONTAINER(data->box_MotorStatus), GTK_WIDGET (data->status_ok_icon_motor));
		gtk_box_pack_end(GTK_BOX (data->box_MotorStatus), data->status_fail_icon_motor, TRUE, TRUE, 0);
	}
	else {
		gtk_container_remove(GTK_CONTAINER(data->box_MotorStatus), GTK_WIDGET (data->status_fail_icon_motor));
		gtk_box_pack_end(GTK_BOX (data->box_MotorStatus), data->status_ok_icon_motor, TRUE, TRUE, 0);
	}

	// **** release GTK thread lock
	gdk_threads_leave();
}
コード例 #2
0
void llStatusCallback (const asctec_msgs::LLStatusConstPtr & dat)
{
    // **** get GTK thread lock
    gdk_threads_enter ();

    llStatus_ = (*dat);
    char buf[FILENAME_MAX];

    // **** update altimeter
    if (IS_GTK_GAUGE (data->gauge1))
        gtk_gauge_set_value (GTK_GAUGE (data->gauge1), (double) (llStatus_.battery_voltage_1 / 1000.));

    /*if(llStatus_.flying==0)
       {
       gtk_container_remove(GTK_CONTAINER(data->box_Flying),GTK_WIDGET (data->status_ok_icon_flying));
       gtk_box_pack_end (GTK_BOX (data->box_Flying),data->status_fail_icon_flying, TRUE, TRUE, 0);
       }
       else
       {
       gtk_container_remove(GTK_CONTAINER(data->box_Flying),GTK_WIDGET (data->status_fail_icon_flying));
       gtk_box_pack_end (GTK_BOX (data->box_Flying),data->status_ok_icon_flying, TRUE, TRUE, 0);
       }
       if(llStatus_.motors_on==0)
       {
       gtk_container_remove(GTK_CONTAINER(data->box_MotorStatus),GTK_WIDGET (data->status_ok_icon_motor));
       gtk_box_pack_end (GTK_BOX (data->box_MotorStatus),data->status_fail_icon_motor, TRUE, TRUE, 0);
       }
       else
       {
       gtk_container_remove(GTK_CONTAINER(data->box_MotorStatus),GTK_WIDGET (data->status_fail_icon_motor));
       gtk_box_pack_end (GTK_BOX (data->box_MotorStatus),data->status_ok_icon_motor, TRUE, TRUE, 0);
       } */

    sprintf (buf, "%d", llStatus_.flightMode);
    gtk_label_set_text (GTK_LABEL (data->flightMode_label), buf);

    sprintf (buf, "%d", llStatus_.up_time);
    gtk_label_set_text (GTK_LABEL (data->upTime_label), buf);

    sprintf (buf, "%d", llStatus_.cpu_load);
    gtk_label_set_text (GTK_LABEL (data->cpuLoad_label), buf);

    // **** release GTK thread lock
    gdk_threads_leave ();
}