Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing distortion model information #101

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ElevationMappingWrapper {
void input(const RowMatrixXd& points, const std::vector<std::string>& channels, const RowMatrixXd& R, const Eigen::VectorXd& t,
const double positionNoise, const double orientationNoise);
void input_image(const std::vector<ColMatrixXf>& multichannel_image, const std::vector<std::string>& channels, const RowMatrixXd& R,
const Eigen::VectorXd& t, const RowMatrixXd& cameraMatrix, const Eigen::VectorXd& D, int height, int width);
const Eigen::VectorXd& t, const RowMatrixXd& cameraMatrix, const Eigen::VectorXd& D, const std::string distortion_model, int height, int width);
void move_to(const Eigen::VectorXd& p, const RowMatrixXd& R);
void clear();
void update_variance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ def input_image(
t: cp._core.core.ndarray,
K: cp._core.core.ndarray,
D: cp._core.core.ndarray,
distortion_model: str,
image_height: int,
image_width: int,
):
Expand Down Expand Up @@ -512,6 +513,18 @@ def input_image(
else:
D = D[:5]

if distortion_model == "radtan":
pass
elif distortion_model == "equidistant":
# Not implemented yet.
D *= 0
elif distortion_model == "plumb_bob":
# Not implemented yet.
D *= 0
else:
# Not implemented yet.
D *= 0

# Calculate transformation matrix
P = cp.asarray(K @ cp.concatenate([R, t[:, None]], 1), dtype=np.float32)
t_cam_map = -R.T @ t - self.center
Expand Down
5 changes: 4 additions & 1 deletion elevation_mapping_cupy/src/elevation_mapping_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ void ElevationMappingNode::inputImage(const sensor_msgs::ImageConstPtr& image_ms
distortionCoeffs = Eigen::VectorXd::Zero(5);
// return;
}

// distortion model
std::string distortion_model = camera_info_msg->distortion_model;

// Get pose of sensor in map frame
tf::StampedTransform transformTf;
Expand Down Expand Up @@ -439,7 +442,7 @@ void ElevationMappingNode::inputImage(const sensor_msgs::ImageConstPtr& image_ms

// Pass image to pipeline
map_.input_image(multichannel_image, channels, transformationMapToSensor.rotation(), transformationMapToSensor.translation(), cameraMatrix,
distortionCoeffs, image.rows, image.cols);
distortionCoeffs, distortion_model, image.rows, image.cols);
}

void ElevationMappingNode::imageCallback(const sensor_msgs::ImageConstPtr& image_msg,
Expand Down
4 changes: 2 additions & 2 deletions elevation_mapping_cupy/src/elevation_mapping_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ void ElevationMappingWrapper::input(const RowMatrixXd& points, const std::vector
}

void ElevationMappingWrapper::input_image(const std::vector<ColMatrixXf>& multichannel_image, const std::vector<std::string>& channels, const RowMatrixXd& R,
const Eigen::VectorXd& t, const RowMatrixXd& cameraMatrix, const Eigen::VectorXd& D, int height, int width) {
const Eigen::VectorXd& t, const RowMatrixXd& cameraMatrix, const Eigen::VectorXd& D, const std::string distortion_model, int height, int width) {
py::gil_scoped_acquire acquire;
map_.attr("input_image")(multichannel_image, channels, Eigen::Ref<const RowMatrixXd>(R), Eigen::Ref<const Eigen::VectorXd>(t),
Eigen::Ref<const RowMatrixXd>(cameraMatrix), Eigen::Ref<const Eigen::VectorXd>(D), height, width);
Eigen::Ref<const RowMatrixXd>(cameraMatrix), Eigen::Ref<const Eigen::VectorXd>(D), distortion_model, height, width);
}

void ElevationMappingWrapper::move_to(const Eigen::VectorXd& p, const RowMatrixXd& R) {
Expand Down
Loading