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
transmission_interface::SimpleTransmission::actuatorToJointEffort
void actuatorToJointEffort(const ActuatorData &act_data, JointData &jnt_data) override
Transform effort variables from actuator to joint space.
Definition: simple_transmission.h:197
transmission_interface::ActuatorData::velocity
std::vector< double * > velocity
Definition: transmission.h:53
transmission_interface
Definition: bidirectional_effort_joint_interface_provider.h:36
transmission_interface::SimpleTransmission::numJoints
std::size_t numJoints() const override
Definition: simple_transmission.h:173
transmission_interface::SimpleTransmission::actuatorToJointPosition
void actuatorToJointPosition(const ActuatorData &act_data, JointData &jnt_data) override
Transform position variables from actuator to joint space.
Definition: simple_transmission.h:215
transmission_interface::JointData::position
std::vector< double * > position
Definition: transmission.h:65
transmission_interface::SimpleTransmission::actuatorToJointVelocity
void actuatorToJointVelocity(const ActuatorData &act_data, JointData &jnt_data) override
Transform velocity variables from actuator to joint space.
Definition: simple_transmission.h:206
transmission_interface::JointData
Contains pointers to raw data representing the position, velocity and acceleration of a transmission'...
Definition: transmission.h:63
transmission_interface::JointData::torque_sensor
std::vector< double * > torque_sensor
Definition: transmission.h:69
transmission_interface::ActuatorData::effort
std::vector< double * > effort
Definition: transmission.h:54
transmission_interface::Transmission
Abstract base class for representing mechanical transmissions.
Definition: transmission.h:91
transmission_interface::ActuatorData::position
std::vector< double * > position
Definition: transmission.h:52
transmission_interface::JointData::absolute_position
std::vector< double * > absolute_position
Definition: transmission.h:68
transmission_interface_exception.h
transmission.h
transmission_interface::SimpleTransmission::jointToActuatorVelocity
void jointToActuatorVelocity(const JointData &jnt_data, ActuatorData &act_data) override
Transform velocity variables from joint to actuator space.
Definition: simple_transmission.h:254
transmission_interface::SimpleTransmission::numActuators
std::size_t numActuators() const override
Definition: simple_transmission.h:172
transmission_interface::JointData::effort
std::vector< double * > effort
Definition: transmission.h:67
transmission_interface::ActuatorData::torque_sensor
std::vector< double * > torque_sensor
Definition: transmission.h:56
transmission_interface::JointData::velocity
std::vector< double * > velocity
Definition: transmission.h:66
transmission_interface::SimpleTransmission::getActuatorReduction
double getActuatorReduction() const
Definition: simple_transmission.h:177
transmission_interface::SimpleTransmission::actuatorToJointAbsolutePosition
void actuatorToJointAbsolutePosition(const ActuatorData &act_data, JointData &jnt_data) override
Definition: simple_transmission.h:224
transmission_interface::SimpleTransmission::jointToActuatorPosition
void jointToActuatorPosition(const JointData &jnt_data, ActuatorData &act_data) override
Transform position variables from joint to actuator space.
Definition: simple_transmission.h:263
transmission_interface::SimpleTransmission::reduction_
double reduction_
Definition: simple_transmission.h:182
transmission_interface::SimpleTransmission::SimpleTransmission
SimpleTransmission(const double reduction, const double joint_offset=0.0)
Definition: simple_transmission.h:186
transmission_interface::SimpleTransmission::hasActuatorToJointTorqueSensor
bool hasActuatorToJointTorqueSensor() const override
Definition: simple_transmission.h:175
transmission_interface::ActuatorData::absolute_position
std::vector< double * > absolute_position
Definition: transmission.h:55
transmission_interface::SimpleTransmission::hasActuatorToJointAbsolutePosition
bool hasActuatorToJointAbsolutePosition() const override
Definition: simple_transmission.h:174
transmission_interface::TransmissionInterfaceException
Definition: transmission_interface_exception.h:37
transmission_interface::SimpleTransmission::jnt_offset_
double jnt_offset_
Definition: simple_transmission.h:183
transmission_interface::SimpleTransmission::getJointOffset
double getJointOffset() const
Definition: simple_transmission.h:178
transmission_interface::ActuatorData
Contains pointers to raw data representing the position, velocity and acceleration of a transmission'...
Definition: transmission.h:50
transmission_interface::SimpleTransmission
Implementation of a simple reducer transmission.
Definition: simple_transmission.h:95
transmission_interface::SimpleTransmission::actuatorToJointTorqueSensor
void actuatorToJointTorqueSensor(const ActuatorData &act_data, JointData &jnt_data) override
Definition: simple_transmission.h:234
transmission_interface::SimpleTransmission::jointToActuatorEffort
void jointToActuatorEffort(const JointData &jnt_data, ActuatorData &act_data) override
Transform effort variables from joint to actuator space.
Definition: simple_transmission.h:245


transmission_interface
Author(s): Adolfo Rodriguez Tsouroukdissian
autogenerated on Tue Jun 22 2021 07:34:32