Skip to content

Commit

Permalink
Tools: ros2: Use 3D distance in goal computation
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Friedman <[email protected]>
  • Loading branch information
Ryanf55 committed Dec 15, 2023
1 parent 6787abb commit 5a07bdb
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
Warning - This is NOT production code; it's a simple demo of capability.
"""

import math
import rclpy
import time
import errno
Expand Down Expand Up @@ -144,9 +145,10 @@ def achieved_goal(goal_global_pos, cur_geopose):
cur_pos = cur_geopose.pose.position
p2 = (cur_pos.latitude, cur_pos.longitude, cur_pos.altitude)

flat_distance_km = distance.distance(p1[:2], p2[:2])
print(f"Goal is {flat_distance_km} away")
return flat_distance_km < 0.15
flat_distance = distance.distance(p1[:2], p2[:2]).m
euclidian_distance = math.sqrt(flat_distance**2 + (p2[2] - p1[2]) ** 2)
print(f"Goal is {euclidian_distance} meters away")
return euclidian_distance < 150


def main(args=None):
Expand Down

0 comments on commit 5a07bdb

Please sign in to comment.