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

let me into main plz #13

Merged
merged 89 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
47bc672
First iteration of serial dual camera support
dylanzemlin Apr 11, 2024
096b011
Add autonav_serial camera node to managed_steam.xml
dylanzemlin Apr 11, 2024
7aad66c
Update camera configuration and image processing in camera.py
dylanzemlin Apr 11, 2024
265d61d
Merge branch 'main' into feat/dual_camera_serial_integration
dylanzemlin Apr 12, 2024
9ae0b8d
Added vectornav to manual launch
dylanzemlin Apr 12, 2024
a43d1f6
Fixed dual camera serial node
dylanzemlin Apr 12, 2024
6a67d98
Add blink_period parameter to SafetyLightsPacket structure and set de…
dylanzemlin Apr 16, 2024
2c91dab
Add blink_period parameter to SafetyLightsPacket structure and set de…
dylanzemlin Apr 16, 2024
c8b9697
Fix safety lights behavior when switching to autonomous mode in Steam…
dylanzemlin Apr 16, 2024
da36c25
Update setup files to use 2024 repo
dylanzemlin Apr 23, 2024
636a910
Merge branch 'main' into feat/dual_camera_serial_integration
dylanzemlin Apr 23, 2024
0f89056
Added new config options to combiner
dylanzemlin Apr 26, 2024
5cc8416
Fix general system info not updating on display load
dylanzemlin Apr 30, 2024
d77af84
Fix expandify config not working and use astar display
dylanzemlin Apr 30, 2024
6036b18
god help us all
dylanzemlin Apr 30, 2024
f97153c
Add expandify node to competition.xml
dylanzemlin May 1, 2024
68c8c06
Fix camera flip issue in autonav_serial/src/camera.py
dylanzemlin May 1, 2024
7ed68f6
First iteration of updated vision
dylanzemlin May 1, 2024
daad968
More work on image stuff
dylanzemlin May 1, 2024
01dda01
Add testing stuff
dylanzemlin May 1, 2024
ee47df9
update rgb lights mode
dylanzemlin May 1, 2024
230aa1e
Change lights mode to solid always
dylanzemlin May 1, 2024
ee59e6c
Update image transformation coordinates in transformations.py
dylanzemlin May 1, 2024
c3c7ce5
Lower default auto speed
dylanzemlin May 13, 2024
4c5cfbf
Fix perspective transform to actually be perspective
dylanzemlin May 13, 2024
4ecb418
Update region of disinterest and combination method
dylanzemlin May 13, 2024
24080a2
Remove extra tabs
dylanzemlin May 13, 2024
18a67c0
scrabby works
dylanzemlin May 13, 2024
7740017
Fix debug astar not showing
dylanzemlin May 14, 2024
2680f03
Clean up astar file a tad
dylanzemlin May 14, 2024
e4401e4
Update default path resolver config
dylanzemlin May 14, 2024
70f268f
Add new config options to camera serial
dylanzemlin May 14, 2024
3682c1f
Adjust subscription qos
dylanzemlin May 14, 2024
8dfbca3
Add new options for vision adjustement and visual lines
dylanzemlin May 14, 2024
59916cf
Clean up particle filter a bit
dylanzemlin May 14, 2024
3152799
Some light launch file cleaning
dylanzemlin May 14, 2024
237cea7
More cleanup
dylanzemlin May 14, 2024
5e0ba73
Adjust default expandify max range
dylanzemlin May 14, 2024
02d73f2
Fix various issues with compilation
dylanzemlin May 14, 2024
abc93d3
Adjust a* debug to always publish
dylanzemlin May 14, 2024
062f698
More display tomfoolerly
dylanzemlin May 14, 2024
fd9ba8e
Try and fix combination image not showing up correctly
dylanzemlin May 14, 2024
26179a1
Update astar to use cfg for fov/waypoint weight
dylanzemlin May 14, 2024
ddb94a6
Update camera output dimensions in camera.py and add new options for …
dylanzemlin May 14, 2024
aee39a4
Update camera.py to destroy and create threads after config update
dylanzemlin May 14, 2024
b5c3d27
Fix issue with camera thread destruction in camera.py
dylanzemlin May 14, 2024
59a7d92
Refactor camera thread destruction and creation in camera.py
dylanzemlin May 14, 2024
dd43881
Refactor camera thread destruction and creation in camera.py
dylanzemlin May 14, 2024
8319011
Update camera.py to change the camera index for the right camera
dylanzemlin May 14, 2024
697cb4e
Update camera.py to change the camera index for the right camera
dylanzemlin May 14, 2024
5b74dd0
Update camera.py to change the camera index for the left and right ca…
dylanzemlin May 14, 2024
56fd827
Update camera.py to change the camera index for the left and right ca…
dylanzemlin May 14, 2024
75554b5
Revert to old camera.py
dylanzemlin May 14, 2024
1c479ab
Update camera.py to change the output dimensions for the left and rig…
dylanzemlin May 14, 2024
29ccc7b
Fix camera flipping issue in camera.py
dylanzemlin May 14, 2024
e0e57ec
Switch to using a node per camera
dylanzemlin May 20, 2024
8b37095
Add shutdown functionality to node.py and node.cpp
dylanzemlin May 20, 2024
ad6b215
The preset system should now work?
dylanzemlin May 20, 2024
8179d63
Try and add left camera
dylanzemlin May 20, 2024
c9f5ea3
Update autonav.rules to add right camera support
dylanzemlin May 20, 2024
2190873
big code
dylanzemlin May 20, 2024
39f4ea0
Update camera.py to use correct camera index for left and right cameras
dylanzemlin May 20, 2024
7c00a64
Add vectornav/imu to launch files
dylanzemlin May 20, 2024
b34988a
Fix vectornav launch name
dylanzemlin May 20, 2024
2fb1e29
Sigkill python processes
dylanzemlin May 20, 2024
53256e8
Change cpp to use sigkill
dylanzemlin May 21, 2024
31a4a34
Make core node end its process
dylanzemlin May 21, 2024
2a2cf5a
noahgram
dylanzemlin May 21, 2024
cc86dc3
refactor: Update epic_noah_transform method to accept additional poin…
dylanzemlin May 21, 2024
fa957a5
add np.array
dylanzemlin May 21, 2024
335c160
refactor: Update epic_noah_transform method to accept additional poin…
dylanzemlin May 21, 2024
63df589
refactor: Update epic_noah_transform method to accept additional poin…
dylanzemlin May 21, 2024
799bbf3
bottom_width = top_width
dylanzemlin May 21, 2024
8ea35ad
"were in" - noah
dylanzemlin May 21, 2024
4015b32
refactor: Combine occupancy grids and publish combined grid as image
dylanzemlin May 21, 2024
0744d19
"its good" - noah
dylanzemlin May 21, 2024
b4e483c
Fix preview image
dylanzemlin May 21, 2024
8b7910b
refactor: Rename try_combine_grids to try_combine_grids_new for clarity
dylanzemlin May 21, 2024
edabf78
refactor: Rename try_combine_grids to try_combine_grids_new for clarity
dylanzemlin May 21, 2024
84d896e
update parallel to stay constant width
dylanzemlin May 21, 2024
3db31bf
Add debug logging helper functions
dylanzemlin May 21, 2024
0afb5f0
Config system now updates with missing keys
dylanzemlin May 21, 2024
acd5af3
Light logging cleanup
dylanzemlin May 21, 2024
1ee2704
Stop simulation launch file from autoparameter
dylanzemlin May 21, 2024
14f5f51
Add ability to turn off autowaypoint calculation
dylanzemlin May 21, 2024
7586874
Fix playback recording different frame rate for each view
dylanzemlin May 21, 2024
9043540
Upscale small images
dylanzemlin May 21, 2024
df6b71c
Fix a silly config issue
dylanzemlin May 21, 2024
4a15d04
Other UI changes
dylanzemlin May 21, 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
782 changes: 354 additions & 428 deletions autonav_ws/src/autonav_display/src/display.py

Large diffs are not rendered by default.

87 changes: 33 additions & 54 deletions autonav_ws/src/autonav_filters/src/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import rclpy
import math


class FilterType(IntEnum):
DEAD_RECKONING = 0,
PARTICLE_FILTER = 1
Expand All @@ -20,25 +21,22 @@ class FilterType(IntEnum):
class FiltersNodeConfig:
def __init__(self):
self.filter_type = FilterType.PARTICLE_FILTER
self.degree_offset = 107.0
self.seed_heading = False


class FiltersNode(Node):
def __init__(self):
super().__init__("autonav_filters")

self.lastIMUReceived = None
self.firstGps = None
self.lastGps = None

self.latitudeLength = self.declare_parameter("latitude_length", 111086.2).get_parameter_value().double_value
self.longitudeLength = self.declare_parameter("longitude_length", 81978.2).get_parameter_value().double_value

self.pf = ParticleFilter(self.latitudeLength, self.longitudeLength)
self.reckoning = DeadReckoningFilter()
self.first_gps = None
self.last_gps = None

self.latitude_length = self.declare_parameter("latitude_length", 111086.2).get_parameter_value().double_value
self.longitude_length = self.declare_parameter("longitude_length", 81978.2).get_parameter_value().double_value

self.pf = ParticleFilter(self.latitude_length, self.longitude_length)
self.dr = DeadReckoningFilter()
self.config = self.get_default_config()

self.onReset()

def config_updated(self, jsonObject):
Expand All @@ -49,80 +47,61 @@ def get_default_config(self):

def init(self):
self.create_subscription(GPSFeedback, "/autonav/gps", self.onGPSReceived, 20)
self.create_subscription(IMUData, "/autonav/imu", self.onIMUReceived, 20);
self.create_subscription(MotorFeedback, "/autonav/MotorFeedback", self.onMotorFeedbackReceived, 20)
self.positionPublisher = self.create_publisher(Position, "/autonav/position", 20)
self.position_publisher = self.create_publisher(Position, "/autonav/position", 20)

self.set_device_state(DeviceStateEnum.OPERATING)

def onIMUReceived(self, msg: IMUData):
self.lastIMUReceived = msg

def getRealHeading(self, heading: float):
if heading < 0:
heading = 360 + -heading

heading += self.config.degree_offset
return heading

def onReset(self):
if self.lastIMUReceived is not None and self.config.seed_heading:
self.reckoning.reset(self.getRealHeading(self.lastIMUReceived.heading))
self.pf.init_particles(self.getRealHeading(self.lastIMUReceived.heading), True)
else:
self.reckoning.reset()
self.pf.init_particles()
self.dr.reset()
self.pf.init_particles()

def system_state_transition(self, old: SystemState, updated: SystemState):
if old.state != SystemStateEnum.AUTONOMOUS and updated.state == SystemStateEnum.AUTONOMOUS:
self.onReset()

if old.mobility == False and updated.mobility == True:
self.onReset()

def onGPSReceived(self, msg: GPSFeedback):
if msg.gps_fix == 0 and msg.is_locked == False:
return

if self.firstGps is None:
self.firstGps = msg

self.lastGps = msg
if self.first_gps is None:
self.first_gps = msg

filterType = self.config.filter_type
if filterType == FilterType.PARTICLE_FILTER:
self.last_gps = msg
if self.config.filter_type == FilterType.PARTICLE_FILTER:
self.pf.gps(msg)
elif filterType == FilterType.DEAD_RECKONING:
self.reckoning.gps(msg)
else:
self.dr.gps(msg)

def onMotorFeedbackReceived(self, msg: MotorFeedback):
filterType = self.config.filter_type
averages = None
if filterType == FilterType.PARTICLE_FILTER:
if self.config.filter_type == FilterType.PARTICLE_FILTER:
averages = self.pf.feedback(msg)
if filterType == FilterType.DEAD_RECKONING:
averages = self.reckoning.feedback(msg)
else:
averages = self.dr.feedback(msg)

if averages is None:
return

position = Position()
position.x = averages[0]
position.y = averages[1]
position.theta = (-1 * math.pi * 2 + averages[2]) * 1


if self.firstGps is not None:
gps_x = self.firstGps.latitude + position.x / self.latitudeLength
gps_y = self.firstGps.longitude - position.y / self.longitudeLength
if self.first_gps is not None:
gps_x = self.first_gps.latitude + position.x / self.latitude_length
gps_y = self.first_gps.longitude - position.y / self.longitude_length
position.latitude = gps_x
position.longitude = gps_y

if self.system_mode == SystemModeEnum.SIMULATION and self.lastGps is not None:
position.latitude = self.lastGps.latitude
position.longitude = self.lastGps.longitude
self.positionPublisher.publish(position)
if self.system_mode == SystemModeEnum.SIMULATION and self.last_gps is not None:
position.latitude = self.last_gps.latitude
position.longitude = self.last_gps.longitude

self.position_publisher.publish(position)


def main():
Expand Down
40 changes: 21 additions & 19 deletions autonav_ws/src/autonav_filters/src/particlefilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
import math
import random


class Particle:
def __init__(self, x = 0, y = 0, theta = 0, weight = 1) -> None:
def __init__(self, x=0, y=0, theta=0, weight=1) -> None:
self.x = x
self.y = y
self.theta = theta
self.weight = weight


class ParticleFilter:
def __init__(self, latitudeLength, longitudeLength) -> None:
self.num_particles = 750
self.gps_noise = [0.45]
self.odom_noise = [0.05, 0.05, 0.1]
self.init_particles()
self.first_gps = None
self.latitudeLength = latitudeLength
self.longitudeLength = longitudeLength

self.latitude_length = latitudeLength
self.longitude_length = longitudeLength

def init_particles(self, seedHeading: float = 0.0, useSeedHeading: bool = False):
if useSeedHeading:
Expand All @@ -33,7 +35,7 @@ def feedback(self, feedback: MotorFeedback) -> list[float]:
sum_theta_x = 0
sum_theta_y = 0
sum_weight = 0

for particle in self.particles:
particle.x += feedback.delta_x * 1.2 * math.cos(particle.theta) + feedback.delta_y * math.sin(particle.theta)
particle.y += feedback.delta_x * 1.2 * math.sin(particle.theta) + feedback.delta_y * math.cos(particle.theta)
Expand All @@ -45,44 +47,44 @@ def feedback(self, feedback: MotorFeedback) -> list[float]:
sum_theta_x += math.cos(particle.theta) * weight
sum_theta_y += math.sin(particle.theta) * weight
sum_weight += weight

if sum_weight < 0.000001:
sum_weight = 0.000001

avg_x = sum_x / sum_weight
avg_y = sum_y / sum_weight
avg_theta = math.atan2(sum_theta_y / sum_weight, sum_theta_x / sum_weight) % (2 * math.pi)

return [avg_x, avg_y, avg_theta]

def gps(self, gps: GPSFeedback) -> list[float]:
if self.first_gps is None:
self.first_gps = gps
gps_x = (gps.latitude - self.first_gps.latitude) * self.latitudeLength
gps_y = (self.first_gps.longitude - gps.longitude) * self.longitudeLength

gps_x = (gps.latitude - self.first_gps.latitude) * self.latitude_length
gps_y = (self.first_gps.longitude - gps.longitude) * self.longitude_length

for particle in self.particles:
dist_sqrt = np.sqrt((particle.x - gps_x) ** 2 + (particle.y - gps_y) ** 2)
particle.weight = math.exp(-dist_sqrt / (2 * self.gps_noise[0] ** 2))

self.resample()
return [gps_x, gps_y]

def resample(self) -> None:
weights = [particle.weight for particle in self.particles]
weights_sum = sum(weights)
if weights_sum <= 0.00001:
weights_sum = 0.00001
weights = [weight / weights_sum for weight in weights]
new_particles = random.choices(self.particles, weights, k = self.num_particles)

new_particles = random.choices(self.particles, weights, k=self.num_particles)
self.particles = []

for particle in new_particles:
rand_x = np.random.normal(0, self.odom_noise[0])
rand_y = np.random.normal(0, self.odom_noise[1])
x = particle.x + rand_x * math.cos(particle.theta) + rand_y * math.sin(particle.theta)
y = particle.y + rand_x * math.sin(particle.theta) + rand_y * math.cos(particle.theta)
theta = np.random.normal(particle.theta, self.odom_noise[2]) % (2 * math.pi)
self.particles.append(Particle(x, y, theta, particle.weight))
self.particles.append(Particle(x, y, theta, particle.weight))
13 changes: 7 additions & 6 deletions autonav_ws/src/autonav_launch/launch/competition.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
<launch>
<!-- Core -->
<node pkg="scr_controller" exec="core">
<param name="mode" value="1" />
<param name="state" value="1" />
<param name="mobility" value="false" />
</node>
<node pkg="scr_controller" exec="core" />
<node pkg="scr_controller" exec="logging" />

<!-- Filtering -->
<node pkg="autonav_filters" exec="filters.py">
<param name="latitude_length" value="111086.2" />
<param name="longitude_length" value="81978.2" />
<param name="default_type" value="1" />
</node>

<!-- Vision Nodes -->
<node pkg="autonav_vision" exec="transformations.py" />
<node pkg="autonav_vision" exec="combination.py" />
<node pkg="autonav_vision" exec="expandify" />

<!-- Manual Nodes -->
<node pkg="autonav_manual" exec="steam.py" />
Expand All @@ -25,7 +21,12 @@
<!-- Serial Nodes -->
<node pkg="autonav_serial" exec="serial_node.py" />
<node pkg="autonav_serial" exec="camera.py" />
<node pkg="autonav_serial" exec="vectornav_node" />

<!-- Other -->
<node pkg="autonav_display" exec="display.py" />

<!-- Robot -->
<node pkg="autonav_nav" exec="path_resolver.py" />
<node pkg="autonav_nav" exec="astar.py" />
</launch>
13 changes: 5 additions & 8 deletions autonav_ws/src/autonav_launch/launch/managed_steam.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<launch>
<!-- Core -->
<node pkg="scr_controller" exec="core">
<param name="mode" value="0" />
<param name="state" value="0" />
<param name="mobility" value="false" />
</node>
<node pkg="scr_controller" exec="core" />
<node pkg="scr_controller" exec="logging" />

<!-- Filtering -->
<node pkg="autonav_filters" exec="filters.py">
<param name="latitude_length" value="111086.2" />
<param name="longitude_length" value="81978.2" />
<param name="default_type" value="1" />
<param name="latitude_length" value="110944.12" />
<param name="longitude_length" value="91071.17" />
</node>

<!-- Vision Nodes -->
Expand All @@ -25,6 +20,8 @@
<!-- Serial Nodes -->
<node pkg="autonav_serial" exec="serial_node.py" />
<node pkg="autonav_serial" exec="camera.py" />
<node pkg="autonav_serial" exec="vectornav_node" />
<node pkg="autonav_serial" exec="vectornav_node" />

<!-- Other -->
<node pkg="autonav_display" exec="display.py" />
Expand Down
8 changes: 2 additions & 6 deletions autonav_ws/src/autonav_launch/launch/practice.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
<launch>
<!-- Core -->
<node pkg="scr_controller" exec="core">
<param name="mode" value="0" />
<param name="state" value="0" />
<param name="mobility" value="false" />
</node>
<node pkg="scr_controller" exec="core" />
<node pkg="scr_controller" exec="logging" />

<!-- Filtering -->
<node pkg="autonav_filters" exec="filters.py">
<param name="latitude_length" value="111086.2" />
<param name="longitude_length" value="81978.2" />
<param name="default_type" value="1" />
</node>

<!-- Vision Nodes -->
Expand All @@ -25,6 +20,7 @@
<!-- Serial Nodes -->
<node pkg="autonav_serial" exec="serial_node.py" />
<node pkg="autonav_serial" exec="camera.py" />
<node pkg="autonav_serial" exec="vectornav_node" />

<!-- Other -->
<node pkg="autonav_display" exec="display.py" />
Expand Down
15 changes: 10 additions & 5 deletions autonav_ws/src/autonav_launch/launch/simulation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@
<include file="$(find-pkg-share rosbridge_server)/launch/rosbridge_websocket_launch.xml" />
<node pkg="scr_controller" exec="core">
<param name="mode" value="1" />
<param name="state" value="1" />
<param name="mobility" value="true" />
<param name="state" value="0" />
<param name="mobility" value="false" />
</node>
<node pkg="scr_controller" exec="logging" />

<!-- Filtering -->
<node pkg="autonav_filters" exec="filters.py">
<param name="latitude_length" value="111086.2" />
<param name="longitude_length" value="81978.2" />
<param name="default_type" value="1" />
<param name="latitude_length" value="110944.12" />
<param name="longitude_length" value="91071.17" />
</node>

<!-- Vision Nodes -->
<node pkg="autonav_vision" exec="transformations.py" />
<node pkg="autonav_vision" exec="combination.py" />
<node pkg="autonav_vision" exec="expandify" />

<!-- Pathing -->
<node pkg="autonav_nav" exec="path_resolver.py" />
<node pkg="autonav_nav" exec="astar.py" />

<!-- Other -->
<node pkg="autonav_display" exec="display.py" />
<node pkg="autonav_playback" exec="playback.py" />
</launch>
1 change: 1 addition & 0 deletions autonav_ws/src/autonav_manual/src/steam.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def onButtonReleased(self, button: SteamControllerButton, msTime: float):
self.safetyLightsPublisher.publish(toSafetyLights(False, False, 2, 100, "#FF6F00"))

if button == SteamControllerButton.STEAM and self.system_state != SystemStateEnum.AUTONOMOUS:
self.safetyLightsPublisher.publish(toSafetyLights(True, False, 2, 100, "#FF0000"))
self.set_system_state(SystemStateEnum.AUTONOMOUS)

if button == SteamControllerButton.BACK and self.system_state != SystemStateEnum.DISABLED:
Expand Down
1 change: 0 additions & 1 deletion autonav_ws/src/autonav_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ set(msg_files
"msg/Position.msg"
"msg/GoalPoint.msg"
"msg/Waypoint.msg"
"msg/ObjectDetection.msg"
"msg/Path.msg"
"msg/Obstacle.msg"
"msg/Obstacles.msg"
Expand Down
3 changes: 0 additions & 3 deletions autonav_ws/src/autonav_msgs/msg/ObjectDetection.msg

This file was deleted.

Loading
Loading