CompassSensor issues

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

CompassSensor issues

Postby Kaye » Tue Oct 11, 2011 6:04 pm

Hello all,

I've recently started working on a project focusing on swarmed exploration. Right now I am in the very early stages, but am having some trouble with the CompassSensor (I'm trying to avoid the CompassPilot since it has been deprecated, I am using the 0.9.0 build).

The issue I'm having is that the sensor doesn't seem to be behaving at all as it should. This is my calibration method, which seems to work correctly:
Code: Select all
private void calibrate()
   {
      compass.startCalibration();
      pilot.setRotateSpeed(18);
      long start = System.currentTimeMillis();
      pilot.rotateRight();
      while((System.currentTimeMillis() - start) < 40*1000);
      pilot.stop();
      compass.stopCalibration();
   }

The issues that I'm having come after this step. If I call
Code: Select all
compass.resetCartesianZero();
float degree = compass.getDegreesCartesian();

degree will be some nonzero value. If I turn the robot by 90 degrees using a DifferentialPilot, the Cartesian degree value will change by some seemingly random interval, usually around 140 degrees.

Is this the expected behavior and I'm somehow misunderstanding, or am I doing something incorrectly? I could post the full code here, but there is a rather large amount of irrelevant code that isn't really relevant.

Also, the documentation mentions using a CompassSensor along with a PoseProvider, and I've been a little bit confused on how one would accomplish that. Can anyone shed some light for me?

Thanks for any help,
Jordan
Kaye
New User
 
Posts: 4
Joined: Tue Oct 11, 2011 5:56 pm

Re: CompassSensor issues

Postby Aswin » Tue Oct 11, 2011 10:06 pm

Are you familiar with the compass sensor? I ask this because it is easily disturbed. so the problem might as well be hardware as software.
My NXT blog: http://nxttime.wordpress.com/
Aswin
leJOS Team Member
 
Posts: 203
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: CompassSensor issues

Postby Kaye » Wed Oct 12, 2011 12:49 am

Thanks for the reply!

I am not at all familiar with the sensor, or with NXT in general. This is actually my first time working with robots of this nature.

Is anything specific I should know or some guidelines that could help me to avoid this problem?
Kaye
New User
 
Posts: 4
Joined: Tue Oct 11, 2011 5:56 pm

Re: CompassSensor issues

Postby gloomyandy » Wed Oct 12, 2011 8:26 am

Readings from a compass sensor can be very heavily influenced by motors and other metal objects, and the sensor needs to be level to operate correctly. I would recommend that you create a small test program and use an NXT with only the compass sensor attached to see how it behaves in your environment. The readings you are reporting do seem a little odd, so I would try and simplify things as much as possible and make sure you fully understand what is going on. If you are not familiar with the NXT then you may wan to spend some time browsing this forum looking at common problems that people run into. In particular if you are displaying data on the NXT screen and using that to judge the output of the sensor you may want to read this thread:
viewtopic.php?f=6&t=2937
which describes a problem that a lot of users have when displaying data on the LCD...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4081
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: CompassSensor issues

Postby Kaye » Tue Oct 18, 2011 5:01 pm

Thanks for the input Andy.

After some frustrating testing, it appears that the issue is in fact interference from other sensors/the NXT itself. Can you suggest any kind of configuration that may solve this issue? It is a bit difficult because my project requires 2 motors, an EOPD, an ultrasonic, and an infrared sensor in addition to the compass. Should I just find some way to attach the compass at a distance from all of the other metal components?

Jordan
Kaye
New User
 
Posts: 4
Joined: Tue Oct 11, 2011 5:56 pm

Re: CompassSensor issues

Postby Aswin » Tue Oct 18, 2011 6:57 pm

Jordan,

The compass is a difficult sensor to use. It should be placed at least 15 cm from the brick and motors.
Even then you should be aware of iron in the environment that might disturb the compass. Speakers, furniture and concrete, or rather the iron within the concrete, can disturb compass readings.

Some compasses do allow for calibrating. Calibration can help to overcome some disturbances. But don't expect miracles from it.
My NXT blog: http://nxttime.wordpress.com/
Aswin
leJOS Team Member
 
Posts: 203
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: CompassSensor issues

Postby kirkpthompson » Tue Oct 18, 2011 6:59 pm

Hi.

Have you tried quantum magnetic shielding?
http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1062382&tag=1

Best,
-K

P.S. :wink:
Leg Godt!
User avatar
kirkpthompson
leJOS Team Member
 
Posts: 304
Joined: Wed Dec 05, 2007 1:27 am
Location: New Mexico, USA

Re: CompassSensor issues

Postby Aswin » Tue Oct 18, 2011 10:15 pm

Well, I did. But it also shielded the earth magnetic field. Also, it is not available in dark bluish gray.
My NXT blog: http://nxttime.wordpress.com/
Aswin
leJOS Team Member
 
Posts: 203
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: CompassSensor issues

Postby Kaye » Thu Oct 20, 2011 4:51 am

Aswin,

Thanks for the 15 cm benchmark - I will try to find a way to build the robot keeping this in mind tomorrow and report back with the results.

Jordan
Kaye
New User
 
Posts: 4
Joined: Tue Oct 11, 2011 5:56 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff