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

Get Pat/FR-07 moving with OAK cone detection #985

Merged
merged 30 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2a92540
config/fr07-go.json - add OAK-D Pro
m3d Jan 27, 2024
f923570
Merge remote-tracking branch 'origin/master' into feature/pat-wanjee-oak
m3d Feb 2, 2024
522cbce
config/fr07-go.json - add GPS
m3d Feb 4, 2024
6044db5
OAK USB - try IR flood laser
m3d Feb 10, 2024
5a4f571
Merge remote-tracking branch 'origin/master' into feature/pat-wanjee-oak
m3d Mar 2, 2024
a46b314
add config/fr07-followpath.json
m3d Mar 2, 2024
41ef366
osgar/logger.py - support gzipped logfiles
m3d Mar 2, 2024
a384f61
OAK - add NN and cone detection config
m3d Mar 8, 2024
5fc0964
osgar/drivers/pcan.py - change log level from debug to info
m3d Mar 10, 2024
c98516e
Merge remote-tracking branch 'origin/master' into feature/pat-wanjee-oak
m3d Mar 11, 2024
38035db
osgar/drivers/vanjee.py - add code snipped for reading lidar IP/port
m3d Mar 15, 2024
39eca4f
osgar/drivers/vanjee.py - hacked set_ip
m3d Mar 15, 2024
2d13f4e
osgar/drivers/vanjee.py - cleanup set/get
m3d Mar 15, 2024
6cb0a00
add osgar/obstdet3d.py
m3d Mar 15, 2024
24e82f3
osgar/obstdet3d.py - add assert for expected depth data resolution
m3d Mar 15, 2024
6dafaca
osgar/obstdet3d.py - handle distance to obstacles in meters
m3d Mar 15, 2024
721ffa4
osgar/drivers/oak_camera.py - add unified detections
m3d Mar 15, 2024
6f5a165
osgar/drivers/oak_camera.py - add seq_num and timestamp_us for synchr…
m3d Mar 16, 2024
a6bc7f6
osgar/drivers/oak_camera.py - cleanup (removed xoutRgb), added debug …
m3d Mar 18, 2024
c32665f
osgar/tools/lidarview.py - hacking yolo bboxes
m3d Mar 18, 2024
e352937
osgar/obstdet3d.py - handle 0 depth array (TODO test :(
m3d Mar 21, 2024
95f4f73
osgar/drivers/vanjee.py - fix ID overflow
m3d Mar 22, 2024
ffad279
osgar/tools/lidarview.py - changed to support only new detections
m3d Mar 22, 2024
6601d10
osgar/platforms/yuhesen.py - SW limit for max speed and steering angle
m3d Apr 9, 2024
dc084f4
Merge remote-tracking branch 'origin/master' into feature/pat-wanjee-oak
m3d Apr 9, 2024
81c5909
Merge remote-tracking branch 'origin/master' into feature/pat-wanjee-oak
m3d Apr 14, 2024
9fce97a
Merge remote-tracking branch 'origin/master' into feature/pat-wanjee-oak
m3d Apr 17, 2024
64397ab
Merge branch 'master' into feature/pat-wanjee-oak
m3d Apr 23, 2024
100597d
Merge branch 'master' into feature/pat-wanjee-oak
m3d Apr 29, 2024
a9ac869
Revert "osgar/logger.py - support gzipped logfiles"
m3d Apr 29, 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
70 changes: 70 additions & 0 deletions config/fr07-followpath.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"version": 2,
"robot": {
"modules": {
"app": {
"driver": "osgar.followpath:FollowPath",
"in": ["emergency_stop", "pose2d", "path"],
"out": ["desired_speed"],
"init": {
"max_speed": 0.1,
"path": [[0, 0], [1, 0], [1, 1]],
"timeout": 10
}
},
"platform": {
"driver": "osgar.platforms.yuhesen:FR07",
"in": ["can"],
"out": ["can"],
"init": {}
},
"can": {
"driver": "pcan",
"in": ["can"],
"out": ["can"],
"init": {}
},
"oak": {
"driver": "osgar.drivers.oak_camera:OakCamera",
"init": {
"fps": 10,
"is_color": true,
"is_depth": true,
"laser_projector_current": 1200,
"is_imu_enabled": true,
"number_imu_records": 10,
"disable_magnetometer_fusion": false,
"cam_ip": "169.254.1.222",
"mono_resolution": "THE_400_P",
"color_resolution": "THE_1080_P",
"color_manual_focus": 130,
"stereo_median_filter": "KERNEL_3x3",
"stereo_mode": "HIGH_ACCURACY",
"stereo_extended_disparity": false,
"stereo_subpixel": false,
"stereo_left_right_check": true
}
},
"gps": {
"driver": "gps",
"in": ["raw"],
"out": ["position"],
"init": {}
},
"gps_serial": {
"driver": "serial",
"in": [],
"out": ["raw"],
"init": {"port": "/dev/ttyUSB0", "speed": 4800}
}
},
"links": [
["can.can", "platform.can"],
["platform.can", "can.can"],
["app.desired_speed", "platform.desired_steering"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont like mixing of the desired_speed and desired_steering. Yes, it is not part of this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, you are right - maybe we should add some module which will do transition from one to another?? (if possible)

["platform.emergency_stop", "app.emergency_stop"],
["platform.pose2d", "app.pose2d"],
["gps_serial.raw", "gps.raw"]
]
}
}
36 changes: 35 additions & 1 deletion config/fr07-go.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,48 @@
"in": ["can"],
"out": ["can"],
"init": {}
},
"oak": {
"driver": "osgar.drivers.oak_camera:OakCamera",
"init": {
"fps": 10,
"is_color": true,
"is_depth": true,
"laser_projector_current": 1200,
"is_imu_enabled": true,
"number_imu_records": 10,
"disable_magnetometer_fusion": false,
"cam_ip": "169.254.1.222",
"mono_resolution": "THE_400_P",
"color_resolution": "THE_1080_P",
"color_manual_focus": 130,
"stereo_median_filter": "KERNEL_3x3",
"stereo_mode": "HIGH_ACCURACY",
"stereo_extended_disparity": false,
"stereo_subpixel": false,
"stereo_left_right_check": true
}
},
"gps": {
"driver": "gps",
"in": ["raw"],
"out": ["position"],
"init": {}
},
"gps_serial": {
"driver": "serial",
"in": [],
"out": ["raw"],
"init": {"port": "/dev/ttyUSB0", "speed": 4800}
}
},
"links": [
["can.can", "platform.can"],
["platform.can", "can.can"],
["app.desired_speed", "platform.desired_steering"],
["platform.emergency_stop", "app.emergency_stop"],
["platform.pose2d", "app.pose2d"]
["platform.pose2d", "app.pose2d"],
["gps_serial.raw", "gps.raw"]
]
}
}
6 changes: 5 additions & 1 deletion osgar/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from ast import literal_eval
import mmap
import pathlib
import gzip

g_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -160,7 +161,10 @@ class LogReader:
def __init__(self, filename, follow=False, only_stream_id=None):
self.filename = filename
self.follow = follow
self.f = open(self.filename, 'rb')
if str(self.filename).endswith('gz'): # support both string and pathlib.Path
self.f = gzip.open(self.filename)
else:
self.f = open(self.filename, 'rb')
data = self._read(4)
assert data == MAGIC, data

Expand Down
25 changes: 25 additions & 0 deletions osgar/obstdet3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Copy link
Collaborator

@tajgr tajgr Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the future plan of this code? It seems like a one off.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, that it is dependent on OAK-D default config of depth camera. This is like "ver0", which detects obstacle in front of the robot and typically next step is STOP, or slow down. I plan to use it on "robotem rovne" as fallback.

Obstacle Detection 3D
"""
import numpy as np

from osgar.node import Node


class ObstacleDetector3D(Node):
def __init__(self, config, bus):
super().__init__(config, bus)
bus.register('obstacle')

def on_depth(self, data):
assert data.shape == (400, 640), data.shape
selection = data[150:250, 300:340]
mask = selection > 0 # not valid data?
if mask.max() == True:
dist = selection[mask].min() / 1000
else:
dist = 0.0
self.publish('obstacle', float(dist))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the float necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

float is needed in order not to propagate numpy structure. Or if you mean why not to use millimeters and int ... then yes, I would like fractional numbers more :)

# print(self.time, dist)

# vim: expandtab sw=4 ts=4
25 changes: 19 additions & 6 deletions osgar/tools/lidarview.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,25 @@ def draw(foreground, pose, scan, poses=[], image=None, bbox=None, callback=None,

foreground.blit(cameraView, (0, 0))

for b in bbox:
assert len(b) > 5, b
name, x, y, width, height = b[:5]
color = (0, 255, 0)
rect = pygame.Rect(x, y, width, height)
pygame.draw.rect(image, color, rect, 2)
def frameNorm(w, h, bbox):
normVals = np.full(len(bbox), w)
normVals[::2] = h
return (np.clip(np.array(bbox), 0, 1) * normVals).astype(int)

for frame_detections in bbox:
for detection in frame_detections:
if len(detection) == 0:
continue # empty bbox is allowed now
# old format (b=detection)
#assert len(b) > 5, b
#name, x, y, width, height = b[:5]
# new (temporary?) format
w, h = image.get_size()
a, b, c, d = frameNorm(h, h, detection[2]).tolist()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand these lines. What are "a, b, c, d"? Is it universal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ugly copy & paste from OAK demo code (abcd is mine) ... this code/format I still do not like, but hopefully somebody else will also need to display bounding boxes in lidarview and we will unify it

name, x, y, width, height = detection[0], a + (w - h) / 2, b, c - a, d - b
color = (0, 255, 0)
rect = pygame.Rect(x, y, width, height)
pygame.draw.rect(image, color, rect, 4)

if callback is not None:
debug_poly = []
Expand Down
Loading