diff --git a/src/drawing_controller/drawing_controller/drawing_controller.py b/src/drawing_controller/drawing_controller/drawing_controller.py index 4500e98..e0ebddc 100644 --- a/src/drawing_controller/drawing_controller/drawing_controller.py +++ b/src/drawing_controller/drawing_controller/drawing_controller.py @@ -59,7 +59,7 @@ class DrawingController(Node): self.timer = self.create_timer(timer_period, self.timer_callback) self.i = 0 - self.cli = self.create_client(ExecuteMotion, 'dummy_execute_path') + self.cli = self.create_client(ExecuteMotion, 'execute_path') while not self.cli.wait_for_service(timeout_sec=1.0): self.get_logger().info('service not available, waiting again...') self.req = ExecuteMotion.Request() diff --git a/src/robot_controller/src/cpp/robot_controller.cpp b/src/robot_controller/src/cpp/robot_controller.cpp index 8761602..f48571f 100644 --- a/src/robot_controller/src/cpp/robot_controller.cpp +++ b/src/robot_controller/src/cpp/robot_controller.cpp @@ -5,57 +5,35 @@ class RobotController : public rclcpp::Node { public: - /// Constructor - RobotController(std::string name) - : Node(name) + RobotController(std::string name) : Node(name) { - //this->service = this->create_service(name+"_execute_path", &this->executePath); - this->service = this->create_service(name+"_execute_path", std::bind(&RobotController::executePath, this, std::placeholders::_1, std::placeholders::_2)); - - // Subscribe to target pose - //target_pose_sub_ = this->create_subscription("/target_pose", rclcpp::QoS(1), std::bind(&MoveItFollowTarget::target_pose_callback, this, std::placeholders::_1)); - - //RCLCPP_INFO(this->get_logger(), "Initialization successful."); - - - //std::shared_ptr node = rclcpp::Node::make_shared("add_two_ints_server"); - - //rclcpp::Service::SharedPtr service = node->create_service("add_two_ints", &add); - - //RCLCPP_INFO(rclcpp::get_logger("rclcpp"), "Ready to add two ints."); - - //rclcpp::spin(node); - //rclcpp::shutdown(); + this->service = this->create_service("execute_path", std::bind(&RobotController::executePath, this, std::placeholders::_1, std::placeholders::_2)); } - //int (RobotController::*executePath)(const std::shared_ptr request, std::shared_ptr response); -void executePath(const std::shared_ptr request, std::shared_ptr response) const -{ - //request->motion->path PoseStamped[] - //request->motion->acceleration float64 - //request->motion->velocity float64 - RCLCPP_INFO(this->get_logger(), "NEW MOTION: Acceleration: "); - //RCLCPP_INFO(this->get_logger(), "Acceleration: " + std::to_string(request.motion.acceleration)); - response->status = "executePath not implemented"; - RCLCPP_WARN(this->get_logger(), "executePath not implemented"); -} + /// Callback that executes path on robot + virtual void executePath(const std::shared_ptr request, std::shared_ptr response) + { + //request->motion->path PoseStamped[] + //request->motion->acceleration float64 + //request->motion->velocity float64 + RCLCPP_INFO(this->get_logger(), "NEW MOTION: Acceleration: "); + //RCLCPP_INFO(this->get_logger(), "Acceleration: " + std::to_string(request.motion.acceleration)); + response->status = "executePath not implemented"; + RCLCPP_WARN(this->get_logger(), "executePath not implemented"); + } private: - /// Callback that executes path on robot - rclcpp::Service::SharedPtr service; }; // A controller for a Dummy robot. Only logs messages and serves as an example for real implementation. -// CRTP pattern used here https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern -//class DummyController : public RobotController class DummyController : public RobotController { public: DummyController(std::string name) : RobotController(name) {} - void executePath(const std::shared_ptr request, std::shared_ptr response) const + virtual void executePath(const std::shared_ptr request, std::shared_ptr response) { //request->motion->path PoseStamped[] //request->motion->acceleration float64 @@ -68,7 +46,6 @@ class DummyController : public RobotController }; -//RobotController::RobotController(name) : Node(name) int main(int argc, char ** argv) {