qb_hand_transmission_interface.h
Go to the documentation of this file.
1 /***
2  * Software License Agreement: BSD 3-Clause License
3  *
4  * Copyright (c) 2016-2018, qbrobotics®
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
8  * following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
11  * following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
14  * following disclaimer in the documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
17  * products derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef QB_HAND_TRANSMISSION_H
29 #define QB_HAND_TRANSMISSION_H
30 
33 
41  public:
49  : qbHandVirtualTransmission(1./19000, 0.2, 0.001) {}
50 
57  qbHandVirtualTransmission(const double &position_factor, const double &velocity_factor, const double &effort_factor)
58  : Transmission(),
59  position_factor_(position_factor),
60  velocity_factor_(velocity_factor),
61  effort_factor_(effort_factor) {}
62 
72  ROS_ASSERT(numActuators() == actuator.effort.size() && numJoints() == joint.effort.size());
73  ROS_ASSERT(actuator.effort[0] && joint.effort[0]);
74 
75  *joint.effort[0] = *actuator.effort[0] * effort_factor_;
76  }
77 
87  ROS_ASSERT(numActuators() == actuator.velocity.size() && numJoints() == joint.velocity.size());
88  ROS_ASSERT(actuator.velocity[0] && joint.velocity[0]);
89 
90  // *actuator.velocity[0] is the current measured velocity in [ticks/s] while *joint.velocity[0] is the previous step velocity in [percent/s]
92  }
93 
103  ROS_ASSERT(numActuators() == actuator.position.size() && numJoints() == joint.position.size());
104  ROS_ASSERT(actuator.position[0] && joint.position[0]);
105 
106  *joint.position[0] = *actuator.position[0] * position_factor_;
107  }
108 
112  inline const double& getPositionFactor() const { return position_factor_; }
113 
117  inline const double& getVelocityFactor() const { return velocity_factor_; }
118 
122  inline const double& getEffortFactor() const { return effort_factor_; }
123 
133  ROS_ASSERT(numActuators() == actuator.effort.size() && numJoints() == joint.effort.size());
134  ROS_ASSERT(actuator.effort[0] && joint.effort[0]);
135 
136  // the qbhand cannot be controlled in current, but this could help in the near future
137  *actuator.effort[0] = *joint.effort[0] / effort_factor_;
138  }
139 
149  ROS_ASSERT(numActuators() == actuator.velocity.size() && numJoints() == joint.velocity.size());
150  ROS_ASSERT(actuator.velocity[0] && joint.velocity[0]);
151 
152  // the qbhand cannot be controlled in velocity
153  *actuator.velocity[0] = 0.0;
154  }
155 
165  ROS_ASSERT(numActuators() == actuator.position.size() && numJoints() == joint.position.size());
166  ROS_ASSERT(actuator.position[0] && joint.position[0]);
167 
168  *actuator.position[0] = *joint.position[0] / position_factor_;
169  }
170 
174  inline std::size_t numActuators() const { return 1; }
175 
179  inline std::size_t numJoints() const { return 1; }
180 
185  inline void setPositionFactor(const int &motor_position_limit) { position_factor_ = 1./motor_position_limit; }
186 
187  private:
191 };
192 } // namespace qb_hand_transmission_interface
193 
194 #endif // QB_HAND_TRANSMISSION_H
std::vector< double * > velocity
void actuatorToJointEffort(const transmission_interface::ActuatorData &actuator, transmission_interface::JointData &joint)
Transform effort variables from actuator to joint space.
std::vector< double * > position
qbHandVirtualTransmission(const double &position_factor, const double &velocity_factor, const double &effort_factor)
Build the qbhand transmission with the given scale factors.
void setPositionFactor(const int &motor_position_limit)
Set the position scale factor.
static double exponentialSmoothing(double current_raw_value, double last_smoothed_value, double alpha)
std::vector< double * > velocity
void jointToActuatorEffort(const transmission_interface::JointData &joint, transmission_interface::ActuatorData &actuator)
Transform effort variables from joint to actuator space.
std::vector< double * > position
qbHandVirtualTransmission()
Build the qbhand transmission with default velocity and effort scale factors (respectively 0...
std::vector< double * > effort
void actuatorToJointPosition(const transmission_interface::ActuatorData &actuator, transmission_interface::JointData &joint)
Transform position variables from actuator to joint space.
std::vector< double * > effort
#define ROS_ASSERT(cond)
void actuatorToJointVelocity(const transmission_interface::ActuatorData &actuator, transmission_interface::JointData &joint)
Transform velocity variables from actuator to joint space.
The qbrobotics qbhand Transmission interface implements the specific transmission_interface::Transmis...
void jointToActuatorVelocity(const transmission_interface::JointData &joint, transmission_interface::ActuatorData &actuator)
Transform velocity variables from joint to actuator space.
void jointToActuatorPosition(const transmission_interface::JointData &joint, transmission_interface::ActuatorData &actuator)
Transform position variables from joint to actuator space.


qb_hand_hardware_interface
Author(s): qbrobotics®
autogenerated on Wed Jun 5 2019 20:23:24