View unanswered posts | View active topics It is currently Tue Oct 22, 2019 10:11 am






Reply to topic  [ 6 posts ] 
HT Compass sensor default mode 
Author Message
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post HT Compass sensor default mode
Hey there,

Does anyone know what the default mode for the HT Compass is? I.e. absolute or relative. Or is it in fact only the NXT-G block that offers this functionality? I am using RobotC 1.46.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Nov 04, 2008 12:14 pm
Profile WWW
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: HT Compass sensor default mode
The compass only supplies absolute values. The NXT-G block handles the "relative" case. It is easy enough to do if you save off the starting orientation at the beginning of your program.

_________________
Jeff McBride
Benson Robotics Club


Tue Nov 04, 2008 12:53 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: HT Compass sensor default mode
Yeah, that is what I thought might be the case, but it's good to get confirmation. Thanks for that.

I wrote the following code to make my life easier:
Code:
task eCompass() {
  int _tmpHeading = 0;
  int _offset = SensorValue[htcompass]; // initial offset value for relative readings.
  while(true) {
    aHeading = SensorValue[htcompass];
    _tmpHeading = (aHeading - _offset) % 360;
    if (_tmpHeading < 0)
      rHeading = 360 + _tmpHeading;
    else
      rHeading = _tmpHeading;
    wait1Msec(10);
  }
}

This will allow me to set the initial heading to 0 when the bot starts. aHeading is the absolute heading and rHeading is the heading using the initial position of the robot as 0. They're globally scoped ints. This code has not been tested, mind you. I won't have the compass sensor until an hour before the competition this coming Saturday, hehe. Here's hoping it works as expected!

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Nov 04, 2008 1:00 pm
Profile WWW
Rookie

Joined: Mon Aug 11, 2014 6:16 am
Posts: 2
Post Re: HT Compass sensor default mode
Im a newbie at nxc and coding. Could you fill me in as to why when the code above, when run as shown displays the error code, "Preprocessor macro function does not match instance (#_p#Sensor(_p))"?


Mon Aug 11, 2014 6:20 am
Profile
Site Admin
Site Admin
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3654
Location: Rotterdam, The Netherlands
Post Re: HT Compass sensor default mode
This is a ROBOTC forum, you could try asking on the EV3 FB group: https://www.facebook.com/groups/legomindstorms

Alternatively, you could switch to ROBOTC instead! :)

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Aug 11, 2014 12:05 pm
Profile WWW
Rookie

Joined: Mon Aug 11, 2014 6:16 am
Posts: 2
Post Re: HT Compass sensor default mode
Alrighty, thanks.


Tue Aug 12, 2014 7:50 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.