1313
1414std::optional<nav_msgs::msg::Path> backend::create_path (std::vector<cv::Point2d>& left_contours,
1515 std::vector<cv::Point2d>& right_contours,
16- image_geometry::PinholeCameraModel& rgb_info_sub ,
16+ image_geometry::PinholeCameraModel& camera_info ,
1717 std::string_view frame_id) {
1818 // take in contours
1919 // DO NOT THE Polynomials
@@ -30,8 +30,8 @@ std::optional<nav_msgs::msg::Path> backend::create_path(std::vector<cv::Point2d>
3030 std::vector<cv::Point2d> cam_path; // this is the vector of path plannign points in camera space
3131 // ground_path.emplace_back(cv::Point2d(0, 0));
3232
33- int width = rgb_info_sub .fullResolution ().width ; // camera space sizes!
34- int height = rgb_info_sub .fullResolution ().height ; // Camera space sizes!
33+ int width = camera_info .fullResolution ().width ; // camera space sizes!
34+ int height = camera_info .fullResolution ().height ; // Camera space sizes!
3535
3636 bool is_right_valid = true ; // stores if Polynomial was intizatized!
3737 bool is_left_valid = true ; // left and right respectively
@@ -51,11 +51,11 @@ std::optional<nav_msgs::msg::Path> backend::create_path(std::vector<cv::Point2d>
5151 bool is_left_bigger = left_contours.size () > right_contours.size ();
5252
5353 if (is_left_bigger) {
54- bigger_array = cameraPixelToGroundPos (left_contours, rgb_info_sub );
55- smaller_array = cameraPixelToGroundPos (right_contours, rgb_info_sub );
54+ bigger_array = cameraPixelToGroundPos (left_contours, camera_info );
55+ smaller_array = cameraPixelToGroundPos (right_contours, camera_info );
5656 } else {
57- smaller_array = cameraPixelToGroundPos (left_contours, rgb_info_sub );
58- bigger_array = cameraPixelToGroundPos (right_contours, rgb_info_sub );
57+ smaller_array = cameraPixelToGroundPos (left_contours, camera_info );
58+ bigger_array = cameraPixelToGroundPos (right_contours, camera_info );
5959 }
6060
6161 for (int i = 0 ; i < smaller_array.size (); i++) {
@@ -89,7 +89,7 @@ std::optional<nav_msgs::msg::Path> backend::create_path(std::vector<cv::Point2d>
8989
9090 // convert from camera to ground
9191 // done further ahead already
92- // std::vector<cv::Point2d> ground_path = cameraPixelToGroundPos(cam_path, rgb_info_sub );
92+ // std::vector<cv::Point2d> ground_path = cameraPixelToGroundPos(cam_path, camera_info );
9393
9494 nav_msgs::msg::Path msg{};
9595 // msg.header.frame_id = frame;
@@ -162,59 +162,3 @@ std::vector<cv::Point2d> backend::cameraPixelToGroundPos(std::vector<cv::Point2d
162162
163163 return rwpoints;
164164}
165-
166- // // why are the pointer things the way they are
167- // // TODO: make it not die when z is too small
168- // // or make z not too small
169- // std::vector<cv::Point2d> backend::cameraPixelToGroundPos(std::vector<cv::Point2d>& pixels,
170- // image_geometry::PinholeCameraModel rgb_info_sub, int i) {
171- // // Rotation that rotates left 90 and backwards 90.
172- // // This converts from camera coordinates in OpenCV to ROS coordinates
173- // tf2::Quaternion optical_to_ros{};
174- // // set the Roll Pitch YAW
175- // /// optical_to_ros.setRPY(0.0, 0.0, 0.0);
176- // optical_to_ros.setRPY(-M_PI / 2, 0.0, -M_PI / 2);
177-
178- // std::vector<cv::Point2d> rwpoints;
179- // const double camera_height = 0.6; // meters
180-
181- // for (cv::Point2d& pixel : pixels) {
182- // // gotta rectify the pixel before we raycast
183- // // pixel.y += 120;
184- // // pixel.x += 320;
185- // // cv::Point2d rectPixel = rgb_info_sub.rectifyPoint(pixel);
186- // cv::Point3d ray = rgb_info_sub.projectPixelTo3dRay(pixel);
187-
188- // // safety check
189- // if (fabs(ray.y) < 1e-6) { // Near zero check
190- // // RCLCPP_WARN(rclcpp::get_logger("backend"), "Invalid ray projection (y near zero)");
191- // continue; // Skip this point
192- // }
193-
194- // // -- CAMERA COORDINATES --
195- // // positive x = +X TO CAMERA
196- // // positive y = STRAIGHT TO GROUND
197- // // positive z = OUT OF CAMERA
198- // // hopefully
199-
200- // // ask zach for the trig, extend ray to the floor.
201- // double divisor = ray.y / camera_height; // divide by how high off the ground the camera is!
202- // ray.x = ray.x / divisor;
203- // ray.y = ray.y / divisor;
204- // ray.z = ray.z / divisor;
205- // // ray /= ray.z / -0.6;
206- // // ray.z = (ray.z * -1); // we don't really care abt z, since it -will- *should* always just be cameraHeight
207- // // tf2::Vector3 tf_vec{ray.z, -ray.x, -ray.y};
208- // tf2::Vector3 tf_vec{ray.x, ray.y, ray.z};
209- // tf_vec = tf2::quatRotate(optical_to_ros, tf_vec);
210-
211- // //return type world_vec, use this is
212-
213- // cv::Point2d dvector(tf_vec.x(), tf_vec.y());
214-
215- // // push back vectors
216- // rwpoints.push_back(dvector);
217- // }
218-
219- // return rwpoints;
220- // }
0 commit comments