From 1bdadaa50f5ca4ade4911d516298f403152c74ad Mon Sep 17 00:00:00 2001 From: Yohan Simard Date: Tue, 2 Mar 2021 18:39:32 +0100 Subject: [PATCH] Add preprocessor definition for simulation --- .../raspberry/superviseur-robot/.gitignore | 2 +- .../superviseur-robot/CMakeLists.txt | 1 + .../raspberry/superviseur-robot/lib/camera.h | 64 +++++++++---------- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/software/raspberry/superviseur-robot/.gitignore b/software/raspberry/superviseur-robot/.gitignore index 64e3d1f..0c50011 100644 --- a/software/raspberry/superviseur-robot/.gitignore +++ b/software/raspberry/superviseur-robot/.gitignore @@ -1,6 +1,6 @@ build/ src.sav/ -cmake-build-debug/ +cmake-build-*/ futur/ CMakeFiles/ diff --git a/software/raspberry/superviseur-robot/CMakeLists.txt b/software/raspberry/superviseur-robot/CMakeLists.txt index 2396d6e..8c9390e 100644 --- a/software/raspberry/superviseur-robot/CMakeLists.txt +++ b/software/raspberry/superviseur-robot/CMakeLists.txt @@ -27,6 +27,7 @@ add_library(lib ) target_include_directories(lib PUBLIC lib) target_link_libraries(lib base64) +target_compile_definitions(lib PUBLIC __FOR_PC__ __SIMULATION__ __WITH_ARUCO__) # Compile main executable add_executable(main main.cpp tasks.cpp tasks.h) diff --git a/software/raspberry/superviseur-robot/lib/camera.h b/software/raspberry/superviseur-robot/lib/camera.h index fc99f4a..2fe7c68 100644 --- a/software/raspberry/superviseur-robot/lib/camera.h +++ b/software/raspberry/superviseur-robot/lib/camera.h @@ -22,8 +22,7 @@ #include #ifndef __FOR_PC__ -// TODO install raspicam and uncomment -//#include "raspicam/raspicam_cv.h" +#include "raspicam/raspicam_cv.h" #endif /* __FOR_PC__ */ #include "img.h" @@ -81,39 +80,38 @@ public: * @return true if camera is open, false otherwise */ bool IsOpen(); - - /** - * Define size for sampled picture - * @param size Size of picture (@see captureSize) - */ - void SetSize(int size); - /** - * Grab next image from camera - * @return Image taken from camera - */ - Img Grab(); - + /** + * Define size for sampled picture + * @param size Size of picture (@see captureSize) + */ + void SetSize(int size); + + /** + * Grab next image from camera + * @return Image taken from camera + */ + Img Grab(); + private: -// TODO install raspicam and uncomment -//#ifdef __FOR_PC__ -// /** -// * Camera descriptor -// */ -// cv::VideoCapture cap; -//#else -// raspicam::RaspiCam_Cv cap; -//#endif /* __FOR_PC__ */ - - /** - * Size for image (default= small) - */ - int size = sm; - - /** - * Width of image - */ - int width; +#ifdef __FOR_PC__ + /** + * Camera descriptor + */ + cv::VideoCapture cap; +#else + raspicam::RaspiCam_Cv cap; +#endif /* __FOR_PC__ */ + + /** + * Size for image (default= small) + */ + int size = sm; + + /** + * Width of image + */ + int width; /** * Height of image