I am currently trying to program the RCX and when I download my code and have it run it make an odd noise and show in the LCD 0074 then the walking man then a 1. The ^also shows up underneath Sensor port 2.
I am not sure whats wrong here is my code.
- Code: Select all
import josx.platform.rcx.*;
import josx.robotics.*;
public class Main
{
static String [][] mazeMap=new String[16][16];//the model for the maze with the given obstacles
static int [][] mazeMetrics=new int [16][16];//Create the model of the map with the given metrics
/**
*
* @param args
*/
public static void main(String []args)throws InterruptedException
{
ButtonExit be=new ButtonExit();
Button.RUN.addButtonListener(be);
Sensor.S1.activate();
Sensor.S1.setTypeAndMode(1,0x00);
while(!be.isrunpressed)
{
TextLCD.print(""+Sensor.S1.readRawValue());
LCD.refresh();
}
//end of main method
}
public static void navigation()
{
Sensor.S1.setTypeAndMode(1, 0x00);
//ascertain our starting position by looking at the wall configuration
while(true)//while we haven't reach our goal
{
update(0,0);//update the current cell that we are in
//look into the mazeMetric array to find the lowest metric
//put move into a stack
//turn and move to that location
}
}
/**
* Check the sensor to see where are the walls are and will return the char representation
* NSEW
* @return the char representation of the obstacles
*/
public static String sensorCheck()
{
/*
* get the raw from the sensor port
* check first to see if sensor 1 is active
* then drill down the search appending the values of direction
*/
String result="";
Sensor.S1.activate();
if(Sensor.S1.readRawValue()<990&&Sensor.S1.readRawValue()>960)
{
result="S";
}
if(Sensor.S1.readRawValue()<930&&Sensor.S1.readRawValue()>900)
{
result="S";
}
if(Sensor.S1.readRawValue()<900)
{
result="NS";
}
Sensor.S3.activate();
if(Sensor.S3.readRawValue()<850&&Sensor.S3.readRawValue()>800)
{
result+="E";
}
if(Sensor.S3.readRawValue()<750&&Sensor.S3.readRawValue()>650)
{
result+="W";
}
if(Sensor.S3.readRawValue()<625)
{
result+="EW";
}
TextLCD.print(result);
return result;
}
/**
* For the given x and y location of the maze it calculate the metric of that cell
* the metric is based upon the distance to the goal in the center of the maze
* @param x the x coordinate of the cell
* @param y the y coordinate of the cell
* @return the metric for the particular cell
*/
public static int calcMetrics(int x, int y)
{
return 0;
}
/**
* Method to update the maze models
*/
public static void update(int x, int y)
{
mazeMap[x][y]=sensorCheck();
for(int x1=0;x<16;x++)
{
for(int y1=0;y<16;y++)
{
calcMetrics(x1,y1);
}
}
}
}
class ButtonExit implements ButtonListener
{
public boolean isrunpressed=false;
public void buttonPressed(Button b)
{
if(b.equals(Button.RUN))
isrunpressed=true;
}
public void buttonReleased(Button b)
{
}
}
Any help would be appreciated.
Thank You in advance.
--William Soetanto
