HLR  0.0.1
AbstractController.hpp
1 #ifndef ABSTRACTCONTROLLER_HPP
2 #define ABSTRACTCONTROLLER_HPP
3 
4 #include <vector>
5 
6 #include "ros/ros.h"
7 #include "std_msgs/String.h"
8 #include "urdf/model.h"
9 
10 #include "VirtualServo.hpp"
11 #include <Simulation/VirtualSerialInterface.hpp>
12 
13 namespace HLR
14 {
15 namespace Simulation
16 {
21 {
22 protected:
29  AbstractController(const std::string& request_topic,
30  const std::string& respond_topic,
31  const std::string& robot_description);
32 
36  virtual void emergency_stop();
37 
42  virtual void parse_message(const std::string& message) = 0;
43 
50  virtual bool arm_is_moving();
51 
52 private:
57  void write(const std::string& message) override;
58 
63  std::string read() override;
64 
69  void handle_message_cb(const std_msgs::String::ConstPtr& message);
70 
74  void start_update_cycles();
75 
76 protected:
82 
87  std::vector<VirtualServo> servos;
88 
93  urdf::Model model;
94 
99  std::string response;
100 
101 private:
105  std_msgs::String feedback;
106 
110  ros::NodeHandle ros_node;
111 
115  ros::Subscriber message_subscriber;
116 
120  ros::Publisher feedback_publisher;
121 };
122 }
123 }
124 
125 #endif /* ABSTRACTCONTROLLER_HPP */
virtual void parse_message(const std::string &message)=0
This function parses the message.
std::vector< VirtualServo > servos
The joint in a vector of servos, this should be initialized in the derived class. ...
Definition: AbstractController.hpp:87
Interface the simulate the serial connection to the robot arm.
Definition: VirtualSerialInterface.hpp:13
AbstractController(const std::string &request_topic, const std::string &respond_topic, const std::string &robot_description)
Constructor for AbstractController.
virtual bool arm_is_moving()
Can be used to checks of any of the servos are moving Can be used to checks of any of the servos are ...
std::string response
The feedback message to send back, should be set by the derived class.
Definition: AbstractController.hpp:99
bool response_available
This should be set by the parser if a message had feedback to send back.
Definition: AbstractController.hpp:81
virtual void emergency_stop()
This function stops the servos immediately.
urdf::Model model
Init in the constructor with the robor parameters loaded from the ROS param server.
Definition: AbstractController.hpp:93
Creates to ROS topics to listen to the incoming messages.
Definition: AbstractController.hpp:20