View unanswered posts | View active topics It is currently Sat Aug 27, 2016 6:11 pm

 Page 1 of 1 [ 5 posts ]
 Print view Previous topic | Next topic
sonar sensor in inches
Author Message
Rookie

Joined: Wed Jun 19, 2013 5:57 pm
Posts: 25
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

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

FLL Team #3414 Team Brickstein -Mentor

Mon Jun 24, 2013 8:55 pm
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
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

Joined: Tue May 15, 2007 9:02 am
Posts: 409
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
ROBOTC Support

Thu Jun 27, 2013 10:35 am
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
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
Professor

Joined: Sat May 18, 2013 1:24 pm
Posts: 271
Location: Olympia, WA
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).

Thu Jun 27, 2013 2:58 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 5 posts ]

#### Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning