Class CameraModule
Defined in File camera.hpp
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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
-
explicit CameraModule(const std::string &name)