From 0e04573e730a0672a1482bfeb0025a4fdb3c193e Mon Sep 17 00:00:00 2001 From: sonelu Date: Fri, 15 Nov 2019 13:37:23 +0000 Subject: [PATCH] separated the initialize() method to allow custom robot configuration before initializing the controller --- .../include/robotis_controller/robotis_controller.h | 1 + .../src/robotis_controller/robotis_controller.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/robotis_controller/include/robotis_controller/robotis_controller.h b/robotis_controller/include/robotis_controller/robotis_controller.h index aab8da0..c27d888 100755 --- a/robotis_controller/include/robotis_controller/robotis_controller.h +++ b/robotis_controller/include/robotis_controller/robotis_controller.h @@ -117,6 +117,7 @@ class RobotisController : public Singleton RobotisController(); bool initialize(const std::string robot_file_path, const std::string init_file_path); + bool initialize(Robot *robot, const std::string init_file_path); void initializeDevice(const std::string init_file_path); void process(); diff --git a/robotis_controller/src/robotis_controller/robotis_controller.cpp b/robotis_controller/src/robotis_controller/robotis_controller.cpp index 82c8c54..0f7f200 100755 --- a/robotis_controller/src/robotis_controller/robotis_controller.cpp +++ b/robotis_controller/src/robotis_controller/robotis_controller.cpp @@ -199,8 +199,14 @@ bool RobotisController::initialize(const std::string robot_file_path, const std: std::string dev_desc_dir_path = ros::package::getPath("robotis_device") + "/devices"; // load robot info : port , device - robot_ = new Robot(robot_file_path, dev_desc_dir_path); + Robot *new_robot = new Robot(robot_file_path, dev_desc_dir_path); + initialize(new_robot, init_file_path); +} + +bool RobotisController::initialize(Robot *robot, const std::string init_file_path) +{ + robot_ = robot; if (gazebo_mode_ == true) { queue_thread_ = boost::thread(boost::bind(&RobotisController::msgQueueThread, this));