Thread: [Plib-users] (cory vs. pui) The attack of setValuator
Brought to you by:
sjbaker
From: cory b. <co...@gm...> - 2008-06-12 20:18:46
|
I found the following in the PUI documentation today: There are many occasions when you'd really like to have the PUI widget directly drive and/or reflect the value of some memory location in the application code. These calls let you do that: void puObject::setValuator ( int *i ) ; void puObject::setValuator ( float *f ) ; void puObject::setValuator ( char *s ) ; Once you make one of these calls, PUI will automatically update the memory location indicated with the current value of the widget whenever it changes - and also update the appearance of the widget to reflect the value stored in that memory location whenever the widget is redrawn. This is often a lot more convenient than using a callback function to register changes in the widget's value. So I tried it out: //global variable float update = 1.0f; //initialize my puInput inside a function //hertz text input hertz_text = new puInput ( curx, cury, curx + PUI_TEXT_WIDTH, cury + PUI_TEXT_HEIGHT ) ; hertz_text->setValuator( &update ); hertz_text->setLabel( "Hertz" ); hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); This compiles, and runs. It seems to work correctly as long as I do not remove all of the characters from the puInput box. However if I am trying to change the value, when I am typing in the new value, if the new value ever becomes a non valid float value, then the program crashes. For example if I want to change 1.0 to 2.0 and I delete 1.0 so I can type 2.0, then instant crash. I can change from 1.0 to 2.0 if I type the 2 after the 1, and then erase the 1. Searching the mail archives and googling didn't help, so I am posting here. I suspect either my weak understanding of pointers means that I am passing an incorrect argument to the setValuator function, or maybe the puInput object is writing invalid data to the update variable. Please let me know how to fix this. thanks, Cory |
From: Fay J. F Dr C. U. 46 S. <joh...@eg...> - 2008-06-12 20:42:34
|
Hmmm ... unless somebody else steps in, please forward me a copy of the offending code. I've tried putting in your code snippet and the program works just fine for me, so evidently something else is going on. John F. Fay Technical Fellow Jacobs Technology TEAS Group 850-883-1294 -----Original Message----- From: pli...@li... [mailto:pli...@li...] On Behalf Of cory barton Sent: Thursday, June 12, 2008 3:19 PM To: PLIB Users Subject: [Plib-users] (cory vs. pui) The attack of setValuator I found the following in the PUI documentation today: There are many occasions when you'd really like to have the PUI widget directly drive and/or reflect the value of some memory location in the application code. These calls let you do that: void puObject::setValuator ( int *i ) ; void puObject::setValuator ( float *f ) ; void puObject::setValuator ( char *s ) ; Once you make one of these calls, PUI will automatically update the memory location indicated with the current value of the widget whenever it changes - and also update the appearance of the widget to reflect the value stored in that memory location whenever the widget is redrawn. This is often a lot more convenient than using a callback function to register changes in the widget's value. So I tried it out: //global variable float update = 1.0f; //initialize my puInput inside a function //hertz text input hertz_text = new puInput ( curx, cury, curx + PUI_TEXT_WIDTH, cury + PUI_TEXT_HEIGHT ) ; hertz_text->setValuator( &update ); hertz_text->setLabel( "Hertz" ); hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); This compiles, and runs. It seems to work correctly as long as I do not remove all of the characters from the puInput box. However if I am trying to change the value, when I am typing in the new value, if the new value ever becomes a non valid float value, then the program crashes. For example if I want to change 1.0 to 2.0 and I delete 1.0 so I can type 2.0, then instant crash. I can change from 1.0 to 2.0 if I type the 2 after the 1, and then erase the 1. Searching the mail archives and googling didn't help, so I am posting here. I suspect either my weak understanding of pointers means that I am passing an incorrect argument to the setValuator function, or maybe the puInput object is writing invalid data to the update variable. Please let me know how to fix this. thanks, Cory ------------------------------------------------------------------------ - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ plib-users mailing list pli...@li... https://lists.sourceforge.net/lists/listinfo/plib-users |
From: cory b. <co...@gm...> - 2008-06-12 20:53:18
|
Here is the code: //#include <memory.h> #include <stdio.h> #include <sstream> #include <simgear/compiler.h> #include <GL/glut.h> //#include SG_GLUT_H #include <plib/fnt.h> #include <plib/pu.h> #include <string> #include <simgear/io/sg_socket.hxx> #include <simgear/io/sg_serial.hxx> #include <simgear/io/sg_file.hxx> #include "SSAircraft.hxx" #include "SSPid.hxx" using namespace std; //defines #define DECIMALS 6 #define KEY_ESCAPE 27 #define GAIN_MIN -1 //gain values for sliders MIN should be 0 or less #define GAIN_MAX 1 #define DEG_MIN -180 //target value limiters #define DEG_MAX 180 //pui gui constants #define WINDOW_X 360 //window width #define WINDOW_Y 300 //window height #define PUI_X_OFFSET 0 #define PUI_Y_OFFSET 0 #define PUI_CTRL_X_OFFSET PUI_BUTTON_WIDTH + PUI_X_GAP * 2 #define PUI_CTRL_WIDTH PUI_ARROW_WIDTH * 2 + PUI_TEXT_WIDTH + PUI_X_GAP * 2 #define PUI_LABEL_X_OFFSET #define PUI_X_GAP 10 #define PUI_Y_GAP 20 #define PUI_TEXT_WIDTH 80 #define PUI_TEXT_HEIGHT 30 #define PUI_ARROW_WIDTH 30 #define PUI_ARROW_HEIGHT 30 #define PUI_BUTTON_WIDTH 120 #define PUI_BUTTON_HEIGHT 30 #define PUI_RADIO_WIDTH 100 #define PUI_RADIO_HEIGHT 60 //global items //objects SGIOChannel *in_channel, *out_channel, *log_file; SSAircraft *sim_craft = new SSAircraft(); SSPid *aileron_pid = new SSPid(); SSPid *elevator_pid = new SSPid(); //vars bool logging = false; bool pauseSoftSim = true; char inport[ 256 ] = "5500"; char outport[ 256 ] = "5501"; int sock; float update = 1.0f; char out_file[ 1024 ] = "sLog.csv"; char save_buf[ 2 * 2048 ]; int save_len = 0; //pui widgets from PLIB library puFrame *gui_frame; //radio buttons char *controller_selector_labels[] = { "Roll", "Pitch", NULL }; puButtonBox *controller_selector; //plain old buttons puButton *pause_button, *log_button; //arrow buttons for adjusting control values puArrowButton *kp_arrow_l, *kp_arrow_r, *ki_arrow_l, *ki_arrow_r, *kd_arrow_l, *kd_arrow_r, *target_arrow_l, *target_arrow_r; //text input boxes puInput *kp_text, *ki_text, *kd_text, *target_text, *hertz_text; char *valid_input = "-.0123456789"; //valid input mask for text boxes char kp_str[ PUSTRING_MAX ], ki_str[ PUSTRING_MAX ], kd_str[ PUSTRING_MAX ], target_str[ PUSTRING_MAX ]; //labels puText *roll_err_label, *pitch_err_label, *udp_label; char roll_text[ PUSTRING_MAX ], pitch_text[ PUSTRING_MAX ]; //function prototypes void timer( int value ); bool parse_fgear_data( char *buf ); void redrawWindow( void ); void reshapeWindow( int w, int h ); string command_output( void ); void processNormalKeys( unsigned char key, int x, int y ); void init_pui_widgets( void ); void pui_callback( puObject *pob ); void gui_update( SSPid *pid ); void processMousefn ( int button, int updown, int x, int y ); void processMotionfn ( int x, int y ); int main( int argc, char **argv ) { //glut setup glutInit( &argc, argv ); glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB ); glutInitWindowPosition( 100, 100 ); glutInitWindowSize( WINDOW_X, WINDOW_Y ); glutCreateWindow( "SoftSim" ); glutDisplayFunc( redrawWindow ); glutReshapeFunc( reshapeWindow ); glutIdleFunc( redrawWindow ); glutMouseFunc ( processMousefn ); // process mouse clicks glutMotionFunc ( processMotionfn ); // process mouse moves glutPassiveMotionFunc ( processMotionfn ); glutKeyboardFunc( processNormalKeys ); glEnable( GL_DEPTH_TEST ); // enable depth testing //this takes care of timing for the program glutTimerFunc( ( int )( 1000.0f/update ), timer, 0 ); //set up networking in_channel = new SGSocket( "", inport, "udp" ); out_channel = new SGSocket( "", outport, "udp" ); in_channel->open( SG_IO_IN ); out_channel->open( SG_IO_OUT ); //set up logging string f_name = out_file; log_file = new SGFile( f_name ); log_file->open( SG_IO_OUT ); //initialize PID controllers //the gains are some that work ok with the default plane aileron_pid->set_gains( 0.06, 0.004, -0.04 ); aileron_pid->set_reference( 0 ); aileron_pid->set_limits( -1, 1 ); elevator_pid->set_gains( -0.05, -0.001, 0 ); elevator_pid->set_reference( 0 ); elevator_pid->set_limits( -1, 1 ); //setup all the buttons and gui stuff init_pui_widgets(); //start glut glutMainLoop(); //clean up in_channel->close(); out_channel->close(); log_file->close(); return 0; } void timer( int value ) { char buffer[ 512 ]; size_t found; string log_str; //string to log to file int length; //do if not paused if ( !pauseSoftSim ){ //read incoming data while ( ( length = in_channel->readline( buffer, 512 ) ) > 0 ) { parse_fgear_data( buffer ); if ( logging ) { //prepare log string log_str = buffer; //find \n char and replace with comma found=log_str.find( '\n' ); if ( found!=string::npos ) { log_str.replace( found, 1, "," ); } } } string command_str = command_output(); //send outgoing data out_channel->write( command_str.c_str(), command_str.size() ); //log to file if ( logging ) { //don't log if no data from udp if ( log_str.length () > 0 ) { log_str.append( command_str ); log_file->writestring( log_str.c_str() ); //cout << command_str.c_str() << endl; //cout << log_str << endl; } } //make some updates system( "clear" ); //this is not portable. I should probably //be using the ncurses library cout.precision( DECIMALS ); cout << "Roll error: " << aileron_pid->get_error() << endl; cout << "Pitch error: " << elevator_pid->get_error() << endl; } glutTimerFunc( ( int )( 1000.0f/update ), timer, value ); } //parse incoming data from flight gear bool parse_fgear_data( char *buf ) { //variables //control double aileron, elevator, rudder, throttle; //position double latitudeDegree, longitudeDegree, altitude; //attitude double headingDegree, rollDegree, pitchDegree, sideSlip; //speed / accel double airspeed, verticalSpd, xAccel, yAccel, zAccel; //printf("%s\n", buf); string msg = buf; string::size_type begin, end; begin = 0; end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } //aileron aileron = atof( msg.substr( begin, end ).c_str() ); begin = end + 1; //elevator end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } elevator = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //rudder end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } rudder = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //throttle end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } throttle = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //latitude end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } latitudeDegree = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //longitude end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } longitudeDegree = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //altitude end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } altitude = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //roll end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } rollDegree = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //pitch end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } pitchDegree = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //heading end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } headingDegree = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //side slip end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } sideSlip = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //airspeed end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } airspeed = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //vertical speed end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } verticalSpd = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //x accel end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } xAccel = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //y accel end = msg.find( ",", begin ); if ( end == string::npos ) { return false; } yAccel = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //z accel end = msg.find( "\n", begin ); if ( end == string::npos ) { return false; } zAccel = atof( msg.substr( begin, end - begin ).c_str() ); begin = end + 1; //set aircraft values sim_craft->set_aileron( aileron ); sim_craft->set_elevator( elevator ); sim_craft->set_rudder( rudder ); sim_craft->set_throttle( throttle ); sim_craft->set_latitude( latitudeDegree ); sim_craft->set_longitude( longitudeDegree ); sim_craft->set_altitude( altitude ); sim_craft->set_roll( rollDegree ); sim_craft->set_pitch( pitchDegree ); sim_craft->set_heading( headingDegree ); sim_craft->set_sideslip( sideSlip ); sim_craft->set_airspeed( airspeed ); sim_craft->set_vert_speed( verticalSpd ); sim_craft->set_xaccel( xAccel ); sim_craft->set_yaccel( yAccel ); sim_craft->set_zaccel( zAccel ); return true; } string command_output( void ) { stringstream s; s.precision( DECIMALS ); s << aileron_pid->update( sim_craft->get_roll() ) << "," << elevator_pid->update( sim_craft->get_pitch() ) << endl; /* s << sim_craft->get_aileron() << "," << sim_craft->get_elevator() << "," << sim_craft->get_rudder() << "," << sim_craft->get_throttle() << endl; */ //cout << s.str() << endl; return s.str(); } void redrawWindow( void ) { puDisplay(); glutSwapBuffers(); glutPostRedisplay(); } void reshapeWindow( int w, int h ) { //I am trying to preven window resizing, but this doesn't seem to work glutReshapeWindow( WINDOW_X, WINDOW_Y ); //set window back to initial size } void processMousefn ( int button, int updown, int x, int y ) { // Invoke the PUI mouse function puMouse ( button, updown, x, y ) ; glutPostRedisplay () ; } void processMotionfn ( int x, int y ){ // Invoke the PUI mouse motion function puMouse ( x, y ) ; glutPostRedisplay () ; } void processNormalKeys(unsigned char key, int x, int y) { // Invoke the PUI keyboard function puKeyboard ( key, PU_DOWN ) ; glutPostRedisplay() ; } /********************************************************************** * Initialize pui controls *********************************************************************/ void init_pui_widgets( void ) { int curx = PUI_X_GAP * 4 + PUI_ARROW_WIDTH * 2 + PUI_TEXT_WIDTH; int cury = PUI_RADIO_HEIGHT + PUI_Y_GAP * 2; puInit(); gui_frame = new puFrame( PUI_X_OFFSET, PUI_Y_OFFSET, PUI_X_OFFSET + WINDOW_X, PUI_Y_OFFSET + WINDOW_Y ); //log button log_button = new puButton( curx, cury, "Log: sLog.csv"); log_button->setSize( PUI_BUTTON_WIDTH, PUI_BUTTON_HEIGHT ); log_button->setValue( 0 ); //logging off by default log_button->setCallback( pui_callback ); cury += PUI_Y_GAP + PUI_BUTTON_HEIGHT; //pause button pause_button = new puButton( curx, cury, "Pause" ); pause_button->setSize( PUI_BUTTON_WIDTH, PUI_BUTTON_HEIGHT ); pause_button->setValue( 1 ); //pause by default pause_button->setCallback( pui_callback ); curx = PUI_X_GAP; cury = PUI_Y_GAP; //radio buttons controller_selector = new puButtonBox ( curx, cury, curx + PUI_RADIO_WIDTH, cury + PUI_RADIO_HEIGHT, controller_selector_labels, 1 ); //value corresponds to index of item in labels array controller_selector->setCallback( pui_callback ); cury += PUI_RADIO_HEIGHT + PUI_Y_GAP; //kd items kd_arrow_l = new puArrowButton ( curx, cury, curx + PUI_ARROW_WIDTH, cury + PUI_ARROW_HEIGHT, PUARROW_LEFT ); kd_arrow_l->setCallback( pui_callback ); curx += PUI_ARROW_WIDTH + PUI_X_GAP; //kd_text kd_text = new puInput ( curx, cury, curx + PUI_TEXT_WIDTH, cury + PUI_TEXT_HEIGHT ) ; kd_text->setValidData( valid_input ); sprintf( kd_str, "%.3f", aileron_pid->get_kd() ); //format label kd_text->setValue( kd_str ); //set value to aileron gains since roll is selected by default kd_text->setLabel( "Kd" ); kd_text->setLabelPlace( PUPLACE_TOP_CENTERED ); kd_text->setCallback( pui_callback ); curx += PUI_TEXT_WIDTH + PUI_X_GAP; kd_arrow_r = new puArrowButton ( curx, cury, curx + PUI_ARROW_WIDTH, cury + PUI_ARROW_HEIGHT, PUARROW_RIGHT ); kd_arrow_r->setCallback( pui_callback ); curx = PUI_X_GAP; cury += PUI_ARROW_HEIGHT + PUI_Y_GAP; //ki items ki_arrow_l = new puArrowButton ( curx, cury, curx + PUI_ARROW_WIDTH, cury + PUI_ARROW_HEIGHT, PUARROW_LEFT ); ki_arrow_l->setCallback( pui_callback ); curx += PUI_ARROW_WIDTH + PUI_X_GAP; //ki_text ki_text = new puInput ( curx, cury, curx + PUI_TEXT_WIDTH, cury + PUI_TEXT_HEIGHT ) ; ki_text->setValidData( valid_input ); sprintf( ki_str, "%.3f", aileron_pid->get_ki() ); //format label ki_text->setValue( ki_str ); //set value to aileron gains since roll is selected by default ki_text->setLabel( "Ki" ); ki_text->setLabelPlace( PUPLACE_TOP_CENTERED ); ki_text->setCallback( pui_callback ); curx += PUI_TEXT_WIDTH + PUI_X_GAP; ki_arrow_r = new puArrowButton ( curx, cury, curx + PUI_ARROW_WIDTH, cury + PUI_ARROW_HEIGHT, PUARROW_RIGHT ); ki_arrow_r->setCallback( pui_callback ); curx = PUI_X_GAP; cury += PUI_ARROW_HEIGHT + PUI_Y_GAP; //kp items kp_arrow_l = new puArrowButton ( curx, cury, curx + PUI_ARROW_WIDTH, cury + PUI_ARROW_HEIGHT, PUARROW_LEFT ); kp_arrow_l->setCallback( pui_callback ); curx += PUI_ARROW_WIDTH + PUI_X_GAP; //kp_text kp_text = new puInput ( curx, cury, curx + PUI_TEXT_WIDTH, cury + PUI_TEXT_HEIGHT ) ; kp_text->setValidData( valid_input ); sprintf( kp_str, "%.3f", aileron_pid->get_kp() ); //format label kp_text->setValue( kp_str ); //set value to aileron gains since roll is selected by default kp_text->setLabel( "Kp" ); kp_text->setLabelPlace( PUPLACE_TOP_CENTERED ); kp_text->setCallback( pui_callback ); curx += PUI_TEXT_WIDTH + PUI_X_GAP; kp_arrow_r = new puArrowButton ( curx, cury, curx + PUI_ARROW_WIDTH, cury + PUI_ARROW_HEIGHT, PUARROW_RIGHT ); kp_arrow_r->setCallback( pui_callback ); curx = PUI_X_GAP; cury += PUI_ARROW_HEIGHT + PUI_Y_GAP; //target items target_arrow_l = new puArrowButton ( curx, cury, curx + PUI_ARROW_WIDTH, cury + PUI_ARROW_HEIGHT, PUARROW_LEFT ); target_arrow_l->setCallback( pui_callback ); curx += PUI_ARROW_WIDTH + PUI_X_GAP; //target_text target_text = new puInput ( curx, cury, curx + PUI_TEXT_WIDTH, cury + PUI_TEXT_HEIGHT ) ; target_text->setValidData( valid_input ); sprintf( target_str, "%.3f", aileron_pid->get_reference() ); //format label target_text->setValue( target_str ); //set value to aileron gains since roll is selected by default target_text->setLabel( "Target" ); target_text->setLabelPlace( PUPLACE_TOP_CENTERED ); target_text->setCallback( pui_callback ); curx += PUI_TEXT_WIDTH + PUI_X_GAP; target_arrow_r = new puArrowButton ( curx, cury, curx + PUI_ARROW_WIDTH, cury + PUI_ARROW_HEIGHT, PUARROW_RIGHT ); target_arrow_r->setCallback( pui_callback ); curx += PUI_ARROW_WIDTH + PUI_X_GAP; cury -= PUI_ARROW_HEIGHT - PUI_Y_GAP; //labels roll_err_label = new puText ( curx, cury ) ; roll_err_label->setLabel( "Roll error: 0.000" ); cury += PUI_ARROW_HEIGHT; pitch_err_label = new puText ( curx, cury ) ; pitch_err_label->setLabel( "Pitch error: 0.000" ); curx = PUI_RADIO_WIDTH + PUI_X_GAP * 2; cury = PUI_Y_GAP; udp_label = new puText ( curx, cury ) ; udp_label->setLabel( "UDP in: 5500 | UDP out: 5501" ); //hertz text input hertz_text = new puInput ( curx, cury, curx + PUI_TEXT_WIDTH, cury + PUI_TEXT_HEIGHT ) ; //hertz_text->setValidData( valid_input ); hertz_text->setValuator( &update ); hertz_text->setLabel( "Hertz" ); hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); //hertz_text->setCallback( pui_callback ); } /********************************************************************** * pui callback *********************************************************************/ void pui_callback( puObject *pob ){ const float interval = 0.001; //increment or decrement interval //this will be 0 for roll and 1 for pitch int val = controller_selector->getValue(); bool aileron; if ( val == 0 ) { aileron = true; } else { aileron = false; } if ( pob == log_button ) { //toggle logging logging = log_button->getValue(); //cout << "log_button" << endl; } else if ( pob == pause_button ) { //toggle pause pauseSoftSim = pause_button->getValue(); //cout << "pause_button" << endl; } else if ( pob == controller_selector ) { //update gui if ( aileron ) { //update for ailerons gui_update( aileron_pid ); } else { //update for elevator gui_update( elevator_pid ); } } else if ( pob == kp_arrow_l ) { //decrement kp if ( aileron ) { aileron_pid->set_kp( aileron_pid->get_kp() - interval ); gui_update( aileron_pid ); } else { elevator_pid->set_kp( elevator_pid->get_kp() - interval ); gui_update( elevator_pid ); } } else if ( pob == kp_arrow_r ) { //increment kp if ( aileron ) { aileron_pid->set_kp( aileron_pid->get_kp() + interval ); gui_update( aileron_pid ); } else { elevator_pid->set_kp( elevator_pid->get_kp() + interval ); gui_update( elevator_pid ); } } else if ( pob == ki_arrow_l ) { //decrement ki if ( aileron ) { aileron_pid->set_ki( aileron_pid->get_ki() - interval ); gui_update( aileron_pid ); } else { elevator_pid->set_ki( elevator_pid->get_ki() - interval ); gui_update( elevator_pid ); } } else if ( pob == ki_arrow_r ) { //increment ki if ( aileron ) { aileron_pid->set_ki( aileron_pid->get_ki() + interval ); gui_update( aileron_pid ); } else { elevator_pid->set_ki( elevator_pid->get_ki() + interval ); gui_update( elevator_pid ); } } else if ( pob == kd_arrow_l ) { //decrement kd if ( aileron ) { aileron_pid->set_kd( aileron_pid->get_kd() - interval ); gui_update( aileron_pid ); } else { elevator_pid->set_kd( elevator_pid->get_kd() - interval ); gui_update( elevator_pid ); } } else if ( pob == kd_arrow_r ) { //increment kd if ( aileron ) { aileron_pid->set_kd( aileron_pid->get_kd() + interval ); gui_update( aileron_pid ); } else { elevator_pid->set_kd( elevator_pid->get_kd() + interval ); gui_update( elevator_pid ); } } else if ( pob == target_arrow_l ) { //decrement target if ( aileron ) { aileron_pid->set_reference( aileron_pid->get_reference() - 1 ); gui_update( aileron_pid ); } else { elevator_pid->set_reference( elevator_pid->get_reference() - 1 ); gui_update( elevator_pid ); } } else if ( pob == target_arrow_r ) { //increment target if ( aileron ) { aileron_pid->set_reference( aileron_pid->get_reference() + 1 ); gui_update( aileron_pid ); } else { elevator_pid->set_reference( elevator_pid->get_reference() + 1 ); gui_update( elevator_pid ); } } else { cout << "Unknown callback to pui_callback" << endl; } } void gui_update( SSPid *pid ) { sprintf( kp_str, "%.3f", pid->get_kp() ); //format label kp_text->setValue( kp_str ); sprintf( ki_str, "%.3f", pid->get_ki() ); //format label ki_text->setValue( ki_str ); sprintf( kd_str, "%.3f", pid->get_kd() ); //format label kd_text->setValue( kd_str ); sprintf( target_str, "%.3f", pid->get_reference() ); //format label target_text->setValue( target_str ); } On Thu, Jun 12, 2008 at 4:42 PM, Fay John F Dr CTR USAF 46 SK <joh...@eg...> wrote: > Hmmm ... unless somebody else steps in, please forward me a copy of the > offending code. I've tried putting in your code snippet and the program > works just fine for me, so evidently something else is going on. > > John F. Fay > Technical Fellow > Jacobs Technology TEAS Group > 850-883-1294 > > -----Original Message----- > From: pli...@li... > [mailto:pli...@li...] On Behalf Of cory > barton > Sent: Thursday, June 12, 2008 3:19 PM > To: PLIB Users > Subject: [Plib-users] (cory vs. pui) The attack of setValuator > > I found the following in the PUI documentation today: > There are many occasions when you'd really like to have the PUI widget > directly drive and/or reflect the value of some memory location in the > application code. These calls let you do that: > > void puObject::setValuator ( int *i ) ; > void puObject::setValuator ( float *f ) ; > void puObject::setValuator ( char *s ) ; > > > Once you make one of these calls, PUI will automatically update the > memory location indicated with the current value of the widget > whenever it changes - and also update the appearance of the widget to > reflect the value stored in that memory location whenever the widget > is redrawn. This is often a lot more convenient than using a callback > function to register changes in the widget's value. > > So I tried it out: > //global variable > float update = 1.0f; > > //initialize my puInput inside a function > //hertz text input > hertz_text = new puInput ( curx, cury, > curx + > PUI_TEXT_WIDTH, > cury + > PUI_TEXT_HEIGHT ) ; > hertz_text->setValuator( &update ); > hertz_text->setLabel( "Hertz" ); > hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); > > > This compiles, and runs. > > It seems to work correctly as long as I do not remove all of the > characters from the puInput box. However if I am trying to change the > value, when I am typing in the new value, if the new value ever > becomes a non valid float value, then the program crashes. For example > if I want to change 1.0 to 2.0 and I delete 1.0 so I can type 2.0, > then instant crash. I can change from 1.0 to 2.0 if I type the 2 after > the 1, and then erase the 1. > > Searching the mail archives and googling didn't help, so I am posting > here. > > I suspect either my weak understanding of pointers means that I am > passing an incorrect argument to the setValuator function, or maybe > the puInput object is writing invalid data to the update variable. > > Please let me know how to fix this. > > thanks, > > Cory > > ------------------------------------------------------------------------ > - > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > |
From: Fay J. F Dr C. U. 46 S. <joh...@eg...> - 2008-06-12 21:30:19
|
Sorry, I still can't get it to crash. What version of PUI are you using? John F. Fay Technical Fellow Jacobs Technology TEAS Group 850-883-1294 -----Original Message----- From: pli...@li... [mailto:pli...@li...] On Behalf Of cory barton Sent: Thursday, June 12, 2008 3:53 PM To: PLIB Users Subject: Re: [Plib-users] (cory vs. pui) The attack of setValuator Here is the code: <snip> On Thu, Jun 12, 2008 at 4:42 PM, Fay John F Dr CTR USAF 46 SK <joh...@eg...> wrote: > Hmmm ... unless somebody else steps in, please forward me a copy of the > offending code. I've tried putting in your code snippet and the program > works just fine for me, so evidently something else is going on. > > John F. Fay > Technical Fellow > Jacobs Technology TEAS Group > 850-883-1294 > > -----Original Message----- > From: pli...@li... > [mailto:pli...@li...] On Behalf Of cory > barton > Sent: Thursday, June 12, 2008 3:19 PM > To: PLIB Users > Subject: [Plib-users] (cory vs. pui) The attack of setValuator > > I found the following in the PUI documentation today: > There are many occasions when you'd really like to have the PUI widget > directly drive and/or reflect the value of some memory location in the > application code. These calls let you do that: > > void puObject::setValuator ( int *i ) ; > void puObject::setValuator ( float *f ) ; > void puObject::setValuator ( char *s ) ; > > > Once you make one of these calls, PUI will automatically update the > memory location indicated with the current value of the widget > whenever it changes - and also update the appearance of the widget to > reflect the value stored in that memory location whenever the widget > is redrawn. This is often a lot more convenient than using a callback > function to register changes in the widget's value. > > So I tried it out: > //global variable > float update = 1.0f; > > //initialize my puInput inside a function > //hertz text input > hertz_text = new puInput ( curx, cury, > curx + > PUI_TEXT_WIDTH, > cury + > PUI_TEXT_HEIGHT ) ; > hertz_text->setValuator( &update ); > hertz_text->setLabel( "Hertz" ); > hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); > > > This compiles, and runs. > > It seems to work correctly as long as I do not remove all of the > characters from the puInput box. However if I am trying to change the > value, when I am typing in the new value, if the new value ever > becomes a non valid float value, then the program crashes. For example > if I want to change 1.0 to 2.0 and I delete 1.0 so I can type 2.0, > then instant crash. I can change from 1.0 to 2.0 if I type the 2 after > the 1, and then erase the 1. > > Searching the mail archives and googling didn't help, so I am posting > here. > > I suspect either my weak understanding of pointers means that I am > passing an incorrect argument to the setValuator function, or maybe > the puInput object is writing invalid data to the update variable. > > Please let me know how to fix this. > > thanks, > > Cory > |
From: cory b. <co...@gm...> - 2008-06-12 22:12:55
|
1.8.4c2 ubuntu package On Thu, Jun 12, 2008 at 5:30 PM, Fay John F Dr CTR USAF 46 SK <joh...@eg...> wrote: > Sorry, I still can't get it to crash. > > What version of PUI are you using? > > John F. Fay > Technical Fellow > Jacobs Technology TEAS Group > 850-883-1294 > > -----Original Message----- > From: pli...@li... > [mailto:pli...@li...] On Behalf Of cory > barton > Sent: Thursday, June 12, 2008 3:53 PM > To: PLIB Users > Subject: Re: [Plib-users] (cory vs. pui) The attack of setValuator > > Here is the code: > > <snip> > > > On Thu, Jun 12, 2008 at 4:42 PM, Fay John F Dr CTR USAF 46 SK > <joh...@eg...> wrote: >> Hmmm ... unless somebody else steps in, please forward me a copy of > the >> offending code. I've tried putting in your code snippet and the > program >> works just fine for me, so evidently something else is going on. >> >> John F. Fay >> Technical Fellow >> Jacobs Technology TEAS Group >> 850-883-1294 >> >> -----Original Message----- >> From: pli...@li... >> [mailto:pli...@li...] On Behalf Of cory >> barton >> Sent: Thursday, June 12, 2008 3:19 PM >> To: PLIB Users >> Subject: [Plib-users] (cory vs. pui) The attack of setValuator >> >> I found the following in the PUI documentation today: >> There are many occasions when you'd really like to have the PUI widget >> directly drive and/or reflect the value of some memory location in the >> application code. These calls let you do that: >> >> void puObject::setValuator ( int *i ) ; >> void puObject::setValuator ( float *f ) ; >> void puObject::setValuator ( char *s ) ; >> >> >> Once you make one of these calls, PUI will automatically update the >> memory location indicated with the current value of the widget >> whenever it changes - and also update the appearance of the widget to >> reflect the value stored in that memory location whenever the widget >> is redrawn. This is often a lot more convenient than using a callback >> function to register changes in the widget's value. >> >> So I tried it out: >> //global variable >> float update = 1.0f; >> >> //initialize my puInput inside a function >> //hertz text input >> hertz_text = new puInput ( curx, cury, >> curx + >> PUI_TEXT_WIDTH, >> cury + >> PUI_TEXT_HEIGHT ) ; >> hertz_text->setValuator( &update ); >> hertz_text->setLabel( "Hertz" ); >> hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); >> >> >> This compiles, and runs. >> >> It seems to work correctly as long as I do not remove all of the >> characters from the puInput box. However if I am trying to change the >> value, when I am typing in the new value, if the new value ever >> becomes a non valid float value, then the program crashes. For example >> if I want to change 1.0 to 2.0 and I delete 1.0 so I can type 2.0, >> then instant crash. I can change from 1.0 to 2.0 if I type the 2 after >> the 1, and then erase the 1. >> >> Searching the mail archives and googling didn't help, so I am posting >> here. >> >> I suspect either my weak understanding of pointers means that I am >> passing an incorrect argument to the setValuator function, or maybe >> the puInput object is writing invalid data to the update variable. >> >> Please let me know how to fix this. >> >> thanks, >> >> Cory >> > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > |
From: Fay J. F Dr C. U. 46 S. <joh...@eg...> - 2008-06-13 13:25:53
|
Hmmm ... I'm running on Windows, but that shouldn't make a difference. (Of course, "shouldn't" is the longest word in the English language, right up there with "if.") Have you tried getting the most recent SVN version? Unfortunately I've been away from the library for a couple of years now, and I'm a bit rusty on what's what. John F. Fay Technical Fellow Jacobs Technology TEAS Group 850-883-1294 -----Original Message----- From: pli...@li... [mailto:pli...@li...] On Behalf Of cory barton Sent: Thursday, June 12, 2008 5:13 PM To: PLIB Users Subject: Re: [Plib-users] (cory vs. pui) The attack of setValuator 1.8.4c2 ubuntu package On Thu, Jun 12, 2008 at 5:30 PM, Fay John F Dr CTR USAF 46 SK <joh...@eg...> wrote: > Sorry, I still can't get it to crash. > > What version of PUI are you using? > > John F. Fay > Technical Fellow > Jacobs Technology TEAS Group > 850-883-1294 > > -----Original Message----- > From: pli...@li... > [mailto:pli...@li...] On Behalf Of cory > barton > Sent: Thursday, June 12, 2008 3:53 PM > To: PLIB Users > Subject: Re: [Plib-users] (cory vs. pui) The attack of setValuator > > Here is the code: > > <snip> > > > On Thu, Jun 12, 2008 at 4:42 PM, Fay John F Dr CTR USAF 46 SK > <joh...@eg...> wrote: >> Hmmm ... unless somebody else steps in, please forward me a copy of > the >> offending code. I've tried putting in your code snippet and the > program >> works just fine for me, so evidently something else is going on. >> >> John F. Fay >> Technical Fellow >> Jacobs Technology TEAS Group >> 850-883-1294 >> >> -----Original Message----- >> From: pli...@li... >> [mailto:pli...@li...] On Behalf Of cory >> barton >> Sent: Thursday, June 12, 2008 3:19 PM >> To: PLIB Users >> Subject: [Plib-users] (cory vs. pui) The attack of setValuator >> >> I found the following in the PUI documentation today: >> There are many occasions when you'd really like to have the PUI widget >> directly drive and/or reflect the value of some memory location in the >> application code. These calls let you do that: >> >> void puObject::setValuator ( int *i ) ; >> void puObject::setValuator ( float *f ) ; >> void puObject::setValuator ( char *s ) ; >> >> >> Once you make one of these calls, PUI will automatically update the >> memory location indicated with the current value of the widget >> whenever it changes - and also update the appearance of the widget to >> reflect the value stored in that memory location whenever the widget >> is redrawn. This is often a lot more convenient than using a callback >> function to register changes in the widget's value. >> >> So I tried it out: >> //global variable >> float update = 1.0f; >> >> //initialize my puInput inside a function >> //hertz text input >> hertz_text = new puInput ( curx, cury, >> curx + >> PUI_TEXT_WIDTH, >> cury + >> PUI_TEXT_HEIGHT ) ; >> hertz_text->setValuator( &update ); >> hertz_text->setLabel( "Hertz" ); >> hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); >> >> >> This compiles, and runs. >> >> It seems to work correctly as long as I do not remove all of the >> characters from the puInput box. However if I am trying to change the >> value, when I am typing in the new value, if the new value ever >> becomes a non valid float value, then the program crashes. For example >> if I want to change 1.0 to 2.0 and I delete 1.0 so I can type 2.0, >> then instant crash. I can change from 1.0 to 2.0 if I type the 2 after >> the 1, and then erase the 1. >> >> Searching the mail archives and googling didn't help, so I am posting >> here. >> >> I suspect either my weak understanding of pointers means that I am >> passing an incorrect argument to the setValuator function, or maybe >> the puInput object is writing invalid data to the update variable. >> >> Please let me know how to fix this. >> >> thanks, >> >> Cory >> > > > ------------------------------------------------------------------------ - > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > ------------------------------------------------------------------------ - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ plib-users mailing list pli...@li... https://lists.sourceforge.net/lists/listinfo/plib-users |
From: cory b. <co...@gm...> - 2008-06-13 18:59:37
|
I haven't tried the most recent SVN version. I will try that and let you know. May be tuesday before I have a chance to try that. I am going out of town. thanks, Cory On Fri, Jun 13, 2008 at 9:25 AM, Fay John F Dr CTR USAF 46 SK <joh...@eg...> wrote: > Hmmm ... I'm running on Windows, but that shouldn't make a difference. > (Of course, "shouldn't" is the longest word in the English language, > right up there with "if.") > > Have you tried getting the most recent SVN version? > > Unfortunately I've been away from the library for a couple of years now, > and I'm a bit rusty on what's what. > > John F. Fay > Technical Fellow > Jacobs Technology TEAS Group > 850-883-1294 > > -----Original Message----- > From: pli...@li... > [mailto:pli...@li...] On Behalf Of cory > barton > Sent: Thursday, June 12, 2008 5:13 PM > To: PLIB Users > Subject: Re: [Plib-users] (cory vs. pui) The attack of setValuator > > 1.8.4c2 ubuntu package > > > > On Thu, Jun 12, 2008 at 5:30 PM, Fay John F Dr CTR USAF 46 SK > <joh...@eg...> wrote: >> Sorry, I still can't get it to crash. >> >> What version of PUI are you using? >> >> John F. Fay >> Technical Fellow >> Jacobs Technology TEAS Group >> 850-883-1294 >> >> -----Original Message----- >> From: pli...@li... >> [mailto:pli...@li...] On Behalf Of cory >> barton >> Sent: Thursday, June 12, 2008 3:53 PM >> To: PLIB Users >> Subject: Re: [Plib-users] (cory vs. pui) The attack of setValuator >> >> Here is the code: >> >> <snip> >> >> >> On Thu, Jun 12, 2008 at 4:42 PM, Fay John F Dr CTR USAF 46 SK >> <joh...@eg...> wrote: >>> Hmmm ... unless somebody else steps in, please forward me a copy of >> the >>> offending code. I've tried putting in your code snippet and the >> program >>> works just fine for me, so evidently something else is going on. >>> >>> John F. Fay >>> Technical Fellow >>> Jacobs Technology TEAS Group >>> 850-883-1294 >>> >>> -----Original Message----- >>> From: pli...@li... >>> [mailto:pli...@li...] On Behalf Of cory >>> barton >>> Sent: Thursday, June 12, 2008 3:19 PM >>> To: PLIB Users >>> Subject: [Plib-users] (cory vs. pui) The attack of setValuator >>> >>> I found the following in the PUI documentation today: >>> There are many occasions when you'd really like to have the PUI > widget >>> directly drive and/or reflect the value of some memory location in > the >>> application code. These calls let you do that: >>> >>> void puObject::setValuator ( int *i ) ; >>> void puObject::setValuator ( float *f ) ; >>> void puObject::setValuator ( char *s ) ; >>> >>> >>> Once you make one of these calls, PUI will automatically update the >>> memory location indicated with the current value of the widget >>> whenever it changes - and also update the appearance of the widget to >>> reflect the value stored in that memory location whenever the widget >>> is redrawn. This is often a lot more convenient than using a callback >>> function to register changes in the widget's value. >>> >>> So I tried it out: >>> //global variable >>> float update = 1.0f; >>> >>> //initialize my puInput inside a function >>> //hertz text input >>> hertz_text = new puInput ( curx, cury, >>> curx + >>> PUI_TEXT_WIDTH, >>> cury + >>> PUI_TEXT_HEIGHT ) ; >>> hertz_text->setValuator( &update ); >>> hertz_text->setLabel( "Hertz" ); >>> hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); >>> >>> >>> This compiles, and runs. >>> >>> It seems to work correctly as long as I do not remove all of the >>> characters from the puInput box. However if I am trying to change the >>> value, when I am typing in the new value, if the new value ever >>> becomes a non valid float value, then the program crashes. For > example >>> if I want to change 1.0 to 2.0 and I delete 1.0 so I can type 2.0, >>> then instant crash. I can change from 1.0 to 2.0 if I type the 2 > after >>> the 1, and then erase the 1. >>> >>> Searching the mail archives and googling didn't help, so I am posting >>> here. >>> >>> I suspect either my weak understanding of pointers means that I am >>> passing an incorrect argument to the setValuator function, or maybe >>> the puInput object is writing invalid data to the update variable. >>> >>> Please let me know how to fix this. >>> >>> thanks, >>> >>> Cory >>> >> >> >> > ------------------------------------------------------------------------ > - >> Check out the new SourceForge.net Marketplace. >> It's the best place to buy or sell services for >> just about anything Open Source. >> http://sourceforge.net/services/buy/index.php >> _______________________________________________ >> plib-users mailing list >> pli...@li... >> https://lists.sourceforge.net/lists/listinfo/plib-users >> > > ------------------------------------------------------------------------ > - > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > |
From: cory b. <co...@gm...> - 2008-06-15 01:25:42
|
I wasn't sure how to get the SVN version, so I am trying to install PLIB 1.8.5, but ./configure is failing. Here is the last bit of the ./configure output(everything before it is yes): checking for pthread_create in -lpthread... no checking for glNewList in -lGL... no checking for glNewList in -lMesaGL... no configure: error: could not find working GL library I do have the following packages installed: ii freeglut3 2.4.0-6 OpenGL Utility Toolkit ii freeglut3-dev 2.4.0-6 OpenGL Utility Toolkit development files ii glutg3 3.7-25 the OpenGL Utility Toolkit ii glutg3-dev 3.7-25 the OpenGL Utility Toolkit development files ii libgl1-mesa-dev 7.0.3~rc2-1ubuntu3 A free implementation of the OpenGL API -- G ii libgl1-mesa-dri 7.0.3~rc2-1ubuntu3 A free implementation of the OpenGL API -- D ii libgl1-mesa-glx 7.0.3~rc2-1ubuntu3 A free implementation of the OpenGL API -- G rc libglew1.4 1.4.0-1ubuntu1 The OpenGL Extension Wrangler - runtime envi ii libglew1.5 1.5.0dfsg1-3ubuntu1 The OpenGL Extension Wrangler - runtime envi ii libglib2.0-0 2.16.3-1ubuntu2 The GLib library of C routines ii libglib2.0-cil 2.12.0-2ubuntu3 CLI binding for the GLib utility library 2.1 ii libglibmm-2.4-1c2a 2.16.0-1 C++ wrapper for the GLib toolkit (shared lib ii libglu1-mesa 7.0.3~rc2-1ubuntu3 The OpenGL utility library (GLU) ii libglu1-mesa-dev 7.0.3~rc2-1ubuntu3 The OpenGL utility library -- development fi ii libglut3 3.7-25 the OpenGL Utility Toolkit ii libglut3-dev 3.7-25 development libraries and headers for GLUT ii xlibmesa-gl-dev 1:7.3+10ubuntu10 transitional package for Debian etch ii xorg-driver-fglrx 1:7.1.0-8-3+2.6.24.13-18.41 Video driver for ATI graphics accelerators ii xscreensaver-gl 5.04-4ubuntu1 GL(Mesa) screen hacks for xscreensaver ii xserver-xorg-video-glint 1:1.1.1-8 X.Org X server -- Glint display driver What am I missing? I have googled all over for a solution to this, but have not found it. Thanks, Cory On Fri, Jun 13, 2008 at 2:59 PM, cory barton <co...@gm...> wrote: > I haven't tried the most recent SVN version. > > I will try that and let you know. May be tuesday before I have a > chance to try that. I am going out of town. > > thanks, > > Cory > > > On Fri, Jun 13, 2008 at 9:25 AM, Fay John F Dr CTR USAF 46 SK > <joh...@eg...> wrote: >> Hmmm ... I'm running on Windows, but that shouldn't make a difference. >> (Of course, "shouldn't" is the longest word in the English language, >> right up there with "if.") >> >> Have you tried getting the most recent SVN version? >> >> Unfortunately I've been away from the library for a couple of years now, >> and I'm a bit rusty on what's what. >> >> John F. Fay >> Technical Fellow >> Jacobs Technology TEAS Group >> 850-883-1294 >> >> -----Original Message----- >> From: pli...@li... >> [mailto:pli...@li...] On Behalf Of cory >> barton >> Sent: Thursday, June 12, 2008 5:13 PM >> To: PLIB Users >> Subject: Re: [Plib-users] (cory vs. pui) The attack of setValuator >> >> 1.8.4c2 ubuntu package >> >> >> >> On Thu, Jun 12, 2008 at 5:30 PM, Fay John F Dr CTR USAF 46 SK >> <joh...@eg...> wrote: >>> Sorry, I still can't get it to crash. >>> >>> What version of PUI are you using? >>> >>> John F. Fay >>> Technical Fellow >>> Jacobs Technology TEAS Group >>> 850-883-1294 >>> >>> -----Original Message----- >>> From: pli...@li... >>> [mailto:pli...@li...] On Behalf Of cory >>> barton >>> Sent: Thursday, June 12, 2008 3:53 PM >>> To: PLIB Users >>> Subject: Re: [Plib-users] (cory vs. pui) The attack of setValuator >>> >>> Here is the code: >>> >>> <snip> >>> >>> >>> On Thu, Jun 12, 2008 at 4:42 PM, Fay John F Dr CTR USAF 46 SK >>> <joh...@eg...> wrote: >>>> Hmmm ... unless somebody else steps in, please forward me a copy of >>> the >>>> offending code. I've tried putting in your code snippet and the >>> program >>>> works just fine for me, so evidently something else is going on. >>>> >>>> John F. Fay >>>> Technical Fellow >>>> Jacobs Technology TEAS Group >>>> 850-883-1294 >>>> >>>> -----Original Message----- >>>> From: pli...@li... >>>> [mailto:pli...@li...] On Behalf Of cory >>>> barton >>>> Sent: Thursday, June 12, 2008 3:19 PM >>>> To: PLIB Users >>>> Subject: [Plib-users] (cory vs. pui) The attack of setValuator >>>> >>>> I found the following in the PUI documentation today: >>>> There are many occasions when you'd really like to have the PUI >> widget >>>> directly drive and/or reflect the value of some memory location in >> the >>>> application code. These calls let you do that: >>>> >>>> void puObject::setValuator ( int *i ) ; >>>> void puObject::setValuator ( float *f ) ; >>>> void puObject::setValuator ( char *s ) ; >>>> >>>> >>>> Once you make one of these calls, PUI will automatically update the >>>> memory location indicated with the current value of the widget >>>> whenever it changes - and also update the appearance of the widget to >>>> reflect the value stored in that memory location whenever the widget >>>> is redrawn. This is often a lot more convenient than using a callback >>>> function to register changes in the widget's value. >>>> >>>> So I tried it out: >>>> //global variable >>>> float update = 1.0f; >>>> >>>> //initialize my puInput inside a function >>>> //hertz text input >>>> hertz_text = new puInput ( curx, cury, >>>> curx + >>>> PUI_TEXT_WIDTH, >>>> cury + >>>> PUI_TEXT_HEIGHT ) ; >>>> hertz_text->setValuator( &update ); >>>> hertz_text->setLabel( "Hertz" ); >>>> hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); >>>> >>>> >>>> This compiles, and runs. >>>> >>>> It seems to work correctly as long as I do not remove all of the >>>> characters from the puInput box. However if I am trying to change the >>>> value, when I am typing in the new value, if the new value ever >>>> becomes a non valid float value, then the program crashes. For >> example >>>> if I want to change 1.0 to 2.0 and I delete 1.0 so I can type 2.0, >>>> then instant crash. I can change from 1.0 to 2.0 if I type the 2 >> after >>>> the 1, and then erase the 1. >>>> >>>> Searching the mail archives and googling didn't help, so I am posting >>>> here. >>>> >>>> I suspect either my weak understanding of pointers means that I am >>>> passing an incorrect argument to the setValuator function, or maybe >>>> the puInput object is writing invalid data to the update variable. >>>> >>>> Please let me know how to fix this. >>>> >>>> thanks, >>>> >>>> Cory >>>> >>> >>> >>> >> ------------------------------------------------------------------------ >> - >>> Check out the new SourceForge.net Marketplace. >>> It's the best place to buy or sell services for >>> just about anything Open Source. >>> http://sourceforge.net/services/buy/index.php >>> _______________________________________________ >>> plib-users mailing list >>> pli...@li... >>> https://lists.sourceforge.net/lists/listinfo/plib-users >>> >> >> ------------------------------------------------------------------------ >> - >> Check out the new SourceForge.net Marketplace. >> It's the best place to buy or sell services for >> just about anything Open Source. >> http://sourceforge.net/services/buy/index.php >> _______________________________________________ >> plib-users mailing list >> pli...@li... >> https://lists.sourceforge.net/lists/listinfo/plib-users >> >> ------------------------------------------------------------------------- >> Check out the new SourceForge.net Marketplace. >> It's the best place to buy or sell services for >> just about anything Open Source. >> http://sourceforge.net/services/buy/index.php >> _______________________________________________ >> plib-users mailing list >> pli...@li... >> https://lists.sourceforge.net/lists/listinfo/plib-users >> > |
From: Stuart M. <stu...@bl...> - 2008-06-15 19:52:43
|
You need to find where the libraries are installed and ensure that the -L library path flag is set correctly. Unfortunately I really don't know much about Linux installs or autoconf, but I do know what it's doing is creating a small C file which has a call to a function that should be in the library (glNewList in this case). It then compile and link that small program and if it works then library must have been found. From the list below it looks like you have Mesa installed so I can only assume it's not in a location the the linker looks by default, therefore the -L<dir path> option must be given to tell it where to look for the libMesaGL.0 (or libMesaGL.a sorry, as I said I don't know much about linux). e.g. it could be the library is /usr/local/lib/libMesaGL.sl so you would need to get -L /usr/local/lib in the the link flags (again, sorry don't know how to drive autoconf to do this). The configure script should generate a log (config.log?) that shows the small program is it trying to compile. To find the library you could do a find / -name "lib*Mesa*" (might take a while 8-) It could also be the library is named something else, (say) libOSMesaGL.a or something. No idea how to properly fix something like that, but as a last resort you could hand edit the configure.ac (might be configure.in) and change the name. Hopefully some help. Good luck, Stuart. cory barton wrote: > I wasn't sure how to get the SVN version, so I am trying to install > PLIB 1.8.5, but ./configure is failing. > > Here is the last bit of the ./configure output(everything before it is yes): > > checking for pthread_create in -lpthread... no > checking for glNewList in -lGL... no > checking for glNewList in -lMesaGL... no > configure: error: could not find working GL library > > I do have the following packages installed: > ii freeglut3 2.4.0-6 > OpenGL Utility Toolkit > ii freeglut3-dev 2.4.0-6 > OpenGL Utility Toolkit development files > ii glutg3 3.7-25 > the OpenGL Utility Toolkit > ii glutg3-dev 3.7-25 > the OpenGL Utility Toolkit development files > ii libgl1-mesa-dev 7.0.3~rc2-1ubuntu3 > A free implementation of the OpenGL API -- G > ii libgl1-mesa-dri 7.0.3~rc2-1ubuntu3 > A free implementation of the OpenGL API -- D > ii libgl1-mesa-glx 7.0.3~rc2-1ubuntu3 > A free implementation of the OpenGL API -- G > rc libglew1.4 1.4.0-1ubuntu1 > The OpenGL Extension Wrangler - runtime envi > ii libglew1.5 1.5.0dfsg1-3ubuntu1 > The OpenGL Extension Wrangler - runtime envi > ii libglib2.0-0 2.16.3-1ubuntu2 > The GLib library of C routines > ii libglib2.0-cil 2.12.0-2ubuntu3 > CLI binding for the GLib utility library 2.1 > ii libglibmm-2.4-1c2a 2.16.0-1 > C++ wrapper for the GLib toolkit (shared lib > ii libglu1-mesa 7.0.3~rc2-1ubuntu3 > The OpenGL utility library (GLU) > ii libglu1-mesa-dev 7.0.3~rc2-1ubuntu3 > The OpenGL utility library -- development fi > ii libglut3 3.7-25 > the OpenGL Utility Toolkit > ii libglut3-dev 3.7-25 > development libraries and headers for GLUT > ii xlibmesa-gl-dev 1:7.3+10ubuntu10 > transitional package for Debian etch > ii xorg-driver-fglrx > 1:7.1.0-8-3+2.6.24.13-18.41 Video driver for ATI graphics > accelerators > ii xscreensaver-gl 5.04-4ubuntu1 > GL(Mesa) screen hacks for xscreensaver > ii xserver-xorg-video-glint 1:1.1.1-8 > X.Org X server -- Glint display driver > > What am I missing? I have googled all over for a solution to this, but > have not found it. > > Thanks, > > Cory > > > On Fri, Jun 13, 2008 at 2:59 PM, cory barton <co...@gm...> wrote: > >> I haven't tried the most recent SVN version. >> >> I will try that and let you know. May be tuesday before I have a >> chance to try that. I am going out of town. >> >> thanks, >> >> Cory >> >> >> On Fri, Jun 13, 2008 at 9:25 AM, Fay John F Dr CTR USAF 46 SK >> <joh...@eg...> wrote: >> >>> Hmmm ... I'm running on Windows, but that shouldn't make a difference. >>> (Of course, "shouldn't" is the longest word in the English language, >>> right up there with "if.") >>> >>> Have you tried getting the most recent SVN version? >>> >>> Unfortunately I've been away from the library for a couple of years now, >>> and I'm a bit rusty on what's what. >>> >>> John F. Fay >>> Technical Fellow >>> Jacobs Technology TEAS Group >>> 850-883-1294 >>> >>> -----Original Message----- >>> From: pli...@li... >>> [mailto:pli...@li...] On Behalf Of cory >>> barton >>> Sent: Thursday, June 12, 2008 5:13 PM >>> To: PLIB Users >>> Subject: Re: [Plib-users] (cory vs. pui) The attack of setValuator >>> >>> 1.8.4c2 ubuntu package >>> >>> >>> >>> On Thu, Jun 12, 2008 at 5:30 PM, Fay John F Dr CTR USAF 46 SK >>> <joh...@eg...> wrote: >>> >>>> Sorry, I still can't get it to crash. >>>> >>>> What version of PUI are you using? >>>> >>>> John F. Fay >>>> Technical Fellow >>>> Jacobs Technology TEAS Group >>>> 850-883-1294 >>>> >>>> -----Original Message----- >>>> From: pli...@li... >>>> [mailto:pli...@li...] On Behalf Of cory >>>> barton >>>> Sent: Thursday, June 12, 2008 3:53 PM >>>> To: PLIB Users >>>> Subject: Re: [Plib-users] (cory vs. pui) The attack of setValuator >>>> >>>> Here is the code: >>>> >>>> <snip> >>>> >>>> >>>> On Thu, Jun 12, 2008 at 4:42 PM, Fay John F Dr CTR USAF 46 SK >>>> <joh...@eg...> wrote: >>>> >>>>> Hmmm ... unless somebody else steps in, please forward me a copy of >>>>> >>>> the >>>> >>>>> offending code. I've tried putting in your code snippet and the >>>>> >>>> program >>>> >>>>> works just fine for me, so evidently something else is going on. >>>>> >>>>> John F. Fay >>>>> Technical Fellow >>>>> Jacobs Technology TEAS Group >>>>> 850-883-1294 >>>>> >>>>> -----Original Message----- >>>>> From: pli...@li... >>>>> [mailto:pli...@li...] On Behalf Of cory >>>>> barton >>>>> Sent: Thursday, June 12, 2008 3:19 PM >>>>> To: PLIB Users >>>>> Subject: [Plib-users] (cory vs. pui) The attack of setValuator >>>>> >>>>> I found the following in the PUI documentation today: >>>>> There are many occasions when you'd really like to have the PUI >>>>> >>> widget >>> >>>>> directly drive and/or reflect the value of some memory location in >>>>> >>> the >>> >>>>> application code. These calls let you do that: >>>>> >>>>> void puObject::setValuator ( int *i ) ; >>>>> void puObject::setValuator ( float *f ) ; >>>>> void puObject::setValuator ( char *s ) ; >>>>> >>>>> >>>>> Once you make one of these calls, PUI will automatically update the >>>>> memory location indicated with the current value of the widget >>>>> whenever it changes - and also update the appearance of the widget to >>>>> reflect the value stored in that memory location whenever the widget >>>>> is redrawn. This is often a lot more convenient than using a callback >>>>> function to register changes in the widget's value. >>>>> >>>>> So I tried it out: >>>>> //global variable >>>>> float update = 1.0f; >>>>> >>>>> //initialize my puInput inside a function >>>>> //hertz text input >>>>> hertz_text = new puInput ( curx, cury, >>>>> curx + >>>>> PUI_TEXT_WIDTH, >>>>> cury + >>>>> PUI_TEXT_HEIGHT ) ; >>>>> hertz_text->setValuator( &update ); >>>>> hertz_text->setLabel( "Hertz" ); >>>>> hertz_text->setLabelPlace( PUPLACE_TOP_CENTERED ); >>>>> >>>>> >>>>> This compiles, and runs. >>>>> >>>>> It seems to work correctly as long as I do not remove all of the >>>>> characters from the puInput box. However if I am trying to change the >>>>> value, when I am typing in the new value, if the new value ever >>>>> becomes a non valid float value, then the program crashes. For >>>>> >>> example >>> >>>>> if I want to change 1.0 to 2.0 and I delete 1.0 so I can type 2.0, >>>>> then instant crash. I can change from 1.0 to 2.0 if I type the 2 >>>>> >>> after >>> >>>>> the 1, and then erase the 1. >>>>> >>>>> Searching the mail archives and googling didn't help, so I am posting >>>>> here. >>>>> >>>>> I suspect either my weak understanding of pointers means that I am >>>>> passing an incorrect argument to the setValuator function, or maybe >>>>> the puInput object is writing invalid data to the update variable. >>>>> >>>>> Please let me know how to fix this. >>>>> >>>>> thanks, >>>>> >>>>> Cory >>>>> >>>>> >>>> >>>> >>> ------------------------------------------------------------------------ >>> - >>> >>>> Check out the new SourceForge.net Marketplace. >>>> It's the best place to buy or sell services for >>>> just about anything Open Source. >>>> http://sourceforge.net/services/buy/index.php >>>> _______________________________________________ >>>> plib-users mailing list >>>> pli...@li... >>>> https://lists.sourceforge.net/lists/listinfo/plib-users >>>> >>>> >>> ------------------------------------------------------------------------ >>> - >>> Check out the new SourceForge.net Marketplace. >>> It's the best place to buy or sell services for >>> just about anything Open Source. >>> http://sourceforge.net/services/buy/index.php >>> _______________________________________________ >>> plib-users mailing list >>> pli...@li... >>> https://lists.sourceforge.net/lists/listinfo/plib-users >>> >>> ------------------------------------------------------------------------- >>> Check out the new SourceForge.net Marketplace. >>> It's the best place to buy or sell services for >>> just about anything Open Source. >>> http://sourceforge.net/services/buy/index.php >>> _______________________________________________ >>> plib-users mailing list >>> pli...@li... >>> https://lists.sourceforge.net/lists/listinfo/plib-users >>> >>> > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > > > |
From: Jan R. <slo...@gm...> - 2008-06-17 19:34:13
|
Am Sun, 15 Jun 2008 20:52:41 +0100 schrieb Stuart McDonald <stu...@bl...>: > The configure script should generate a log (config.log?) that shows the > small program is it trying to compile. That's right, there should be a config.log and you'll find the description of the error towards the end of the file. > It could also be the library is named something else, (say) > libOSMesaGL.a or something. No idea how to properly fix something like > that, but as a last resort you could hand edit the configure.ac (might > be configure.in) and change the name. I usually create a symlink with the required name that points to the real lib, e.g. ln -s /usr/lib/libFancyGL.so.1.2.3 /usr/lib/libGL.so A quick look at /usr/lib shows that this is what Ubuntu does by default: lrwxrwxrwx 1 root root 17 2008-05-31 09:51 /usr/lib/libGL.so -> libGL.so.96.43.01 On my PC /usr/lib/libGL.so is only a symlink pointing to the libGL provided by NVIDIA. But take a look at config.log first to make sure that this is the problem. Kind regards, Jan R. -- Jan Reucker email: jan dot reucker at web dot de web: http://www.reucker-online.de |
From: cory b. <co...@gm...> - 2008-06-17 20:03:09
|
Jan, I haven't made any progress on this issue. I added a post to the ubuntu forums, but still don't have a reply. I did look in config.log and found the following: configure:6841: checking for glNewList in -lGL configure:6876: gcc -o conftest -g -O2 conftest.c -lGL -lSM -lICE -lXi -lXmu -lXext -lX11 -lm >&5 /usr/bin/ld: cannot find -lXmu collect2: ld returned 1 exit status and: configure:6929: checking for glNewList in -lMesaGL configure:6964: gcc -o conftest -g -O2 conftest.c -lMesaGL -lSM -lICE -lXi -lXmu -lXext -lX11 -lm >&5 /usr/bin/ld: cannot find -lMesaGL collect2: ld returned 1 exit status In my searches, I found some suggestion that I should check for libGl.so I found it in /usr/lib/ libGl.so is a link to libGl.so.1 which is a link to libGl.so.1.2 I also found a suggestion that I should try using: ./configure --with-lGL=/usr but that failed, so I also tried: ./configure --with-lGL=/usr/ ./configure --with-lGL=/usr/lib ./configure --with-lGL=/usr/lib/ all fail. I have no idea what else to do. On Tue, Jun 17, 2008 at 3:34 PM, Jan Reucker <slo...@gm...> wrote: > Am Sun, 15 Jun 2008 20:52:41 +0100 schrieb Stuart McDonald <stu...@bl...>: > >> The configure script should generate a log (config.log?) that shows the >> small program is it trying to compile. > > That's right, there should be a config.log and you'll find the > description of the error towards the end of the file. > >> It could also be the library is named something else, (say) >> libOSMesaGL.a or something. No idea how to properly fix something like >> that, but as a last resort you could hand edit the configure.ac (might >> be configure.in) and change the name. > > I usually create a symlink with the required name that points > to the real lib, e.g. > > ln -s /usr/lib/libFancyGL.so.1.2.3 /usr/lib/libGL.so > > A quick look at /usr/lib shows that this is what Ubuntu does > by default: > > lrwxrwxrwx 1 root root 17 2008-05-31 09:51 /usr/lib/libGL.so -> libGL.so.96.43.01 > > On my PC /usr/lib/libGL.so is only a symlink pointing to the libGL > provided by NVIDIA. > > But take a look at config.log first to make sure that this is the > problem. > > Kind regards, > Jan R. > > -- > Jan Reucker > email: jan dot reucker at web dot de > web: http://www.reucker-online.de > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > |
From: Jan R. <slo...@gm...> - 2008-06-17 20:45:48
|
Am Tue, 17 Jun 2008 16:02:49 -0400 schrieb "cory barton" <co...@gm...>: Hi Cory, > /usr/bin/ld: cannot find -lXmu > collect2: ld returned 1 exit status sudo apt-get install libxmu-dev libxmu6 > and: > configure:6929: checking for glNewList in -lMesaGL > configure:6964: gcc -o conftest -g -O2 conftest.c -lMesaGL -lSM > -lICE -lXi -lXmu -lXext -lX11 -lm >&5 > /usr/bin/ld: cannot find -lMesaGL > collect2: ld returned 1 exit status What does find /usr -name lib*GL* or find /usr -name lib*Mesa* report? Kind regards, Jan R. -- Jan Reucker email: jan dot reucker at web dot de web: http://www.reucker-online.de |
From: cory b. <co...@gm...> - 2008-06-18 15:35:31
|
Jan, > sudo apt-get install libxmu-dev libxmu6 That was enough to move me to the next set of stumbling blocks. I have plib1.8.4 and had plib1.8.4-dev installed Once I did sudo make install, then my program started seg faulting. So I looked around a bit and decided that I should have removed plib1.8.4-dev So I removed it, and reran sudo make install. I did not want to remove plib1.8.4, since it will break flight gear (says synaptic) Now g++ is failing to link to the plib libraries. I have all of the corresponding libplibxxx.a files and also a bunch of libplibxxx.so.1.8.4 files in /usr/lib/ when I had plib-dev installed I had a bunch of libplibxxx.so links to the corresponding libplibxxx.so.1.8.4 files. I am not sure what I do now. Do I have to manually create the libplibxxx.so.1.8.5 files and corresponding links? Is there a different syntax for inking to libplibxxx.a? Should I remove the plib1.8.4 package? Please advise Thanks, Cory On Tue, Jun 17, 2008 at 4:45 PM, Jan Reucker <slo...@gm...> wrote: > Am Tue, 17 Jun 2008 16:02:49 -0400 schrieb "cory barton" <co...@gm...>: > > Hi Cory, > >> /usr/bin/ld: cannot find -lXmu >> collect2: ld returned 1 exit status > > sudo apt-get install libxmu-dev libxmu6 > >> and: >> configure:6929: checking for glNewList in -lMesaGL >> configure:6964: gcc -o conftest -g -O2 conftest.c -lMesaGL -lSM >> -lICE -lXi -lXmu -lXext -lX11 -lm >&5 >> /usr/bin/ld: cannot find -lMesaGL >> collect2: ld returned 1 exit status > > What does > > find /usr -name lib*GL* > > or > > find /usr -name lib*Mesa* > > report? > > Kind regards, > Jan R. > > -- > Jan Reucker > email: jan dot reucker at web dot de > web: http://www.reucker-online.de > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > |
From: Jan R. <slo...@gm...> - 2008-06-22 08:08:25
|
Am Wed, 18 Jun 2008 11:35:34 -0400 schrieb "cory barton" <co...@gm...>: > I am not sure what I do now. > Do I have to manually create the libplibxxx.so.1.8.5 files and > corresponding links? > Is there a different syntax for inking to libplibxxx.a? > Should I remove the plib1.8.4 package? Cory, I'd recommend re-installing all the 1.8.4 stuff to make your system work again. Then compile and install 1.8.5 to a different place, e.g. in your home directory: ./configure --prefix=$HOME make make install Then compile and link your program with -I$HOME/include and -L$HOME/lib . Kind regards, Jan R. -- Jan Reucker email: jan dot reucker at web dot de web: http://www.reucker-online.de |
From: cory b. <co...@gm...> - 2008-06-23 14:47:50
|
I found out why I was having trouble with setValuator. When the textbox has no value, then the associated variable is set to 0. I was using that variable elsewhere in my program in division, thus causing a divide be zero error. Oops! :( Anyhow, Jan thanks for all the help. I now have plib 1.8.5 installed in my home directory, and plib 1.8.4 is working again. Cory On Fri, Jun 20, 2008 at 4:08 PM, Jan Reucker <slo...@gm...> wrote: > Am Wed, 18 Jun 2008 11:35:34 -0400 schrieb "cory barton" <co...@gm...>: > >> I am not sure what I do now. >> Do I have to manually create the libplibxxx.so.1.8.5 files and >> corresponding links? >> Is there a different syntax for inking to libplibxxx.a? >> Should I remove the plib1.8.4 package? > > Cory, > > I'd recommend re-installing all the 1.8.4 stuff to make your system > work again. Then compile and install 1.8.5 to a different place, > e.g. in your home directory: > > ./configure --prefix=$HOME > make > make install > > Then compile and link your program with -I$HOME/include and -L$HOME/lib . > > Kind regards, > Jan R. > > -- > Jan Reucker > email: jan dot reucker at web dot de > web: http://www.reucker-online.de > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users > |
From: Jan R. <slo...@gm...> - 2008-06-24 20:27:20
|
Am Mon, 23 Jun 2008 10:47:56 -0400 schrieb "cory barton" <co...@gm...>: > Oops! :( :) Long live gdb! > Anyhow, Jan thanks for all the help. I now have plib 1.8.5 installed > in my home directory, and plib 1.8.4 is working again. You're welcome. Kind regards, Jan R. -- Jan Reucker email: jan dot reucker at web dot de web: http://www.reucker-online.de |