Skip to content
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

pylon_camera fps not reaching set frame_rate #200

Open
JaleesaHoule opened this issue Jan 23, 2024 · 10 comments
Open

pylon_camera fps not reaching set frame_rate #200

JaleesaHoule opened this issue Jan 23, 2024 · 10 comments

Comments

@JaleesaHoule
Copy link

JaleesaHoule commented Jan 23, 2024

Hi there,

I am using pylon_camera for a Basler a2A1920-160umBAS and am encountering the same issue as previously described in #27. The same message is spit out [ INFO] [1583442203.551151871]: Start image grabbing if node connects to topic with a frame_rate of: 100 Hz when launching. No errors are given, but when checking the topic rostopic hz /pylon_camera_node/image_raw, the frame rate is maxing out between 42-56fps.

I have tried the following:

  • Adjusting set_trigger_selector, set_trigger_source, set_trigger_activation, and set_trigger_mode service commands (no change to fps)
  • Lowering the exposure (increases the frame rate slightly)
  • Changing grab_strategy (no change)
  • Changing the trigger_timeout and grab_timeout (no change)
  • Changing binning_x and binning_y (changes fps slightly)

I have also tried reverting to one of the older commits of ros-pylon-camera that were supposed to have fixed the issue (around Dec 15, 2020 according to #27). That also did not solve the problem.

There are no issues running the camera at 100 - 150 fps in pylonviewer. Is this a camera specific issue or is there any setting that may help to resolve this?

Thanks in advance for your help.

@JaleesaHoule JaleesaHoule changed the title pylon_camera fps not reaching set frame rate of 100 hz pylon_camera fps not reaching set frame_rate Jan 23, 2024
@m-binev
Copy link

m-binev commented Jan 24, 2024

Hi @JaleesaHoule, assuming the camera is runnung at 100+ Hz with the same settings in pylon (Viewer), then you should check the Acquisition Mode settings.
That is, if the camera image acquistion is triggered by Sofware Trigger (I belive this is the default), then you can never get the maximum frame rate, because you sequentially trigger the image acquisition, which is not overlapping then.
To get the maximum frame rate, you should either

  1. let the camera run ( Acquisition Mode = Continuous + Trigger Mode = Off), or
  2. trigger it externally ( Acquisition Mode = Continuous + Trigger Mode = On + External trigger signal via IO).
    You may check the camera/pylon docs here:
    https://docs.baslerweb.com/acquisition-mode#continuous-acquisition-mode
    Also, I believe there was a similar "issue" already and some other user got rid of it by implementing one of those approaches.
    Regards

@JaleesaHoule
Copy link
Author

Hi @m-binev, thank you for taking the time to respond.

Please correct me if I am wrong, but I am under the impression that changing settings in Acquisition Mode in pylon (viewer) will not affect the camera settings used when running pylon_camera in ros. In order to get the same settings in ros, I have been using the list of service commands in the pylon_camera documentation.

In pylon (viewer), letting the camera run (Acquisition Mode = Continuous + Trigger Mode = Off) gives the desired frame rate of 100Hz. Correspondingly, I have tried to run the pylon_camera node with the service commands 'set_trigger_mode: =false' and 'frame_rate:=100', but the resulting frame rate is maxing out around 52 Hz.

@m-binev
Copy link

m-binev commented Jan 25, 2024

Hi @JaleesaHoule, when loading the ros driver, some/many camera settings get overwritten. Thus, you have to do the "right" configuration for your use case in ROS.
I think, just setting the trigger mode to "off" won't be enough.
I suggest you check some of the closed issues related to "low frame rate", e.g., #116 , #81

@JaleesaHoule
Copy link
Author

JaleesaHoule commented Jan 26, 2024

Hi @m-binev, it seems like the solution for both #116 and #81 was to change the 'enable_current_params_publisher' setting to false. Unfortunately, this only seems to improve performance from about 52 to 63 Hz. At this point, I have tried most of the parameters that are listed in the documentation, but have not been able to get to the desired 100 Hz frame rate. Are there any other settings that can be disabled to potentially improve camera speeds? Could this be a compatibility issue with the version of ROS that I'm running (noetic)?

These are the current parameters I have set:

PARAMETERS

  • /pylon_camera_node/camera_frame: pylon_camera
  • /pylon_camera_node/camera_info_url:
  • /pylon_camera_node/device_user_id:
  • /pylon_camera_node/enable_current_params_publisher: False
  • /pylon_camera_node/enable_status_publisher: False (I have tried having this set to True as well - doesn't change anything)
  • /pylon_camera_node/exposure: 4000.0 (I have played around with the exposure - lowering it to 20.0 increases performance by 2-3 Hz)
  • /pylon_camera_node/frame_rate: 100.0
  • /pylon_camera_node/gige/mtu_size: 3000
  • /pylon_camera_node/grab_strategy: 0 (I have tried all 3 grab strategies, no change in performance)
  • /pylon_camera_node/set_trigger_mode: False
  • /pylon_camera_node/startup_user_set: CurrentSetting
  • /rosdistro: noetic
  • /rosversion: 1.16.0

@fhwedel-hoe
Copy link

fhwedel-hoe commented Feb 14, 2024

@JaleesaHoule Since basler's pylon-ros-camera is hard-coded to use a software trigger, I wrote a ROS2 node that is optimized for speed: https://github.com/fhwedel-hoe/pylon_instant_camera Perhaps it is useful for you, too?

@rahulAquila
Copy link

Have there been any resolutions to this? This is a critical issue within this library that is hindering us from using it in any of our applications, the instructions on read me are not sufficient and misleading as well.

@fhwedel-hoe
Copy link

Hi @rahulAquila

Indeed, it is a bit hidden. The readme to this project says "it is not possible to get the maximum frame rate, because the image acquisition is sequentially triggered".

You may use an external trigger source (I have no experience with that) or use a different implementation (such as mine, see above). There are other implementations as well. You surely can find one that fits your needs. :)

@JaleesaHoule
Copy link
Author

@fhwedel-hoe Thank you for working on a solution to this problem.

The documentation states "If the camera image acquistion is triggered by sofware trigger (default setting), then it is not possible to get the maximum frame rate." However, the documentation does give instructions for changing the trigger mode so that it is not on a software trigger. Therefore, according to the documentation, it should theoretically be possible to get the maximum frame rate if the trigger settings are changed. If this is not in fact possible, the documentation should be updated.

That said, @rahulAquila, I have not managed to achieve the desired frame rate using any of the suggested fixes above or in the other relevant issues. The max fps that I was able to achieve after playing around with the exposure and other settings was around 92 hz, and those results were inconsistent. This project has been shelved for the time being, so I have not yet tried @fhwedel-hoe's node to see if that may work for my needs, but will plan to give that a shot when I circle back to this project.

@ne01230
Copy link

ne01230 commented Oct 30, 2024

rosservice call /pylon_camera_node2440/set_trigger_mode "data: off"
close the software trigger, the frame rate reach the max frame rate as pylon viewer reached.

@fhwedel-hoe
Copy link

fhwedel-hoe commented Nov 15, 2024

@ne01230 It does not work for me. Can you share some more details about your set-up? I am using a daA1600-60uc connected via USB 3.0. These are the settings I use:

# {05D8C294-F295-4dfb-9D01-096BD04049F4}
# GenApi persistence file (version 3.1.0)
# Device = Basler::UsbCameraParams -- Basler USB3Vision camera interface -- Device version = 1.0.0 -- Product GUID = 71351C50-4DDC-4D3B-BDF7-0D1539FEFD30 -- Product version GUID = 69D3B11D-28C0-48EE-90BB-86FADE264D4D
GainSelector	All
GainRaw	72
GainAuto	Continuous
AutoGainLowerLimitRaw	64
AutoGainUpperLimitRaw	161
Width	1280
Height	960
OffsetX	0
OffsetY	0
BinningHorizontal	1
BinningVertical	1
ReverseX	0
ReverseY	0
PixelFormat	RGB8
TestPattern	Off
SensorShutterMode	Global
OverlapMode	On
ExposureTimeRaw	13370
ExposureAuto	Off
TriggerMode	Off
AcquisitionFramePeriodRaw	25000
LightSourcePreset	Off
BalanceWhiteAuto	Off
DeviceLinkThroughputLimitMode	Off

In pylonviewer, the camera saturates the USB, achieving 40 FPS. With ros2 launch pylon_ros2_camera_wrapper pylon_ros2_camera.launch.py at default settings, I get meager 5 FPS. The node prints The connected camera device does not support waiting for frame trigger ready. Software trigger will be immediately executed and Error while trying to getting the Chunk Mode Active. The connected Camera not supporting this feature is printed once per frame. The first is the default behaviour and the latter is to be expected since the dart does indeed not support Data Chunks.

After executing ros2 service call /my_camera/pylon_ros2_camera_node/set_trigger_mode std_srvs/srv/SetBool "{data: False}", the node prints Payload data has been discarded. and stops supplying images entirely. I guess, the camera increases the FPS but saturation of the USB is handled in a more restrictive manner. Did you set an option to adjust for this behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants