We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Need help with this roomba program
Page Index Toggle Pages: 1
Need help with this roomba program (Read 732 times)
Need help with this roomba program
Aug 7th, 2009, 9:08am
 
Hey how is everybody doing today on this fine friday, Saturday from some don't know.

Anyway here is my inquiry,
I am trying to design a GUI for a high school based lab where the iRobot create can be moved based on a speed and a time inserted into the roombacomm.goFowardAt() and roombacomm.pause() commands through the GUI. So far everything is working alright, I was able to use interfascia to create text boxes on my GUI, and I think I found a way to save whatever is entered by the user into two variables in the code.

So here is the problem, everytime I run the GUI and I try and insert a speed to time value I get an error saying

"NoSuchMethodException",

and when I try and click on one of the buttons I get the error message

"No method named actionPerformed was found in root" .

I cannot post the whole code, but if anybody has used the roomba stuff with processing then this was the same scheme behind the roombaview program. Go easy on me I just started programming  Embarrassed . The highlighted stuff is what I tried with the interfascia libraries.  

Any type of help would be greatly appreciated, thanks
Ryan

import mkv.MyGUI.*;
import roombacomm.*;
import roombacomm.net.*;
import java.io.*;
import interfascia.*;


String roombacommPort = "testdummy";

RoombaCommSerial roombacomm;

MyGUI gui;
MyGUIButton butForward, butBackward, butStop;
MyGUIButton butSpinLeft, butSpinRight, butTurnLeft, butTurnRight;
MyGUIButton butReset, butSafe, butFull, butSpy, butVacuum, butBeep;
MyGUIPinSlider sliderSpeed;

PFont fontA;

//Color declarations for various components in GUI window
color cBack = color(150);
color cOff  = color(100);
color cFlor = color(180);        
color cOn = color(255,0,0);
color cTxt = color(40);
color cWhl = color(10);
color cGrid = color(120);
color cStat = color(200);        
color cTir = color(20);                  
color cGry = color(110);
color cBut = color(170,170,210);

float rx,ry,rangle;                      
float scalex = 0.4;                      
float scaley = 0.4;                      

int frameCounter = 0;
GUIController c;

IFTextField speed;                
IFLabel speedlabel;
IFTextField time;
IFLabel timelabel;

// called on startup

void setup ()
{
 size (700,700);                            
 frameRate(10);                            
 smooth();                                  
 background(cFlor);                        
 stroke(0, 200);                          
 ellipseMode(CORNER);                      
//  fill(200);                              
//  ellipse(35,35,50,50);                  
 rectMode(LEFT);

 //Initiate GUI objects
 fontA = loadFont("CourierNewPSMT-9.vlw");
 textFont(fontA, 10);                      
 fill(0);                                  
 gui = new MyGUI(this);                    
 c = new GUIController(this);
 speedlabel = new IFLabel("Speed",450,610);
 speed = new IFTextField("Speed",450,625,75);
 timelabel = new IFLabel("Time",450,645);
 time = new IFTextField("Time",450,665,75);
 
 speed.addActionListener(this);
 time.addActionListener(this);
 
 c.add(speedlabel);
 c.add(speed);
 c.add(timelabel);
 c.add(time);

 float speed_entered;                      
 float time_entered;                        
 

 makeMoveButtons(width-70, height-100);    
 makeControlButtons(width-75,height-225);  

 roombacommSetup();                      
 reset();                                
}

void reset()                            
{
 rx = width/2;
 ry = height/2;
 rangle = 0;
}

void draw()
{
 frameCounter++;                        
 background(cFlor);                    
 fill(0);
 stroke(100);

 drawGridlines();                      
 drawStatus();                        

 if (roombacomm != null )
 {
   computeRoombaLocation();            
   drawRoombaStatus(rx, ry, rangle);
   updateRoombaState();
 }
}

void actionPerformed(ActionEvent a, GUIEvent e, float speed_entered, float time_entered)
{
      println("a= "+a);
      if(!roombacomm.connected())return;
      String cmd = a.getActionCommand();
      Object src = a.getSource();
       
       int time_conv;
       int speed_conv;
       
       if(e.getMessage().equals("Modified"))
         {
           try
           {
             if(e.getSource()==speed)
               if(key == CODED)
                 {
                   if(key == RETURN)
                     {speed_entered =Float.parseFloat(speed.getValue());}
                 }
           }
           catch(Exception e2){}
         }
           else if(e.getMessage().equals("Modified"))
           {
               try
                 {
                 
                     {time_entered = Float.parseFloat(time.getValue());}
                 }
                   catch(Exception e2){}
            }
         
        speed_conv = int(speed_entered);
        time_conv = int(time_entered);
     
        if(src == butForward)
          {
            roombacomm.goForward();
            //roombacomm.pause(time_conv);
          }
        else if(src == butBackward)
          {
            roombacomm.goBackward();
          }
        else if(src == butStop)
          {
            roombacomm.stop();
          }
}


void updateRoombaState()
{
 roombacomm.sensors();              
}


void computeRoombaLocation()
{
 int distance = roombacomm.distance();
 float angle = roombacomm.angleInRadians();
 rangle = rangle - angle;
 rangle %=TWO_PI;
 float dx = distance * sin(rangle);
 float dy = distance * cos(rangle);
 rx = rx +(dx*scaley);
 ry = ry - (dy * scalex);

 if(rx > width) rx = 0;
 if(rx < 0) rx = width;
 if(ry > height) ry = 0;
 if(ry < 0) ry = height;

}
Re: Need help with this roomba program
Reply #1 - Aug 7th, 2009, 2:22pm
 
please paste the entire error message you get.

i have a feeling that whilst you have defined actionPerformed it doesn't have the right signature.

a quick google turned up this:
http://todbot.com/roomba/roombacomm/src/roombacomm/processing-examples/roombaview/roombaview.pde

which uses

void actionPerformed(ActionEvent e)...
Page Index Toggle Pages: 1