Hi! I am new to Arduino Coding and is currently doing a project on autonomous robot car. My robot car has an Arduino Mega 2560, RN-42 Bluetooth Module and 4 PING)))) Sensor. I do not know how to retrieve the latitude and longitude values.
Hi! I am new to Arduino programming. I would like to ask for some help. My robot is currently able to follow my mobile using Bluetooth but it is not moving in a straight line. It always goes slanted. How can I solve this problem?
If you just want to get it, you'll need a GPS module. I suppose you could calculate it if you know where your robot starts, and keep track of it's movements, but that would be ... non-ideal.
Thank you for the suggestions! Right now, I am able to get the coordinates on the mobile phone created using Android Studio. Does anyone have any ideas how am I able to retrieve those values in Arduino from the mobile phone? Thank You once again!
Hi! The robot is only able to move in a straight for a few seconds before it starts to slant. Yes, this post is associated with the previous post. Thanks for replying too! : D
The purpose of sending coordinates is to let the robot know the positioning of the mobile phone as the robot will be following the movement of the mobile phone via Bluetooth connection. Thanks for the reply.
TomGeorge:
Good question, I hope the OP doesn't expect the robot to follow the phone? :o :o :o
ngjy:
The purpose of sending coordinates is to let the robot know the positioning of the mobile phone as the robot will be following the movement of the mobile phone via Bluetooth connection. Thanks for the reply.
How will the robot know where it is with respect to the phone?
Does the robot have a GPS as well?
Tom...
TomGeorge:
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.
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.
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?
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.
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:
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);
 }