# How do i move a robot to a certain coordinate?

Hello, i need help to move a robot

i have a set of coordinates stored in a txt file that i will be uploading its data to an array in my code, then i want to move the robot to these coordinates.

I can't figure out a way to move it to these coordinates accurately with my current hardware which has no sensors except the ultrasonic for obstacle avoidance. I have a limited budget so i prefer not to buy extra hardware if possible.

fawaris: I can't figure out a way to move it to these coordinates accurately with my current hardware which has no sensors except the ultrasonic for obstacle avoidance.

Without any extra sensors you will not be able to do this accurately. You have no way to tell how much your robot has moved, so the best you can do is to test how it moves when given a variety of commands e.g. when told to go forward at full speed it moves forward at 10cm/s. You can use this model to calculate what commands you need to give it in order to reach the desired goal. You will almost certainly have effects that make it quite difficult e.g. when you tell the robot to move forward, it doesn't move in an exactly straight line. I think it will be very hard to quantify this effectively. (and if you have to do obstacle avoidance in the middle of your route it will make things even less accurate)

At a minimum I suggest you get encoders for your wheels, so you can measure the wheel velocities. This will allow you to control the motion more effectively i.e. with PID control to make sure the wheels are moving at the same speed to go straight forward. Even if you don't achieve the exact control you want, you still have a better estimate of what the motion actually was (and therefore where your robot is). You will need to understand how to convert your wheel velocities into motion (which depends on the physical configuration of your exact robot).

Using a magnetometer as well in order to determine your heading may help a lot as well since inaccuracy in estimating heading will probably be a significant contributor to the total final error otherwise.

With just that information it sounds somewhere between difficult and impossible. Moving accurately to a defined position without any way of knowing where you are now or where you're moving to is plain impossible.

So what is the format of these coordinates? How far away is the robot starting from? Indoors or outdoors? Does the robot always start in exactly the same place? Is it in the same room as the place it is aiming for? How does it move and how does it steer?

Steve

Wheel encoders, to count wheel revolutions, can be made quite cheaply with Hall or optical sensors.

To do what you want accurately is very difficult.

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html

What form are the co-ordinates in? Long and Lat? X and Y on a grid of the area the robot is in? What is the reference for the co-ordinate system?

You will have to be more specific in your explanation.

Thanks.. Tom.. :)

slipstick: With just that information it sounds somewhere between difficult and impossible. Moving accurately to a defined position without any way of knowing where you are now or where you're moving to is plain impossible.

So what is the format of these coordinates? How far away is the robot starting from? Indoors or outdoors? Does the robot always start in exactly the same place? Is it in the same room as the place it is aiming for? How does it move and how does it steer?

Steve

Its in x,y format. Assume its initial position is 0,0. It will be working indoors in a small area without leaving the room. Movement is there but its without a goal, which are the coordinates. I want the robot to move to coordinates that are placed in an array.

TomGeorge: Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html

What form are the co-ordinates in? Long and Lat? X and Y on a grid of the area the robot is in? What is the reference for the co-ordinate system?

You will have to be more specific in your explanation.

Thanks.. Tom.. :)

The coordinates are in x,y grid. What do you mean by the reference for the co-ordinate system? do you mean the initial position of the robot? If that's the case, it's 0,0.

bms001: Without any extra sensors you will not be able to do this accurately. You have no way to tell how much your robot has moved, so the best you can do is to test how it moves when given a variety of commands e.g. when told to go forward at full speed it moves forward at 10cm/s. You can use this model to calculate what commands you need to give it in order to reach the desired goal. You will almost certainly have effects that make it quite difficult e.g. when you tell the robot to move forward, it doesn't move in an exactly straight line. I think it will be very hard to quantify this effectively. (and if you have to do obstacle avoidance in the middle of your route it will make things even less accurate)

At a minimum I suggest you get encoders for your wheels, so you can measure the wheel velocities. This will allow you to control the motion more effectively i.e. with PID control to make sure the wheels are moving at the same speed to go straight forward. Even if you don't achieve the exact control you want, you still have a better estimate of what the motion actually was (and therefore where your robot is). You will need to understand how to convert your wheel velocities into motion (which depends on the physical configuration of your exact robot).

Using a magnetometer as well in order to determine your heading may help a lot as well since inaccuracy in estimating heading will probably be a significant contributor to the total final error otherwise.

What I was thinking is to make it work in this method. I get the speed of my robot and keep it as a constant in my code, then once I get the first coordinate, that will be the distance from the initial, so I divide the speed by the distance to get the time needed for that movement, and based on that time, I move the robot accordingly. then once it reaches that coordinate, it will do everything in reverse to go back to 0,0 point ( I know its not efficient but its the best way i could think of), and once it goes back to 0,0, it will calculate the time required to go to the 2nd coordinate and so on.

Good plan. Try it out and let us know how it works.

fawaris: What I was thinking is to make it work in this method. I get the speed of my robot and keep it as a constant in my code, then once I get the first coordinate, that will be the distance from the initial, so I divide the speed by the distance to get the time needed for that movement, and based on that time, I move the robot accordingly. then once it reaches that coordinate, it will do everything in reverse to go back to 0,0 point ( I know its not efficient but its the best way i could think of), and once it goes back to 0,0, it will calculate the time required to go to the 2nd coordinate and so on.

You will need to measure the turning radius and speed as well, and I think that this is likely to be the biggest source of error, hence my suggestion of a magnetometer. There are lots of other things that you should also try and understand if you go ahead with this method, like how the motion is affected by changing battery voltage, how long it takes to accelerate up to a given speed etc.

How well you can quantify the motion produced by a given command input will determine how effective this method is. As I already mentioned, I think this will be very hard. And even if you do it well, I would not expect particularly good results. But it doesn't hurt to try it. At the very least you will learn something.

The coordinates are in x,y grid. What do you mean by the reference for the co-ordinate system? do you mean the initial position of the robot? If that's the case, it's 0,0.

So, what does a position of 10, 7 mean? 10 miles? 10 meters? 10 angstroms?

PaulS: So, what does a position of 10, 7 mean? 10 miles? 10 meters? 10 angstroms?

I'd put my money on furlongs.

vinceherman: I'd put my money on furlongs.

Not fathoms?

So the Coordinates are always relative to where the robot is sitting and which way it is pointing? Kind of gives new meaning to the first word of "Dead Reckoning"!

Indeed - more dead than reckoning on a good day I would say.

You have to know where you are, where you're aiming towards, ans where your destination is. Then, if your distance and direction travelled can be measured accurately, you can calculate where you are after moving a bit, and finally get to the target coordinates.

Having no intermittent feed-back on your location makes this stand and fall with the accuracy of your speed and direction measurement and control.

fawaris: What I was thinking is to make it work in this method. I get the speed of my robot and keep it as a constant in my code, then once I get the first coordinate, that will be the distance from the initial, so I divide the speed by the distance to get the time needed for that movement, and based on that time, I move the robot accordingly. then once it reaches that coordinate,

Sorry to trample on your illusions but that will not work reliably, if at all.

For example how will the robot know it has reached the co-ordinate rather than some other location?

There will be slippage at the wheels so it won't run in the exact direction that you want it to. And as @bms001 said, distance errors will creep in every time there is a change of direction.

You just might get acceptable results for one or two out-and-back journeys but once the route becomes complicated it will get completely lost.

To experience the problem set up a route in your living room with some chairs to mark the corners. Walk the route and count the steps between turns and the note the direction to turn. Then go back to the start and follow the route with your eyes shut and NO peeking. Then imagine how much more difficult it would be for a totally stupid robot.

...R

Well, advantage robot: it is not trying to make smaller steps as it's not afraid to trip and fall. A robot is just as happy to reach its destination as it is to crash and burn.

Nevertheless, dead reckoning is not exactly reliable.

PaulS: So, what does a position of 10, 7 mean? 10 miles? 10 meters? 10 angstroms?

Assuming each coordinate is going to be 3 cm space, so you could say its 30,21 cm I have the plan in mind regarding spacing

Robin2: Sorry to trample on your illusions but that will not work reliably, if at all.

For example how will the robot know it has reached the co-ordinate rather than some other location?

There will be slippage at the wheels so it won't run in the exact direction that you want it to. And as @bms001 said, distance errors will creep in every time there is a change of direction.

You just might get acceptable results for one or two out-and-back journeys but once the route becomes complicated it will get completely lost.

To experience the problem set up a route in your living room with some chairs to mark the corners. Walk the route and count the steps between turns and the note the direction to turn. Then go back to the start and follow the route with your eyes shut and NO peeking. Then imagine how much more difficult it would be for a totally stupid robot.

...R

Good point there, I will see if I can add at least a distance sensor or a magnetometer from my budget because I think it will be the cheapest solution for now.

bms001: Without any extra sensors you will not be able to do this accurately. You have no way to tell how much your robot has moved, so the best you can do is to test how it moves when given a variety of commands e.g. when told to go forward at full speed it moves forward at 10cm/s. You can use this model to calculate what commands you need to give it in order to reach the desired goal. You will almost certainly have effects that make it quite difficult e.g. when you tell the robot to move forward, it doesn't move in an exactly straight line. I think it will be very hard to quantify this effectively. (and if you have to do obstacle avoidance in the middle of your route it will make things even less accurate)

At a minimum I suggest you get encoders for your wheels, so you can measure the wheel velocities. This will allow you to control the motion more effectively i.e. with PID control to make sure the wheels are moving at the same speed to go straight forward. Even if you don't achieve the exact control you want, you still have a better estimate of what the motion actually was (and therefore where your robot is). You will need to understand how to convert your wheel velocities into motion (which depends on the physical configuration of your exact robot).

Using a magnetometer as well in order to determine your heading may help a lot as well since inaccuracy in estimating heading will probably be a significant contributor to the total final error otherwise.

Regarding the Magnetometer, i also found an accelerometer, and both of them exist on 1 sensor called IMU Sensor. Can I just use the accelerometer alone or do I also need the magnetometer for this job?

From what I understood after some research, the accelerometer reads displacement and its orientation stays fixed so no matter which direction the robot rotates, it stays on the same axis but the magnetometer rotates its orientation with the robot.