|
Page 1 of 1
|
[ 11 posts ] |
|
Rotaing radar ultrasonic sensor
Author |
Message |
Strma
Rookie
Joined: Sun Apr 21, 2013 11:34 am Posts: 4
|
 Rotaing radar ultrasonic sensor
Hello everybody I'm new in programming, using RobotC and I'm trying to navigate my NXT robot around using UltraSonic sensor attached to motor(A). I'd like it to do 180° scans (centerline and 90° to the left and right in 30° increments ( guess that should be sufficient considering width of the ultrasonic "beam") then compare measurements to use the largest one to point my robot toward direction that particular measurement was taken from (motor(A) possition in degrees). Is it possible (And if it is, please, how?) to "store" those parameters and feed them to drive motors (B&C) making the robot travel in direction without obsticles? Is there a way to do all that in motion or the robot should stop while scaning?
|
Sun Apr 21, 2013 12:11 pm |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: Rotaing radar ultrasonic sensor
Yes, it's certainly possible. In fact, pretty easy, depending on how you're gonna choose which direction to go in. I imagine you'd start with an array like this: And then have a for loop which moves the US sensor 30* and then takes a US reading, storing it in the equivalent array element. Now, depending on what you want for navigation, you could just go with the greatest distance, or something else. You could make a function for turning, and pass in which way and how far to turn. It'd be best to stop and scan, so that you don't run into anything while scanning. Maybe scan again when you see something get close. If you need anything explained, just say so. I certainly had no idea what arrays or elements or for loops where when I first started, since RobotC was the first programming language I learned.
_________________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.
|
Sun Apr 21, 2013 1:01 pm |
|
 |
Strma
Rookie
Joined: Sun Apr 21, 2013 11:34 am Posts: 4
|
 Re: Rotaing radar ultrasonic sensor
Thank you NeXT-Generation for finding time to answer my absolute beginner question. As you already guess I got no clue about arrays and as far as looping, I just start to scratch the subject  What I had in mind was robot finding an area where the obsticle is farther and drive to it untill reaching some safe distance...then scan to find another "free"way and travel there. I looked everywhere to find something to help me understand "mechanics" behind such scenario but without success. I'd be more than grateful if you would share some of your knowledge and help me crack this problem with some example and step-by step guidance.
|
Sun Apr 21, 2013 3:30 pm |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: Rotaing radar ultrasonic sensor
Basic working of a for loop and arrays: Basic for loop: Basics of array usage:  |  |  |  | Code: int exampleArray[10];// creates an array of type "integer" and names it "exampleArray". This array has 10 elements in it, signified by the square-bracketed 10.
//Array "elements" are the individual parts of the array, and can be accesed and changed like this.
exampleArray[0] = 1;//Set element 0 to a value of 1. The count starts at 0, so this array has the elements 0-9 nxtDisplayCenteredBigTextLine(2, "%d", exampleArray[0]);//Displays the value of array element 0
//So, to summarise, an array is basically an easy and compact way to deal with a bunch of similar variables. I use "exampleArray[10]" instead of //ExampleVar1, ExampleVar2, ExampleVar3, etc. |  |  |  |  |
So, that's the raw basics. A quick Google search will give more detailed info. And here's a for loop with arrays! So, that's basically what you need for your project. At least for starters. Still need motor movements, path deciding and the like.
_________________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.
|
Sun Apr 21, 2013 4:52 pm |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: Rotaing radar ultrasonic sensor
Oh and btw, you can usually just use integers for your number variables. The only real need to use as small as bytes is if you have a huuuge program or are transmitting messages via BT, RS485, or other means. Just a force of habit with me to use the smallest I'd need.
_________________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.
|
Sun Apr 21, 2013 4:54 pm |
|
 |
Strma
Rookie
Joined: Sun Apr 21, 2013 11:34 am Posts: 4
|
 Re: Rotaing radar ultrasonic sensor
Thank you NeXT-Generation fo your efforts to enlighten me 
|
Mon Apr 22, 2013 5:42 am |
|
 |
Coder A
Moderator
Joined: Thu Jan 03, 2013 5:10 pm Posts: 207 Location: The plateau north of the Ohio River Valley, also known as Cave Country.
|
 Re: Rotaing radar ultrasonic sensor
Yeah, I almost never use int. Short is the same thing on most platforms.
_________________ I'm not a robot! I'm british! ~ quote from an asparagus I am not a robot! I am a unicorn! ~ quote from a robot
|
Mon Apr 22, 2013 4:52 pm |
|
 |
MHTS
Guru
Joined: Sun Nov 15, 2009 5:46 am Posts: 1523
|
 Re: Rotaing radar ultrasonic sensor
This will not help you regarding basic programming but I do have a robotics library that incidentally contains a radar module that does exactly what you want. It's developed as an object in the library. If you have some concept on object oriented programming, you will feel at home using the library. You can also look at the source code to learn how it uses array to implement the functions. The radar object consists of an ultrasonic sensor and a motor. By default, you can register up to 4 sampling positions but you can override it by defining higher number for the MAX_SAMPLE_POINTS define. After the radar object is initialized, you can make several calls to RadarAddSample to register several degree positions you want the radar to scan. After that you can call RadarSetState with true to start the scanning or false to stop the scanning. At any time, you can call RadarGetData with a given degree angle to get the reading for that angle. Here is the source code to the radar module: http://proj.titanrobotics.net/hg/Ftc/20 ... ib/radar.hIf you are interested in using the library module, let me know and I can walk you through how to use the library.
|
Thu May 02, 2013 2:54 am |
|
 |
TORQUE
Rookie
Joined: Tue Apr 30, 2013 11:13 am Posts: 2
|
 Re: Rotaing radar ultrasonic sensor
Hi pls i would need u to explain more about how to transmit message via BT or let me say intruction. for example how can u specify to the robot the amount of distance to travel next while its running? thank you in anticipation guys
|
Thu May 02, 2013 8:24 am |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: Rotaing radar ultrasonic sensor
Don't hijack threads. Make a new one.
_________________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 May 02, 2013 9:20 am |
|
 |
Strma
Rookie
Joined: Sun Apr 21, 2013 11:34 am Posts: 4
|
 Re: Rotaing radar ultrasonic sensor
Thank you very much MHTS I'm not very skillful in programming but I'll certainly take a look into your code and then come back with a lot of questions 
|
Fri May 03, 2013 2:54 am |
|
|
|
Page 1 of 1
|
[ 11 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
|
|