Go to Post I owe it to the FIRST community and the awesome users of this site to keep working on this site and making it better. I will do so until someone from Chief Delphi pulls me away from it and tells me to stop. - Brandon Martus [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-02-2009, 22:08
nekng's Avatar
nekng nekng is offline
Former 1836 Captain
AKA: Nate
FRC #1836 (MilkenKnights)
Team Role: Alumni
 
Join Date: Aug 2006
Rookie Year: 2007
Location: Los Angeles
Posts: 43
nekng is on a distinguished road
Ultrasonics / Sonar

I have spent literally hours trying to figure this out, could someone post every single step involved in programming ultrasonic sensors using the interactive robot class?
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 14-02-2009, 23:43
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: Ultrasonics / Sonar

You need to give more details....

What sensor are you using, and maybe a bit of the code you are trying to use?
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
Reply With Quote
  #3   Spotlight this post!  
Unread 15-02-2009, 00:40
nekng's Avatar
nekng nekng is offline
Former 1836 Captain
AKA: Nate
FRC #1836 (MilkenKnights)
Team Role: Alumni
 
Join Date: Aug 2006
Rookie Year: 2007
Location: Los Angeles
Posts: 43
nekng is on a distinguished road
Re: Ultrasonics / Sonar

We are using vex ultrasonic sensors.
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 15-02-2009, 00:50
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 325
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: Ultrasonics / Sonar

The code should work fine with that, have you looked at page 46 of the "C Programming Guide for FRC"? What kind of results do you get.
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
Reply With Quote
  #5   Spotlight this post!  
Unread 15-02-2009, 01:34
Shira Shira is offline
Registered User
FRC #1836
Team Role: College Student
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Los Angeles
Posts: 30
Shira is an unknown quantity at this point
Re: Ultrasonics / Sonar

Hey, I'm working with Nate (who started this thread) on the code and here's what happens:

In the class variables declaration:
Ultrasonic *m_ultra;
double range;
static const UINT32 pingChannel=1;
static const UINT32 echoChannel=2;


In the constructor:
m_ultra = new Ultrasonic(pingChannel, echoChannel);
m_ultra->SetAutomaticMode(true);
range = m_ultra->GetRangeInches();


But when I print out the range I get only zeros. Actually, I've gotten other values with that code occasionally (still not functional though, just random values that don't update often at all), but we tested so many sensors and configurations that I am not convinced it is a hardware problem.

Also, I can't get that sample code from the Programming Guide to work. I get compiler errors. I've tried a number of things, but unless i use that code with pointers, I can't get the code to compile.

So can anyone give some sample code, or detailed instructions, on how they set up their ultrasonic sensors?
Reply With Quote
  #6   Spotlight this post!  
Unread 15-02-2009, 13:44
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Ultrasonics / Sonar

Quote:
Originally Posted by Shira View Post
Code:
double range;
 :
range = m_ultra->GetRangeInches();
But when I print out the range I get only zeros. Actually, I've gotten other values with that code occasionally...
How are you printing it? If your format specifier doesn't match the variable type, it won't work properly.
Reply With Quote
  #7   Spotlight this post!  
Unread 15-02-2009, 16:35
nekng's Avatar
nekng nekng is offline
Former 1836 Captain
AKA: Nate
FRC #1836 (MilkenKnights)
Team Role: Alumni
 
Join Date: Aug 2006
Rookie Year: 2007
Location: Los Angeles
Posts: 43
nekng is on a distinguished road
Re: Ultrasonics / Sonar

Quote:
Originally Posted by Alan Anderson View Post
How are you printing it? If your format specifier doesn't match the variable type, it won't work properly.
We are using a %f to print it.
__________________
Reply With Quote
  #8   Spotlight this post!  
Unread 15-02-2009, 20:11
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Ultrasonics / Sonar

Quote:
Originally Posted by Shira View Post
In the constructor:
Code:
m_ultra = new Ultrasonic(pingChannel, echoChannel);	
m_ultra->SetAutomaticMode(true);
range = m_ultra->GetRangeInches();
But when I print out the range I get only zeros.
Are you ever setting range anywhere else? The assignment in the constructor most likely occurs before any echoes have been received, so it won't be a valid value. I believe calling m_ultra->GetRangeInches() later should give you the current range.
Reply With Quote
  #9   Spotlight this post!  
Unread 15-02-2009, 23:28
Shira Shira is offline
Registered User
FRC #1836
Team Role: College Student
 
Join Date: Jan 2008
Rookie Year: 2008
Location: Los Angeles
Posts: 30
Shira is an unknown quantity at this point
Re: Ultrasonics / Sonar

Quote:
Originally Posted by Alan Anderson View Post
Are you ever setting range anywhere else? The assignment in the constructor most likely occurs before any echoes have been received, so it won't be a valid value. I believe calling m_ultra->GetRangeInches() later should give you the current range.
We're calling it in Autonomous Periodic or Autonomous Continuous (I'm not sure where we're going to put our code yet but I think it is all going to go in autonomous continuous unless there is a good reason not to..)

There is no other setting of the range anywhere else. I declare the var in the class and then I set the range to the value returned by the get range function.
Reply With Quote
  #10   Spotlight this post!  
Unread 17-02-2009, 14:03
X-Istence X-Istence is offline
Melt the RC controller!
AKA: Bert JW Regeer
no team
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Montville
Posts: 151
X-Istence will become famous soon enoughX-Istence will become famous soon enough
Send a message via AIM to X-Istence Send a message via MSN to X-Istence
Re: Ultrasonics / Sonar

Check to see if the Range is valid, using the function:

Code:
IsRangeValid()
It will return a boolean letting you know if the sensors have fired yet and some result has come back.
__________________
My Blog!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sonar is being lame Sparky_68 Programming 5 13-02-2009 00:55
How to program sonar FearlessLeader C/C++ 1 11-02-2009 22:39
Sonar Sensor help eagleslg Programming 9 05-05-2008 21:14
Ultrasonics Ctx32 Programming 1 06-06-2006 10:56
Ultrasonics Ctx32 FIRST Tech Challenge 3 06-05-2006 14:32


All times are GMT -5. The time now is 14:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi