Skip to content

Commit 4b11bad

Browse files
committed
updated array & matrix access to the range-checked version
1 parent 4acc9cd commit 4b11bad

File tree

3 files changed

+240
-242
lines changed

3 files changed

+240
-242
lines changed

src/common.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ std::optional<Eigen::Vector3d> sanitizeDesiredForce(const Eigen::Vector3d& input
3232
const std::string& node_name) {
3333

3434
// calculate the force in spherical coordinates
35-
double theta = acos(input[2]);
36-
double phi = atan2(input[1], input[0]);
35+
double theta = acos(input(2));
36+
double phi = atan2(input(1), input(0));
3737

3838
// check for the failsafe limit
3939
if (!std::isfinite(theta)) {
@@ -275,22 +275,22 @@ std::optional<mrs_msgs::HwApiAttitudeRateCmd> attitudeController(const mrs_msgs:
275275

276276
// | --------------- saturate the attitude rate --------------- |
277277

278-
if (rate_feedback[0] > rate_saturation[0]) {
279-
rate_feedback[0] = rate_saturation[0];
280-
} else if (rate_feedback[0] < -rate_saturation[0]) {
281-
rate_feedback[0] = -rate_saturation[0];
278+
if (rate_feedback(0) > rate_saturation(0)) {
279+
rate_feedback(0) = rate_saturation(0);
280+
} else if (rate_feedback(0) < -rate_saturation(0)) {
281+
rate_feedback(0) = -rate_saturation(0);
282282
}
283283

284-
if (rate_feedback[1] > rate_saturation[1]) {
285-
rate_feedback[1] = rate_saturation[1];
286-
} else if (rate_feedback[1] < -rate_saturation[1]) {
287-
rate_feedback[1] = -rate_saturation[1];
284+
if (rate_feedback(1) > rate_saturation(1)) {
285+
rate_feedback(1) = rate_saturation(1);
286+
} else if (rate_feedback(1) < -rate_saturation(1)) {
287+
rate_feedback(1) = -rate_saturation(1);
288288
}
289289

290-
if (rate_feedback[2] > rate_saturation[2]) {
291-
rate_feedback[2] = rate_saturation[2];
292-
} else if (rate_feedback[2] < -rate_saturation[2]) {
293-
rate_feedback[2] = -rate_saturation[2];
290+
if (rate_feedback(2) > rate_saturation(2)) {
291+
rate_feedback(2) = rate_saturation(2);
292+
} else if (rate_feedback(2) < -rate_saturation(2)) {
293+
rate_feedback(2) = -rate_saturation(2);
294294
}
295295

296296
// | ------------ fill in the attitude rate command ----------- |
@@ -299,9 +299,9 @@ std::optional<mrs_msgs::HwApiAttitudeRateCmd> attitudeController(const mrs_msgs:
299299

300300
cmd.stamp = ros::Time::now();
301301

302-
cmd.body_rate.x = rate_feedback[0];
303-
cmd.body_rate.y = rate_feedback[1];
304-
cmd.body_rate.z = rate_feedback[2];
302+
cmd.body_rate.x = rate_feedback(0);
303+
cmd.body_rate.y = rate_feedback(1);
304+
cmd.body_rate.z = rate_feedback(2);
305305

306306
cmd.throttle = reference.throttle;
307307

@@ -326,9 +326,9 @@ std::optional<mrs_msgs::HwApiControlGroupCmd> attitudeRateController(const mrs_m
326326

327327
cmd.throttle = reference.throttle;
328328

329-
cmd.roll = ctrl_group_action[0];
330-
cmd.pitch = ctrl_group_action[1];
331-
cmd.yaw = ctrl_group_action[2];
329+
cmd.roll = ctrl_group_action(0);
330+
cmd.pitch = ctrl_group_action(1);
331+
cmd.yaw = ctrl_group_action(2);
332332

333333
return {cmd};
334334
}
@@ -374,7 +374,7 @@ mrs_msgs::HwApiActuatorCmd actuatorMixer(const mrs_msgs::HwApiControlGroupCmd& c
374374
actuator_msg.stamp = ros::Time::now();
375375

376376
for (int i = 0; i < motors.size(); i++) {
377-
actuator_msg.motors.push_back(motors[i]);
377+
actuator_msg.motors.push_back(motors(i));
378378
}
379379

380380
return actuator_msg;

0 commit comments

Comments
 (0)