Skip to content
Snippets Groups Projects
Commit b33ddfc4 authored by Joaquim Casals Buñuel's avatar Joaquim Casals Buñuel
Browse files

Added Loader layer, reverted to Raw loading

parent 62af3d6b
No related branches found
No related tags found
1 merge request!260WIP: params autoconf
Pipeline #2588 failed
......@@ -5,8 +5,10 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
# ADD_EXECUTABLE(hello_plugin hello_plugin.cpp sensor_odom_2D.cpp processor_odom_2D.cpp)
ADD_EXECUTABLE(hello_plugin hello_plugin.cpp)
ADD_EXECUTABLE(params_autoconf params_autoconf.cpp)
target_link_libraries(hello_plugin class_loader boost_system console_bridge wolf yaml-cpp ${CERES_LIBRARIES})
target_link_libraries(params_autoconf class_loader boost_system console_bridge wolf yaml-cpp )
# target_link_libraries(hello_plugin class_loader boost_system console_bridge wolf yaml-cpp ${CERES_LIBRARIES})
# target_link_libraries(params_autoconf class_loader boost_system console_bridge wolf yaml-cpp )
target_link_libraries(hello_plugin boost_system wolf yaml-cpp ${CERES_LIBRARIES} dl)
target_link_libraries(params_autoconf boost_system wolf yaml-cpp dl)
# These lines always at the end
SET(HDRS_PLUGIN ${HDRS_PLUGIN} PARENT_SCOPE )
SET(SRCS_PLUGIN ${SRCS_PLUGIN} PARENT_SCOPE )
......
......@@ -4,7 +4,6 @@
* Created on: Nov 12, 2018
* Author: jcasals
*/
#include <class_loader/class_loader.hpp>
#include "base/sensor/sensor_base.h"
#include "base/wolf.h"
// #include "sensor_odom_2D.cpp"
......@@ -16,13 +15,13 @@
#include "../hello_wolf/feature_range_bearing.h"
#include "../hello_wolf/constraint_range_bearing.h"
#include "../hello_wolf/landmark_point_2D.h"
#include "loader.hpp"
#include "base/processor/processor_odom_2D.h"
#include "base/solver/solver_factory.h"
#include "base/ceres_wrapper/ceres_manager.h"
using namespace std;
using namespace class_loader;
using namespace wolf;
using namespace Eigen;
......@@ -40,10 +39,15 @@ int main(int argc, char** argv) {
a segmentation fault. Likewise, it seems that these ClassLoaders must be allocated at the heap, because
the constructor refuses to build an object if I try to do local (stack) allocation, i.e `ClassLoader(it)` is not allowed but `new ClassLoader(it)` is.
**/
vector<ClassLoader*> class_loaders = vector<ClassLoader*>();
// vector<ClassLoader*> class_loaders = vector<ClassLoader*>();
// for(auto it : parser.getFiles()) {
// auto c = new ClassLoader(it);
// class_loaders.push_back(c);
// }
auto loaders = vector<Loader*>();
for(auto it : parser.getFiles()) {
auto c = new ClassLoader(it);
class_loaders.push_back(c);
auto l = new LoaderRaw(it);
loaders.push_back(l);
}
ProblemPtr problem = Problem::create("PO 2D");
auto sensorMap = map<string, SensorBasePtr>();
......
#ifndef LOADER_HPP
#define LOADER_HPP
#include <dlfcn.h>
class Loader{
protected:
std::string path_;
public:
Loader(std::string _file){
this->path_ = _file;
}
virtual void load() = 0;
virtual void close() = 0;
};
class LoaderRaw: public Loader{
void* resource_;
public:
LoaderRaw(std::string _file):
Loader(_file)
{
//
}
~LoaderRaw(){
this->close();
}
void load(){
this->resource_ = dlopen(this->path_.c_str(), RTLD_LAZY);
if(not this->resource_)
throw std::runtime_error("Couldn't load resource with path " + this->path_);
}
void close(){
if(this->resource_) dlclose(this->resource_);
}
};
// class LoaderPlugin: public Loader{
// ClassLoader* resource_;
// void load(){
// this->resource_ = new ClassLoader(this->path_);
// }
// void close(){
// delete this->resource_;
// }
// };
#endif
\ No newline at end of file
......@@ -4,7 +4,6 @@
* Created on: Feb 15, 2019
* Author: jcasals
*/
#include <class_loader/class_loader.hpp>
#include "base/sensor/sensor_base.h"
#include "base/wolf.h"
// #include "sensor_odom_2D.cpp"
......@@ -16,13 +15,13 @@
#include "../hello_wolf/feature_range_bearing.h"
#include "../hello_wolf/constraint_range_bearing.h"
#include "../hello_wolf/landmark_point_2D.h"
#include "loader.hpp"
#include "base/processor/processor_odom_2D.h"
#include "base/solver/solver_factory.h"
#include "base/ceres_wrapper/ceres_manager.h"
using namespace std;
using namespace class_loader;
using namespace wolf;
using namespace Eigen;
......@@ -40,10 +39,10 @@ int main(int argc, char** argv) {
a segmentation fault. Likewise, it seems that these ClassLoaders must be allocated at the heap, because
the constructor refuses to build an object if I try to do local (stack) allocation, i.e `ClassLoader(it)` is not allowed but `new ClassLoader(it)` is.
**/
vector<ClassLoader*> class_loaders = vector<ClassLoader*>();
auto loaders = vector<Loader*>();
for(auto it : parser.getFiles()) {
auto c = new ClassLoader(it);
class_loaders.push_back(c);
auto l = new LoaderRaw(it);
loaders.push_back(l);
}
ProblemPtr problem = Problem::create("PO 2D");
auto sensorMap = map<string, SensorBasePtr>();
......
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