Skip to content
Snippets Groups Projects
Commit 5a30638c authored by Joan Solà Ortega's avatar Joan Solà Ortega
Browse files

New macro GET_WOLF_ROOT

This loads the WOLF_ROOT environment variable to the local set of
variables.
parent a0a6c96b
No related branches found
No related tags found
No related merge requests found
...@@ -16,8 +16,8 @@ int main() ...@@ -16,8 +16,8 @@ int main()
char const* tmp = std::getenv( "WOLF_ROOT" ); char const* tmp = std::getenv( "WOLF_ROOT" );
if ( tmp == nullptr ) if ( tmp == nullptr )
throw std::runtime_error("WOLF_ROOT environment not loaded."); throw std::runtime_error("WOLF_ROOT environment not loaded.");
std::string wolf_path( tmp ); std::string wolf_root( tmp );
std::cout << "Wolf path: " << wolf_path << std::endl; std::cout << "Wolf root: " << wolf_root << std::endl;
// Wolf problem // Wolf problem
ProblemPtr wolf_problem_ptr_ = Problem::create(FRM_PO_3D); ProblemPtr wolf_problem_ptr_ = Problem::create(FRM_PO_3D);
...@@ -35,12 +35,12 @@ int main() ...@@ -35,12 +35,12 @@ int main()
const Eigen::VectorXs extr = extrinsic_cam; const Eigen::VectorXs extr = extrinsic_cam;
/* Do this while there aren't extrinsic parameters on the yaml */ /* Do this while there aren't extrinsic parameters on the yaml */
SensorBasePtr sensor_ptr = wolf_problem_ptr_->installSensor("CAMERA", "PinHole", extr, wolf_path + "/src/examples/camera_params.yaml"); SensorBasePtr sensor_ptr = wolf_problem_ptr_->installSensor("CAMERA", "PinHole", extr, wolf_root + "/src/examples/camera_params.yaml");
std::shared_ptr<SensorCamera> camera_ptr_ = std::static_pointer_cast<SensorCamera>(sensor_ptr); std::shared_ptr<SensorCamera> camera_ptr_ = std::static_pointer_cast<SensorCamera>(sensor_ptr);
// PROCESSOR // PROCESSOR
// one-liner API // one-liner API
wolf_problem_ptr_->installProcessor("IMAGE LANDMARK", "ORB", "PinHole", wolf_path + "/src/examples/processor_image_ORB.yaml"); wolf_problem_ptr_->installProcessor("IMAGE LANDMARK", "ORB", "PinHole", wolf_root + "/src/examples/processor_image_ORB.yaml");
// create the current frame // create the current frame
......
...@@ -70,8 +70,8 @@ int main(int argc, char** argv) ...@@ -70,8 +70,8 @@ int main(int argc, char** argv)
if ( tmp == nullptr ) if ( tmp == nullptr )
throw std::runtime_error("WOLF_ROOT environment not loaded."); throw std::runtime_error("WOLF_ROOT environment not loaded.");
std::string wolf_path( tmp ); std::string wolf_root( tmp );
std::cout << "Wolf path: " << wolf_path << std::endl; std::cout << "Wolf root: " << wolf_root << std::endl;
ProblemPtr wolf_problem_ = Problem::create(FRM_PO_3D); ProblemPtr wolf_problem_ = Problem::create(FRM_PO_3D);
...@@ -134,14 +134,14 @@ int main(int argc, char** argv) ...@@ -134,14 +134,14 @@ int main(int argc, char** argv)
// SENSOR // SENSOR
// one-liner API // one-liner API
SensorBasePtr sensor_ptr = wolf_problem_->installSensor("CAMERA", "PinHole", Eigen::VectorXs::Zero(7), wolf_path + "/src/examples/camera_params.yaml"); SensorBasePtr sensor_ptr = wolf_problem_->installSensor("CAMERA", "PinHole", Eigen::VectorXs::Zero(7), wolf_root + "/src/examples/camera_params.yaml");
shared_ptr<SensorCamera> camera_ptr = static_pointer_cast<SensorCamera>(sensor_ptr); shared_ptr<SensorCamera> camera_ptr = static_pointer_cast<SensorCamera>(sensor_ptr);
camera_ptr->setImgWidth(img_width); camera_ptr->setImgWidth(img_width);
camera_ptr->setImgHeight(img_height); camera_ptr->setImgHeight(img_height);
// PROCESSOR // PROCESSOR
// one-liner API // one-liner API
ProcessorImageFeature::Ptr prc_img_ptr = std::static_pointer_cast<ProcessorImageFeature>( wolf_problem_->installProcessor("IMAGE FEATURE", "ORB", "PinHole", wolf_path + "/src/examples/processor_image_ORB.yaml") ); ProcessorImageFeature::Ptr prc_img_ptr = std::static_pointer_cast<ProcessorImageFeature>( wolf_problem_->installProcessor("IMAGE FEATURE", "ORB", "PinHole", wolf_root + "/src/examples/processor_image_ORB.yaml") );
prc_img_ptr->setup(camera_ptr); prc_img_ptr->setup(camera_ptr);
std::cout << "sensor & processor created and added to wolf problem" << std::endl; std::cout << "sensor & processor created and added to wolf problem" << std::endl;
//===================================================== //=====================================================
......
...@@ -66,15 +66,15 @@ int main(int argc, char** argv) ...@@ -66,15 +66,15 @@ int main(int argc, char** argv)
//===================================================== //=====================================================
//===================================================== // //=====================================================
// Environment variable for configuration files // // Environment variable for configuration files
char const* tmp = std::getenv( "WOLF_ROOT" ); // char const* tmp = std::getenv( "WOLF_ROOT" );
if ( tmp == nullptr ) // if ( tmp == nullptr )
throw std::runtime_error("WOLF_ROOT environment not loaded."); // throw std::runtime_error("WOLF_ROOT environment not loaded.");
std::string wolf_path( tmp ); // std::string wolf_root( tmp );
std::cout << "Wolf path: " << wolf_path << std::endl; // std::cout << "Wolf root: " << wolf_root << std::endl;
//===================================================== // //=====================================================
GET_WOLF_ROOT
//===================================================== //=====================================================
...@@ -82,16 +82,16 @@ int main(int argc, char** argv) ...@@ -82,16 +82,16 @@ int main(int argc, char** argv)
ProblemPtr wolf_problem_ptr_ = Problem::create(FRM_PO_3D); ProblemPtr wolf_problem_ptr_ = Problem::create(FRM_PO_3D);
// CAMERA SENSOR // CAMERA SENSOR
SensorBasePtr sensor_ptr = wolf_problem_ptr_->installSensor("CAMERA", "PinHole", (Vector7s()<<0,0,0,0,0,0,1).finished(), wolf_path + "/src/examples/camera_params.yaml"); SensorBasePtr sensor_ptr = wolf_problem_ptr_->installSensor("CAMERA", "PinHole", (Vector7s()<<0,0,0,0,0,0,1).finished(), wolf_root + "/src/examples/camera_params.yaml");
SensorCamera::Ptr camera_ptr = std::static_pointer_cast<SensorCamera>(sensor_ptr); SensorCamera::Ptr camera_ptr = std::static_pointer_cast<SensorCamera>(sensor_ptr);
camera_ptr->setImgWidth(img_width); camera_ptr->setImgWidth(img_width);
camera_ptr->setImgHeight(img_height); camera_ptr->setImgHeight(img_height);
// IMAGE PROCESSOR // IMAGE PROCESSOR
wolf_problem_ptr_->installProcessor("IMAGE LANDMARK", "ORB", "PinHole", wolf_path + "/src/examples/processor_image_ORB.yaml"); wolf_problem_ptr_->installProcessor("IMAGE LANDMARK", "ORB", "PinHole", wolf_root + "/src/examples/processor_image_ORB.yaml");
// ODOM SENSOR AND PROCESSOR // ODOM SENSOR AND PROCESSOR
SensorBasePtr sen_ptr = wolf_problem_ptr_->installSensor("ODOM 3D", "odom", (Vector7s()<<0,0,0,0,0,0,1).finished(), wolf_path + "/src/examples/odom_3D.yaml"); SensorBasePtr sen_ptr = wolf_problem_ptr_->installSensor("ODOM 3D", "odom", (Vector7s()<<0,0,0,0,0,0,1).finished(), wolf_root + "/src/examples/odom_3D.yaml");
ProcessorBasePtr prc_ptr = wolf_problem_ptr_->installProcessor("ODOM 3D", "odometry integrator", "odom"); ProcessorBasePtr prc_ptr = wolf_problem_ptr_->installProcessor("ODOM 3D", "odometry integrator", "odom");
SensorOdom3D::Ptr sen_odo_ptr = std::static_pointer_cast<SensorOdom3D>(sen_ptr); SensorOdom3D::Ptr sen_odo_ptr = std::static_pointer_cast<SensorOdom3D>(sen_ptr);
//===================================================== //=====================================================
......
...@@ -31,14 +31,15 @@ int main (int argc, char** argv) ...@@ -31,14 +31,15 @@ int main (int argc, char** argv)
{ {
cout << "\n========= Test ProcessorOdom3D ===========" << endl; cout << "\n========= Test ProcessorOdom3D ===========" << endl;
//===================================================== // //=====================================================
// Environment variable for configuration files // // Environment variable for configuration files
char const* tmp = std::getenv( "WOLF_ROOT" ); // char const* tmp = std::getenv( "WOLF_ROOT" );
if ( tmp == nullptr ) // if ( tmp == nullptr )
throw std::runtime_error("WOLF_ROOT environment not loaded."); // throw std::runtime_error("WOLF_ROOT environment not loaded.");
std::string wolf_path( tmp ); // std::string wolf_root( tmp );
std::cout << "Wolf path: " << wolf_path << std::endl; // std::cout << "Wolf root: " << wolf_root << std::endl;
//===================================================== // //=====================================================
GET_WOLF_ROOT
TimeStamp tf; TimeStamp tf;
...@@ -54,7 +55,7 @@ int main (int argc, char** argv) ...@@ -54,7 +55,7 @@ int main (int argc, char** argv)
ProblemPtr problem = Problem::create(FRM_PO_3D); ProblemPtr problem = Problem::create(FRM_PO_3D);
CeresManager ceres_manager(problem); CeresManager ceres_manager(problem);
SensorBasePtr sen = problem->installSensor("ODOM 3D", "odom", (Vector7s()<<0,0,0,0,0,0,1).finished(), wolf_path + "/src/examples/odom_3D.yaml"); SensorBasePtr sen = problem->installSensor("ODOM 3D", "odom", (Vector7s()<<0,0,0,0,0,0,1).finished(), wolf_root + "/src/examples/odom_3D.yaml");
problem->installProcessor("ODOM 3D", "odometry integrator", "odom"); problem->installProcessor("ODOM 3D", "odometry integrator", "odom");
problem->getProcessorMotionPtr()->setOrigin((Vector7s()<<0,0,0,0,0,0,1).finished(), TimeStamp(0)); problem->getProcessorMotionPtr()->setOrigin((Vector7s()<<0,0,0,0,0,0,1).finished(), TimeStamp(0));
......
...@@ -415,6 +415,20 @@ inline const Eigen::Vector3s gravity(void) { ...@@ -415,6 +415,20 @@ inline const Eigen::Vector3s gravity(void) {
return Eigen::Vector3s(0,0,-9.8); return Eigen::Vector3s(0,0,-9.8);
} }
//===================================================
// Some macros
//=====================================================
// Environment variable for configuration files
// this sets the local variable wolf_root from the environment variable WOLF_ROOT
#define GET_WOLF_ROOT \
char const* tmp = std::getenv( "WOLF_ROOT" ); \
if ( tmp == nullptr ) \
throw std::runtime_error("WOLF_ROOT environment not loaded."); \
std::string wolf_root( tmp ); \
std::cout << "Wolf root: " << wolf_root << " set at variable 'wolf_root'." << std::endl;
//=====================================================
} // namespace wolf } // namespace wolf
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment