View unanswered posts | View active topics It is currently Sun May 19, 2013 7:41 pm

 Page 1 of 1 [ 12 posts ]
 Print view Previous topic | Next topic
Need to evaluate the input from 3 sensors
Author Message
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Need to evaluate the input from 3 sensors
I am using 3 sonar sensors to determine position in amaze.
I am new to robotc but have experience in basic and foxpro

I have not found a way to use
If (value1) and (value2) and (value3) then result = x

I could use x in a switch that calls motor routines.

Wed Nov 23, 2011 8:44 am
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 509
Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
Re: Need to evaluate the input from 3 sensors
If I understand you correctly, then you need something like this:
 Code:if(Value1==x && Value2==x && Value3==x)//'x' is there because I don't know the values you want.{  result=x;}//add however many sensor configurations there are.switch(result){  case "Left":  //actions  break;  case "DeadEnd":  //actions  break;//etc,ect.}

does this help?

_________________
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.

Wed Nov 23, 2011 10:00 am
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Re: Need to evaluate the input from 3 sensors
Thanks

Specificly here are the conditions I want to evaluate to navigate the maze

// Forward Front Sensor > 13, left sensor > 7 right sensor > 7cm .. Centered in hallway no end in sight
// AdjustLeft Turn FrontSensor >13, left Sensor >7 Right Sensor < 7cm .. getting close to right wall
// AdjustRight Turn FrontSensor >13 left Sensor < 7 Right Sensor > 7cm...

// HardLeft Turn FrontSensor < 13 left Sensor > 10 Right Sensor < 26cm Near end, left open
// HardRight Turn FrontSensor < 13 left Sensor < 10 Right Sensor > 26cm

Does the" &&" above equal the "and" in my post where all conditions need to be present to = true.
Where can I find concantation statements.
In Foxpro it is 1>2 .and. 2>3 = true

Wed Nov 23, 2011 2:35 pm
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 509
Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
Re: Need to evaluate the input from 3 sensors

_________________
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.

Wed Nov 23, 2011 3:40 pm
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Re: Need to evaluate the input from 3 sensors
That article is exactly what I needed.
Is it part of a larger document that I could obtain?
My next need is to learn how to call subroutines with parameters.

Wed Nov 23, 2011 6:21 pm
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 509
Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
Re: Need to evaluate the input from 3 sensors
 gemoomaw wrote:That article is exactly what I needed.Is it part of a larger document that I could obtain?

Yes, it is part of the "Introduction to ROBOTC" by the Carnagie Mellon Robotics Academy. It's available here. But before you can view it, you will have to make a account with them.

 gemoomaw wrote:My next need is to learn how to call subroutines with parameters.
http://www.robotc.net/teachingmindstorms/reference/hp_functions.pdf

_________________
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.

Wed Nov 23, 2011 7:31 pm
Moderator

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 495
Re: Need to evaluate the input from 3 sensors
Subroutines in ROBOTC are used in exactly the same way as in ANSI C (except that you cannot have any recursion). A quick google search on "functions in C" will help you out. However, I will display some of the basics here.
 Code:void someFunctionName(int i){  motor[arm] = i;}

That is a simple subroutine with one integer parameter. If you want to add more parameters, just separate them with a comma. To have a subroutine that returns something:
 Code:int someFunctionName(int i, int j){  return i + j;}

You will need to place these functions above the main task, or place function prototypes above the main task and the actual functions afterwards.

_________________
sudo rm -rf /

Wed Nov 23, 2011 7:34 pm
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Re: Need to evaluate the input from 3 sensors
Wow this is great. Now I need to put this to work

Thanks a lot

I may be back

Wed Nov 23, 2011 10:00 pm
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Re: Need to evaluate the input from 3 sensors
I may be blind but I have failed to find the full document("Introduction to ROBOTC") you reference on cs2n. Could you send me a link?

There are many valuable resources here. I have a student who will greatly profit from the beginning lessons in RobotC

Thanks for your help

Thu Nov 24, 2011 8:02 am
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 509
Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
Re: Need to evaluate the input from 3 sensors
I did. In my previous post, the word "here" is a link. Click on it, and it will bring you to that page. Try signing in on another tab, and then going to it.

_________________
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 Nov 24, 2011 9:54 am
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Re: Need to evaluate the input from 3 sensors
Found the resource files.

Getting closer

Now I need sound files for testing my sonar sensors but cannot find the files so that I can know what I can call.
I find the ones for Lego Mindstorms in the Lego directory but none with the RobotC directory. Where should the Robotc files reside?
If they are missing I could copy the Lego files to that directory.

There is a "woops.rso" in one of the sample programs and it works. I have searched for that file and for *.rso but get no results

!!! Found that I can copy sound files from the Lego..engine/sounds to Robomatterinc/RobotC../systemfiles

Thu Nov 24, 2011 9:01 pm
Senior Roboticist

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 509
Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
Re: Need to evaluate the input from 3 sensors
 gemoomaw wrote:!!! Found that I can copy sound files from the Lego..engine/sounds to Robomatterinc/RobotC../systemfiles
Good for you!!(and for me ) That's exactly what I was about to suggest.

_________________
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 Nov 24, 2011 11:18 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 12 posts ]

#### Who is online

Users browsing this forum: No registered users and 4 guests

 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 Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions    Robotics Merit Badge Robotics Discussions    General Discussions    Project Discussions International Forums    Spanish Forums       ROBOTC for MINDSTORMS       ROBOTC for VEX    French Forums       ROBOTC pour Mindstorms       ROBOTC pour IFI VEX    Japanese Forums （日本語のフォーラム） 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

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