<commit_before>// Copyright 2015 <Magazino GmbH>

#ifndef PYLON_CAMERA_INTERNAL_DART_H_
#define PYLON_CAMERA_INTERNAL_DART_H_

#include <string>
#include <vector>

#include <pylon_camera/internal/impl/pylon_camera_usb.hpp>

namespace pylon_camera
{

class PylonDARTCamera : public PylonUSBCamera
{
public:
    explicit PylonDARTCamera(Pylon::IPylonDevice* device);
    virtual ~PylonDARTCamera();

    virtual std::string typeName() const;

    virtual bool registerCameraConfiguration(const PylonCameraParameter& params);

    virtual bool setUserOutput(int output_id, bool value);


protected:
    virtual bool setupSequencer(const std::vector<float>& exposure_times, std::vector<float>& exposure_times_set);

    virtual bool grab(Pylon::CGrabResultPtr& grab_result);
};

PylonDARTCamera::PylonDARTCamera(Pylon::IPylonDevice* device) :
    PylonUSBCamera(device)
{
}

PylonDARTCamera::~PylonDARTCamera()
{
}

bool PylonDARTCamera::registerCameraConfiguration(const PylonCameraParameter& params)
{
    if (PylonUSBCamera::registerCameraConfiguration(params))
    {
        try
        {
//            cam_->SensorShutterMode.SetValue(ShutterModeEnums::SensorShutterMode_Rolling);
            cam_->GainAuto.SetValue(Basler_UsbCameraParams::GainAuto_Off);
            cam_->Gain.SetValue(0.0);
            cam_->Gamma.SetValue(1.0);
            return true;
        }
        catch (const GenICam::GenericException &e)
        {
            ROS_ERROR("%s", e.GetDescription());
            return false;
        }
    }
    return false;
}

bool PylonDARTCamera::setupSequencer(const std::vector<float>& exposure_times, std::vector<float>& exposure_times_set)
{
    ROS_ERROR("SEQUENCER FOR DART CAMERAS NOT YET IMPLEMENTED!!!");
    return false;
}

bool PylonDARTCamera::grab(Pylon::CGrabResultPtr& grab_result)
{
    try
    {
        // /!\ The dart camera device does not support waiting for frame trigger ready
        cam_->ExecuteSoftwareTrigger();

        // BaslerDebugDay: hard coded timeout of 5s makes most sense for all applications
        cam_->RetrieveResult(5000,  // ms
                             grab_result,
                             Pylon::TimeoutHandling_ThrowException);
        return true;
    }
    catch (const GenICam::GenericException &e)
    {
        if (cam_->IsCameraDeviceRemoved())
        {
            is_cam_removed_ = true;
        }
        else
        {
            ROS_ERROR_STREAM("An image grabbing exception in pylon camera occurred: " << e.GetDescription());
        }
    }
    return false;
}

bool PylonDARTCamera::setUserOutput(int output_id, bool value)
{
    ROS_ERROR("Dart camera has no digital output.");
    return false;
}

std::string PylonDARTCamera::typeName() const
{
    return "DART";
}

}  // namespace pylon_camera

#endif  // PYLON_CAMERA_INTERNAL_DART_H_
<commit_msg>gain for dart cameras not hard coded any more, one can set it in initializeing process using the ros-params<commit_after>// Copyright 2015 <Magazino GmbH>

#ifndef PYLON_CAMERA_INTERNAL_DART_H_
#define PYLON_CAMERA_INTERNAL_DART_H_

#include <string>
#include <vector>

#include <pylon_camera/internal/impl/pylon_camera_usb.hpp>

namespace pylon_camera
{

class PylonDARTCamera : public PylonUSBCamera
{
public:
    explicit PylonDARTCamera(Pylon::IPylonDevice* device);
    virtual ~PylonDARTCamera();

    virtual std::string typeName() const;

    virtual bool registerCameraConfiguration(const PylonCameraParameter& params);

    virtual bool setUserOutput(int output_id, bool value);


protected:
    virtual bool setupSequencer(const std::vector<float>& exposure_times, std::vector<float>& exposure_times_set);

    virtual bool grab(Pylon::CGrabResultPtr& grab_result);
};

PylonDARTCamera::PylonDARTCamera(Pylon::IPylonDevice* device) :
    PylonUSBCamera(device)
{
}

PylonDARTCamera::~PylonDARTCamera()
{
}

bool PylonDARTCamera::registerCameraConfiguration(const PylonCameraParameter& params)
{
    if (PylonUSBCamera::registerCameraConfiguration(params))
    {
        try
        {
            cam_->GainSelector.SetValue(Basler_UsbCameraParams::GainSelector_All);
            cam_->GainAuto.SetValue(Basler_UsbCameraParams::GainAuto_Off);
            cam_->Gain.SetValue(params.target_gain_ * cam_->Gain.GetMax());
            cam_->Gamma.SetValue(1.0);
            return true;
        }
        catch (const GenICam::GenericException &e)
        {
            ROS_ERROR("%s", e.GetDescription());
            return false;
        }
    }
    return false;
}

bool PylonDARTCamera::setupSequencer(const std::vector<float>& exposure_times, std::vector<float>& exposure_times_set)
{
    ROS_ERROR("SEQUENCER FOR DART CAMERAS NOT YET IMPLEMENTED!!!");
    return false;
}

bool PylonDARTCamera::grab(Pylon::CGrabResultPtr& grab_result)
{
    try
    {
        // /!\ The dart camera device does not support waiting for frame trigger ready
        cam_->ExecuteSoftwareTrigger();

        // BaslerDebugDay: hard coded timeout of 5s makes most sense for all applications
        cam_->RetrieveResult(5000,  // ms
                             grab_result,
                             Pylon::TimeoutHandling_ThrowException);
        return true;
    }
    catch (const GenICam::GenericException &e)
    {
        if (cam_->IsCameraDeviceRemoved())
        {
            is_cam_removed_ = true;
        }
        else
        {
            ROS_ERROR_STREAM("An image grabbing exception in pylon camera occurred: " << e.GetDescription());
        }
    }
    return false;
}

bool PylonDARTCamera::setUserOutput(int output_id, bool value)
{
    ROS_ERROR("Dart camera has no digital output.");
    return false;
}

std::string PylonDARTCamera::typeName() const
{
    return "DART";
}

}  // namespace pylon_camera

#endif  // PYLON_CAMERA_INTERNAL_DART_H_

{'fraction_non_alphanumeric': 0.09882920110192837, 'fraction_numerical': 0.004132231404958678, 'mean_word_length': 3.24014598540146, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7388355', 'n_tokens_mistral': 1831, 'n_tokens_neox': 1784, 'n_words': 365}