cartesian_command_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 
30 
32 {
40 {
41 public:
42  PoseCommandHandle() = default;
43  PoseCommandHandle(const CartesianStateHandle& state_handle, geometry_msgs::Pose* cmd)
44  : CartesianStateHandle(state_handle), cmd_(cmd)
45  {
46  if (!cmd)
47  {
48  throw hardware_interface::HardwareInterfaceException("Cannot create pose command handle for frame '" +
49  state_handle.getName() + "'. Command data pointer is null.");
50  }
51  }
52  virtual ~PoseCommandHandle() = default;
53 
54  void setCommand(const geometry_msgs::Pose& pose)
55  {
56  assert(cmd_);
57  *cmd_ = pose;
58  }
59 
60  geometry_msgs::Pose getCommand() const
61  {
62  assert(cmd_);
63  return *cmd_;
64  }
65  const geometry_msgs::Pose* getCommandPtr() const
66  {
67  assert(cmd_);
68  return cmd_;
69  }
70 
71 private:
72  geometry_msgs::Pose* cmd_ = { nullptr };
73 };
74 
82 {
83 public:
84  TwistCommandHandle() = default;
85  TwistCommandHandle(const CartesianStateHandle& state_handle, geometry_msgs::Twist* cmd)
86  : CartesianStateHandle(state_handle), cmd_(cmd)
87  {
88  if (!cmd)
89  {
90  throw hardware_interface::HardwareInterfaceException("Cannot create twist command handle for frame '" +
91  state_handle.getName() + "'. Command data pointer is null.");
92  }
93  }
94  virtual ~TwistCommandHandle() = default;
95 
96  void setCommand(const geometry_msgs::Twist& twist)
97  {
98  assert(cmd_);
99  *cmd_ = twist;
100  }
101 
102  geometry_msgs::Twist getCommand() const
103  {
104  assert(cmd_);
105  return *cmd_;
106  }
107  const geometry_msgs::Twist* getCommandPtr() const
108  {
109  assert(cmd_);
110  return cmd_;
111  }
112 
113 private:
114  geometry_msgs::Twist* cmd_ = { nullptr };
115 };
116 
125  : public hardware_interface::HardwareResourceManager<PoseCommandHandle, hardware_interface::ClaimResources>
126 {
127 };
128 
137  : public hardware_interface::HardwareResourceManager<TwistCommandHandle, hardware_interface::ClaimResources>
138 {
139 };
140 } // namespace ros_controllers_cartesian
void setCommand(const geometry_msgs::Pose &pose)
PoseCommandHandle(const CartesianStateHandle &state_handle, geometry_msgs::Pose *cmd)
const geometry_msgs::Pose * getCommandPtr() const
const geometry_msgs::Twist * getCommandPtr() const
void setCommand(const geometry_msgs::Twist &twist)
A state handle for Cartesian hardware interfaces.
TwistCommandHandle(const CartesianStateHandle &state_handle, geometry_msgs::Twist *cmd)
A Cartesian command interface for twists.


cartesian_interface
Author(s):
autogenerated on Thu Feb 23 2023 03:10:45