View unanswered posts | View active topics It is currently Tue Sep 30, 2014 4:01 pm






Reply to topic  [ 5 posts ] 
sonar sensor in inches 
Author Message
Rookie
User avatar

Joined: Wed Jun 19, 2013 5:57 pm
Posts: 25
Post sonar sensor in inches
Is there any way to to program with the US (sonar) sensor in inches instead centimeters? or do i have to convert it

_________________
-TheRobotMaster (or soon to be one)

FRC Team #2550 Skynet -Programmer 2013 - present
Website [url]sites.google.com/site/2550robotics[/url]

FTC Team #4508 E=MC^Squirreled -Second Programmer 2013-2014

FLL Team #3414 Team Brickstein -Mentor


Mon Jun 24, 2013 8:55 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: sonar sensor in inches
I don't believe there's a way you can. But a quick little function will take care of that for you.

Code:
byte USInInches(tSensors SensorPort)
{
   return SensorValue[SensorPort] / 2.54;
}


At least I assume it works... Let me know if it does :)

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Mon Jun 24, 2013 9:45 pm
Profile WWW
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 405
Post Re: sonar sensor in inches
The virtual worlds only returns the value in centimeters. Like NeXT-Generation suggested, you can convert the value. I haven't tested his code but I suspect that you'll want the return type to be a float, not a byte.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Thu Jun 27, 2013 10:35 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: sonar sensor in inches
You might, but I was thinking that if you're going with decimals of inches you might as well be using centimeters.

_________________
A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.


Thu Jun 27, 2013 10:45 am
Profile WWW
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: sonar sensor in inches
Agreeing with NeXT-Generation. The code snippet provided is more than adequate, and if you're annoyed by it just add another one like "readUS()" which outputs in inches.

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Thu Jun 27, 2013 2:58 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.