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

Problem::setup() to avoid shared_from_this() in the constructor

Will have to do this ALWAYS.
parent 41cd5f7d
No related branches found
No related tags found
No related merge requests found
......@@ -74,6 +74,7 @@ int main(int argc, char** argv)
// Wolf problem
ProblemPtr wolf_problem_ptr_ = make_shared<Problem>(FRM_PVQBB_3D);
wolf_problem_ptr_->setup();
Eigen::VectorXs extrinsics(7);
extrinsics << 0,0,0, 0,0,0,1; // IMU pose in the robot
SensorBasePtr sensor_ptr = wolf_problem_ptr_->installSensor("IMU", "Main IMU", extrinsics, shared_ptr<IntrinsicsBase>());
......
......@@ -7,12 +7,12 @@ namespace wolf {
HardwareBase::HardwareBase() :
NodeBase("HARDWARE")
{
//std::cout << "HardwareBase::HardwareBase(): " << __LINE__ << std::endl;
std::cout << "constructed H" << std::endl;
}
HardwareBase::~HardwareBase()
{
std::cout << "destructing H" << nodeId() << std::endl;
std::cout << "destructed H" << nodeId() << std::endl;
}
SensorBasePtr HardwareBase::addSensor(SensorBasePtr _sensor_ptr)
......
......@@ -21,7 +21,7 @@ namespace wolf {
MapBase::MapBase() :
NodeBase("MAP")
{
std::cout << "created M"<< std::endl;
std::cout << "constructed M"<< std::endl;
}
MapBase::~MapBase()
......
......@@ -25,11 +25,18 @@ std::string uppercase(std::string s) {for (auto & c: s) c = std::toupper(c); ret
Problem::Problem(FrameStructure _frame_structure) :
hardware_ptr_(new HardwareBase),
trajectory_ptr_(new TrajectoryBase(_frame_structure)),
map_ptr_(new MapBase),
processor_motion_ptr_(nullptr),
hardware_ptr_(),
trajectory_ptr_(),
map_ptr_(),
processor_motion_ptr_(),
origin_is_set_(false)
{
hardware_ptr_ = std::make_shared<HardwareBase>();
trajectory_ptr_ = std::make_shared<TrajectoryBase>(_frame_structure);
map_ptr_ = std::make_shared<MapBase>();
}
void Problem::setup()
{
hardware_ptr_->setProblem(shared_from_this());
trajectory_ptr_->setProblem(shared_from_this());
......
......@@ -61,6 +61,7 @@ class Problem : public std::enable_shared_from_this<Problem>
public:
Problem(FrameStructure _frame_structure);
void setup();
virtual ~Problem();
// Properties -----------------------------------------
......
......@@ -7,6 +7,7 @@ TrajectoryBase::TrajectoryBase(FrameStructure _frame_structure) :
NodeBase("TRAJECTORY"),
frame_structure_(_frame_structure), last_key_frame_ptr_(nullptr)
{
std::cout << "constructed T" << std::endl;
//
}
......@@ -19,6 +20,7 @@ TrajectoryBase::~TrajectoryBase()
frame_list_.pop_front();
}
//std::cout << "deleting TrajectoryBase " << nodeId() << std::endl;
std::cout << "destructed T" << std::endl;
}
//void TrajectoryBase::destruct()
......
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