70 sensor_msgs::msg::JointState m_ros_struct;
74 std::vector<std::string> m_jointNames;
75 std::string m_nodeName;
76 std::string m_jointStateTopicName;
77 std::string m_jointControlModeTopicName;
78 std::string m_posTopicName;
79 std::string m_posDirTopicName;
80 std::string m_velTopicName;
81 std::string m_getModesSrvName;
82 std::string m_getPositionSrvName;
83 std::string m_getVelocitySrvName;
84 std::string m_setModesSrvName;
85 std::string m_getJointsNamesSrvName;
86 std::string m_getAvailableModesSrvName;
87 std::map<std::string,size_t> m_quickJointRef;
88 mutable std::mutex m_cmdMutex;
91 std::uint32_t m_counter {0};
96 rclcpp::Publisher<sensor_msgs::msg::JointState>::SharedPtr m_publisherJointStates;
97 rclcpp::Publisher<std_msgs::msg::Int8MultiArray>::SharedPtr m_publisherControlModes;
98 rclcpp::Node::SharedPtr m_node;
100 static constexpr double m_default_period = 0.02;
104 size_t m_subdevice_joints {0};
118 rclcpp::Subscription<yarp_control_msgs::msg::Position>::SharedPtr m_posSubscription;
119 rclcpp::Subscription<yarp_control_msgs::msg::PositionDirect>::SharedPtr m_posDirectSubscription;
120 rclcpp::Subscription<yarp_control_msgs::msg::Velocity>::SharedPtr m_velSubscription;
121 rclcpp::Service<yarp_control_msgs::srv::GetJointsNames>::SharedPtr m_getJointsNamesSrv;
122 rclcpp::Service<yarp_control_msgs::srv::GetControlModes>::SharedPtr m_getControlModesSrv;
123 rclcpp::Service<yarp_control_msgs::srv::GetPosition>::SharedPtr m_getPositionSrv;
124 rclcpp::Service<yarp_control_msgs::srv::GetVelocity>::SharedPtr m_getVelocitySrv;
125 rclcpp::Service<yarp_control_msgs::srv::SetControlModes>::SharedPtr m_setControlModesSrv;
126 rclcpp::Service<yarp_control_msgs::srv::GetAvailableControlModes>::SharedPtr m_getAvailableModesSrv;
129 bool initRos2Control(
const std::string& name);
133 bool updateAxisName();
136 bool messageVectorsCheck(
const std::string &valueName,
const std::vector<std::string> &names,
const std::vector<double> &ref_values,
const std::vector<double> &derivative);
137 bool messageVectorsCheck(
const std::string &valueName,
const std::vector<std::string> &names,
const std::vector<double> &ref_values);
138 bool messageVectorsCheck(
const std::string &valueName,
const std::vector<std::string> &names,
const std::vector<std::string> &ref_values);
139 bool namesCheck(
const std::vector<std::string> &names);
142 void getControlModesCallback(
const std::shared_ptr<rmw_request_id_t> request_header,
143 const std::shared_ptr<yarp_control_msgs::srv::GetControlModes::Request> request,
144 std::shared_ptr<yarp_control_msgs::srv::GetControlModes::Response> response);
145 void getPositionCallback(
const std::shared_ptr<rmw_request_id_t> request_header,
146 const std::shared_ptr<yarp_control_msgs::srv::GetPosition::Request> request,
147 std::shared_ptr<yarp_control_msgs::srv::GetPosition::Response> response);
148 void getVelocityCallback(
const std::shared_ptr<rmw_request_id_t> request_header,
149 const std::shared_ptr<yarp_control_msgs::srv::GetVelocity::Request> request,
150 std::shared_ptr<yarp_control_msgs::srv::GetVelocity::Response> response);
151 void setControlModesCallback(
const std::shared_ptr<rmw_request_id_t> request_header,
152 const std::shared_ptr<yarp_control_msgs::srv::SetControlModes::Request> request,
153 std::shared_ptr<yarp_control_msgs::srv::SetControlModes::Response> response);
154 void getJointsNamesCallback(
const std::shared_ptr<rmw_request_id_t> request_header,
155 const std::shared_ptr<yarp_control_msgs::srv::GetJointsNames::Request> request,
156 std::shared_ptr<yarp_control_msgs::srv::GetJointsNames::Response> response);
157 void getAvailableModesCallback(
const std::shared_ptr<rmw_request_id_t> request_header,
158 const std::shared_ptr<yarp_control_msgs::srv::GetAvailableControlModes::Request> request,
159 std::shared_ptr<yarp_control_msgs::srv::GetAvailableControlModes::Response> response);
162 void positionTopic_callback(
const yarp_control_msgs::msg::Position::SharedPtr msg);
163 void positionDirectTopic_callback(
const yarp_control_msgs::msg::PositionDirect::SharedPtr msg);
164 void velocityTopic_callback(
const yarp_control_msgs::msg::Velocity::SharedPtr msg);
175 bool close()
override;