Subject:
|
Plz can someone help me understand an error code in my RCX?
|
Newsgroups:
|
lugnet.robotics.rcx.java
|
Date:
|
Tue, 25 Feb 2003 02:43:43 GMT
|
Viewed:
|
4822 times
|
| |
| |
Hi everyone, Im a new Lego Mindstorms user and Im starting with leJOS
version 2.1.1 and a j2SDK 1.4.1 platform. I have already made a simple line
follower robot with only 1 light sensor. The code was really simple and I
use a listener to make it work. The problem start when I try to make another
line follower but with 2 light sensors (1 for each motor) so it can follow
more difficult paths (like a figure 8 path). I try to use 2 listeners, 1 for
each of them, and the approach to the problem is that if the left sensor is
out of the path, it turns to the right until the sensor is on the track
again, and vice versa. The code works fine until in a random time a buzz
comes with and error number on the LCD and the program crash
I have no idea
why is this happening, and what the code means
I try different approaches
of the problem but it doesnt work
the same error comes out
the code is
0064 5.
If someone can help me understand this error code or if someone can show me
where can I find a web page whit this information or anything that could get
me on a correct way, ill be really appreciated.
Thank for taking time to help me
A friend from Venezuela Y NI UN PASO ATRAS!!!!
In case someone didnt understand my poor English, this is the code Im using:
This is the code for the listener on the 1 sensor version, and it works fine
public static class lectorDeLuz2 implements SensorListener{
public void stateChanged(Sensor sensor, int new_value, int old_value){
if (Sensor.S2.readValue() == 0){
LCD.showNumber(new_value);
if (new_value > inst.promedio){
Motor.A.forward();
Motor.C.stop();
}else {
Motor.A.stop();
Motor.C.forward();
}
}
}
}
This is the code with the problem (in S2 I have a touch sensor that stop all
activity until released)
// BEGIN OF THE PROGRAM
import josx.platform.rcx.Motor;
import josx.platform.rcx.Sensor;
import josx.platform.rcx.SensorConstants;
import josx.platform.rcx.SensorListener;
import josx.platform.rcx.TextLCD;
import josx.platform.rcx.LCD;
import josx.platform.rcx.Sound;
import josx.platform.rcx.Button;
public class ProyRob{
public static Calibracion inst;
public static class Calibracion{
public int blanco;
public int negro;
public int promedio;
public Calibracion(){
esperarUsuario("blanco");
blanco = Sensor.S1.readValue();
LCD.showNumber(blanco);
esperarUsuario(null);
Sound.twoBeeps();
esperarUsuario("negro");
negro = Sensor.S1.readValue();
LCD.showNumber(negro);
esperarUsuario(null);
Sound.twoBeeps();
esperarUsuario("listo");
promedio = Math.round((blanco+negro)/2);
LCD.showNumber(promedio);
esperarUsuario(null);
Sound.twoBeeps();
}
public void esperarUsuario (String mensaje) {
if (mensaje!=null){
TextLCD.print (mensaje);
}
try {
Button.VIEW.waitForPressAndRelease();
}catch(InterruptedException err){
TextLCD.print("err 1");
}
}
}
public static class lectorDeLuzI implements SensorListener{
public void stateChanged(Sensor sensor, int new_value, int old_value){
if (Sensor.S2.readValue() == 0){
if (new_value > inst.promedio){
TextLCD.print("IOUT");
Motor.A.forward();
if (Sensor.S3.readValue() < inst.promedio){
Motor.C.stop();
}
}
}
}
}
public static class lectorDeLuzD implements SensorListener{
public void stateChanged(Sensor sensor, int new_value, int old_value){
if (Sensor.S2.readValue() == 0){
if (new_value > inst.promedio){
TextLCD.print("DOUT");
// El sensor izquierdo salio del camino
if (Sensor.S1.readValue() < inst.promedio){
Motor.A.stop();
}
Motor.C.forward();
}
}
}
}
public static class lectorDeContacto implements SensorListener{
public void stateChanged(Sensor sensor, int new_value, int old_value){
if (new_value==0){
TextLCD.print("Stop");
Motor.A.stop();
Motor.C.stop();
}else {
Motor.A.forward();
Motor.C.forward();
}
}
}
public static void main (String args[]){
Sensor.S1.setTypeAndMode(SensorConstants.SENSOR_TYPE_LIGHT,SensorConstants.SENSOR_MODE_PCT);
Sensor.S1.activate();
Sensor.S3.setTypeAndMode(SensorConstants.SENSOR_TYPE_LIGHT,SensorConstants.SENSOR_MODE_PCT);
Sensor.S3.activate();
inst = new Calibracion();
Sensor.S1.addSensorListener(new lectorDeLuzI());
Sensor.S3.addSensorListener(new lectorDeLuzD());
Motor.A.setPower(7);
Motor.C.setPower(7);
Motor.A.forward();
Motor.C.forward();
Sensor.S2.setTypeAndMode(SensorConstants.SENSOR_TYPE_TOUCH,SensorConstants.SENSOR_MODE_BOOL);
Sensor.S2.addSensorListener(new lectorDeContacto());
try {
Button.PRGM.waitForPressAndRelease();
}catch(InterruptedException err){
TextLCD.print("err 2");
}
Sound.buzz();
Sensor.S1.passivate();
Sensor.S3.passivate();
}
} //END OF THE PROGRAM
|
|
Message has 1 Reply:
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|