Monash-Connected-Autonomous-Vehicle / ENV200-Shadow-Repo

0 stars 0 forks source link

Mono Camera Pylon #5

Open hubdwoo opened 1 year ago

hubdwoo commented 1 year ago
dylan-gonzalez commented 1 year ago

26-09-23 Kendrick & Vedesh

Driver for pylon cameras install on PC using this link: https://github.com/basler/pylon-ros-camera/tree/humble

When trying to build, there is a header file missing and pretty sure it is from the pylon camera software suite. When using the link to install the software suite, the website times out.

Image

klo40 commented 1 year ago

13-10-2023 Kendrick

-Since the drive was wiped, redownloaded ROS2 and all dependencies, downloaded rosdep, GIT and xterm. -When doing sudo apt update and upgrade, some missing NVIDIA modules from noveau, not relevant for this driver but maybe something to note -The pylon camera software suite website worked (not sure why but yay), so downloaded both 7.4.0 and 6.3.0 software suites x86 for Linux to try and address the issue mentioned in the following link: https://github.com/basler/pylon-ros-camera/issues/160 The software suites are saved in Home/Desktop/ENV200_ws/src -Still not able to fix the pylonIncludes.h not existing problem, but with the software suites seems like it may be fixable.

dylan-gonzalez commented 1 year ago

So in terms of the pylonIncludes.h missing file error, just checking - we haven't yet tested the new software suites you downloaded, yes? @klo40

klo40 commented 1 year ago

So in terms of the pylonIncludes.h missing file error, just checking - we haven't yet tested the new software suites you downloaded, yes? @klo40

Kind of? Tried to colcon build the whole thing with the suites in the src folder but doesn't work

Also tried to open the suites because I thought they may work like applications but that hasn't really worked.

dylan-gonzalez commented 1 year ago

Kind of? Tried to colcon build the whole thing with the suites in the src folder but doesn't work

Can you post a screenshot of the build error?

klo40 commented 1 year ago

Kind of? Tried to colcon build the whole thing with the suites in the src folder but doesn't work

Can you post a screenshot of the build error?

I'll probs head into the workshop on Monday and get a screenshot then

dylan-gonzalez commented 1 year ago

Following the README from this repo

Installing prequisites

(I also removed a sources.list file for a ros1 jammy package repository - throws an error when trying to perform apt update)

Following Install and Build step

No issues, not even with diagnostic_updater and pcl_ros as they described.

colcon build gave warnings for the pylon_ros2 libraries but these don't seem to matter.

Running the drivers

Running the drivers gives no errors, except that it can't actually find the cameras.

Image

But running lsusb shows that Basler cameras are properly connected...

Image

Opening pylon viewer also shows no available USB devices...

Image

Update Managed to fix the issue! Literally just re-connecting the usb cables fixed the issue.

Running the ros2 driver gives no errors... there is a way to get the display output but will take a look later.

Image

We can view all 6 cameras in pylon viewer! (i'm not showing all 6 feeds because it starts to lag quite a bit if you show more than 2)

Image

hubdwoo commented 1 year ago

Should we send a ticket to SD about slow feeds when viewing more than 2 cameras?

dylan-gonzalez commented 1 year ago

Possibly, I think it might just have something to do with Pylon Viewer though...

We'll know for sure once we test it out in RVIZ if we can view all 6 feeds at once - hopefully this can be done soon.

dylan-gonzalez commented 1 year ago

Log from vedesh

Just able to see this in rviz. Other feeds do not show

Image

Image

dylan-gonzalez commented 1 year ago

Trying to run ros2 launch pylon_ros2_camera_wrapper pylon_ros2_camera.launch.py gives the following:

Image

in the config/default.yaml, there is a camera_info_url parameter to be set, seems to be a calibration file specific to the camera to be used. These links are relevant:

Will just try for now copying a random calibration file from here, and see if the ros node will actually start publishing topics if a CameraInfoURL is set.

(Also, in the README here it says that ros2 has an inbuilt _cameracalibration package that will actually generate the required YAML file to use (which is in the same format as that random calibration file I have just copied). So later I will try to run this package to generate the proper yaml file. )

colcon build generates warnings in relation to the _cameracalibration package.

Update: I don't think the calibration file is necessary for there to be publishers. When opening RVIZ2 it shows the topics, but when I do ros2 topic list nothing shows. Same issue as @vedesh1408 in terms of only being able to see 1 feed, I think the script just starts publishing whatever camera device it sees first and stops there.

Image

Running the node twice does not work, even when specifying a different device id.

Image

Update: think I know how to fix it. You have to assign unique device ids for each camera, by disconnecting and reconnecting them, then running this command.

Image

This hasn't worked though because the device id can't have hyphens as ros namespaces aren't allowed hyphens. So will try again but assign different device ids next time.

hubdwoo commented 1 year ago

Possible Fix

Image

There is an option in the BIOS to enable HS Mode for the USB Controllers. According to the description it said that it can increase the speed of the data transfer. This might fixes the mono pylon cameras lagging after loading 2 or more cameras.

Another option that we can try is that in pylon view, according to SD there is an option for lowering down the frame rates for the cameras. This might take a few load off from transferring the data.

AbBaSaMo commented 11 months ago

We're experiencing this issue while string to set device IDs. So tl:dr, it seems the cables are worn (cause it occurs on both usb hubs and the first assignment worked and so the hubs aren't the issue), and then as a result something uses usb2.0 which is incompatible with the device.

Solution might be new cables if this is the issue and avoiding too much unplugging and plugging back in such that the cables will wear out.

https://forums.developer.nvidia.com/t/basler-usb-camera-not-working/75955/12

edit: ok so after a while we tried again and now it works

aallendarmawan commented 11 months ago

I haven't gotten RVIZ to work yet. It currently only shows 1 camera, and I couldn't find out how to show the other cameras; this may be because there is another launch file besides the one that we used called pylon_ros2_camera_multiple.launch.py, which I presume can handle multiple cameras as opposed to pylon_ros2_camera.launch.py. I tried running pylon_ros2_camera_multiple.launch.py but there is an issue with namespace due to hyphens.

As for Pylon Viewer, all cameras can be shown except one. When I try to open the one camera, it comes up with Error 'Device is exclusively opened by another client.' image Additionally, although I can see most cameras, when I view more than 1 camera side-by-side, it starts to lag a little and even crash. I have seen @hubdwoo's suggestion about lowering frame rates for the cameras but I couldn't find the option for doing so. I will look further into this tomorrow as I have to go now.

dylan-gonzalez commented 11 months ago

So you were able to assign unique device IDs to each camera (also did you put hyphens in the device id, because that might be throwing the error)

As for that one camera - did you already have it open in RVIZ. Because a camera can't be opened by two applications at the one time

aallendarmawan commented 11 months ago

I was able to assign unique device IDs to each camera (just named them 1 through 6). I did not put any hyphens. The strange thing is, on Pylon viewer, even though 5 cameras work, most of their IDs are the default IDs (acA1920...) and not the IDs I had assigned them.

I think for that one camera, I had closed RVIZ before opening Pylon Viewer, though it's possible I may not have closed it properly.

aallendarmawan commented 11 months ago

Okay I logged in and ran Pylon Viewer without rviz running beforehand, all cameras do indeed work now so I think I just forgot to close rviz or i had two windows of pylon viewer open accidentally

aallendarmawan commented 11 months ago

Camera IDs cannot start with a number

aallendarmawan commented 11 months ago

Basler Camera serial numbers as appears from running lsusb from top to bottom: Device 029: 24603815 Device 028: 24603805 Device 027: 24603818 Device 024: 24603803 Device 026: 24611509 Device 025: 24603801

AbBaSaMo commented 11 months ago

With regards to the serial numbers in https://github.com/Monash-Connected-Autonomous-Vehicle/ENV200-Shadow-Repo/issues/5#issuecomment-1853391373

We should be able to run rosrun pylon_camera set_device_user_id [-sn SERIAL_NB] your_device_user_id to set them and possibly avoid having to plug and unplug one by one. If so, maybe this can be automated??

So for example in a bash file

ros2 run pylon_ros2_camera_component set_device_user_id -sn 24603815 CAM1 && \
ros2 run pylon_ros2_camera_component set_device_user_id -sn 24603805 CAM2 && \
ros2 run pylon_ros2_camera_component set_device_user_id -sn 24603818 CAM3 && \
ros2 run pylon_ros2_camera_component set_device_user_id -sn 24603803 CAM4 && \
ros2 run pylon_ros2_camera_component set_device_user_id -sn 24611509 CAM5 && \
ros2 run pylon_ros2_camera_component set_device_user_id -sn 24603801 CAM6;

The repo does state that they need to be unplugged and plugged in when changing so it's not clear if we can plug them all in at once when starting up, and then run the above command or continue to do it one by one.

edit: so this works and then it just says 'don't forget to unplug and plug if USB'. So we could run this one command and then maybe if they are all in one hub, just unplug and plug the hub. Is there a way to programatically turn off the usb hub to achieve this? would it work?

dylan-gonzalez commented 11 months ago

@Monash-Connected-Autonomous-Vehicle/avp-team

Anyone good with python launch files? We have the following launch file that runs multiple instances of pylon_ros2_camera_node but each node needs its own config file, namespace (which is the easy part as it's a string), and probably node name?

At the top of the file these seem to be defined but only one config file and node name is defined and we want one per cameras 1-6. How do we implement this?

#!/usr/bin/env python3

import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

def generate_launch_description():

    # adapt if needed
    debug = False
    respawn = False

    default_config_file = os.path.join(
        get_package_share_directory('pylon_ros2_camera_wrapper'),
        'config',
        'default.yaml'
    )

    # launch configuration variables
    node_name = LaunchConfiguration('node_name')
    camera_id = LaunchConfiguration('camera_id')

    config_file = LaunchConfiguration('config_file')

    mtu_size = LaunchConfiguration('mtu_size')
    startup_user_set = LaunchConfiguration('startup_user_set')
    enable_status_publisher = LaunchConfiguration('enable_status_publisher')
    enable_current_params_publisher = LaunchConfiguration('enable_current_params_publisher')

    # launch arguments
    declare_node_name_cmd = DeclareLaunchArgument(
        'node_name',
        default_value='pylon_ros2_camera_node',
        description='Name of the wrapper node.'
    )

    declare_camera_id_cmd = DeclareLaunchArgument(
        'camera_id',
        default_value='my_camera',
        description='Id of the camera. Used as node namespace.'
    )

    declare_config_file_cmd = DeclareLaunchArgument(
        'config_file',
        default_value=default_config_file,
        description='Camera parameters structured in a .yaml file.'
    )

    declare_mtu_size_cmd = DeclareLaunchArgument(
        'mtu_size',
        default_value='1500',
        description='Maximum transfer unit size. To enable jumbo frames, set it to a high value (8192 recommended)'
    )

    declare_startup_user_set_cmd = DeclareLaunchArgument(
        'startup_user_set',
        # possible value: Default, UserSet1, UserSet2, UserSet3, CurrentSetting
        default_value='CurrentSetting',
        description='Specific user set defining user parameters to run the camera.'
    )

    declare_enable_status_publisher_cmd = DeclareLaunchArgument(
        'enable_status_publisher',
        default_value='true',
        description='Enable/Disable the status publishing.'
    )

    declare_enable_current_params_publisher_cmd = DeclareLaunchArgument(
        'enable_current_params_publisher',
        default_value='true',
        description='Enable/Disable the current parameter publishing.'
    )

    # log format
    os.environ['RCUTILS_CONSOLE_OUTPUT_FORMAT'] = '{time} [{name}] [{severity}] {message}'

    # see https://navigation.ros.org/tutorials/docs/get_backtrace.html
    if (debug == True):
        launch_prefix = ['xterm -e gdb -ex run --args']
    else:
        launch_prefix = ''

    # node
    pylon_ros2_camera_node = Node(
        package='pylon_ros2_camera_wrapper',        
        namespace="CAM1",
        executable='pylon_ros2_camera_wrapper',
        name=node_name,
        output='screen',
        respawn=respawn,
        emulate_tty=True,
        prefix=launch_prefix,
        parameters=[
            config_file,
            {
                'gige/mtu_size': mtu_size,
                'startup_user_set': startup_user_set,
                'enable_status_publisher': enable_status_publisher,
                'enable_current_params_publisher': enable_current_params_publisher
            }
        ]
    )

    pylon_ros2_camera_node = Node(
        package='pylon_ros2_camera_wrapper',        
        namespace="CAM2",
        executable='pylon_ros2_camera_wrapper',
        name=node_name,
        output='screen',
        respawn=respawn,
        emulate_tty=True,
        prefix=launch_prefix,
        parameters=[
            config_file,
            {
                'gige/mtu_size': mtu_size,
                'startup_user_set': startup_user_set,
                'enable_status_publisher': enable_status_publisher,
                'enable_current_params_publisher': enable_current_params_publisher
            }
        ]
    )

    '''
    pylon_ros2_camera_node = Node(
        package='pylon_ros2_camera_wrapper',        
        namespace=camera_id,
        executable='pylon_ros2_camera_wrapper',
        name=node_name,
        output='screen',
        respawn=respawn,
        emulate_tty=True,
        prefix=launch_prefix,
        parameters=[
            config_file,
            {
                'gige/mtu_size': mtu_size,
                'startup_user_set': startup_user_set,
                'enable_status_publisher': enable_status_publisher,
                'enable_current_params_publisher': enable_current_params_publisher
            }
        ]
    )
    pylon_ros2_camera_node = Node(
        package='pylon_ros2_camera_wrapper',        
        namespace=camera_id,
        executable='pylon_ros2_camera_wrapper',
        name=node_name,
        output='screen',
        respawn=respawn,
        emulate_tty=True,
        prefix=launch_prefix,
        parameters=[
            config_file,
            {
                'gige/mtu_size': mtu_size,
                'startup_user_set': startup_user_set,
                'enable_status_publisher': enable_status_publisher,
                'enable_current_params_publisher': enable_current_params_publisher
            }
        ]
    )
    pylon_ros2_camera_node = Node(
        package='pylon_ros2_camera_wrapper',        
        namespace=camera_id,
        executable='pylon_ros2_camera_wrapper',
        name=node_name,
        output='screen',
        respawn=respawn,
        emulate_tty=True,
        prefix=launch_prefix,
        parameters=[
            config_file,
            {
                'gige/mtu_size': mtu_size,
                'startup_user_set': startup_user_set,
                'enable_status_publisher': enable_status_publisher,
                'enable_current_params_publisher': enable_current_params_publisher
            }
        ]
    )

    pylon_ros2_camera_node = Node(
        package='pylon_ros2_camera_wrapper',        
        namespace=camera_id,
        executable='pylon_ros2_camera_wrapper',
        name=node_name,
        output='screen',
        respawn=respawn,
        emulate_tty=True,
        prefix=launch_prefix,
        parameters=[
            config_file,
            {
                'gige/mtu_size': mtu_size,
                'startup_user_set': startup_user_set,
                'enable_status_publisher': enable_status_publisher,
                'enable_current_params_publisher': enable_current_params_publisher
            }
        ]
    )
    '''
    # Define LaunchDescription variable and return it
    ld = LaunchDescription()

    ld.add_action(declare_node_name_cmd)
    ld.add_action(declare_camera_id_cmd)

    ld.add_action(declare_config_file_cmd)
    ld.add_action(declare_mtu_size_cmd)
    ld.add_action(declare_startup_user_set_cmd)
    ld.add_action(declare_enable_status_publisher_cmd)
    ld.add_action(declare_enable_current_params_publisher_cmd)

    ld.add_action(pylon_ros2_camera_node)

    return ld
dtonda8 commented 11 months ago

I did some work with python launch files. I'm guessing that only the last pylon_ros2_camera_node is launched (assuming you'll uncomment the last four nodes). It seems like your program is instantiating nodes without adding them to the launch description (except for the last one).

You could try defining the launch description ld at the beginning of the generate_launch function and adding ld.add_action(pylon_ros2_camera_node) after each node instantiation:

def generate_launch_description():
    ld = LaunchDescription() ##
    ...
    pylon_ros2_camera_node = Node(...)
    ld.add_action(pylon_ros2_camera_node) ##

    pylon_ros2_camera_node = Node(...)
    ld.add_action(pylon_ros2_camera_node) ##
    # and so on for each pylon node
        ...
AbBaSaMo commented 11 months ago

@dtonda8 thanks for pointing that out, it most probably is the issue. @dylan-gonzalez just wanted to confirm, did one of us create the launch file? cause it's not on the basler repo. If so then once it's fixed (hopefully by today) things should be working and the issue can likely be closed

edit: nm, git status confirms this

dylan-gonzalez commented 11 months ago

Not sure if it's from the smartmicro radar git repo or from the pylon ros2 library (honestly can't remember it was a while ago)

AbBaSaMo commented 11 months ago

Good news!

So I fixed up the multiple launch file and went off of the ros2 humble docs on managing large projects. We have all cameras publishing as ros topics and I managed to get at most 5 displaying with one not displaying anything as shown in the image below

Image

New error

At the same time the logs were showing the error shown below which is probs why some cameras were not displaying anything at times. Suggestion at the top of the error is to increase usb memory. Either myself, @Avocado-hash or @adar0024 will have to trial this to see if it will resolve the issue. Note that all 6 nodes had the issue despite only some of them not displaying an image. This could be an indicator that there is an issue besides the memory issue noted in the error logs. Hope not though.

Image

To reproduce, we need yaml config files per camera which only differ in the camera ID they specify. So we used CAM1.yaml to CAM6.yaml atm. And then the following launch file can be used to launch 1 node per camera given the aforementioned names for the config files:

Image

Thoughts on convention for naming cameras??

William and I also mapped out which cameras are which using the current ID system. They are as follows in a counter clock wise fashion assuming you are behind the van and facing it:

I reckon if we provide names corresponding to their position, we can better isolate and debug issues pertaining to specific cameras where they arise. The following bash command would then set the id in accordance with the above convention (but keep in mind the 6 config files would have to reflect the new camera id names as well as the launch file mentioned above):

edit: updated naming convention to match radar convention

ros2 run pylon_ros2_camera_component set_device_user_id -sn 24603805 lf && \
ros2 run pylon_ros2_camera_component set_device_user_id -sn 24603803 lb && \
ros2 run pylon_ros2_camera_component set_device_user_id -sn 24603815 bl && \
ros2 run pylon_ros2_camera_component set_device_user_id -sn 24611509 br && \
ros2 run pylon_ros2_camera_component set_device_user_id -sn 24603818 rb && \
ros2 run pylon_ros2_camera_component set_device_user_id -sn 24603801 rf ;

Also

Shout out to @dtonda8 for pointing out the issue with the original launch file.

dylan-gonzalez commented 11 months ago

Great work guys!!!

I suspect the error you are getting may be to do with the usb hubs not being able to handle all the data from the 6 cameras, which Streetdrone is trying to fix (apparently)

In terms of naming convention, we could probably just do something like:

this ^ is sort of similar to the radar convention

image

but doesn't really matter

AbBaSaMo commented 11 months ago

I think that convention is good. Is consistent and concise. So I'm not too sure about the implications on streetdrone working on the error in terms of what work we have to do now.

I'll try what was suggested in the error logs but otherwise do we need to wait for streetdrone, or can we use another hub or something? Is there a ticket we can refer to on the issue?

AbBaSaMo commented 11 months ago

@dylan-gonzalez because we use a custom launch file and 6 custom config files, should we make a fork of the basler repo that'll ultimately be called by our autoware launch repo?

@hubdwoo are you aware of any linux commands that can programatically turn a plugged in device on and off such that it simulates us plugging the camera USB cables out and back in? So we can avoid having to manually do it on start up.

dylan-gonzalez commented 11 months ago

Yep make a fork

aallendarmawan commented 11 months ago

camera config files 1-6 (just replace number in deviceuserid for each camera)

Camera parameters

/**: ros__parameters:

#  The tf frame under which the images were published
camera_frame: pylon_camera

#  The DeviceUserID of the camera. If empty, the first camera found in the
#  device list will be used
device_user_id: CAM1

#  The CameraInfo URL (Uniform Resource Locator) where the optional intrinsic
#  camera calibration parameters are stored. This URL string will be parsed
#  from the ROS-CameraInfoManager:
camera_info_url: "file:///home/mcav/data/calibrations/random_calibration.yaml"

#  The encoding of the pixels -- channel meaning, ordering, size
#  taken from the list of strings in include/sensor_msgs/image_encodings.h
#  The supported encodings are 'mono8', 'bgr8', 'rgb8', 'bayer_bggr8',
#  'bayer_gbrg8' and 'bayer_rggb8'
#  Default values are 'mono8' and 'rgb8'
# image_encoding: "mono8"

#  Binning factor to get downsampled images. It refers here to any camera
#  setting which combines rectangular neighborhoods of pixels into larger
#  "super-pixels." It reduces the resolution of the output image to
#  (width / binning_x) x (height / binning_y).
#  The default values binning_x = binning_y = 0 are considered the same
#  as binning_x = binning_y = 1 (no subsampling).
# binning_x: 1
# binning_y: 1

#  The desired publisher frame rate if listening to the topics.
#  This parameter can only be set once at startup
#  Calling the GrabImages-Action can result in a higher framerate
frame_rate: 20.0 #5.0

#  Mode of camera's shutter.
#  The supported modes are "rolling", "global" and "global_reset"
#  Default value is "" (empty) means default_shutter_mode
# shutter_mode: ""

##########################################################################
######################## Image Intensity Settings ########################
##########################################################################
# The following settings do *NOT* have to be set. Each camera has default
# values which provide an automatic image adjustment resulting in valid
# images
##########################################################################

#  The exposure time in microseconds to be set after opening the camera.
# exposure: 1000.0

#  The target gain in percent of the maximal value the camera supports
#  For USB cameras, the gain is in dB, for GigE cameras it is given in so
#  called 'device specific units'.
# gain: 0.5

#  Gamma correction of pixel intensity.
#  Adjusts the brightness of the pixel values output by the camera's sensor
#  to account for a non-linearity in the human perception of brightness or
#  of the display system (such as CRT).
# gamma: 1.0

#  The average intensity value of the images. It depends the exposure time
#  as well as the gain setting. If 'exposure' is provided, the interface will
#  try to reach the desired brightness by only varying the gain. (What may
#  often fail, because the range of possible exposure vaules is many
#  times higher than the gain range). If 'gain' is provided, the interface will
#  try to reach the desired brightness by only varying the exposure time. If
#  gain AND exposure are given, it is not possible to reach the brightness,
#  because both are assumed to be fix.
# brightness: 100

#  Only relevant, if 'brightness' is set:
#  The brightness_continuous flag controls the auto brightness function.
#  If it is set to false, the brightness will only be reached once.
#  Hence changing light conditions lead to changing brightness values.
#  If it is set to true, the given brightness will be reached continuously,
#  trying to adapt to changing light conditions. This is only possible for
#  values in the possible auto range of the pylon API which is e.g., [50 - 205]
#  for acA2500-14um and acA1920-40gm
# brightness_continuous: true

#  Only relevant, if 'brightness' is set:
#  If the camera should try to reach and / or keep the brightness, hence
#  adapting to changing light conditions, at least one of the following flags
#  must be set.
#  If both are set, the interface will use the profile that tries to keep the
#  gain at minimum to reduce white noise.
#  The exposure_auto flag indicates, that the desired brightness will be
#  reached by adapting the exposure time.
#  The gain_auto flag indicates, that the desired brightness will be
#  reached by adapting the gain.
# exposure_auto: true
# gain_auto: true

##########################################################################

#  The timeout while searching the exposure which is connected to the
#  desired brightness. For slow system this has to be increased.
# exposure_search_timeout: 5.0

#  The exposure search can be limited with an upper bound. This is to prevent
#  very high exposure times and resulting timeouts.
#  A typical value for this upper bound is ~2000000us.
#  Beware that this upper limit is only set if `startup_user_set` is set to `Default`.
# auto_exposure_upper_limit: 2000000.0

#  The MTU size. Only used for GigE cameras.
#  To prevent lost frames configure the camera has to be configured
#  with the MTU size the network card supports. A value greater 3000
#  should be good (1500 for single-board computer)
# gige:
#  mtu_size: 3000

#  Only used for GigE cameras.
#  The inter-package delay in ticks to prevent lost frames.
#  For most of GigE cameras, a value of 1000 is reasonable.
#  For cameras used on a single-board computer this value should be set to 11772.
# gige:
#  inter_pkg_delay: 1000

multiplelaunchfile

import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource

def generate_launch_description(): ''' Launches multiple instances of the single camera launch file using appropriate config files and names as arguments to those launch files.

    Arguments of interest are:
        'node_name':
            Name of the wrapper node.
            (default: 'pylon_ros2_camera_node')

        'camera_id':
            Id of the camera. Used as node namespace.
            (default: 'my_camera')

        'config_file':
            Camera parameters structured in a .yaml file.
            (default: '/home/mcav/pylon_ws/install/pylon_ros2_camera_wrapper/share/pylon_ros2_camera_wrapper/config/default.yaml')
'''

camera_launch_descriptions = [
    IncludeLaunchDescription(
        PythonLaunchDescriptionSource([
            os.path.join(get_package_share_directory('pylon_ros2_camera_wrapper'), 'launch'),
            '/pylon_ros2_camera.launch.py'
        ]),
        launch_arguments={
            'node_name': 'CAM' + str(cam_num),
            'camera_id': 'CAM' + str(cam_num),
            'config_file': [
                os.path.join(get_package_share_directory('pylon_ros2_camera_wrapper'), 'config'),
                '/CAM' + str(cam_num) + '.yaml'
            ]
        }.items(),
    ) for cam_num in range(1,7)
]

ld = LaunchDescription(camera_launch_descriptions)

return ld
aallendarmawan commented 11 months ago

^ I thought it would be easier to copy the files directly rather than manually type

dylan-gonzalez commented 11 months ago

Great work!

If there are any custom launch files that we need to call if we want to run this driver in the future, can you please make sure they are mentioned in the repo's README (if they haven't yet)?