ros-event-camera / metavision_driver

driver for event based cameras using the MetaVision SDK (Prophesee and CenturyArk)
Apache License 2.0
42 stars 12 forks source link

Non-deterministic camera name assignment by serial ID #47

Closed ghoshsuman closed 3 months ago

ghoshsuman commented 4 months ago

Hi @berndpfrommer, thanks for the amazing work! I am recording with a stereo setup with EVK4 cameras in primary-secondary mode. I have defined my launch file as follows:

  <!-- cam 0 -->
  <node pkg="nodelet" type="nodelet"
    name="event_cam_0" args="load
                metavision_driver/DriverNodelet recording_driver"
    clear_params="true" output="screen">
    <param name="frame_id" value="event_cam_0"/>
    <param name="sync_mode" value="primary"/>
    <param name="trigger_in_mode" value="external"/>
    <rosparam command="load" file="$(find metavision_driver)/config/trigger_pins_stereo_custom.yaml"/>
    <param name="event_message_time_threshold" value="0.0001"/>
    <!-- time interval between printout of rate statistics -->
    <param name="statistics_print_interval" value="2.0"/>
    <!-- from where to load the bias file (if any)  -->
    <param name="bias_file" value="$(arg bias_file)"/>
    <!-- run in multithreaded mode -->
    <param name="use_multithreading" value="true"/>
    <!-- listen for ready message from cam 1 -->
    <remap from="~ready" to ="/event_cam_1/ready"/>
    <param name="serial" value="00050673"/>
  </node>

  <!-- cam 1 -->
  <node pkg="nodelet" type="nodelet"
    name="event_cam_1" args="load metavision_driver/DriverNodelet recording_driver"
    clear_params="true" output="screen">
    <param name="frame_id" value="event_cam_1"/>
    <param name="sync_mode" value="secondary"/>
    <param name="trigger_in_mode" value="external"/>
    <rosparam command="load" file="$(find metavision_driver)/config/trigger_pins_stereo_custom.yaml"/>
    <param name="event_message_time_threshold" value="0.0001"/>
    <!-- time interval between printout of rate statistics -->
    <param name="statistics_print_interval" value="2.0"/>
    <!-- from where to load the bias file (if any)  -->
    <param name="bias_file" value="$(arg bias_file)"/>
    <!-- run in multithreaded mode -->
    <param name="use_multithreading" value="true"/>
    <param name="serial" value="00050675"/>
  </node>

As you can see, I'd like camera 0673 to be cam_0 (primary) and 0675 to be cam_1 (secondary), but when I launch the recording nodelet, this assignment seems to be flipped at random sometimes.

I did some investigation into this. Setting the serial values above wrong also makes the nodelet work, so I guess these serial numbers are ignored while launching the driver? Is there a way to keep this assignment fixed?

From a few tries, it seems that whichever camera USB is plugged in first becomes cam_0.

berndpfrommer commented 4 months ago

I have no idea why it would do that. It should respect the serial number. Can you stick some debugging statements near this line to see that the serial number is actually non-empty?

berndpfrommer commented 3 months ago

Closing for now. Please re-open if this is still a problem.

ghoshsuman commented 3 months ago

Sorry I forgot about this issue, but this still persists. With debugging statements that you suggested, it seems that the ROS node parameters are not being properly read when it is a non-string value, and hence it is getting empty. I think the problem has been described here: https://github.com/ros/ros_comm/issues/1339. Numbers and booleans passed like this are somehow getting converted to non-string values. Not sure how to prevent this type conversion. I think it can be handled in the code by choosing non-string appropriate datatypes for the member variables, however this will still cause problems with serial numbers containing leading 0s.