Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Costmap #639

Merged
merged 94 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from 84 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
8691b67
Test
RyanAspen Sep 19, 2023
46a2479
First commit
RyanAspen Sep 21, 2023
ca4cb07
Initial Cost_map commit
RyanAspen Nov 1, 2023
f79037b
Removed costmap folder copy
RyanAspen Nov 5, 2023
01cca13
Initial README.md
RyanAspen Nov 5, 2023
c61599b
Update README.md
RyanAspen Nov 5, 2023
c3bd12f
Update README.md
RyanAspen Nov 5, 2023
6eb8d2b
Update README.md to account for clarification on project specifications
RyanAspen Nov 10, 2023
d945109
Added clarification
RyanAspen Nov 10, 2023
7c2c227
Created water_bottle_search.py
26pawarp Nov 12, 2023
6d08489
Updated code for new project scope
RyanAspen Nov 14, 2023
db012d2
Added more complete logic for stitching
RyanAspen Nov 17, 2023
5bf78fa
Removed Line which kills Clang servers
RyanAspen Nov 17, 2023
0e6360d
Added rostopic and started callback function
26pawarp Nov 19, 2023
95761c0
add costmap nodelet in cmakelists
alisonryckman Nov 19, 2023
d82f70a
Added a debug file for testng the occupency grid message
26pawarp Nov 19, 2023
2ff1505
changed costmap removed redundant code
MackenzieMurphy Nov 19, 2023
9a82b0c
add costmap to cmakelists, fix some includes compatibility issues
umroverPerception Nov 26, 2023
782e22a
Started publisher for msg debugging
26pawarp Nov 26, 2023
bf8c75f
Debug course publisher update with test, also added temporary subscri…
26pawarp Nov 29, 2023
de8ce87
Callback function done and tested, data retrieved properly
26pawarp Nov 29, 2023
234315f
Removed duplicate code
Depicar Nov 30, 2023
6a448eb
remove pcl from build
alisonryckman Dec 3, 2023
c06b6f3
worked on grid filling
Crypt1cG Dec 3, 2023
5e0f139
merge
Crypt1cG Dec 3, 2023
ea4471e
fixed build and header
alisonryckman Jan 16, 2024
70aa5f0
add normals to zed processing
alisonryckman Jan 19, 2024
d452ba4
Cartesian Coordinates COnverting Function
26pawarp Jan 21, 2024
8535c3e
Merge branch 'master' into obs-avoidance
Emerson-Ramey Jan 21, 2024
da29226
Merge remote-tracking branch 'origin/integration' into obs-avoidance
qhdwight Jan 23, 2024
4b4df3b
Merge remote-tracking branch 'origin/integration' into costmap
umroverPerception Jan 23, 2024
beae107
Fix compile
umroverPerception Jan 23, 2024
40acab3
Update
umroverPerception Jan 24, 2024
41c4681
costmap stuff
umroverPerception Jan 24, 2024
5342537
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Jan 24, 2024
3039c9c
Remove old file
qhdwight Jan 24, 2024
5c65ea4
Merge remote-tracking branch 'origin/integration' into obs-avoidance
kayleyge Jan 25, 2024
36c1351
costmap node
Crypt1cG Jan 26, 2024
3e9cbb0
Merge remote-tracking branch 'origin/obs-avoidance' into obs-avoidance
kayleyge Jan 26, 2024
996575b
normal tweaks
Crypt1cG Jan 26, 2024
52a5bd8
Conversion function (Real World -> Occupancy Grid) & (Occupancy Grid …
26pawarp Jan 26, 2024
4a4afa8
Added setup for the A* program
26pawarp Jan 27, 2024
04654f3
pointcloud working
Crypt1cG Jan 31, 2024
e987b17
fast costmap
Crypt1cG Jan 31, 2024
99bb271
fixed costmap
Crypt1cG Jan 31, 2024
227170c
faster costmap
Crypt1cG Feb 1, 2024
6b74531
Finished adding A-Start
26pawarp Feb 2, 2024
52df6b2
Added A-Star call, but we need to do something with the list returned
26pawarp Feb 2, 2024
be439f3
Added reset cur point in trajector.py and made small changes to conve…
26pawarp Feb 3, 2024
e8b314c
reorganize and add path logic to on_loop
Emerson-Ramey Feb 4, 2024
caec28b
change incrementing of paths
Emerson-Ramey Feb 4, 2024
3f9c09c
minor tweaks
Crypt1cG Feb 6, 2024
57a5b43
removed allocations from hot-path
Crypt1cG Feb 6, 2024
973f25a
cleaned up starter project stuff
Crypt1cG Feb 6, 2024
aea0665
small changes for nav
Crypt1cG Feb 7, 2024
6c8f040
Merge remote-tracking branch 'origin/obs-avoidance' into costmap
Crypt1cG Feb 8, 2024
3cfd481
fix errors when running and add transitions
umroverPerception Feb 10, 2024
890cb25
minor fixes
Crypt1cG Feb 11, 2024
17b3a55
fix driving to same target point
umroverPerception Feb 11, 2024
ef3c646
Merge branch 'costmap' of github.com:umrover/mrover-ros into costmap
umroverPerception Feb 11, 2024
ce364ac
small fixes
Crypt1cG Feb 11, 2024
d555242
Merge branch 'costmap' of github.com:umrover/mrover-ros into costmap
Crypt1cG Feb 11, 2024
2be051e
got rid of z limit (might be needed in real world though)
Crypt1cG Feb 11, 2024
572e818
not done - testing path planning
umroverPerception Feb 18, 2024
a2592d4
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Feb 20, 2024
bc8d1f3
Update to use manif
qhdwight Feb 20, 2024
a13a89d
Formatting
qhdwight Feb 20, 2024
60fa76b
Fix nav imports
qhdwight Feb 20, 2024
59fb619
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Feb 20, 2024
e5d9092
Correct frame
qhdwight Feb 20, 2024
b877028
Enable ekf
qhdwight Feb 20, 2024
4cb242e
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Feb 20, 2024
6b466e5
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Feb 22, 2024
3e3b545
changed debug course publisher for waterbottle
kayleyge Feb 23, 2024
3e27986
Costmap touchup (#652)
qhdwight Feb 26, 2024
1cbff99
fix zed frame name
alisonryckman Feb 27, 2024
1d277cd
Merge remote-tracking branch 'origin/integration' into costmap
qhdwight Mar 3, 2024
cd678cf
fix navigation merge conflicts
Emerson-Ramey Mar 4, 2024
3728c6d
add message file
umroverPerception Mar 4, 2024
fe8ab31
fix percep topic name and testing nav path planning
umroverPerception Mar 8, 2024
d794ae4
fix orientation of costmap and start to consider average of neighbor …
umroverPerception Mar 8, 2024
eaa6467
update printed map, add kernel, traversable terrian
umroverPerception Mar 12, 2024
e5179c7
add transition to approach object, add exceptions and reset trajectory
umroverPerception Mar 16, 2024
7e69d19
add extra points to water bottle search spiral
umroverPerception Mar 22, 2024
bb27616
create new file for astar, move costmap callback to context
umroverPerception Mar 26, 2024
40d8b3e
Added ground1 test One mountain test
26pawarp Mar 28, 2024
ca76f89
Adding ground2.fbx and ground2.blend for testing and there's some tes…
arleencheema Mar 28, 2024
3effc25
added the arena for the 70th hunger games as a map
kayleyge Mar 31, 2024
fb9b018
Merge remote-tracking branch 'refs/remotes/origin/costmap' into costmap
kayleyge Mar 31, 2024
f7c85ea
update grounds
umroverPerception Apr 4, 2024
93fce06
worked on moving costmap
Crypt1cG Apr 11, 2024
87bbb85
forgot to add something
Crypt1cG Apr 11, 2024
054b377
Merge remote-tracking branch 'origin/integration' into costmap
Apr 28, 2024
a29f629
Merge remote-tracking branch 'origin/integration' into costmap
umroverPerception Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ endif ()

## Perception

mrover_add_nodelet(costmap src/perception/cost_map/*.cpp src/perception/cost_map src/perception/cost_map/pch.hpp)
mrover_nodelet_link_libraries(costmap lie)

mrover_add_library(streaming src/esw/streaming/*.cpp src/esw/streaming)
target_compile_definitions(streaming PUBLIC BOOST_ASIO_NO_DEPRECATED)

Expand Down
6 changes: 6 additions & 0 deletions config/navigation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ search:
segments_per_rotation: 8
distance_between_spirals: 3

water_bottle_search:
stop_thresh: 0.5
drive_fwd_thresh: 0.34
coverage_radius: 10
segments_per_rotation: 8

object_search:
coverage_radius: 10
distance_between_spirals: 3
Expand Down
4 changes: 2 additions & 2 deletions config/rviz/auton_sim.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Visualization Manager:
Value: true
right_camera_link:
Value: true
zed2i_left_camera_frame:
zed_left_camera_frame:
Value: true
Marker Alpha: 1
Marker Scale: 1
Expand Down Expand Up @@ -112,7 +112,7 @@ Visualization Manager:
{}
right_camera_link:
{}
zed2i_left_camera_frame:
zed_left_camera_frame:
{}
Update Interval: 0
Value: true
Expand Down
6 changes: 3 additions & 3 deletions config/rviz/zed_test.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Visualization Manager:
Value: false
zed2i_camera_center:
Value: false
zed2i_left_camera_frame:
zed_left_camera_frame:
Value: false
zed2i_left_camera_optical_frame:
Value: false
Expand Down Expand Up @@ -102,7 +102,7 @@ Visualization Manager:
zed2i_camera_center:
zed2i_baro_link:
{}
zed2i_left_camera_frame:
zed_left_camera_frame:
zed2i_left_camera_optical_frame:
{}
zed2i_temp_left_link:
Expand Down Expand Up @@ -145,7 +145,7 @@ Visualization Manager:
Show Axes: false
Show Trail: false
Value: true
zed2i_left_camera_frame:
zed_left_camera_frame:
Alpha: 1
Show Axes: false
Show Trail: false
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@
<nodelet plugin="${prefix}/plugins/can.xml" />
<nodelet plugin="${prefix}/plugins/simulator.xml" />
<nodelet plugin="${prefix}/plugins/nv_gst_h265_enc.xml" />
<nodelet plugin="${prefix}/plugins/costmap.xml" />
</export>
</package>
6 changes: 6 additions & 0 deletions plugins/costmap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<library path="lib/libcostmap_nodelet">
<class name="mrover/CostMapNodelet"
type="mrover::CostMapNodelet"
base_class_type="nodelet::Nodelet">
</class>
</library>
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies = [
"aenum==3.1.15",
"daphne==4.0.0",
"channels==4.0.0",
"scipy==1.12.0"
]

[project.optional-dependencies]
Expand Down
22 changes: 11 additions & 11 deletions scripts/debug_course_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
convert_waypoint_to_gps(waypoint)
for waypoint in [
(
Waypoint(tag_id=0, type=WaypointType(val=WaypointType.NO_SEARCH)),
SE3(position=np.array([4, 4, 0])),
),
(
Waypoint(tag_id=0, type=WaypointType(val=WaypointType.POST)),
SE3(position=np.array([-2, -2, 0])),
),
(
Waypoint(tag_id=1, type=WaypointType(val=WaypointType.POST)),
SE3(position=np.array([11, -10, 0])),
),
Waypoint(tag_id=-1, type=WaypointType(val=WaypointType.WATER_BOTTLE)),
SE3(position=np.array([0, 0, 0])),
)#,
# (
# Waypoint(tag_id=0, type=WaypointType(val=WaypointType.POST)),
# SE3(position=np.array([-2, -2, 0])),
# ),
# (
# Waypoint(tag_id=1, type=WaypointType(val=WaypointType.POST)),
# SE3(position=np.array([11, -10, 0])),
# ),
]
]
)
47 changes: 47 additions & 0 deletions scripts/debug_water_bottle_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3

import numpy as np

import rospy
import time
from nav_msgs.msg import OccupancyGrid, MapMetaData
from geometry_msgs.msg import Pose
from std_msgs.msg import Header
from util.course_publish_helpers import publish_waypoints


"""
The purpose of this file is for testing the water bottle search state.
Specifically the occupancy grid message.
"""

if __name__ == "__main__":
rospy.init_node("debug_water_bottle")
try:
# int8[] data
test_grid = OccupancyGrid()
test_grid.data = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=np.int8)

# nav_msgs/MapMetaData info
metadata = MapMetaData()
metadata.map_load_time = rospy.Time.now()
metadata.resolution = 3
metadata.width = 3
metadata.height = 3
metadata.origin = Pose()
test_grid.info = metadata

# std_msgs/Header header
header = Header()
test_grid.header = header

# rospy.loginfo(f"Before publish")
# #costpub = rospy.Publisher("costmap", OccupancyGrid, queue_size=1)
# for i in range(10):
# costpub.publish(test_grid)
# time.sleep(1)
# rospy.loginfo(f"After publish")
# rospy.spin()

except rospy.ROSInterruptException as e:
print(f"Didn't work to publish or retrieve message from ros")
3 changes: 2 additions & 1 deletion src/navigation/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import rospy
import tf2_ros
from geometry_msgs.msg import Twist
from util.SE3 import SE3
from mrover.msg import (
Waypoint,
GPSWaypoint,
Expand Down Expand Up @@ -119,7 +120,7 @@ def current_target_pos(self, odom_override: bool = True) -> Optional[np.ndarray]
return self.get_target_pos(f"fiducial{current_waypoint.tag_id}", in_odom)
elif current_waypoint.type.val == WaypointType.MALLET:
return self.get_target_pos("hammer", in_odom)
elif current_waypoint.type == WaypointType.WATER_BOTTLE:
elif current_waypoint.type.val == WaypointType.WATER_BOTTLE:
return self.get_target_pos("bottle", in_odom)
else:
return None
Expand Down
3 changes: 2 additions & 1 deletion src/navigation/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def get_lookahead_pt(
:return: the lookahead point
"""
# compute the vector from the previous target position to the current target position

path_vec = path_end - path_start
# compute the vector from the previous target position to the rover position
rover_vec = rover_pos - path_start
Expand Down Expand Up @@ -192,7 +193,7 @@ def get_drive_command(
self.reset()
return Twist(), True

if path_start is not None:
if path_start is not None and np.linalg.norm(path_start - target_pos) > LOOKAHEAD_DISTANCE:
target_pos = self.get_lookahead_pt(path_start, target_pos, rover_pos, LOOKAHEAD_DISTANCE)

target_dir = target_pos - rover_pos
Expand Down
5 changes: 5 additions & 0 deletions src/navigation/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from navigation.search import SearchState
from navigation.state import DoneState, OffState, off_check
from navigation.waypoint import WaypointState
from navigation.water_bottle_search import WaterBottleSearchState
from navigation.approach_object import ApproachObjectState
from navigation.long_range import LongRangeState

Expand Down Expand Up @@ -53,6 +54,7 @@ def __init__(self, context: Context):
PostBackupState(),
ApproachPostState(),
ApproachObjectState(),
WaterBottleSearchState(),
LongRangeState(),
SearchState(),
RecoveryState(),
Expand All @@ -62,6 +64,9 @@ def __init__(self, context: Context):
self.state_machine.add_transitions(ApproachObjectState(), [DoneState(), SearchState(), RecoveryState()])
self.state_machine.add_transitions(LongRangeState(), [ApproachPostState(), SearchState(), RecoveryState()])
self.state_machine.add_transitions(OffState(), [WaypointState(), DoneState()])
self.state_machine.add_transitions(
WaterBottleSearchState(), [WaypointState(), RecoveryState(), ApproachObjectState()]
)
self.state_machine.configure_off_switch(OffState(), off_check)
self.state_machine_server = StatePublisher(self.state_machine, "nav_structure", 1, "nav_state", 10)

Expand Down
70 changes: 3 additions & 67 deletions src/navigation/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,73 +12,7 @@

from navigation import approach_post, approach_object, recovery, waypoint, long_range
from navigation.context import convert_cartesian_to_gps
from navigation.trajectory import Trajectory


@dataclass
class SearchTrajectory(Trajectory):
# Associated fiducial for this trajectory
fid_id: int

@classmethod
def gen_spiral_coordinates(
cls, coverage_radius: float, distance_between_spirals: float, num_segments_per_rotation: int
) -> np.ndarray:
"""
Generates a set of coordinates for a spiral search pattern centered at the origin
:param coverage_radius: radius of the spiral search pattern (float)
:param distance_between_spirals: distance between each spiralradii = angles * (distance_between_spirals / (2*np.pi)) (float)
:param num_segments_per_rotation: number of segments that the spiral has per rotation (int)
:return: np.ndarray of coordinates
"""
# the number of spirals should ensure coverage of the entire radius.
# We add 1 to ensure that the last spiral covers the radius along the entire rotation,
# as otherwise we will just make the outermost point touch the radius
num_spirals = np.ceil(coverage_radius / distance_between_spirals).astype("int") + 1
# the angles are evenly spaced between 0 and 2pi*num_segments_per_rotation (add one to the number of points because N+1 points make N segments)
angles = np.linspace(0, 2 * np.pi * num_spirals, num_segments_per_rotation * num_spirals + 1)
# radii are computed via following polar formula.
# This is correct because you want the radius to increase by 'distance_between_spirals' every 2pi radians (one rotation)
radii = angles * (distance_between_spirals / (2 * np.pi))
# convert to cartesian coordinates
xcoords = np.cos(angles) * radii
ycoords = np.sin(angles) * radii
# we want to return as a 2D matrix where each row is a coordinate pair
# so we reshape x and y coordinates to be (n, 1) matricies then stack horizontally to get (n, 2) matrix
return np.hstack((xcoords.reshape(-1, 1), ycoords.reshape(-1, 1)))

@classmethod
def spiral_traj(
cls,
center: np.ndarray,
coverage_radius: float,
distance_between_spirals: float,
segments_per_rotation: int,
fid_id: int,
) -> SearchTrajectory:
"""
Generates a square spiral search pattern around a center position, assumes rover is at the center position
:param center: position to center spiral on (np.ndarray)
:param coverage_radius: radius of the spiral search pattern (float)
:param distance_between_spirals: distance between each spiral (float)
:param segments_per_rotation: number of segments per spiral (int), for example, 4 segments per rotation would be a square spiral, 8 segments per rotation would be an octagonal spiral
:param fid_id: tag id to associate with this trajectory (int)
:return: SearchTrajectory object
"""
zero_centered_spiral_r2 = cls.gen_spiral_coordinates(
coverage_radius, distance_between_spirals, segments_per_rotation
)

# numpy broadcasting magic to add center to each row of the spiral coordinates
spiral_coordinates_r2 = zero_centered_spiral_r2 + center
# add a column of zeros to make it 3D
spiral_coordinates_r3 = np.hstack(
(spiral_coordinates_r2, np.zeros(spiral_coordinates_r2.shape[0]).reshape(-1, 1))
)
return SearchTrajectory(
spiral_coordinates_r3,
fid_id,
)
from navigation.trajectory import SearchTrajectory


class SearchState(State):
Expand Down Expand Up @@ -106,6 +40,7 @@ def on_enter(self, context) -> None:
self.DISTANCE_BETWEEN_SPIRALS,
self.SEGMENTS_PER_ROTATION,
search_center.tag_id,
False
)
else: # water bottle or mallet
self.traj = SearchTrajectory.spiral_traj(
Expand All @@ -114,6 +49,7 @@ def on_enter(self, context) -> None:
self.OBJECT_DISTANCE_BETWEEN_SPIRALS,
self.SEGMENTS_PER_ROTATION,
search_center.tag_id,
False
)
self.prev_target = None

Expand Down
Loading