basler / pylon-ros-camera

The official pylon ROS driver for Basler GigE Vision and USB3 Vision cameras:
http://www.baslerweb.com
Other
147 stars 145 forks source link

pylon_camera fps not reaching set frame_rate #200

Open JaleesaHoule opened 9 months ago

JaleesaHoule commented 9 months ago

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:

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.

m-binev commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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 commented 9 months ago

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

fhwedel-hoe commented 8 months ago

@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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

@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 commented 1 week ago

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.