Home

Awesome

pylon-ROS-camera

The official pylon ROS driver for Basler GigE Vision and USB3 Vision cameras

Please Note: This project is offered with no technical support by Basler AG. You are welcome to post any questions or issues on GitHub

This driver was improved by drag and bot GmbH from the version originally released by Magazino GmbH.

ROS packages included:

Please check the README file of each package for more details and help.

For the Impatient

The pylon Camera Software Suite is automatically installed through rosdep installation.

Available functionalities:

This package offers many functions of the Basler pylon Camera Software Suite C++ API inside the ROS-Framework.

This is a list of the supported functionality accesible through ROS services, which may depend on the exact camera model you are using:

Image Format Control

Analog Control

Image Quality Control

Acquisition Control

Digital I/O Control

User Set Control

Device Control

Transport Layer

Stream & Statistic Parameters

Chunk Data

ROS Service list

The ROS interface with the camera was extended with new functionality. Here is presented a list of current available services.

Service NameNotes
/pylon_camera_node/get_loggers-
/pylon_camera_node/gamma_enable(For GigE Cameras)
/pylon_camera_node/set_binning-
/pylon_camera_node/set_brightness-
/pylon_camera_node/set_camera_info-
/pylon_camera_node/set_exposure-
/pylon_camera_node/set_gain-
/pylon_camera_node/set_gamma-
/pylon_camera_node/set_gamma_selectorvalue : 0 = User, 1 = sRGB (For GigE Cameras)
/pylon_camera_node/set_logger_level-
/pylon_camera_node/set_roi-
/pylon_camera_node/set_sleeping-
/pylon_camera_node/execute_software_trigger-
/pylon_camera_node/load_user_set-
/pylon_camera_node/reset_device-
/pylon_camera_node/save_user_set-
/pylon_camera_node/select_default_user_setvalue : 0 = Default, 1 = UserSet1, 2 = UserSet2, 3 = UserSet3, 4 = HighGain, 5 = AutoFunctions, 6 = ColorRaw
/pylon_camera_node/select_user_setvalue : 0 = Default, 1 = UserSet1, 2 = UserSet2, 3 = UserSet3, 4 = HighGain, 5 = AutoFunctions, 6 = ColorRaw
/pylon_camera_node/set_acquisition_frame_countvalue = new targeted frame count
/pylon_camera_node/set_balance_white_autovalue : 0 = Off, 1 = Once, 2 = Continuous
/pylon_camera_node/set_black_levelvalue = new targeted black level
/pylon_camera_node/set_demosaicing_modevalue : 0 = Simple, 1 = Basler PGI
/pylon_camera_node/set_device_link_throughput_limitvalue = new targeted throughput limit in Bytes/sec.
/pylon_camera_node/set_device_link_throughput_limit_modedata : false = deactivate, true = activate
/pylon_camera_node/set_image_encodingvalue = mono8, mono16, bgr8, rgb8, bayer_bggr8, bayer_gbrg8, bayer_rggb8, bayer_grbg8, bayer_rggb16, bayer_bggr16, bayer_gbrg16, bayer_grbg16
/pylon_camera_node/set_light_source_presetvalue : 0 = Off, 1 = Daylight5000K, 2 = Daylight6500K, 3 = Tungsten2800K
/pylon_camera_node/set_line_debouncer_timevalue = delay in micro sec.
/pylon_camera_node/set_line_inverterdata : false = deactivate, true = activate
/pylon_camera_node/set_line_modevalue : 0 = Input, 1 = Output
/pylon_camera_node/set_line_selectorvalue : 0 = Line1, 1 = Line2, 2 = Line3, 3 = Line4
/pylon_camera_node/set_line_sourcevalue : 0 = Exposure Active, 1 = FrameTriggerWait, 2 = UserOutput1, 3 = Timer1Active, 4 = FlashWindow
/pylon_camera_node/set_noise_reductionvalue = reduction value
/pylon_camera_node/set_max_transfer_sizeMaximum USB data transfer size in bytes
/pylon_camera_node/set_offset_xvalue = targeted offset in x-axis
/pylon_camera_node/set_offset_yvalue = targeted offset in y-axis
/pylon_camera_node/set_pgi_modedata : false = deactivate, true = activate
/pylon_camera_node/set_reverse_xdata : false = deactivate, true = activate
/pylon_camera_node/set_reverse_ydata : false = deactivate, true = activate
/pylon_camera_node/set_sensor_readout_modevalue : 0 = Normal, 1 = Fast
/pylon_camera_node/set_sharpness_enhancementvalue = sharpness value
/pylon_camera_node/set_trigger_activationvalue : 0 = RigingEdge, 1 = FallingEdge
/pylon_camera_node/set_trigger_delayvalue = delay in micro sec.
/pylon_camera_node/set_trigger_modedata : false = deactivate, true = activate
/pylon_camera_node/set_trigger_selectorvalue : 0 = Frame start, 1 = Frame burst start (ace USB cameras) / Acquisition Start (ace GigE cameras)
/pylon_camera_node/set_trigger_sourcevalue : 0 = Software, 1 = Line1, 2 = Line3, 3 = Line4, 4 = Action1 (only selected GigE Camera)
/pylon_camera_node/start_grabbing-
/pylon_camera_node/stop_grabbing-
/pylon_camera_node/set_grab_timeout-
/pylon_camera_node/set_trigger_timeout-
/pylon_camera_node/set_white_balanceTriggering this service will turn off the white balance auto
/pylon_camera_node/set_grabbing_strategyvalue : 0 = GrabStrategy_OneByOne, 1 = GrabStrategy_LatestImageOnly, 2 = GrabStrategy_LatestImages
/pylon_camera_node/set_output_queue_size-
/pylon_camera_node/set_max_num_buffervalue = Maximum number of buffers that can be used simultaneously for grabbing images.
/pylon_camera_node/get_max_num_buffervalue : -1 = Feature not supported by current camera, -2 = error getting the value.
/pylon_camera_node/get_statistic_total_buffer_countvalue : -1 = Feature not supported by current camera, -2 = error getting the value.
/pylon_camera_node/get_statistic_failed_buffer_countvalue : -1 = Feature not supported by current camera, -2 = error getting the value.
/pylon_camera_node/get_statistic_buffer_underrun_countvalue : -1 = Feature not supported by current camera, -2 = error getting the value.
/pylon_camera_node/get_statistic_failed_packet_countvalue : -1 = Feature not supported by current camera, -2 = error getting the value.
/pylon_camera_node/get_statistic_resend_request_countvalue : -1 = Feature not supported by current camera, -2 = error getting the value.
/pylon_camera_node/get_statistic_missed_frame_countvalue : -1 = Feature not supported by current camera, -2 = error getting the value.
/pylon_camera_node/get_statistic_resynchronization_countvalue : -1 = Feature not supported by current camera, -2 = error getting the value.
/pylon_camera_node/set_chunk_mode_active-
/pylon_camera_node/get_chunk_mode_activevalue 1 : enabled , value 2 : disabled, -1 = Feature not supported by current camera, -2 = error setting the value.
/pylon_camera_node/set_chunk_selector1 = AutoBrightnessStatus , 2 = BrightPixel , 3 = CounterValue 4 = DynamicRangeMax , 5 = DynamicRangeMin , 6 = ExposureTime , 7 = FrameID , 8 = FrameTriggerCounter , 9 = FrameTriggerIgnoredCounter , 10 = Framecounter , 11 = FramesPerTriggerCounter , 12 = Gain , 13 = GainAll , 14 = Height , 15 = Image , 16 = InputStatusAtLineTrigger , 17 = LineStatusAll , 18 = LineTriggerCounter , 19 = LineTriggerEndToEndCounter , 20 = LineTriggerIgnoredCounter, 21 = OffsetX , 22 = OffsetY, 23 = PayloadCRC16 , 24 = PixelFormat , 25 = SequenceSetIndex , 26 = SequencerSetActive, 27 = ShaftEncoderCounter , 28 = Stride , 29 = Timestamp , 30 = Triggerinputcounter , 31 = VirtLineStatusAll , 32 = Width
/pylon_camera_node/get_chunk_selector1 = AutoBrightnessStatus , 2 = BrightPixel , 3 = CounterValue 4 = DynamicRangeMax , 5 = DynamicRangeMin , 6 = ExposureTime , 7 = FrameID , 8 = FrameTriggerCounter , 9 = FrameTriggerIgnoredCounter , 10 = Framecounter , 11 = FramesPerTriggerCounter , 12 = Gain , 13 = GainAll , 14 = Height , 15 = Image , 16 = InputStatusAtLineTrigger , 17 = LineStatusAll , 18 = LineTriggerCounter , 19 = LineTriggerEndToEndCounter , 20 = LineTriggerIgnoredCounter, 21 = OffsetX , 22 = OffsetY, 23 = PayloadCRC16 , 24 = PixelFormat , 25 = SequenceSetIndex , 26 = SequencerSetActive, 27 = ShaftEncoderCounter , 28 = Stride , 29 = Timestamp , 30 = Triggerinputcounter , 31 = VirtLineStatusAll , 32 = Width
/pylon_camera_node/set_chunk_enable-
/pylon_camera_node/get_chunk_enablevalue 1 : enabled , value 2 : disabled, -1 = Feature not supported by current camera, -2 = error setting the value.
/pylon_camera_node/get_chunk_timestamp-
/pylon_camera_node/get_chunk_timestamp-
/pylon_camera_node/get_chunk_exposure_time-
/pylon_camera_node/set_chunk_exposure_time-
/pylon_camera_node/get_chunk_line_status_all-
/pylon_camera_node/get_chunk_frame_counter-
/pylon_camera_node/get_chunk_counter_value-

Image pixel encoding

This package currently support the following ROS image pixel formats :

* mono8	        (Basler Format : Mono8)
* mono16	(Basler Format : Mono16, Mono12)       (Notes 1&2)
* bgr8 		(Basler Format : BGR8)
* rgb8 		(Basler Format : RGB8)
* bayer_bggr8 	(Basler Format : BayerBG8)
* bayer_gbrg8 	(Basler Format : BayerGB8)
* bayer_rggb8 	(Basler Format : BayerRG8)
* bayer_grbg8 	(Basler Format : BayerRG8)
* bayer_rggb16	(Basler Format : BayerRG16, BayerRG12) (Notes 1&2)
* bayer_bggr16 	(Basler Format : BayerBG16, BayerBG12) (Notes 1&2)
* bayer_gbrg16 	(Basler Format : BayerGB16, BayerGB12) (Notes 1&2)
* bayer_grbg16 	(Basler Format : BayerGR16, BayerGR12) (Notes 1&2)

<u>NOTES: </u>

1 : 12-bits image will be remapped to 16-bits using bit shifting to make it work with the ROS 16-bits sensor standard message.

2 : When the user call the /pylon_camera_node/set_image_encoding to use 16-bits encoding, the driver will check first for the availability of the requested 16-bits encoding to set it, when the requested 16-bits image encoding is not available, then the driver will check the availability of the equivalent 12-bits encoding to set it. When both 16-bits and 12-bits image encoding are not available then an error message will be returned.

Usage

Start the driver with command: roslaunch pylon_camera pylon_camera_node.launch. Then the driver will try to connect to the available cameras automatically.

To test if the driver is correctly working we recommend to use the rqt ROS tool (http://wiki.ros.org/rqt). You will need to add an image viewer through the the contextual menu RQT Plugin --> Visualization --> Image View. Then please select the pylon_camera_node/image_raw to display the current camera picture. If the intrinsic calibration file was configured, pylon_camera_node/image_rect will also appear. Please check Intrinsic calibration section for further information.

This drivers offers different ROS services to change the camera parameters. To see the list of available services please use rosservice list command. Once you have located the desired service you can call it by using the rosservice call /service_name {...parameters...} (with the corresponding service and parameters). E.g.:

~/workspace/dnb_docs$ rosservice call /pylon_camera_node/set_reverse_x "data: true" 
success: True
message: "done"

To auto-fill the parameters you can use Tab after writing the service name. Please refer to http://wiki.ros.org/rosservice for ros service usage.

Intrinsic calibration

ROS includes a standardised camera intrinsic calibration process through camera_calibration package (http://wiki.ros.org/camera_calibration). This calibration process generates a file which can be read by the pylon-ros-camera driver by setting the camera_info_url parameter of the config/default.yaml file to the correct URI (e.g. file:///home/user/data/calibrations/my_calibration.yaml)

Setting device user id

Set the device user id with command: rosrun pylon_camera set_device_user_id [-sn SERIAL_NB] your_device_user_id. If no serial number is specified thanks to the option -sn, the specified device user id your_device_user_id will be assigned to the first available camera. USB cameras must be disconnected and then reconnected after setting a new device user id. USB cameras keep their old user id otherwise.

Troubleshooting

To increase performance and to minimize CPU usage when grabbing images, the following settings should be considered:

Camera hot-swapping

If you hot-swap the camera with a different camera with a non-compatible pixel encoding format (e.g. mono and color cameras), you need to restart the ROS system to replace the encoding value or replace the rosparam directly by setting the image_encoding parameter. E.g.: rosparam set /pylon_camera_node/image_encoding "mono8"

Slow frame rate

If the camera image acquistion is triggered by sofware trigger (default setting), then it is not possible to get the maximum frame rate, because the image acquisition is sequentially triggered, which is not overlapping then. Several possible solutions are mentionned and tested in issue #21, #28, #29, #81, #116, #147, and #200. Please refer to them for more information.

GigE Devices

Maximum UDP Socket Buffer Size

The system's maximum UDP receive buffer size should be increased to ensure a stable image acquisition. A maximum size of 2 MB is recommended. This can be achieved by issuing the sudo sysctl net.core.rmem_max=2097152 command. To make this setting persistent, you can add the net.core.rmem_max setting to the /etc/sysctl.conf file.

Enable Jumbo Frames.

Many GigE network adapters support so-called jumbo frames, i.e., network packets larger than the usual 1500 bytes. To enable jumbo frames, the maximum transfer unit (MTU) size of the PC's network adapter must be set to a high value. We recommend using a value of 8192.

Increase the packet size.

If your network adapter supports jumbo frames, you set the adapter's MTU to 8192 as described above. In order to take advantage of the adapter's jumbo frame capability, you must also set the packet size used by the camera to 8192.

If you are working with the pylon Viewer application, you can set the packet size by first selecting a camera from the tree in the "Device" pane. In the "Features" pane, expand the features group that shows the camera's name, expand the "Transport Layer" parameters group, and set the "Packet Size" parameter to 8192. If you write your own application, use the camera API to set the PacketSize parameter to 8192.

Real-time Priority

The GigE Vision implementation of Basler pylon software uses a thread for receiving image data. Basler pylon tries to set the thread priority for the receive thread to real-time thread priority. This requires certain permissions. The 'Permissions for Real-time Thread Priorities' section of the pylon INSTALL document describes how to grant the required permissions.

U3V Devices

Increasing Packet Size

For faster USB transfers you should increase the packet size. You can do this by changing the "Stream Parameters" -> "Maximum Transfer Size" value from inside the pylon Viewer or by setting the corresponding value via the API. After increasing the package size you will likely run out of kernel space and see corresponding error messages on the console. The default value set by the kernel is 16 MB. To set the value (in this example to 1000 MB) you can execute as root: echo 1000 > /sys/module/usbcore/parameters/usbfs_memory_mb This would assign a maximum of 1000 MB to the USB stack.