24 #include "linear_motor_instruct.h"
26 #include <utils/math/common.h>
51 Configuration * config)
52 : BaseMotorInstruct(motor, frequency, logger, config)
76 LinearMotorInstruct::calculate_translation(
float current,
float desired,
float time_factor)
78 float exec_trans = 0.0;
80 if (desired < current) {
84 exec_trans = max(exec_trans, desired);
86 }
else if (current < 0.0) {
89 exec_trans = max(exec_trans, desired);
96 }
else if (desired > current) {
100 exec_trans = min(exec_trans, desired);
102 }
else if (current < 0.0) {
105 exec_trans = min(exec_trans, desired);
114 exec_trans = desired;
117 return exec_trans * time_factor;
131 LinearMotorInstruct::calculate_rotation(
float current,
float desired,
float time_factor)
133 float exec_rot = 0.0;
135 if (desired < current) {
139 exec_rot = max(exec_rot, desired);
141 }
else if (current < 0.0) {
144 exec_rot = max(exec_rot, desired);
151 }
else if (desired > current) {
155 exec_rot = min(exec_rot, desired);
157 }
else if (current < 0.0) {
160 exec_rot = min(exec_rot, desired);
172 return exec_rot * time_factor;