[Pogamut-list] RayCasting Bot II

Daniel pogamut-forum at artemis.ms.mff.cuni.cz
Mon Mar 30 00:53:21 CEST 2009


Re: RayCasting Bot II

Author: Daniel

OK! Finally I worked this out.

The story is that memory.getAutoTrace(FRONT_SENSOR).result doesn´t work, it always return false, which by the way is a bug.

If someone needs to use ray casting and this bug is not fixed yet, hope this little trick helps to you :)

1.- First delete all the getAutoTrace
2.- Make a GB AUTO_TRACE_RAY listener, here you can see a lot of parametres, some of them are the one you tried to get before, and you can see that they are indeed always asigned to false. But fortunately there are some of then that work and indicate us if it is detecting something, for example  "hitLocation", so, if hitLocation is zero, means the ray didn´t touch anything, meanwhile if it has any value, something was touched. With this idea you might write something like:


public void receiveMessage(RcvMsgEvent e) {

        //We are looking for ray trace messages only
        if (e.getMessage().type == MessageType.AUTO_TRACE_RAY){
            AutoTraceRay autoTraceRay = (AutoTraceRay)e.getMessage();

            if(autoTraceRay.getUnrealID().equalsIgnoreCase("1") && !autoTraceRay.hitLocation.zero()){                
                sensorLeft = true;
            }else sensorLeft = false;
            
            if(autoTraceRay.getUnrealID().equalsIgnoreCase("2") && !autoTraceRay.hitLocation.zero()){                
                sensorFront = true;
            }else sensorFront = false;
            
            if(autoTraceRay.getUnrealID().equalsIgnoreCase("3") && !autoTraceRay.hitLocation.zero()){                
                sensorRight = true;
            }else sensorRight = false;


        }
 }

After deleting the getAutoTrace senteces and copy paste the method before showed, the Khepera should work now.

Hope it helps.

Bye!





More information about the Pogamut-list mailing list