Package jaron.gps

Examples of jaron.gps.Waypoint


   *
   * @param latitude the latitude coordinate in decimal form
   * @param longitude the longitude coordinate in decimal form
   */
  public void addWaypoint(double latitude, double longitude) {
    waypoints.add(new Waypoint(latitude, longitude));
  }
View Full Code Here


    // by default the target course is the current course
    double course = courseOverGround.getValue();

    if (navigationMode == DO_NAVIGATE && waypoints.size() > 0) {
      // get the current target waypoint
      Waypoint waypoint = waypoints.get(currentWaypointIndex);
      // get the distnace to the target waypoint...
      double distance = Navigation.getDistanceInMeters(latitude.getValue(), longitude.getValue(), waypoint.getLatitude(), waypoint.getLongitude());
      // ...and check if the vehicle is within the target waypoint radius
      if (distance <= targetRadius) {
        // switch to the next waypoint
        ++currentWaypointIndex;
      }
      if (currentWaypointIndex < waypoints.size()) {
        // calculate the new target course
        waypoint = waypoints.get(currentWaypointIndex);
        course  = Navigation.getCourseInDegrees(latitude.getValue(), longitude.getValue(), waypoint.getLatitude(), waypoint.getLongitude());
      }
      else {
        // all waypoints are reached -> set mission completed
        navigationMode = missionCompletedAction;
      }
      currentWaypoint.setValue(currentWaypointIndex + 1);
    }
    else if (navigationMode == CIRCLE_AT_HOME) {
      // calculate the new course (inspired by http://tom.pycke.be/mav/101/circle-navigation)
      double tSeconds = 1; // timer for the ahead calculation (in seconds)
      double vAngular = speedOverGround.getValue() / circlingRadius;
      double alpha = Navigation.getCourseInRadians(latitude.getValue(), longitude.getValue(), homeLatitude, homeLongitude) + Math.PI;
      Waypoint dest = Navigation.getDestinationPoint(new Waypoint(homeLatitude, homeLongitude), Math.toDegrees(alpha + (vAngular * tSeconds) * circlingDirection), circlingRadius);
      course = Navigation.getCourseInDegrees(latitude.getValue(), longitude.getValue(), dest.getLatitude(), dest.getLongitude());
    }
    else if (navigationMode == RESTART_MISSION) {
      currentWaypointIndex = 0;
      navigationMode = DO_NAVIGATE;
    }
View Full Code Here

    double lon2 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(distance / R) *
                  Math.cos(lat1), Math.cos(distance / R) - Math.sin(lat1) *
                  Math.sin(lat2));
    lon2 = (lon2 + Math.PI) % (2 * Math.PI) - Math.PI;  // normalize to -180...+180
   
    return new Waypoint(Math.toDegrees(lat2), Math.toDegrees(lon2));
  }
View Full Code Here

TOP

Related Classes of jaron.gps.Waypoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.