richrd / nxt-python

Automatically exported from code.google.com/p/nxt-python
GNU General Public License v3.0
1 stars 0 forks source link

hitechnic.Compass.get_heading returns inaccurate values #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. compass = hitechnic.Compass(brick, sensor.PORT_2)
2. compass.get_heading()
3. compass.set_mode(compass.Modes.CALIBRATE)

What is the expected output? What do you see instead?
Heading in degrees from North. An incorrect value is returned instead. So I 
tried to calibrate the compass, and got the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "nxt/sensor/hitechnic.py", line 85, in set_mode
    if mode != CompassMode.MEASUREMENT and \
NameError: global name 'CompassMode' is not defined

What version of nxt-python are you using? On what operating system?
revision 277 on Ubuntu 10.10

Please provide any additional information below.
Before calibrating the compass, I modified Compass.get_heading() to use the two 
degree heading and adder instead of the low byte from register 0x44 (which 
didn't appear to fully correspond with the spec).

Upon attempting to calibrate the compass, I discovered another bug, resulting 
in the above exception. I also fixed this. I'm unsure if the original 
get_heading() method would work now as well, but the modified method tests out 
ok, so I suggest sticking with it. 

Original issue reported on code.google.com by jerradge...@gmail.com on 23 Jan 2011 at 5:00

Attachments:

GoogleCodeExporter commented 9 years ago
I can also confirm that Compass.get_relative_heading() and 
Compass.is_in_range()seem to function correctly.

Original comment by jerradge...@gmail.com on 23 Jan 2011 at 5:11

GoogleCodeExporter commented 9 years ago
Thanks. Patched in r280. I've given you SVN access so you can commit things 
directly if you want. When you've tested things you can remove the "Not Tested" 
notices.

Original comment by marcus@wanners.net on 23 Jan 2011 at 5:43

GoogleCodeExporter commented 9 years ago
Thanks. I'm considering adding support for the Hitechnic sensor multiplexer in 
the future, so that might come in handy.

Original comment by jerradge...@gmail.com on 23 Jan 2011 at 6:33