Class CameraModule

Inheritance Relationships

Base Type

  • public rclcpp_lifecycle::LifecycleNode

Class Documentation

class psdk_ros2::CameraModule : public rclcpp_lifecycle::LifecycleNode

Public Functions

explicit CameraModule(const std::string &name)

Construct a new CameraModule object.

Parameters

node_name – Name of the node

~CameraModule()

Destroy the camera module object.

CallbackReturn on_configure(const rclcpp_lifecycle::State &state)

Configures the camera module. Creates the ROS 2 subscribers and services.

Parameters

state – rclcpp_lifecycle::State. Current state of the node.

Returns

CallbackReturn SUCCESS or FAILURE

CallbackReturn on_activate(const rclcpp_lifecycle::State &state)

Activates the camera module.

Parameters

state – rclcpp_lifecycle::State. Current state of the node.

Returns

CallbackReturn SUCCESS or FAILURE

CallbackReturn on_cleanup(const rclcpp_lifecycle::State &state)

Cleans the camera module. Resets the ROS 2 subscribers and services.

Parameters

state – rclcpp_lifecycle::State. Current state of the node.

Returns

CallbackReturn SUCCESS or FAILURE

CallbackReturn on_deactivate(const rclcpp_lifecycle::State &state)

Deactivates the camera module.

Parameters

state – rclcpp_lifecycle::State. Current state of the node.

Returns

CallbackReturn SUCCESS or FAILURE

CallbackReturn on_shutdown(const rclcpp_lifecycle::State &state)

Shuts down the camera module.

Parameters

state – rclcpp_lifecycle::State. Current state of the node.

Returns

CallbackReturn SUCCESS or FAILURE

bool init()

Initialize the camera module.

Returns

true/false

bool deinit()

Deinitialize the camera module.

Returns

true/false

Private Functions

bool get_camera_type(std::string *camera_type, const E_DjiMountPosition index)

Get camera type for a given payload index.

Parameters
  • camera_type – pointer to be filled if camera is detected

  • index – payload index to be checked

Returns

true - if camera has been found, false - otherwise

void camera_get_type_cb(const std::shared_ptr<CameraGetType::Request> request, const std::shared_ptr<CameraGetType::Response> response)

Get the camera type of the selected camera mounted position.

Parameters
  • request – CameraGetType service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetType service response. Check enum E_DjiCameraType to obtain more information.

void camera_set_exposure_mode_ev_cb(const std::shared_ptr<CameraSetExposureModeEV::Request> request, const std::shared_ptr<CameraSetExposureModeEV::Response> response)

Set the camera exposure mode and exposure compensatio.

Note

The Exposure compensation parameter can only be set if the exposure mode is set to manual, shutter or aperture.

Parameters
  • request – CameraSetExposureModeEV service request. The camera mounted position for which the request is made needs to be specified as well as the exposure mode and exposure compensation if desired. Check enums E_DjiCameraManagerExposureMode and E_DjiCameraManagerExposureCompensation to obtain more information.

  • response – CameraSetExposureModeEV service response.

void camera_get_exposure_mode_ev_cb(const std::shared_ptr<CameraGetExposureModeEV::Request> request, const std::shared_ptr<CameraGetExposureModeEV::Response> response)

Get the camera exposure mode and exposure compensatio.

Parameters
  • request – CameraGetExposureModeEV service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetExposureModeEV service response. Check enums E_DjiCameraManagerExposureMode and E_DjiCameraManagerExposureCompensation to obtain more information.

void camera_set_shutter_speed_cb(const std::shared_ptr<CameraSetShutterSpeed::Request> request, const std::shared_ptr<CameraSetShutterSpeed::Response> response)

Set the camera shutter speed.

Note

This parameter can only be set if the camera exposure mode is previously set to manual or shutter priority mode.

Parameters
  • request – CameraSetShutterSpeed service request. The camera mounted position for which the request is made needs to be specified as well as the desired shutter speed. See enum E_DjiCameraManagerShutterSpeed.

  • response – CameraSetShutterSpeed service response.

void camera_get_shutter_speed_cb(const std::shared_ptr<CameraGetShutterSpeed::Request> request, const std::shared_ptr<CameraGetShutterSpeed::Response> response)

Get the camera shutter speed.

Parameters
  • request – CameraGetShutterSpeed service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetShutterSpeed service response. Check enums E_DjiCameraManagerShutterSpeed to obtain more information.

void camera_set_iso_cb(const std::shared_ptr<CameraSetISO::Request> request, const std::shared_ptr<CameraSetISO::Response> response)

Set the camera ISO.

Note

This parameter can only be set if the camera exposure mode is previously set to manual mode.

Parameters
  • request – CameraSetISO service request. The camera mounted position for which the request is made needs to be specified as well as the desired ISO. See enum E_DjiCameraManagerISO.

  • response – CameraSetISO service response.

void camera_get_iso_cb(const std::shared_ptr<CameraGetISO::Request> request, const std::shared_ptr<CameraGetISO::Response> response)

Get the camera ISO.

Parameters
  • request – CameraGetISO service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetISO service response. Check enums E_DjiCameraManagerISO to obtain more information.

void camera_set_focus_target_cb(const std::shared_ptr<CameraSetFocusTarget::Request> request, const std::shared_ptr<CameraSetFocusTarget::Response> response)

Set the focus target.

Note

This parameter can only be set if the camera focus mode is different than auto or manual. For auto focus mode the focus target is the focal point, and for manual focus mode, the target is the zoom out area if the focus assistant is enabled in the manaual mode.

Parameters
  • request – CameraSetFocusTarget service request. The camera mounted position for which the request is made needs to be specified as well as the desired ISO. See enum E_DjiCameraManagerISO.

  • response – CameraSetFocusTarget service response.

void camera_get_focus_target_cb(const std::shared_ptr<CameraGetFocusTarget::Request> request, const std::shared_ptr<CameraGetFocusTarget::Response> response)

Get the camera focus point.

Parameters
  • request – CameraGetFocusTarget service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetFocusTarget service response. Check enums T_DjiCameraManagerFocusPosData to obtain more information.

void camera_set_focus_mode_cb(const std::shared_ptr<CameraSetFocusMode::Request> request, const std::shared_ptr<CameraSetFocusMode::Response> response)

Set the camera focus mode.

Parameters
  • request – CameraSetFocusMode service request. The camera mounted position for which the request is made needs to be specified as well as the desired focus mode. See enum E_DjiCameraManagerFocusMode.

  • response – CameraSetFocusMode service response.

void camera_get_focus_mode_cb(const std::shared_ptr<CameraGetFocusMode::Request> request, const std::shared_ptr<CameraGetFocusMode::Response> response)

Get the camera focus mode.

Parameters
  • request – CameraGetFocusMode service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetFocusMode service response. Check enums E_DjiCameraManagerFocusMode to obtain more information.

void camera_set_optical_zoom_cb(const std::shared_ptr<CameraSetOpticalZoom::Request> request, const std::shared_ptr<CameraSetOpticalZoom::Response> response)

Set the camera optical zoom.

Parameters
  • request – CameraSetOpticalZoom service request. The camera mounted position for which the request is made needs to be specified as well as the zoom factor.

  • response – CameraSetOpticalZoom service response.

void camera_get_optical_zoom_cb(const std::shared_ptr<CameraGetOpticalZoom::Request> request, const std::shared_ptr<CameraGetOpticalZoom::Response> response)

Get the current and maximum camera optical zoom.

Parameters
  • request – CameraGetOpticalZoom service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetOpticalZoom service response. Check enums T_DjiCameraManagerOpticalZoomParam to obtain more information.

void camera_set_infrared_zoom_cb(const std::shared_ptr<CameraSetInfraredZoom::Request> request, const std::shared_ptr<CameraSetInfraredZoom::Response> response)

Set the camera infrared zoom.

Parameters
  • request – CameraSetInfraredZoom service request. The camera mounted position for which the request is made needs to be specified as well as the desired infrared zoom.

  • response – CameraSetInfraredZoom service response.

void camera_set_aperture_cb(const std::shared_ptr<CameraSetAperture::Request> request, const std::shared_ptr<CameraSetAperture::Response> response)

Set the camera aperture.

Parameters
  • request – CameraSetAperture service request. The camera mounted position for which the request is made needs to be specified as well as the desired aperture. See enum E_DjiCameraManagerAperture for more details.

  • response – CameraSetAperture service response.

void camera_get_aperture_cb(const std::shared_ptr<CameraGetAperture::Request> request, const std::shared_ptr<CameraGetAperture::Response> response)

Get the camera aperture.

Parameters
  • request – CameraGetAperture service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetAperture service response. See enum E_DjiCameraManagerAperture for more details.

void camera_shoot_single_photo_cb(const std::shared_ptr<CameraShootSinglePhoto::Request> request, const std::shared_ptr<CameraShootSinglePhoto::Response> response)

Request shooting single photo. This service sets the camera work mode to DJI_CAMERA_MANAGER_WORK_MODE_SHOOT_PHOTO and the shoot photo mode to DJI_CAMERA_MANAGER_SHOOT_PHOTO_MODE_SINGLE. Then, triggers the start shoot photo method.

Parameters
  • request – CameraShootSinglePhoto service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraShootSinglePhoto service response.

void camera_shoot_burst_photo_cb(const std::shared_ptr<CameraShootBurstPhoto::Request> request, const std::shared_ptr<CameraShootBurstPhoto::Response> response)

Request shooting photos in burst mode. This service sets the camera work mode to DJI_CAMERA_MANAGER_WORK_MODE_SHOOT_PHOTO, the shoot photo mode to DJI_CAMERA_MANAGER_SHOOT_PHOTO_MODE_BURST and sets the desired burst count. Then, triggers the start shoot photo method.

Parameters
  • request – CameraShootBurstPhoto service request. The camera mounted position for which the request is made needs to be specified as well as the burst count. (see enum E_DjiCameraBurstCount).

  • response – CameraShootBurstPhoto service response.

void camera_shoot_interval_photo_cb(const std::shared_ptr<CameraShootIntervalPhoto::Request> request, const std::shared_ptr<CameraShootIntervalPhoto::Response> response)

Request shooting photos at a certain interval. This service sets the camera work mode to DJI_CAMERA_MANAGER_WORK_MODE_SHOOT_PHOTO, the shoot photo mode to DJI_CAMERA_MANAGER_SHOOT_PHOTO_MODE_INTERVAL and sets the desired number of photos to be captured in a desired time interval [s]. count. Then, triggers the start shoot photo method.

Note

The number of pictures to be captured can be set to 1~254. 255 represents to keep capturing until stopping the photo shoot action.

Parameters
  • request – CameraShootIntervalPhoto service request. The camera mounted position for which the request is made needs to be specified as well as the time interval and photo count.

  • response – CameraShootIntervalPhoto service response.

void camera_stop_shoot_photo_cb(const std::shared_ptr<CameraStopShootPhoto::Request> request, const std::shared_ptr<CameraStopShootPhoto::Response> response)

Request stop shooting photos.

Parameters
  • request – CameraStopShootPhoto service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraStopShootPhoto service response.

void camera_record_video_cb(const std::shared_ptr<CameraRecordVideo::Request> request, const std::shared_ptr<CameraRecordVideo::Response> response)

Request to start/stop to record video with a specific camera.This service sets the camera work mode to DJI_CAMERA_MANAGER_WORK_MODE_RECORD_VIDEO and triggers the start record video or the stop record video as desired.

Parameters
  • request – CameraRecordVideo service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraRecordVideo service response.

void camera_get_laser_ranging_info_cb(const std::shared_ptr<CameraGetLaserRangingInfo::Request> request, const std::shared_ptr<CameraGetLaserRangingInfo::Response> response)

Request laser ranging info for specific camera. Unit (m).

Parameters
  • request – CameraGetLaserRangingInfo service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetLaserRangingInfo service response.

void camera_get_focus_ring_range_cb(const std::shared_ptr<CameraGetFocusRingRange::Request> request, const std::shared_ptr<CameraGetFocusRingRange::Response> response)

Request downloading of a file list.

Parameters
  • request – CameraGetFileListInfo service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetFileListInfo service response.

void camera_get_focus_ring_value_cb(const std::shared_ptr<CameraGetFocusRingValue::Request> request, const std::shared_ptr<CameraGetFocusRingValue::Response> response)

Request the range of the focus ring.

Parameters
  • request – CameraGetFocusRingRange service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetFocusRingRange service response.

void camera_set_focus_ring_value_cb(const std::shared_ptr<CameraSetFocusRingValue::Request> request, const std::shared_ptr<CameraSetFocusRingValue::Response> response)

Request downloading of a file list.

Parameters
  • request – CameraGetFocusRingValue service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetFocusRingValue service response.

void camera_get_file_list_info_cb(const std::shared_ptr<CameraGetFileListInfo::Request> request, const std::shared_ptr<CameraGetFileListInfo::Response> response)

Request downloading of a file list.

Parameters
  • request – CameraSetFocusRingValue service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraSetFocusRingValue service response.

void execute_download_file_by_index()

Execute the request of downloading of a file by index.

void camera_format_sd_card_cb(const std::shared_ptr<CameraFormatSdCard::Request> request, const std::shared_ptr<CameraFormatSdCard::Response> response)

Request to format SD card.

Parameters
  • request – CameraFormatSdCard service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraFormatSdCard service response.

void camera_get_sd_storage_info_cb(const std::shared_ptr<CameraGetSDStorageInfo::Request> request, const std::shared_ptr<CameraGetSDStorageInfo::Response> response)

Request SD card storage information.

Parameters
  • request – CameraGetSDStorageInfo service request. The camera mounted position for which the request is made needs to be specified.

  • response – CameraGetSDStorageInfo service response.

void execute_delete_file_by_index()

Execute the request of deleting a file by index.

psdk_interfaces::msg::FileInfo set_file_info(const T_DjiCameraManagerFileListInfo file_info)

Set the file info msg object.

Parameters

file_info – received from the SD card

Returns

psdk_interfaces::msg::FileInfo msg object

std::time_t get_unix_time(const T_DjiCameraManagerFileCreateTime &time)

Get the unix time object.

Parameters

time – Time object as defined by T_DjiCameraManagerFileCreateTime

Returns

std::time_t

psdk_interfaces::msg::FileAttributes set_file_attributes(const T_DjiCameraManagerFileAttributeData &attributes)

Set the file attributes msg.

Parameters

attributes – received file attributes

Returns

psdk_interfaces::msg::FileAttributes file attributes msg

bool write_to_file(const uint8_t *data, uint16_t len)

Write data to a file.

Parameters
  • data – data to be written

  • len – length of data

Returns

true if succedded / false otherwise

bool create_directory(const std::string &path)

Create a directory if it does not exist already.

Parameters

path – path of the directory to be created

Returns

true if succedded / false otherwise

void register_file_data_callback(E_DjiMountPosition index)

Register the callback for downloading files from the sd card.

Parameters

index – camera index

void obtain_downloader_rights(E_DjiMountPosition index)

Obtain the rights to download files from the sd card.

Parameters

index – camera index

void release_downloader_rights(E_DjiMountPosition index)

Release the rights to download files from the sd card.

Parameters

index – camera index