simple_transmission.h
Go to the documentation of this file.
1 // Copyright (C) 2013, PAL Robotics S.L.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name of PAL Robotics S.L. nor the names of its
12 // contributors may be used to endorse or promote products derived from
13 // this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 // POSSIBILITY OF SUCH DAMAGE.
27 
29 
30 #pragma once
31 
32 
33 #include <cassert>
34 #include <string>
35 #include <vector>
36 
39 
40 namespace transmission_interface
41 {
42 
96 {
97 public:
103  SimpleTransmission(const double reduction,
104  const double joint_offset = 0.0);
105 
113  void actuatorToJointEffort(const ActuatorData& act_data,
114  JointData& jnt_data) override;
115 
123  void actuatorToJointVelocity(const ActuatorData& act_data,
124  JointData& jnt_data) override;
125 
133  void actuatorToJointPosition(const ActuatorData& act_data,
134  JointData& jnt_data) override;
135 
136  void actuatorToJointAbsolutePosition(const ActuatorData& act_data,
137  JointData& jnt_data) override;
138 
139  void actuatorToJointTorqueSensor(const ActuatorData& act_data,
140  JointData& jnt_data) override;
141 
149  void jointToActuatorEffort(const JointData& jnt_data,
150  ActuatorData& act_data) override;
151 
159  void jointToActuatorVelocity(const JointData& jnt_data,
160  ActuatorData& act_data) override;
161 
169  void jointToActuatorPosition(const JointData& jnt_data,
170  ActuatorData& act_data) override;
171 
172  std::size_t numActuators() const override {return 1;}
173  std::size_t numJoints() const override {return 1;}
174  bool hasActuatorToJointAbsolutePosition() const override {return true;}
175  bool hasActuatorToJointTorqueSensor() const override {return true;}
176 
177  double getActuatorReduction() const {return reduction_;}
178  double getJointOffset() const {return jnt_offset_;}
179 
180 
181 private:
182  double reduction_;
183  double jnt_offset_;
184 };
185 
186 inline SimpleTransmission::SimpleTransmission(const double reduction,
187  const double joint_offset)
188  : reduction_(reduction),
189  jnt_offset_(joint_offset)
190 {
191  if (0.0 == reduction_)
192  {
193  throw TransmissionInterfaceException("Transmission reduction ratio cannot be zero.");
194  }
195 }
196 
198  JointData& jnt_data)
199 {
200  assert(numActuators() == act_data.effort.size() && numJoints() == jnt_data.effort.size());
201  assert(act_data.effort[0] && jnt_data.effort[0]);
202 
203  *jnt_data.effort[0] = *act_data.effort[0] * reduction_;
204 }
205 
207  JointData& jnt_data)
208 {
209  assert(numActuators() == act_data.velocity.size() && numJoints() == jnt_data.velocity.size());
210  assert(act_data.velocity[0] && jnt_data.velocity[0]);
211 
212  *jnt_data.velocity[0] = *act_data.velocity[0] / reduction_;
213 }
214 
216  JointData& jnt_data)
217 {
218  assert(numActuators() == act_data.position.size() && numJoints() == jnt_data.position.size());
219  assert(act_data.position[0] && jnt_data.position[0]);
220 
221  *jnt_data.position[0] = *act_data.position[0] / reduction_ + jnt_offset_;
222 }
223 
225  JointData& jnt_data)
226 {
227 
228  assert(numActuators() == act_data.absolute_position.size() && numJoints() == jnt_data.absolute_position.size());
229  assert(act_data.absolute_position[0] && jnt_data.absolute_position[0]);
230 
231  *jnt_data.absolute_position[0] = *act_data.absolute_position[0] / reduction_ + jnt_offset_;
232 }
233 
235  JointData& jnt_data)
236 {
237 
238  assert(numActuators() == act_data.torque_sensor.size() && numJoints() == jnt_data.torque_sensor.size());
239  assert(act_data.torque_sensor[0] && jnt_data.torque_sensor[0]);
240 
241  *jnt_data.torque_sensor[0] = *act_data.torque_sensor[0] * reduction_;
242 }
243 
244 
246  ActuatorData& act_data)
247 {
248  assert(numActuators() == act_data.effort.size() && numJoints() == jnt_data.effort.size());
249  assert(act_data.effort[0] && jnt_data.effort[0]);
250 
251  *act_data.effort[0] = *jnt_data.effort[0] / reduction_;
252 }
253 
255  ActuatorData& act_data)
256 {
257  assert(numActuators() == act_data.velocity.size() && numJoints() == jnt_data.velocity.size());
258  assert(act_data.velocity[0] && jnt_data.velocity[0]);
259 
260  *act_data.velocity[0] = *jnt_data.velocity[0] * reduction_;
261 }
262 
264  ActuatorData& act_data)
265 {
266  assert(numActuators() == act_data.position.size() && numJoints() == jnt_data.position.size());
267  assert(act_data.position[0] && jnt_data.position[0]);
268 
269  *act_data.position[0] = (*jnt_data.position[0] - jnt_offset_) * reduction_;
270 }
271 
272 } // transmission_interface
void jointToActuatorPosition(const JointData &jnt_data, ActuatorData &act_data) override
Transform position variables from joint to actuator space.
std::vector< double * > absolute_position
Definition: transmission.h:68
std::vector< double * > velocity
Definition: transmission.h:66
void actuatorToJointAbsolutePosition(const ActuatorData &act_data, JointData &jnt_data) override
std::vector< double * > absolute_position
Definition: transmission.h:55
Contains pointers to raw data representing the position, velocity and acceleration of a transmission&#39;...
Definition: transmission.h:63
std::vector< double * > position
Definition: transmission.h:52
void jointToActuatorEffort(const JointData &jnt_data, ActuatorData &act_data) override
Transform effort variables from joint to actuator space.
std::vector< double * > torque_sensor
Definition: transmission.h:69
std::vector< double * > torque_sensor
Definition: transmission.h:56
void actuatorToJointPosition(const ActuatorData &act_data, JointData &jnt_data) override
Transform position variables from actuator to joint space.
void actuatorToJointTorqueSensor(const ActuatorData &act_data, JointData &jnt_data) override
Contains pointers to raw data representing the position, velocity and acceleration of a transmission&#39;...
Definition: transmission.h:50
Implementation of a simple reducer transmission.
std::vector< double * > velocity
Definition: transmission.h:53
std::vector< double * > position
Definition: transmission.h:65
void actuatorToJointEffort(const ActuatorData &act_data, JointData &jnt_data) override
Transform effort variables from actuator to joint space.
void jointToActuatorVelocity(const JointData &jnt_data, ActuatorData &act_data) override
Transform velocity variables from joint to actuator space.
void actuatorToJointVelocity(const ActuatorData &act_data, JointData &jnt_data) override
Transform velocity variables from actuator to joint space.
std::vector< double * > effort
Definition: transmission.h:67
std::vector< double * > effort
Definition: transmission.h:54
SimpleTransmission(const double reduction, const double joint_offset=0.0)
Abstract base class for representing mechanical transmissions.
Definition: transmission.h:91


transmission_interface
Author(s): Adolfo Rodriguez Tsouroukdissian
autogenerated on Mon Feb 28 2022 23:30:26