hw_interface.h
Go to the documentation of this file.
1 // -- BEGIN LICENSE BLOCK ----------------------------------------------
2 // Copyright 2020 FZI Forschungszentrum Informatik
3 // Created on behalf of Universal Robots A/S
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 // -- END LICENSE BLOCK ------------------------------------------------
17 
18 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 // ROS
30 #include "cartesian_control_msgs/FollowCartesianTrajectoryResult.h"
31 #include "control_msgs/FollowJointTrajectoryResult.h"
32 #include "ros/publisher.h"
33 #include "ros/subscriber.h"
34 #include <ros/ros.h>
35 #include <geometry_msgs/Twist.h>
36 #include <geometry_msgs/Pose.h>
37 #include <geometry_msgs/Accel.h>
42 
43 // Joint-based control
44 #include <control_msgs/FollowJointTrajectoryAction.h>
45 #include <control_msgs/FollowJointTrajectoryFeedback.h>
48 
49 // Cartesian-based control
50 #include <cartesian_control_msgs/FollowCartesianTrajectoryAction.h>
51 #include <cartesian_control_msgs/FollowCartesianTrajectoryFeedback.h>
54 
55 // Dynamic reconfigure
56 #include <dynamic_reconfigure/server.h>
57 #include <pass_through_controllers/SpeedScalingConfig.h>
58 
59 // Speed scaling
61 
62 // Other
63 #include <string>
64 #include <vector>
65 #include <array>
66 #include <memory>
67 
68 namespace examples
69 {
71 {
72 public:
73  HWInterface();
74  ~HWInterface();
75 
76  void read(const ros::Time& time, const ros::Duration& period) override;
77  void write(const ros::Time& time, const ros::Duration& period) override;
78 
79 private:
89 
99 
106 
113 
115  std::vector<std::string> joint_names_;
116 
117  // Interfaces
125 
126  // Buffers
127  std::vector<double> cmd_;
128  std::vector<double> pos_;
129  std::vector<double> vel_;
130  std::vector<double> eff_;
132  geometry_msgs::Pose pose_cmd_;
133 
134  // Configuration
135  std::string ref_frame_id_;
136  std::string frame_id_;
137 
138  // Dynamic reconfigure
139  using SpeedScalingConfig = pass_through_controllers::SpeedScalingConfig;
140 
153  void dynamicReconfigureCallback(SpeedScalingConfig& config, uint32_t level);
154 
155  std::shared_ptr<dynamic_reconfigure::Server<SpeedScalingConfig>> reconfig_server_;
156  dynamic_reconfigure::Server<SpeedScalingConfig>::CallbackType callback_type_;
157 
158  // States
159  geometry_msgs::Pose cartesian_pose_;
160  geometry_msgs::Twist cartesian_twist_;
161  geometry_msgs::Accel cartesian_accel_;
162  geometry_msgs::Accel cartesian_jerk_;
163 
164  // Handles
165  std::vector<hardware_interface::JointHandle> joint_handles_;
166  std::vector<hardware_interface::JointStateHandle> joint_state_handles_;
167 
168  // Robot connection and communication
169  std::unique_ptr<actionlib::SimpleActionClient<control_msgs::FollowJointTrajectoryAction>> joint_based_communication_;
170  void handleJointFeedback(const control_msgs::FollowJointTrajectoryFeedbackConstPtr& feedback);
171 
173  const control_msgs::FollowJointTrajectoryResultConstPtr& result);
174 
175  std::unique_ptr<actionlib::SimpleActionClient<cartesian_control_msgs::FollowCartesianTrajectoryAction>>
177  void handleCartesianFeedback(const cartesian_control_msgs::FollowCartesianTrajectoryFeedbackConstPtr& feedback);
178 
180  const cartesian_control_msgs::FollowCartesianTrajectoryResultConstPtr& result);
181 };
182 
183 } // namespace examples
examples::HWInterface::pose_cmd_
geometry_msgs::Pose pose_cmd_
Definition: hw_interface.h:132
examples::HWInterface::pos_
std::vector< double > pos_
Definition: hw_interface.h:128
examples::HWInterface::speed_scaling_
double speed_scaling_
Definition: hw_interface.h:131
examples::HWInterface::cmd_
std::vector< double > cmd_
Definition: hw_interface.h:127
examples::HWInterface::startJointInterpolation
void startJointInterpolation(const hardware_interface::JointTrajectory &trajectory)
Dummy implementation for joint interpolation on the robot.
Definition: hw_interface.cpp:169
examples::HWInterface::ref_frame_id_
std::string ref_frame_id_
Definition: hw_interface.h:135
ros_controllers_cartesian::PoseCommandInterface
examples::HWInterface::cartesian_pose_
geometry_msgs::Pose cartesian_pose_
Definition: hw_interface.h:159
examples::HWInterface::callback_type_
dynamic_reconfigure::Server< SpeedScalingConfig >::CallbackType callback_type_
Definition: hw_interface.h:156
hardware_interface::JointStateInterface
examples::HWInterface::cartesian_jerk_
geometry_msgs::Accel cartesian_jerk_
Definition: hw_interface.h:162
examples::HWInterface::joint_based_communication_
std::unique_ptr< actionlib::SimpleActionClient< control_msgs::FollowJointTrajectoryAction > > joint_based_communication_
Definition: hw_interface.h:169
ros.h
examples::HWInterface::cart_state_interface_
ros_controllers_cartesian::CartesianStateInterface cart_state_interface_
Definition: hw_interface.h:118
terminal_state.h
examples::HWInterface::cartesian_twist_
geometry_msgs::Twist cartesian_twist_
Definition: hw_interface.h:160
actionlib::SimpleClientGoalState
examples::HWInterface::read
void read(const ros::Time &time, const ros::Duration &period) override
Definition: hw_interface.cpp:159
examples::HWInterface::SpeedScalingConfig
pass_through_controllers::SpeedScalingConfig SpeedScalingConfig
Definition: hw_interface.h:139
trajectory_interface.h
hardware_interface::TrajectoryInterface
Hardware interface for forwarding trajectories.
Definition: trajectory_interface.h:104
examples::HWInterface::cart_traj_interface_
hardware_interface::CartesianTrajectoryInterface cart_traj_interface_
Definition: hw_interface.h:123
examples::HWInterface
Definition: hw_interface.h:70
examples::HWInterface::jnt_pos_interface_
hardware_interface::PositionJointInterface jnt_pos_interface_
Definition: hw_interface.h:121
publisher.h
examples::HWInterface::handleJointDone
void handleJointDone(const actionlib::SimpleClientGoalState &state, const control_msgs::FollowJointTrajectoryResultConstPtr &result)
Definition: hw_interface.cpp:216
cartesian_command_interface.h
examples::HWInterface::cancelJointInterpolation
void cancelJointInterpolation()
Dummy implementation for canceling a running joint interpolation on the robot.
Definition: hw_interface.cpp:185
examples::HWInterface::jnt_traj_interface_
hardware_interface::JointTrajectoryInterface jnt_traj_interface_
Definition: hw_interface.h:122
examples::HWInterface::vel_
std::vector< double > vel_
Definition: hw_interface.h:129
examples::HWInterface::reconfig_server_
std::shared_ptr< dynamic_reconfigure::Server< SpeedScalingConfig > > reconfig_server_
Definition: hw_interface.h:155
joint_command_interface.h
simple_action_client.h
hardware_interface::RobotHW
examples::HWInterface::cancelCartesianInterpolation
void cancelCartesianInterpolation()
Dummy implementation for canceling a running Cartesian interpolation on the robot.
Definition: hw_interface.cpp:195
speed_scaling_interface.h
subscriber.h
examples::HWInterface::write
void write(const ros::Time &time, const ros::Duration &period) override
Definition: hw_interface.cpp:164
examples::HWInterface::jnt_state_interface_
hardware_interface::JointStateInterface jnt_state_interface_
Definition: hw_interface.h:120
examples::HWInterface::handleCartesianDone
void handleCartesianDone(const actionlib::SimpleClientGoalState &state, const cartesian_control_msgs::FollowCartesianTrajectoryResultConstPtr &result)
Definition: hw_interface.cpp:240
scaled_controllers::SpeedScalingInterface
hardware_interface::CartesianTrajectory
cartesian_control_msgs::FollowCartesianTrajectoryGoal CartesianTrajectory
TrajectoryType for Cartesian trajectories.
Definition: trajectory_interface.h:63
examples::HWInterface::speedsc_interface_
scaled_controllers::SpeedScalingInterface speedsc_interface_
Definition: hw_interface.h:124
examples::HWInterface::handleCartesianFeedback
void handleCartesianFeedback(const cartesian_control_msgs::FollowCartesianTrajectoryFeedbackConstPtr &feedback)
Definition: hw_interface.cpp:234
cartesian_state_handle.h
examples::HWInterface::frame_id_
std::string frame_id_
Definition: hw_interface.h:136
joint_state_interface.h
ros::Time
examples::HWInterface::joint_state_handles_
std::vector< hardware_interface::JointStateHandle > joint_state_handles_
Definition: hw_interface.h:166
examples::HWInterface::HWInterface
HWInterface()
Definition: hw_interface.cpp:43
examples::HWInterface::joint_handles_
std::vector< hardware_interface::JointHandle > joint_handles_
Definition: hw_interface.h:165
hardware_interface::JointTrajectory
control_msgs::FollowJointTrajectoryGoal JointTrajectory
TrajectoryType for joint-based trajectories.
Definition: trajectory_interface.h:58
examples::HWInterface::pose_cmd_interface_
ros_controllers_cartesian::PoseCommandInterface pose_cmd_interface_
Definition: hw_interface.h:119
examples::HWInterface::~HWInterface
~HWInterface()
Definition: hw_interface.cpp:155
examples::HWInterface::joint_names_
std::vector< std::string > joint_names_
Actuated joints in order from base to tip.
Definition: hw_interface.h:115
examples
Definition: hw_interface.cpp:41
robot_hw.h
examples::HWInterface::cartesian_based_communication_
std::unique_ptr< actionlib::SimpleActionClient< cartesian_control_msgs::FollowCartesianTrajectoryAction > > cartesian_based_communication_
Definition: hw_interface.h:176
hardware_interface::PositionJointInterface
examples::HWInterface::eff_
std::vector< double > eff_
Definition: hw_interface.h:130
examples::HWInterface::handleJointFeedback
void handleJointFeedback(const control_msgs::FollowJointTrajectoryFeedbackConstPtr &feedback)
Definition: hw_interface.cpp:211
ros_controllers_cartesian::CartesianStateInterface
ros::Duration
examples::HWInterface::dynamicReconfigureCallback
void dynamicReconfigureCallback(SpeedScalingConfig &config, uint32_t level)
Use dynamic reconfigure to mimic the driver's speed scaling.
Definition: hw_interface.cpp:205
examples::HWInterface::startCartesianInterpolation
void startCartesianInterpolation(const hardware_interface::CartesianTrajectory &trajectory)
Dummy implementation for Cartesian interpolation on the robot.
Definition: hw_interface.cpp:177
examples::HWInterface::cartesian_accel_
geometry_msgs::Accel cartesian_accel_
Definition: hw_interface.h:161


pass_through_controllers
Author(s):
autogenerated on Tue Oct 15 2024 02:10:52