The dinsmore 1655 decribed in the book and the
hitechnic wouldn't be compatable.  There really is
nothing more that I could give you that you can
siimply  plug in.  

You said earlier that you are getting a reading from
the dinsmore compass but are having trouble deriving
the angle. 

The hitechic comnpass returns a reading from 0 - 99
     north = 0,east = 25,south=  50 ,west = 75 

The exmample I provided shows how you can convert 
convert degrees (-180 to 180) to the compass  0 - 99.

 
good luck


From: made agus <[EMAIL PROTECTED]>
Re: Re: Ask Compass Programming  
2006-05-19 06:53

Thank Mr David. I'll try it. May be work in my compass
sensor dinsmore 1655. I am beginner in java
programming. Would you like to tell me detail code ?.
Many thank.
  
 

--- David Levy <[EMAIL PROTECTED]> wrote:

> 
> I'm using the one from HiTechnic.com. 
> 
> compassSensor = Sensor.S1;
>
compassSensor.setTypeAndMode(SensorConstants.SENSOR_TYPE_LIGHT,
>               SensorConstants.SENSOR_MODE_PCT);
>               compassSensor.activate();
> 
> compassSensor.readValue() returns a value from 0 -
> 99.
> compassAngle - 
>     north = 0,east = 25,south=  50 ,west = 75   
> angleInDegrees-   
>   0 = north ( pointing to right on x-axis)
>   90 = east  ( pointing up on y axis)
>   -90 = west
>   180 = south  
>                                          
>  
> 
> Negotiate coordinate: say (100,100)
> 
> public void negotiatePoint(int anX, int anY) {
>   rotSensor.setPreviousValue(0);
> 
>   // Determine relative points
>   int x1 = anX - getCurrentX();
>   int y1 = anY - getCurrentY();
> 
>   // Calculate angle to go to:              
> setAngleInRads((double)Math.atan2(y1,x1));
> 
>  // Calculate distance to travel:
>  if(y1 != 0) {
>    distanceToTravel = 
>        y1/(float)Math.sin(getAngleInRads());
>  }
>  else 
>  {
>   distanceToTravel = 
>        x1/(float)Math.cos(getAngleInRads());
>   }
>                            
> }
> 
> 
> 
> private void setAngleInRads(double anAngleInRads) {
>               
>  angleInRads = anAngleInRads;
>  // Convert angle from rads to degrees:
>  double angleInDegrees =    
>       (float)Math.toDegrees(anAngleInRads);
> 
> // convert degrees (-180 to 180) to  compass  0 - 99
>  
> if (angleInDegrees < 0) {
>  compassAngle = (angleInDegrees + 360) / 3.6;
>  } 
>  else 
>  {
>    compassAngle = (angleInDegrees) / 3.6;
>  }      
> }
> 
> 
> 
> 
> >>From: made agus <[EMAIL PROTECTED]>
> >> 2006-05-16 21:38
>  
> >>I was try Navigation Lego with compass sensor
> pewatron
> >>6100/dinsmore 1655. I am successfull try read the
> >>sensor (from Core Lego Mindstorms book by Brian
> >>Bagnall). But i have a problem when try get the
> angle
> >>(CompassSensor.java). Any can help me ?. Many
> thank.
> 
> >>Regards,
> >>Agoes 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> http://mail.yahoo.com 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Lejos-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lejos-discussion

Reply via email to