### Author Topic: Determining X,Y position of robot  (Read 2605 times)

0 Members and 1 Guest are viewing this topic.

#### ArtBot

• Jr. Member
• Posts: 14
##### Determining X,Y position of robot
« on: January 01, 2012, 03:49:17 AM »
I'm working on a drawing robot - basically a more complex turtle. It needs to know it's 2D Cartesian location (X,Y co-ordinates) within a fixed space (the canvas it's drawing on).

One traditional way to do this is with wheel encoders to keep track of how far the robot has moved. But for various reasons I'd prefer not to use this method. Rather than that kind of mapping, I'd like a method for the bot to be able to check its position at any time.

The only thing I've been able to come up with so far its to have some kind of target positioned at each corner of the canvas that the robot can identify using its camera and then measure the distance using its ultrasonic sensor (accuracy to within a few cm is fine). But this seems inelegant somehow. I'd appreciate any other ideas as to how this can be done.
Speculatrix - thinking machines and artificial smarts

• Full Member
• Posts: 107
• Necessity is the mother of invention.
##### Re: Determining X,Y position of robot
« Reply #1 on: January 01, 2012, 11:04:01 AM »
This idea I saw it on a reply from Soeren to another person: make a grid with wires at different frequencies and from there determine coordinates. I'm pretty sure when he replies he'll give a widet insight to that idea. Meanwhile you search the forum for it.
Knowledge does not weigh.

#### ArtBot

• Jr. Member
• Posts: 14
##### Re: Determining X,Y position of robot
« Reply #2 on: January 17, 2012, 03:28:24 AM »
A wire grid isn't going to be that convenient for this application. So this is what I've got in mind for now & would appreciate comments/input:

Rather than DC motors, I could use stepper motors to gain some level of precision in the movement based purely on the commands sent to the motors. The robot will presume it knows where it is because it knows how much it *should* have moved. This would probably result in some degree of imprecision, but that's fine because this is art, not manufacturing, and some measure of randomness is quite attractive. However, I don't want these errors to accumulate too much, so...

The robot will move in straight lines. Every now and then it's going to arrive at the edge of the canvas. I'm going to need some way of detecting that anyway, so what I figured I'd do is paint a bright red line around all four sides of the canvas that can be detected using a photoresistor. Actually, I thought I'd use two - one with a red filter and one with a blue filter. When the values between them differ greatly, I could assume I've hit the red line. At that point, the robot can recalibrate its position (on one axis, anyway) and eliminate the errors.

Thoughts?
Speculatrix - thinking machines and artificial smarts

#### newInRobotics

• Supreme Robot
• Posts: 1,015
• N.I.R.
##### Re: Determining X,Y position of robot
« Reply #3 on: January 17, 2012, 04:00:12 AM »
Why so complicated?

Use steppers as that way You can hold robot in it's posture.

To measure X and Y You can use Sharp IR sensor (actually two of them, one for X and one for Y). Another way to do it is to have linear encoder (a strip of paper with black and white squares, and IR detector/emitter pair used to count transitions from black to white (and vice versa) while end effector moves from one side to another). To get more precision, a shaft encoder (striped disk on motor shaft and IR emitter/detector pair) will be excellent. If, say, You use threaded steel rod (thread pitch of 1mm) as axis of movement, then with one rotation of the motor You will get 1mm movement of end effector. Now, say You use shaft encoder disk with 16 stripes (pretty rough), that gives You precision of 0.0625mm, which is pretty good.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

#### ArtBot

• Jr. Member
• Posts: 14
##### Re: Determining X,Y position of robot
« Reply #4 on: January 17, 2012, 04:21:42 AM »
My experience with the Sharp sensors is that their resolution is quite poor. And they need something to bounce off.

The reason I didn't want to use encoders (as I mentioned in the original post) is that they seem to tie up a lot of processing power. Either you use interrupts (which ties up precious interrupt pins that I want for other purposes) or you do nothing but watch the encoders during movement. I want the robots to be able to read other sensors & carry out other actions during movement.
Speculatrix - thinking machines and artificial smarts

#### newInRobotics

• Supreme Robot
• Posts: 1,015
• N.I.R.
##### Re: Determining X,Y position of robot
« Reply #5 on: January 17, 2012, 04:46:29 AM »
Well, AFAIK, almost any pin can be tied to PIN CHANGE interrupt (at least in ATmega48 and the like), having that said, You'll need 2 pins (any 1 sensor will use at least 1 pin of uC) to know how far on X and Y end effector is. Going one side You will increment xCounter/yCounter with every detected transition, going to the other side You will decrement them. xCounter/yCounter hold actual position of the end effector. You probably won't find anything simpler and more precise than this for DIY CNC
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

#### ArtBot

• Jr. Member
• Posts: 14
##### Re: Determining X,Y position of robot
« Reply #6 on: January 17, 2012, 04:51:42 AM »
I'm using the Arduino Mega for this. As far as I know, there are only 6 pins that can be used for interrupts and some of those will be used for other purposes (eg, I2C). And I need some interrupts for other sensors.
Speculatrix - thinking machines and artificial smarts

#### newInRobotics

• Supreme Robot
• Posts: 1,015
• N.I.R.
##### Re: Determining X,Y position of robot
« Reply #7 on: January 17, 2012, 05:37:59 AM »
I'm using the Arduino Mega for this. As far as I know, there are only 6 pins that can be used for interrupts and some of those will be used for other purposes (eg, I2C). And I need some interrupts for other sensors.
That's why I don't like pre-built boards. The base of Arduino Mega is ATmega1280, which has 24 Pin Change Interrupt capable pins, however, Arduino Mega decided to use only 6 of them

Anyway, I hope You will be able to find some other way to achieve Your goal  Good luck.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

#### Billy

• Robot Overlord
• Posts: 132
##### Re: Determining X,Y position of robot
« Reply #8 on: January 17, 2012, 06:04:41 PM »
The robot will move in straight lines.....at that point, the robot can recalibrate its position (on one axis, anyway) and eliminate the errors.

Thoughts?

You've got the right idea, but using either stepper or encoder, you will be able to get pretty good results determining distance traveled.  The larger issue is the angle. A very small error in angle will accumulate into a large lateral error as you move across the canvass...so when you get to the edge of the canvas, you should focus more on correcting the orientation of the robot than linear distance traveled.

For orientation, I like the brute force method. Have a wall around the canvas and run the robot into it, and have it keep pushing a little bit. That will align the robot with wall and you'll be pointing in a known direction, and also know you position in at least one direction... occasionally you drive into a corner and you'll know just where you are.

#### ArtBot

• Jr. Member
• Posts: 14
##### Re: Determining X,Y position of robot
« Reply #9 on: January 18, 2012, 02:03:10 AM »
I'm a big fan of brute force myself  I am, however, trying to eliminate the amount of construction necessary (which is why I shied away from the wire grid idea). This project will ultimately be for live art events with a need to set up as quickly as possible.

I take your point, tough, about angle. My first robot (or, to be more precise, first for about 25 years) does have a bit of a limp. Going back to the light sensor idea, I figured if I mounted two laterally across the robot then it would be easy to know if the 'bot had hit the line at right angles. If both sensors trigger at the same time, all is fine. If only one triggers, then keep the motor on that side stopped and edge forward the other one until the sensor fires and, hey presto, you've aligned with the line.

I'm definitely keeping the wall idea as a fallback, though. I'm working with a painter on this project, so I can outsource the wall construction to him...
Speculatrix - thinking machines and artificial smarts

#### Ro-Bot-X

• Contest Winner
• Supreme Robot
• Posts: 1,431
• Store: RoBotXDesigns.ca
##### Re: Determining X,Y position of robot
« Reply #10 on: January 18, 2012, 06:42:24 AM »
There is an easy method to calculate the position of the robot in a determined space. But for this you need 3 things:
- a Christmas bauble (globe or whatever you may call it) installed on the robot hanging from a pole
- a WiiCam board from Chris The Carpenter (Rocket Brand Studios) mounted on the robot pointing vertically at the bauble
- 3 IR LEDs mounted in the corners of the canvas

The WiiCam board will give you over the I2C interface coordinates of the IR blobs reflected on the bauble. Depending on the position of the robot on the canvas, the coordinates will always be different and you can use some trig math to triangulate the position and also get the orientation.
Check out the uBotino robot controller!

• Full Member
• Posts: 107
• Necessity is the mother of invention.
##### Re: Determining X,Y position of robot
« Reply #11 on: January 18, 2012, 02:25:59 PM »
Use a compass to determine angle.
Knowledge does not weigh.

#### ArtBot

• Jr. Member
• Posts: 14
##### Re: Determining X,Y position of robot
« Reply #12 on: January 18, 2012, 02:40:27 PM »
Is the resolution really that good? I've never tried one, but have been considering the Adafruit breakout board.
Speculatrix - thinking machines and artificial smarts

#### Billy

• Robot Overlord
• Posts: 132
##### Re: Determining X,Y position of robot
« Reply #13 on: January 18, 2012, 03:26:22 PM »
If your artist friend will allow the intrusion of a USB cam on a tripod or hanging from the ceiling, the software "roborealm" (sp?) will solve your problem nicely and allow for super quick set up.  I forget exactly what the SW is called, but tested it at home once and it worked well.

Setup would need to expand with PC and wireless connection to the robot, but that could be well hidden.

• Jr. Member
• Posts: 14