-
Notifications
You must be signed in to change notification settings - Fork 12
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
Changes from 29 commits
2a92540
f923570
522cbce
6044db5
5a4f571
a46b314
41ef366
a384f61
5fc0964
c98516e
38035db
39eca4f
2d13f4e
6cb0a00
24e82f3
6dafaca
721ffa4
6f5a165
a6bc7f6
c32665f
e352937
95f4f73
ffad279
6601d10
dc084f4
81c5909
9fce97a
64397ab
100597d
a9ac869
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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"], | ||
["platform.emergency_stop", "app.emergency_stop"], | ||
["platform.pose2d", "app.pose2d"], | ||
["gps_serial.raw", "gps.raw"] | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the float necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 = [] | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)