View unanswered posts | View active topics It is currently Sat Dec 27, 2014 11:25 pm






Reply to topic  [ 12 posts ] 
Need to evaluate the input from 3 sensors 
Author Message
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Post 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
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: 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
Profile WWW
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Post 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
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: Need to evaluate the input from 3 sensors
I believe this will help you.

_________________
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
Profile WWW
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Post 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
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: 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
Profile WWW
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post 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
Profile
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Post 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
Profile
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Post 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
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: 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
Profile WWW
Rookie

Joined: Tue Nov 22, 2011 7:57 am
Posts: 8
Post 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
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: 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 8) ) 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
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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.