31 std::scoped_lock lock(dataMutex);
34 if (!(reportedSensorValues && initialOrientation && reportedJointAnglesBool))
39 if (velocityBased && !(reportedJointVelocitiesBool))
47 NameValueMap reportedJointAngles = this->reportedJointAngles;
48 NameValueMap reportedJointVelocities = this->reportedJointVelocities;
50 reportedJointAnglesBool =
false;
51 reportedJointVelocitiesBool =
false;
55 std::map<std::string, float> headJoints;
59 std::vector<float> error = std::vector<float>(3);
96 headJoints[eye_pitch_left] =
97 -1 * rotationVelocity[1] + kp * (rpy[1] - reportedJointAngles[eye_pitch_left]);
98 headJoints[eye_pitch_left] = 0.;
100 headJoints[eye_yaw_left] =
101 rotationVelocity[2] + kp * (rpy[2] - reportedJointAngles[eye_yaw_left]);
102 headJoints[eye_yaw_right] =
103 rotationVelocity[2] + kp * (rpy[2] - reportedJointAngles[eye_yaw_right]);
109 headJoints[eye_pitch_left] = -1.0 * rpy[1];
112 headJoints[eye_pitch_right] = rpy[1];
115 headJoints[eye_yaw_left] = 1 * rpy[2];
116 headJoints[eye_yaw_right] = 1 * rpy[2];
120 std::scoped_lock lock2(
mutex);
128 std::scoped_lock lock(dataMutex);
130 std::vector<float>
q =
values.orientationQuaternion;
134 rotationVelocity.clear();
136 rotationVelocity =
values.gyroscopeRotation;
138 reportedSensorValues =
true;
140 if (!initialOrientation)
142 initialOrientation =
true;
150 std::string eye_pitch_right,
151 std::string eye_yaw_left,
152 std::string eye_yaw_right,
153 std::string neck_roll)
155 std::scoped_lock lock(
mutex);
157 this->eye_pitch_left = eye_pitch_left;
158 this->eye_pitch_right = eye_pitch_right;
159 this->eye_yaw_left = eye_yaw_left;
160 this->eye_yaw_right = eye_yaw_right;
161 this->neck_roll = neck_roll;
167 std::scoped_lock lock(
mutex);
177 std::scoped_lock lock(
mutex);
179 this->armar4 = armar4;
180 this->velocityBased = velocityBased;
184 VOR::pid(std::vector<float> error,
185 std::vector<float> kp,
186 std::vector<float> ki,
187 std::vector<float> kd)
189 if (error.size() != kp.size() || kp.size() != ki.size() || ki.size() != kd.size())
192 return {0.0, 0.0, 0.0};
196 std::vector<float> y;
198 for (
size_t i = 0; i < error.size(); i++)
200 err_sum[i] += error[i];
202 y.push_back(kp[i] * error[i] + (ki[i] * err_sum[i]) + (kd[i] * (error[i] - err_old[i])));
204 err_old[i] = error[i];
211 armarx::VOR::onStop()
213 std::scoped_lock lock(dataMutex);
215 reportedSensorValues =
false;
216 initialOrientation =
false;
218 reportedJointVelocitiesBool =
false;
219 reportedJointAnglesBool =
false;
222 std::vector<float> err_old(3, 0.0);
223 err_old.swap(this->err_old);
224 std::vector<float> err_sum(3, 0.0);
225 err_sum.swap(this->err_sum);
231 std::scoped_lock lock(dataMutex);
233 reportedJointAnglesBool =
true;
234 this->reportedJointAngles =
values;
240 const Ice::Current&
c)
242 std::scoped_lock lock(dataMutex);
244 reportedJointVelocitiesBool =
true;
245 this->reportedJointVelocities =
values;