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

Sequential step noetic #8

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
945d0a8
fix catkin, separate plane_seg_ros app and lib
Dec 8, 2020
a21b697
putting code from rosbag_pass into plane_seg_ros
ChristosIoannou Dec 14, 2020
77ec326
make function stepThroughFile accept filename as argument
ChristosIoannou Dec 14, 2020
fdb58ab
add config launch
Dec 14, 2020
c093831
change the param name to rosbag_path. read it when needed
Dec 14, 2020
07f6b8e
rviz node to view results
ChristosIoannou Dec 14, 2020
86f1bb8
printing centroids
ChristosIoannou Jan 6, 2021
728429d
moving tracking to Tracker.cpp (1)
ChristosIoannou Jan 10, 2021
0113ffe
moving tracker into Tracker.cpp (2)
ChristosIoannou Jan 10, 2021
1cabb63
Moving tracker to Tracker.cpp (3)
ChristosIoannou Jan 10, 2021
0f939fc
the internal algorithms of a Visualiser
ChristosIoannou Jan 12, 2021
d97043e
remove qtcreator project files from versioning
Jan 12, 2021
7f0c697
ignore qtcreator project files for the future
Jan 12, 2021
857d6a6
fix compilation issues (see comments for details)
Jan 12, 2021
493b50d
Tracker fixes
ChristosIoannou Jan 12, 2021
06ad146
completing functions for tracker
ChristosIoannou Jan 13, 2021
c6491b7
displayString to change id to string within function
ChristosIoannou Jan 13, 2021
80d93c6
fixed printIds
ChristosIoannou Jan 13, 2021
bdc0d4b
remove test() from Tracker
ChristosIoannou Jan 13, 2021
ccfcac9
print entrance lines to trace code
ChristosIoannou Jan 13, 2021
d7a7a45
debugging
ChristosIoannou Jan 14, 2021
f049778
Tracker working - show ids as numbers
ChristosIoannou Jan 14, 2021
569b51f
display markers at centroids
ChristosIoannou Jan 15, 2021
90492df
tracker and visualiser working
ChristosIoannou Jan 15, 2021
e2860ec
tracker and visualizer cleanup
ChristosIoannou Jan 16, 2021
7fa8930
trace centroids through time
ChristosIoannou Jan 16, 2021
8ee2d63
functionality to process nth cloud
ChristosIoannou Jan 20, 2021
efafa6b
display gridmap as image and provide option to save and erode
ChristosIoannou Jan 21, 2021
12d8292
image processor class
ChristosIoannou Jan 22, 2021
6651c6a
cleaning up includes
ChristosIoannou Jan 22, 2021
fe50fca
cleanup includes so it compiles
Jan 22, 2021
7d10e5b
removed plane_seg dependency on ros and full include cleanup
ChristosIoannou Jan 23, 2021
e39b3d5
integration of filter chain
ChristosIoannou Jan 25, 2021
d689e41
pass filtered grid_map to elevationMapCallback
ChristosIoannou Jan 25, 2021
d4a8e99
move rviz config for filters to plane_seg_ros
ChristosIoannou Jan 26, 2021
1c0a0ef
find and create the folder for image processor if it does not exist
Jan 26, 2021
134ff49
fix typo in launch
Jan 26, 2021
774ef51
improve initial prinitng
Jan 26, 2021
1a2cdda
use a copy of the other rviz config as placeholder for the real one
Jan 26, 2021
891419a
move filters config to plane_seg_ros
ChristosIoannou Jan 26, 2021
9d5c20f
get a reference of the node instead of copying it
Jan 26, 2021
8642970
no need to use a pointer to the tf listener
Jan 26, 2021
d21245c
print more checks and put the filters under the same namespace
Jan 26, 2021
8f03128
visualize point clouds and exit cleanly from the program
Jan 26, 2021
835f9d6
relative param, return 0 when the program ends
Jan 26, 2021
49502f5
morphological filtering of gridmap image and then remove small blobs
ChristosIoannou Feb 1, 2021
dcc58d7
created new layer with processed gridmap and used to mask elevation l…
ChristosIoannou Feb 8, 2021
15c2ac0
added rectangle fitting function to image processor
ChristosIoannou Feb 9, 2021
910fdcf
convert gridmap to floating point cvimage
ChristosIoannou Feb 11, 2021
5268a7e
StepCreator to recreate steps in rviz from cv image
ChristosIoannou Feb 16, 2021
6437f79
3 algorithms working with visualization in rviz
ChristosIoannou Feb 23, 2021
1a508e0
choose algorithm as a parameter + cleanup
ChristosIoannou Feb 24, 2021
4d2dd7f
implemented tracker to track rectangles from algorithm C
ChristosIoannou Feb 24, 2021
abb6564
final cleanup of parameter and launch files for easy interface
ChristosIoannou Mar 10, 2021
cbdda48
modifications to extract info about step properties
ChristosIoannou Apr 6, 2021
d0257f9
add config files to visualise elevation map on rooster
Apr 7, 2021
b170c1f
go back to filter_chain.h for melodic compatibility
Apr 7, 2021
537e2e2
take minimum bounding rectangle instead of convex hulls
ChristosIoannou Apr 21, 2021
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CMakeLists.txt.user
15 changes: 12 additions & 3 deletions plane_seg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ find_package(catkin REQUIRED COMPONENTS
pcl_ros
)

find_package(OpenCV REQUIRED)
find_package(OpenCV REQUIRED COMPONENTS core highgui imgproc imgcodecs features2d)

catkin_package(
INCLUDE_DIRS
Expand All @@ -34,9 +34,14 @@ add_library(${LIB_NAME} SHARED
src/PlaneSegmenter.cpp
src/RectangleFitter.cpp
src/BlockFitter.cpp
src/Tracker.cpp
src/ImageProcessor.cpp
src/StepCreator.cpp
src/Tracker2D.cpp
)
add_dependencies(plane_seg ${catkin_EXPORTED_TARGETS})
target_link_libraries(plane_seg ${catkin_LIBRARIES})
target_link_libraries(plane_seg ${OpenCV_LIBRARIES})


# standalone lcm-based block fitter
Expand All @@ -63,5 +68,9 @@ install(TARGETS plane_seg
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})

# Mark header files for installation
install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})

install(TARGETS block_fitter plane_seg_test plane_seg_test2
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

35 changes: 35 additions & 0 deletions plane_seg/config/rooster_elevation_mapping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
point_cloud_topic: "/camera/depth/color/points"
map_frame_id: "odom"
sensor_frame_id: "ground_camera_depth_optical_frame"
robot_base_frame_id: "base"
robot_pose_with_covariance_topic: "/vilens/pose_optimized"
robot_pose_cache_size: 500
track_point_frame_id: "base"
track_point_x: 0.0
track_point_y: 0.0
track_point_z: 0.0


# Robot.

min_update_rate: 0.5
time_tolerance: 0.5
time_offset_for_point_cloud: 0.0
sensor_processor/ignore_points_above: 0.4
robot_motion_map_update/covariance_scale: 0.01

# Map.
length_in_x: 10.0
length_in_y: 4.0
position_x: 0.0
position_y: 0.0
resolution: 0.02
min_variance: 0.0001
max_variance: 0.05
mahalanobis_distance_threshold: 2.5
multi_height_noise: 0.001
surface_normal_positive_axis: z
fused_map_publishing_rate: 0.5
enable_visibility_cleanup: false
visibility_cleanup_rate: 1.0
scanning_duration: 1.0
83 changes: 83 additions & 0 deletions plane_seg/include/plane_seg/ImageProcessor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#pragma once
#include <cv_bridge/cv_bridge.h>

namespace planeseg {
/*
struct colour{
double r;
double g;
double b;
};
*/
struct contours{
std::vector<std::vector<cv::Point>> contours_;
std::vector<std::vector<cv::Point>> contours_rect_;
void filterSmallContours();
void filterMinConvexity(int min_convexity);
void filterMinElongation(int min_elongation);
void filterMinRectangularity(int min_rectangularity);
void fitMinAreaRect();
void approxAsPoly();
void fitSquare();
bool isSquare(std::vector<cv::Point> contour_);
void print(std::vector<double> property);
std::vector<double> elongations_;
std::vector<double> convexities_;
std::vector<double> rectangularities_;

/*
void setColors();
void assignColors();
void assignIDs();
double getR(int id);
double getG(int id);
double getB(int id);
std::vector<colour> contour_colours_;
std::vector<int> ids;
std::vector<double> colors_;
*/
};

class ImageProcessor {
public:
ImageProcessor();
~ImageProcessor();

void process();
void copyOrigToProc();
void displayImage(std::string process, cv::Mat img, int n = 0);
void saveImage(cv::Mat image);
void erodeImage(int erode_size);
void thresholdImage(float threshold_value);
void dilateImage(int dilate_size);
void blobDetector(cv_bridge::CvImage image);
void removeBlobs(cv_bridge::CvImage image);
void extractContours();
void fillContours();
void splitContours();
void mergeContours();
void drawContoursIP(contours contour, std::string process, int n = 0);
void displayResult();
void reset();
void histogram(cv_bridge::CvImage img);
cv::Mat createMask(cv_bridge::CvImage img);
cv_bridge::CvImage original_img_;
cv_bridge::CvImage processed_img_;
cv_bridge::CvImage rect_img_;
cv_bridge::CvImage final_img_;
cv_bridge::CvImage colour_img_;

contours all_contours_;
contours large_contours_;
contours med_contours_;

std::vector<double> ip_elongations_;
std::vector<double> ip_convexities_;
std::vector<double> ip_rectangularities_;

private:

};

} //namespace planeseg

38 changes: 38 additions & 0 deletions plane_seg/include/plane_seg/StepCreator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once
#include <cv_bridge/cv_bridge.h>

namespace planeseg {

struct contour{
std::vector<cv::Point> points_;
double elevation_;
int id_;
};


class StepCreator{

public:
StepCreator();
~StepCreator();

void go();
void setImages(cv_bridge::CvImage img1, cv_bridge::CvImage img2);
void extractContours();
void displayImage(std::string process, cv::Mat img, int n);
void maskElevation(cv::Mat mask_);
void reset();
double medianMat(cv::Mat Input);
cv::Mat createMask(contour cntr);
cv_bridge::CvImage processed_;
cv_bridge::CvImage elevation_;
cv_bridge::CvImage elevation_masked_;
cv_bridge::CvImage reconstructed_;
std::vector<contour> rectangles_;
std::vector<std::vector<cv::Point>> pnts_;

private:

};

} // namespace planeseg
40 changes: 40 additions & 0 deletions plane_seg/include/plane_seg/Tracker.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include "plane_seg/BlockFitter.hpp"

namespace planeseg {

struct plane {
pcl::PointCloud<pcl::PointXYZ> cloud;
int id;
pcl::PointXYZ centroid;
};

// a vector to hold the ids of oldStairs and a flag for whether the id has been assigned
struct IdAssigned{
bool taken;
int id;
};

class Tracker3D {
public:
Tracker3D();
~Tracker3D();

int get_plane_id(planeseg::plane plane_);
pcl::PointXYZ find_centroid(pcl::PointCloud<pcl::PointXYZ> cloud );
void reset();
void convertResult(planeseg::BlockFitter::Result result);
void test(planeseg::BlockFitter::Result result);
void printIds();
std::vector<plane> newStairs;

private:

std::vector<plane> oldStairs;
std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> cloud_ptrs;
int totalIds;
};

} // namespace planeseg
28 changes: 28 additions & 0 deletions plane_seg/include/plane_seg/Tracker2D.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include "plane_seg/BlockFitter.hpp"
#include "plane_seg/StepCreator.hpp"

namespace planeseg {

class Tracker2D {
public:
Tracker2D();
~Tracker2D();

int get_contour_id(contour contour);
pcl::PointXYZ find_centroid(pcl::PointCloud<pcl::PointXYZ> cloud );
void reset();
void assignIDs(std::vector<contour> contours);
void printIds();
std::vector<contour> newRects_;

private:

std::vector<contour> oldRects_;
std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> cloud_ptrs;
int totalIds;
};

} // namespace planeseg
4 changes: 2 additions & 2 deletions plane_seg/include/plane_seg/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace planeseg {

/*
/*
struct Point {
PCL_ADD_POINT4D;
float delta;
Expand All @@ -23,7 +23,7 @@ POINT_CLOUD_REGISTER_POINT_STRUCT(Point,
(float, delta, delta)
(int, label, label)
)
*/
*/
typedef pcl::PointXYZL Point;

typedef pcl::PointCloud<pcl::Normal> NormalCloud;
Expand Down
4 changes: 2 additions & 2 deletions plane_seg/src/BlockFitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ go() {
results.push_back(result);
}

if (mDebug) {
if (true) { // Used to be mDebug
std::ofstream ofs("boxes.txt");
for (int i = 0; i < (int)results.size(); ++i) {
auto& res = results[i];
Expand Down Expand Up @@ -383,7 +383,7 @@ go() {
block.mPose = res.mPose;
block.mPose.translation() -=
block.mPose.rotation().col(2)*mBlockDimensions[2]/2;
block.mHull = res.mConvexHull;
block.mHull = res.mPolygon; // USED TO BE res.mConvexHull
result.mBlocks.push_back(block);
}
if (mDebug) {
Expand Down
Loading