Heading Sensor information on Create

32 views
Skip to first unread message

paul trang

unread,
Apr 5, 2015, 12:05:02 PM4/5/15
to irobot-cr...@googlegroups.com
Hi, Im just wondering what the required code is in regards to knowing where the heading position of the create is. I know how to get the angle difference from the last time asked but how do i know how far i am from the original heading or how to return to the original heading position.

thanks for your help!

Joe Lucia

unread,
Apr 6, 2015, 12:44:12 PM4/6/15
to irobot-cr...@googlegroups.com
Every time you receive the Angle sensor data from the Create, add it to a variable to maintain a running "current heading".

// update bearing from new angle readings (0..359 degrees)
bearing += -((int)((sensors[SenAng1] << 8) | sensors[SenAng0]));
if(bearing>359)
bearing-=360;
if(bearing<0)
bearing+=360;

.. bearing is your "compass heading", you are facing 0 deg (North) on startup.

Periodic checks of the difference between your beginning bearing and your current bearing indicate how far you've turned and in what direction.


Joe Lucia, CTO

AZSecurity Control
 | www.AzSecurity.com
1042 E Guadalupe Rd, Tempe, AZ 85283
Phone 480-752-7115 | Fax 480-829-9290
Email J...@AzSecurity.com

On Sun, Apr 5, 2015 at 9:05 AM, paul trang <paultr...@gmail.com> wrote:
Hi, Im just wondering what the required code is in regards to knowing where the heading position of the create is. I know how to get the angle difference from the last time asked but how do i know how far i am from the original heading or how to return to the original heading position.

thanks for your help!

--
You received this message because you are subscribed to the Google Groups "iRobot Create Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to irobot-create-f...@googlegroups.com.
To post to this group, send email to irobot-cr...@googlegroups.com.
Visit this group at http://groups.google.com/group/irobot-create-forum.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages