hardware_interface.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017, 2018 Simon Rasmussen (refactor)
3  *
4  * Copyright 2015, 2016 Thomas Timm Andersen (original version)
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
20 #include "ur_modern_driver/log.h"
21 
22 const std::string JointInterface::INTERFACE_NAME = "hardware_interface::JointStateInterface";
23 JointInterface::JointInterface(std::vector<std::string> &joint_names)
24 {
25  for (size_t i = 0; i < 6; i++)
26  {
28  }
29 }
30 
32 {
33  positions_ = packet.q_actual;
34  velocities_ = packet.qd_actual;
35  efforts_ = packet.i_actual;
36 }
37 
38 const std::string WrenchInterface::INTERFACE_NAME = "hardware_interface::ForceTorqueSensorInterface";
39 WrenchInterface::WrenchInterface(std::string wrench_frame)
40 {
41  // the frame_id for the Wrench is set to what is configured as the "base frame".
42  // Refer to ros-industrial/ur_modern_driver#318 for the rationale.
43  registerHandle(hardware_interface::ForceTorqueSensorHandle("wrench", wrench_frame, tcp_.begin(), tcp_.begin() + 3));
44 }
45 
47 {
48  tcp_ = packet.tcp_force;
49 }
50 
51 const std::string VelocityInterface::INTERFACE_NAME = "hardware_interface::VelocityJointInterface";
53  std::vector<std::string> &joint_names, double max_vel_change)
54  : commander_(commander), prev_velocity_cmd_({ 0, 0, 0, 0, 0, 0 }), max_vel_change_(max_vel_change)
55 {
56  for (size_t i = 0; i < 6; i++)
57  {
58  registerHandle(JointHandle(js_interface.getHandle(joint_names[i]), &velocity_cmd_[i]));
59  }
60 }
61 
63 {
64  for (size_t i = 0; i < 6; i++)
65  {
66  // clamp value to ±max_vel_change
67  double prev = prev_velocity_cmd_[i];
68  double lo = prev - max_vel_change_;
69  double hi = prev + max_vel_change_;
70  prev_velocity_cmd_[i] = std::max(lo, std::min(velocity_cmd_[i], hi));
71  }
73 }
74 
76 {
77  for (auto &val : prev_velocity_cmd_)
78  {
79  val = 0;
80  }
81 }
82 
83 const std::string PositionInterface::INTERFACE_NAME = "hardware_interface::PositionJointInterface";
86  std::vector<std::string> &joint_names)
87  : follower_(follower)
88 {
89  for (size_t i = 0; i < 6; i++)
90  {
91  registerHandle(JointHandle(js_interface.getHandle(joint_names[i]), &position_cmd_[i]));
92  }
93 }
94 
96 {
98 }
99 
101 {
102  follower_.start();
103 }
104 
106 {
107  follower_.stop();
108 }
void update(RTShared &packet)
std::array< double, 6 > velocity_cmd_
static const std::string INTERFACE_NAME
bool execute(std::array< double, 6 > &positions, bool keep_alive)
static const std::string INTERFACE_NAME
std::array< double, 6 > i_actual
Definition: rt_state.h:51
TrajectoryFollower & follower_
static const std::string INTERFACE_NAME
std::array< double, 6 > efforts_
std::array< double, 6 > qd_actual
Definition: rt_state.h:50
std::array< double, 6 > tcp_force
Definition: rt_state.h:55
URCommander & commander_
WrenchInterface(std::string wrench_frame)
std::array< double, 6 > q_actual
Definition: rt_state.h:49
virtual bool speedj(std::array< double, 6 > &speeds, double acceleration)=0
std::array< double, 6 > position_cmd_
void registerHandle(const JointStateHandle &handle)
static const std::string INTERFACE_NAME
JointStateHandle getHandle(const std::string &name)
VelocityInterface(URCommander &commander, hardware_interface::JointStateInterface &js_interface, std::vector< std::string > &joint_names, double max_vel_change)
std::array< double, 6 > positions_
JointInterface(std::vector< std::string > &joint_names)
PositionInterface(TrajectoryFollower &follower, hardware_interface::JointStateInterface &js_interface, std::vector< std::string > &joint_names)
void update(RTShared &packet)
std::array< double, 6 > prev_velocity_cmd_
std::array< double, 6 > velocities_


ur_modern_driver
Author(s): Thomas Timm Andersen, Simon Rasmussen
autogenerated on Fri Jun 26 2020 03:37:00