Go Down

Topic: Retrieving the latitude and longitude values in Arduino (Read 599 times) previous topic - next topic

ngjy

How will the robot know where it is with respect to the phone?
Does the robot have a GPS as well?
Tom... :)
The robot will be following a map on the phone which was done by another person whereby it will have the latitude and longitude of the map. The robot does not have any GPS sensor on it. It follows the map and the movement of the robot.

DrDiettrich

How can the robot follow a map stored on the phone?

Delta_G

How does the robot know where it is on the map? 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

ngjy

The robot knows where it is on the map by clicking on the starting point on the map. When the user starts moving with the phone, the robot will follow the movement of the user. :)

Delta_G

The robot only knows it's position at the start of that.  How does he know where he is later?   He can't see the map.  He can't get his coordinates. 

Here, think of it this way.  You know your GPS coordinates right now but not mine.  Now which way would I have to travel to get to you?  If you can answer that then you can do this project. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

DrDiettrich

Close your eyes, and you can play the robot. You are told your starting position, relative to the phone, then the movement of the phone. Which direction will you go, to follow the phone? Which use do you have for the map stored in the phone?

TomGeorge

Hi,
Does the robot have encoders on its wheels so it know how far it is moving?

If the robot and the phone start at the same spot. 

Then the phone moves, the robot can workout where the phone has moved too, BUT how does it know how far it has traveled when following to keep up or catch the phone?


The idea has merit but the robot will need some dead reckoning capability, then accuracy will be your problem after 3 or 4 iterations. 

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

ngjy

Hi everyone! Thanks for all the replies. I will think about the questions that you all have suggested to me. Thanks so much for all the help! I have found the coding on the data of the positioning of the mobile phone that was sent over to the Arduino side. However, the angle of the robot seems to a bit off sometimes.
The codes are as follows:

Code: [Select]
private void sendBluetooth() {
     if (btSocket != null) {
        try {
               btSocket.getOutputStream().write((Float.toString(distFrom(startLat, startLong, endLat, endLong)) + "," + Float.toString(bearing(startLat, startLong, endLat, endLong, degree)) + "\n").getBytes());

               msg("Message Sent");
        } catch (Exception e) {
           msg("Sending Error");
        }
     }
  }

   public float distFrom(float lat1, float lon1, float lat2, float lon2) { // one point to another point
       float earthRadius = 6371000; //meters
       double dLat = Math.toRadians(lat2-lat1);
       double dLng = Math.toRadians(lon2-lon1);
       double a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLng/2) * Math.sin(dLng/2);
       double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
       float dist = totalDistance + (float) (earthRadius * c);
       totalDistance = dist;
       return dist;
   }

   // start lat and long, end lat and long
   public int bearing(float lat1, float lon1, float lat2, float lon2, float previousDegree){

       double latitude1 =  lat1;
       double longitude1 = lon1;
       double latitude2 =  lat2;
       double longitude2 = lon2;

     double brng = Math.atan2((latitude2-latitude1),(longitude2-longitude1));
       double atan2 = Math.toDegrees(brng);

       if (atan2 < 0.0)
       {
        atan2 += 360;
       }
       degree = (float)atan2;
       return (int)(atan2-previousDegree);
   }

TomGeorge

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....

Johan_Ha

So in theory this could work. Robot is placed on a starting spot, heading to the North (have your compass with you). Robot is equipped with encoder plates so its movements can be calculated, both travelled distance and angle of changed direction. This will all be dead reckoning! When everything starts, the phone position is saved. When phone finds itself in a new position, the direction and distance is calculated from start position to the new position. This data is sent to Arduino, which rotates itself to the direction and starts to travel the given distance.  If each new measurement on the phone could be 5 m off, that won't add error in the long run. But all errors the robot makes will add up. When robot meets a bump, direction might be off by 5 degrees. Nothing will correct that. When the wheels are slipping, distance and direction will be off. One could add accuracy to the dead reckoning with a compass, a gyro and an accelerometer. Or a camera that scanns the surface under the robot like a computer mouse. But it's still dead reckoning.
____________________

If you ask for help and write 'u' instead of 'you' because you think it's convenient, I will write 'no' instead of 'yes'. For same reasons.

ngjy

So in theory this could work. Robot is placed on a starting spot, heading to the North (have your compass with you). Robot is equipped with encoder plates so its movements can be calculated, both travelled distance and angle of changed direction. This will all be dead reckoning! When everything starts, the phone position is saved. When phone finds itself in a new position, the direction and distance is calculated from start position to the new position. This data is sent to Arduino, which rotates itself to the direction and starts to travel the given distance.  If each new measurement on the phone could be 5 m off, that won't add error in the long run. But all errors the robot makes will add up. When robot meets a bump, direction might be off by 5 degrees. Nothing will correct that. When the wheels are slipping, distance and direction will be off. One could add accuracy to the dead reckoning with a compass, a gyro and an accelerometer. Or a camera that scanns the surface under the robot like a computer mouse. But it's still dead reckoning.
Thanks for the reply. I will try to fully understand it and apply the concept in my project. Thank you so much for your help! :)

Go Up