-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
try to fix low framerate #103 add ros parameters loading more parameters from parameter server #103 use argparse to get arguments from command line untested correction to args ignore unknown args set proper default device and look for more bad return values trying to find why framerate is limited to about 8 fps framerate ok for low-exposure settings print list of valid formats #105
- Loading branch information
Showing
9 changed files
with
247 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
usb_cam: | ||
ros__parameters: | ||
video_device: "/dev/video0" | ||
framerate: 15 | ||
io_method: "mmap" | ||
frame_id: "camera" | ||
pixel_format: "yuyv" | ||
image_width: 640 | ||
image_height: 480 | ||
camera_name: "test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Copyright 2018 Lucas Walter | ||
|
||
import argparse | ||
import launch | ||
import launch_ros.actions | ||
import os | ||
import sys | ||
import time | ||
import yaml | ||
|
||
from ament_index_python.packages import get_package_share_directory | ||
|
||
|
||
def generate_launch_description(): | ||
parser = argparse.ArgumentParser(description='usb_cam demo') | ||
parser.add_argument('-d', '--device', dest='device', type=str, | ||
help='video device', default='/dev/video0') | ||
parser.add_argument('-wd', '--width', dest='width', type=int, | ||
help='image width', default=640) | ||
parser.add_argument('-ht', '--height', dest='height', type=int, | ||
help='image height', default=480) | ||
parser.add_argument('-f', '--fps', dest='frame_rate', type=float, | ||
help='frame rate', default=5) | ||
args, unknown = parser.parse_known_args(sys.argv[4:]) | ||
|
||
usb_cam_dir = get_package_share_directory('usb_cam') | ||
print('usb_cam dir ' + usb_cam_dir) | ||
launches = [] | ||
|
||
prefix = "/tmp/ros2/" + str(int(time.time())) + "/" | ||
if not os.path.exists(prefix): | ||
os.makedirs(prefix) | ||
|
||
# TODO(lucasw) get from commandline | ||
# TODO(lucasw) if these are an invalid combination usb_cam just dies- | ||
# need a more helpfull error message. | ||
device = args.device | ||
framerate = int(args.frame_rate) | ||
width = args.width | ||
height = args.height | ||
|
||
# usb camera | ||
params = prefix + "demo_usb_cam.yaml" | ||
ns = 'demo' | ||
node_name = 'usb_cam' | ||
with open(params, 'w') as outfile: | ||
print("opened " + params + " for yaml writing") | ||
data = {} | ||
data[ns] = {} | ||
data[ns][node_name] = {} | ||
data[ns][node_name]['ros__parameters'] = dict( | ||
video_device = device, | ||
framerate = framerate, | ||
io_method = "mmap", | ||
frame_id = "camera", | ||
pixel_format = "yuyv", | ||
image_width = width, | ||
image_height = height, | ||
camera_name = "camera", | ||
) | ||
yaml.dump(data, outfile, default_flow_style=False) | ||
|
||
launches.append(launch_ros.actions.Node( | ||
package='usb_cam', node_executable='usb_cam_node', output='screen', | ||
node_name=node_name, | ||
node_namespace=ns, | ||
arguments=["__params:=" + params], | ||
# arguments=["__params:=" + usb_cam_dir + "/config/params.yaml"] | ||
)) | ||
launches.append(launch_ros.actions.Node( | ||
package='usb_cam', node_executable='show_image.py', output='screen', | ||
node_namespace=ns, | ||
# arguments=[image_manip_dir + "/data/mosaic.jpg"]) | ||
# remappings=[('image_in', 'image_raw')] | ||
)) | ||
|
||
return launch.LaunchDescription(launches) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# uint32 type | ||
string pixel_format | ||
uint32 width | ||
uint32 height | ||
float32 fps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.