-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support from Hokuyo lidar #1186
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -106,13 +106,18 @@ def drive(cfg, model_path=None, use_joystick=False, model_type=None, | |
|
||
# add lidar | ||
if cfg.USE_LIDAR: | ||
from donkeycar.parts.lidar import RPLidar | ||
if cfg.LIDAR_TYPE == 'RP': | ||
from donkeycar.parts.lidar import RPLidar | ||
print("adding RP lidar part") | ||
lidar = RPLidar(lower_limit = cfg.LIDAR_LOWER_LIMIT, upper_limit = cfg.LIDAR_UPPER_LIMIT) | ||
V.add(lidar, inputs=[],outputs=['lidar/dist_array'], threaded=True) | ||
if cfg.LIDAR_TYPE == 'YD': | ||
print("YD Lidar not yet supported") | ||
if cfg.LIDAR_TYPE == "HOKUYO": | ||
from donkeycar.parts.lidar import HokuyoLidar | ||
print("adding Hokuyo lidar part") | ||
lidar = HokuyoLidar(max_dist = cfg.LIDAR_MAX_DIST) | ||
V.add(lidar, inputs=[], outputs=['lidar/dist_scan'], threaded=False) | ||
|
||
if cfg.HAVE_TFMINI: | ||
from donkeycar.parts.tfmini import TFMini | ||
|
@@ -820,6 +825,9 @@ def get_camera(cfg): | |
elif cfg.CAMERA_TYPE == "MOCK": | ||
from donkeycar.parts.camera import MockCamera | ||
cam = MockCamera(image_w=cfg.IMAGE_W, image_h=cfg.IMAGE_H, image_d=cfg.IMAGE_DEPTH) | ||
elif cfg.CAMERA_TYPE == "LIDAR_PLOT": | ||
from donkeycar.parts.lidar import LidarPlot2 | ||
cam = LidarPlot2(resolution=(cfg.IMAGE_H, cfg.IMAGE_W)) | ||
else: | ||
raise(Exception("Unkown camera type: %s" % cfg.CAMERA_TYPE)) | ||
return cam | ||
|
@@ -872,7 +880,22 @@ def add_camera(V, cfg, camera_type): | |
outputs=['cam/image_array', 'cam/depth_array', | ||
'imu/acl_x', 'imu/acl_y', 'imu/acl_z', | ||
'imu/gyr_x', 'imu/gyr_y', 'imu/gyr_z'], | ||
threaded=False) | ||
|
||
|
||
elif cfg.CAMERA_TYPE == "LIDAR_PLOT": | ||
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 very interesting. So the idea here is that the lidar plot would be used as the input to the CNN? Separate from the code concerns, have you tried this? Does it produce a reasonable autopilot? 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 was thinking more along the lines of being able to see what the lidar sees. I haven't tried to train an autopilot with it although that does sound like an interesting idea. |
||
from donkeycar.parts.lidar import LidarPlot2 | ||
cam = LidarPlot2( | ||
resolution=(cfg.IMAGE_W, cfg.IMAGE_H), | ||
rotate_plot=cfg.LIDAR_ANGLE_OFFSET, | ||
max_dist=cfg.LIDAR_MAX_DIST, | ||
plot_type=LidarPlot2.PLOT_TYPE_CIRCLE, | ||
mark_px=1 | ||
) | ||
V.add(cam, inputs=['lidar/dist_scan'], | ||
outputs=['cam/image_array'], | ||
threaded=True) | ||
|
||
else: | ||
inputs = [] | ||
outputs = ['cam/image_array'] | ||
|
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.
These values need to have defaults based on the chose lidar type. RP/YD would be 0 for angle and I'm not sure for distance.
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.
Do you mean these should be set to zero for the user to put in themselves? I wanted to give this example to show that the back half of scans should likely be discarded in most set-ups. As for the max distance, I think this is reasonable for the entry level RP Lidar/ YD Lidar. If someone buys a fancier model then I would assume they would also know how to change this value to reflect the capabilities of their lidar.