Skip to content

Commit 9ce56eb

Browse files
author
alireza@general
committed
feat: individual camera info for each vga camera
1 parent 6e1af60 commit 9ce56eb

4 files changed

Lines changed: 48 additions & 2 deletions

File tree

include/dji_osdk_ros_obsoleted/dji_sdk/dji_sdk_node.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ class DJISDKNode
231231
bool setupCameraStreamCallback(dji_osdk_ros::SetupCameraStream::Request& request,
232232
dji_osdk_ros::SetupCameraStream::Response& response);
233233
void publishCameraInfo(const std_msgs::Header &header);
234+
235+
sensor_msgs::CameraInfo getCameraInfo(int camera_select);
234236
#endif
235237

236238
//! data broadcast callback

src/dji_osdk_ros/dji_vehicle_node.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ bool VehicleNode::getM300StereoParamsCallback(dji_osdk_ros::GetM300StereoParams:
946946
Vehicle* vehicle = ptr_wrapper_->getVehicle();
947947
M300StereoParamTool *tool = new M300StereoParamTool(vehicle);
948948
Perception::CamParamType stereoParam =
949-
tool->getM300stereoParams(Perception::DirectionType::RECTIFY_FRONT);
949+
tool->getM300stereoParams(Perception::DirectionType::RECTIFY_LEFT);
950950
if (tool->createStereoParamsYamlFile(M300_FRONT_STEREO_PARAM_YAML_NAME, stereoParam))
951951
{
952952
tool->setParamFileForM300(M300_FRONT_STEREO_PARAM_YAML_NAME);

src/dji_osdk_ros/modules/stereo_utility/m300_stereo_param_tool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void M300StereoParamTool::PerceptionCamParamCB(
5151
if ((pack.directionNum > 0) && (pack.directionNum <= IMAGE_MAX_DIRECTION_NUM))
5252
for (int i = 0; i < pack.directionNum; i++) {
5353
if ((userData)
54-
&& (pack.cameraParam[i].direction == Perception::RECTIFY_FRONT)) {
54+
&& (pack.cameraParam[i].direction == Perception::RECTIFY_LEFT)) {
5555
auto camParam = (Perception::CamParamType *) userData;
5656
*camParam = pack.cameraParam[i];
5757
}

src/dji_osdk_ros_obsoleted/modules/dji_sdk_node_publisher.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,50 @@ void DJISDKNode::alignRosTimeWithFlightController(ros::Time now_time, uint32_t t
792792
}
793793

794794
#ifdef ADVANCED_SENSING
795+
796+
sensor_msgs::CameraInfo DJISDKNode::getCameraInfo(int camera_select)
797+
{
798+
sensor_msgs::CameraInfo cam_info;
799+
800+
cam_info.width = 640;
801+
cam_info.height = 480;
802+
803+
cam_info.distortion_model = "plumb_bob";
804+
805+
cam_info.D = std::vector<double>(5,0.0);
806+
807+
switch(camera_select)
808+
{
809+
//front camera
810+
case 1:
811+
{
812+
cam_info.K = {407.1327819824219, 0, 321.8077392578125, 0.0, 407.1327819824219, 236.9904937744141, 0.0, 0.0, 1.0};
813+
cam_info.R = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
814+
cam_info.P = {407.1327819824219, 0, 321.8077392578125, -116.0410842895508, 0.0, 407.1327819824219, 236.9904937744141, 0.0, 0.0, 0.0, 1.0, 0.0};
815+
break;
816+
}
817+
//left camera
818+
case 2:
819+
{
820+
cam_info.K = {488.5599365234375, 0.0, 319.80328369140625, 0.0, 488.5599365234375, 239.97528076171875, 0.0, 0.0, 1.0};
821+
cam_info.R = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
822+
cam_info.P = {488.5599365234375, 0.0, 319.80328369140625, -99.43592071533203, 0.0, 488.5599365234375, 239.97528076171875, 0.0, 0.0, 0.0, 1.0, 0.0};
823+
break;
824+
}
825+
//up camera
826+
case 6:
827+
{
828+
cam_info.K = {405.4823913574219, 0.0, 322.5506896972656, 0.0, 405.4823913574219, 240.0494689941406, 0.0, 0.0, 1.0};
829+
cam_info.R = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
830+
cam_info.P = {405.4823913574219, 0.0, 322.5506896972656, 0.0, 0.0, 405.4823913574219, 240.0494689941406, 96.79345703125, 0.0, 0.0, 1.0, 0.0};
831+
break;
832+
}
833+
}
834+
835+
836+
return cam_info;
837+
}
838+
795839
void DJISDKNode::publishCameraInfo(const std_msgs::Header &header)
796840
{
797841
static bool isFirstTime = true;

0 commit comments

Comments
 (0)