perception_interfaces 1.1.2
Loading...
Searching...
No Matches
state_setters.h
Go to the documentation of this file.
1// Copyright Institute for Automotive Engineering (ika), RWTH Aachen University
2// SPDX-License-Identifier: MIT
3
9#pragma once
10
14
15
16namespace perception_msgs {
17
18namespace object_access {
19
27 inline void setX(ObjectState& state, const double val, const bool reset_covariance = true) {
29 const int idx = indexX(state.model_id);
30 state.continuous_state[idx] = val;
31 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
32 }
33
42 template <typename T>
43 inline void setX(T& obj, const double val, const bool reset_covariance = true) {
44 setX(obj.state, val, reset_covariance);
45 }
46
54 inline void setY(ObjectState& state, const double val, const bool reset_covariance = true) {
56 const int idx = indexY(state.model_id);
57 state.continuous_state[idx] = val;
58 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
59 }
60
69 template <typename T>
70 inline void setY(T& obj, const double val, const bool reset_covariance = true) {
71 setY(obj.state, val, reset_covariance);
72 }
73
81 inline void setZ(ObjectState& state, const double val, const bool reset_covariance = true) {
83 const int idx = indexZ(state.model_id);
84 state.continuous_state[idx] = val;
85 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
86 }
87
96 template <typename T>
97 inline void setZ(T& obj, const double val, const bool reset_covariance = true) {
98 setZ(obj.state, val, reset_covariance);
99 }
100
108 inline void setVelLon(ObjectState& state, const double val, const bool reset_covariance = true) {
110 const int idx = indexVelLon(state.model_id);
111 state.continuous_state[idx] = val;
112 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
113 }
114
123 template <typename T>
124 inline void setVelLon(T& obj, const double val, const bool reset_covariance = true) {
125 setVelLon(obj.state, val, reset_covariance);
126 }
127
135 inline void setVelLat(ObjectState& state, const double val, const bool reset_covariance = true) {
137 const int idx = indexVelLat(state.model_id);
138 state.continuous_state[idx] = val;
139 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
140 }
141
150 template <typename T>
151 inline void setVelLat(T& obj, const double val, const bool reset_covariance = true) {
152 setVelLat(obj.state, val, reset_covariance);
153 }
154
162 inline void setAccLon(ObjectState& state, const double val, const bool reset_covariance = true) {
164 const int idx = indexAccLon(state.model_id);
165 state.continuous_state[idx] = val;
166 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
167 }
168
177 template <typename T>
178 inline void setAccLon(T& obj, const double val, const bool reset_covariance = true) {
179 setAccLon(obj.state, val, reset_covariance);
180 }
181
189 inline void setAccLat(ObjectState& state, const double val, const bool reset_covariance = true) {
191 const int idx = indexAccLat(state.model_id);
192 state.continuous_state[idx] = val;
193 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
194 }
195
204 template <typename T>
205 inline void setAccLat(T& obj, const double val, const bool reset_covariance = true) {
206 setAccLat(obj.state, val, reset_covariance);
207 }
208
216 inline void setRoll(ObjectState& state, const double val, const bool reset_covariance = true) {
218 double capped_val = val;
219 capped_val -= 2.0 * M_PI * std::floor((capped_val + M_PI) * (M_1_PI * 0.5));
220 if (capped_val <= -M_PI) capped_val += 2 * M_PI;
221 const int idx = indexRoll(state.model_id);
222 state.continuous_state[idx] = capped_val;
223 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
224 }
225
234 template <typename T>
235 inline void setRoll(T& obj, const double val, const bool reset_covariance = true) {
236 setRoll(obj.state, val, reset_covariance);
237 }
238
246 inline void setRollRate(ObjectState& state, const double val, const bool reset_covariance = true) {
248 const int idx = indexRollRate(state.model_id);
249 state.continuous_state[idx] = val;
250 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
251 }
252
261 template <typename T>
262 inline void setRollRate(T& obj, const double val, const bool reset_covariance = true) {
263 setRollRate(obj.state, val, reset_covariance);
264 }
265
273 inline void setPitch(ObjectState& state, const double val, const bool reset_covariance = true) {
275 double capped_val = val;
276 capped_val -= 2.0 * M_PI * std::floor((capped_val + M_PI) * (M_1_PI * 0.5));
277 if (capped_val <= -M_PI) capped_val += 2 * M_PI;
278 const int idx = indexPitch(state.model_id);
279 state.continuous_state[idx] = capped_val;
280 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
281 }
282
291 template <typename T>
292 inline void setPitch(T& obj, const double val, const bool reset_covariance = true) {
293 setPitch(obj.state, val, reset_covariance);
294 }
295
303 inline void setPitchRate(ObjectState& state, const double val, const bool reset_covariance = true) {
305 const int idx = indexPitchRate(state.model_id);
306 state.continuous_state[idx] = val;
307 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
308 }
309
318 template <typename T>
319 inline void setPitchRate(T& obj, const double val, const bool reset_covariance = true) {
320 setPitchRate(obj.state, val, reset_covariance);
321 }
322
330 inline void setYaw(ObjectState& state, const double val, const bool reset_covariance = true) {
332 double capped_val = val;
333 capped_val -= 2.0 * M_PI * std::floor((capped_val + M_PI) * (M_1_PI * 0.5));
334 if (capped_val <= -M_PI) capped_val += 2 * M_PI;
335 const int idx = indexYaw(state.model_id);
336 state.continuous_state[idx] = capped_val;
337 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
338 }
339
348 template <typename T>
349 inline void setYaw(T& obj, const double val, const bool reset_covariance = true) {
350 setYaw(obj.state, val, reset_covariance);
351 }
352
360 inline void setYawRate(ObjectState& state, const double val, const bool reset_covariance = true) {
362 const int idx = indexYawRate(state.model_id);
363 state.continuous_state[idx] = val;
364 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
365 }
366
375 template <typename T>
376 inline void setYawRate(T& obj, const double val, const bool reset_covariance = true) {
377 setYawRate(obj.state, val, reset_covariance);
378 }
379
387 inline void setSteeringAngleAck(ObjectState& state, const double val, const bool reset_covariance = true) {
389 const int idx = indexSteeringAngleAck(state.model_id);
390 state.continuous_state[idx] = val;
391 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
392 }
393
402 template <typename T>
403 inline void setSteeringAngleAck(T& obj, const double val, const bool reset_covariance = true) {
404 setSteeringAngleAck(obj.state, val, reset_covariance);
405 }
406
414 inline void setSteeringAngleRateAck(ObjectState& state, const double val, const bool reset_covariance = true) {
416 const int idx = indexSteeringAngleRateAck(state.model_id);
417 state.continuous_state[idx] = val;
418 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
419 }
420
429 template <typename T>
430 inline void setSteeringAngleRateAck(T& obj, const double val, const bool reset_covariance = true) {
431 setSteeringAngleRateAck(obj.state, val, reset_covariance);
432 }
433
441 inline void setSteeringAngleFront(ObjectState& state, const double val, const bool reset_covariance = true) {
443 const int idx = indexSteeringAngleFront(state.model_id);
444 state.continuous_state[idx] = val;
445 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
446 }
447
456 template <typename T>
457 inline void setSteeringAngleFront(T& obj, const double val, const bool reset_covariance = true) {
458 setSteeringAngleFront(obj.state, val, reset_covariance);
459 }
460
468 inline void setSteeringAngleRear(ObjectState& state, const double val, const bool reset_covariance = true) {
470 const int idx = indexSteeringAngleRear(state.model_id);
471 state.continuous_state[idx] = val;
472 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
473 }
474
483 template <typename T>
484 inline void setSteeringAngleRear(T& obj, const double val, const bool reset_covariance = true) {
485 setSteeringAngleRear(obj.state, val, reset_covariance);
486 }
487
495 inline void setWidth(ObjectState& state, const double val, const bool reset_covariance = true) {
497 const int idx = indexWidth(state.model_id);
498 state.continuous_state[idx] = val;
499 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
500 }
501
510 template <typename T>
511 inline void setWidth(T& obj, const double val, const bool reset_covariance = true) {
512 setWidth(obj.state, val, reset_covariance);
513 }
514
522 inline void setLength(ObjectState& state, const double val, const bool reset_covariance = true) {
524 const int idx = indexLength(state.model_id);
525 state.continuous_state[idx] = val;
526 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
527 }
528
537 template <typename T>
538 inline void setLength(T& obj, const double val, const bool reset_covariance = true) {
539 setLength(obj.state, val, reset_covariance);
540 }
541
549 inline void setHeight(ObjectState& state, const double val, const bool reset_covariance = true) {
551 const int idx = indexHeight(state.model_id);
552 state.continuous_state[idx] = val;
553 if (reset_covariance) setContinuousStateCovarianceToUnknownAt(state, idx, idx);
554 }
555
564 template <typename T>
565 inline void setHeight(T& obj, const double val, const bool reset_covariance = true) {
566 setHeight(obj.state, val, reset_covariance);
567 }
568
575 inline void setStandstill(ObjectState& state, const bool val) {
577 const int idx = indexStandstill(state.model_id);
578 state.discrete_state[idx] = val;
579 }
580
588 template <typename T>
589 inline void setStandstill(T& obj, const bool val) {
590 setStandstill(obj.state, val);
591 }
592
599 inline void setTurnIndicator(ObjectState& state, const uint8_t val) {
601 const int idx = indexTurnIndicator(state.model_id);
602 state.discrete_state[idx] = val;
603 }
604
612 template <typename T>
613 inline void setTurnIndicator(T& obj, const uint8_t val) {
614 setTurnIndicator(obj.state, val);
615 }
616
623 inline void setBrakeLight(ObjectState& state, const uint8_t val) {
625 const int idx = indexBrakeLight(state.model_id);
626 state.discrete_state[idx] = val;
627 }
628
636 template <typename T>
637 inline void setBrakeLight(T& obj, const uint8_t val) {
638 setBrakeLight(obj.state, val);
639 }
640
647 inline void setReverseLight(ObjectState& state, const uint8_t val) {
649 const int idx = indexReverseLight(state.model_id);
650 state.discrete_state[idx] = val;
651 }
652
660 template <typename T>
661 inline void setReverseLight(T& obj, const uint8_t val) {
662 setReverseLight(obj.state, val);
663 }
664
671 inline void setTrafficLightState(ObjectState& state, const uint8_t val) {
673 const int idx = indexTrafficLightState(state.model_id);
674 state.discrete_state[idx] = val;
675 }
676
685 template <typename T>
686 inline void setTrafficLightState(T& obj, const uint8_t val) {
687 setTrafficLightState(obj.state, val);
688 }
689
696 inline void setTrafficLightType(ObjectState& state, const uint8_t val) {
698 const int idx = indexTrafficLightType(state.model_id);
699 state.discrete_state[idx] = val;
700 }
701
710 template <typename T>
711 inline void setTrafficLightType(T& obj, const uint8_t val) {
712 setTrafficLightType(obj.state, val);
713 }
714
715} // namespace object_access
716
717} // namespace perception_msgs
Object state sanity checks.
void sanityCheckContinuousState(const ObjectState &state)
Perform sanity check on continuous state of given object state.
Definition checks.h:63
void sanityCheckDiscreteState(const ObjectState &state)
Perform sanity check on discrete state of given object state.
Definition checks.h:83
Object state vector indices based on state model.
int indexBrakeLight(const unsigned char &model_id)
Get the vector-index that stores the brake light state for a given model-id.
int indexRollRate(const unsigned char &model_id)
Get the vector-index that stores the roll rate for a given model-id.
int indexVelLon(const unsigned char &model_id)
Get the vector-index that stores the longitudinal velocity for a given model-id.
Definition state_index.h:93
int indexWidth(const unsigned char &model_id)
Get the vector-index that stores the width for a given model-id.
int indexRoll(const unsigned char &model_id)
Get the vector-index that stores the roll for a given model-id.
int indexLength(const unsigned char &model_id)
Get the vector-index that stores the length for a given model-id.
int indexPitchRate(const unsigned char &model_id)
Get the vector-index that stores the pitch rate for a given model-id.
int indexYawRate(const unsigned char &model_id)
Get the vector-index that stores the yaw-rate for a given model-id.
int indexHeight(const unsigned char &model_id)
Get the vector-index that stores the height for a given model-id.
int indexVelLat(const unsigned char &model_id)
Get the vector-index that stores the lateral velocity for a given model-id.
int indexTurnIndicator(const unsigned char &model_id)
Get the vector-index that stores the turn indicator state for a given model-id.
int indexY(const unsigned char &model_id)
Get the vector-index that stores the y-position for a given model-id.
Definition state_index.h:47
int indexSteeringAngleFront(const unsigned char &model_id)
Get the vector-index that stores the front wheel angle for a given model-id.
int indexSteeringAngleRear(const unsigned char &model_id)
Get the vector-index that stores the rear wheel angle for a given model-id.
int indexReverseLight(const unsigned char &model_id)
Get the vector-index that stores the reverse light state for a given model-id.
int indexZ(const unsigned char &model_id)
Get the vector-index that stores the z-position for a given model-id.
Definition state_index.h:70
int indexAccLon(const unsigned char &model_id)
Get the vector-index that stores the longitudinal acceleration for a given model-id.
int indexStandstill(const unsigned char &model_id)
Get the vector-index that stores the standstill indication for a given model-id.
int indexTrafficLightType(const unsigned char &model_id)
Get the vector-index that stores the traffic light type for a given model-id.
int indexSteeringAngleRateAck(const unsigned char &model_id)
Get the vector-index that stores the steering angle rate for a given model-id.
int indexPitch(const unsigned char &model_id)
Get the vector-index that stores the pitch for a given model-id.
int indexAccLat(const unsigned char &model_id)
Get the vector-index that stores the lateral acceleration for a given model-id.
int indexSteeringAngleAck(const unsigned char &model_id)
Get the vector-index that stores the ackermann steering angle for a given model-id.
int indexX(const unsigned char &model_id)
Get the vector-index that stores the x-position for a given model-id.
Definition state_index.h:24
int indexTrafficLightState(const unsigned char &model_id)
Get the vector-index that stores the traffic light state for a given model-id.
int indexYaw(const unsigned char &model_id)
Get the vector-index that stores the yaw for a given model-id.
void setReverseLight(ObjectState &state, const uint8_t val)
Set the reverse light for a given object state.
void setYawRate(ObjectState &state, const double val, const bool reset_covariance=true)
Set the yaw-rate for a given object state.
void setSteeringAngleRear(ObjectState &state, const double val, const bool reset_covariance=true)
Set the rear wheel angle for a given object state.
void setHeight(ObjectState &state, const double val, const bool reset_covariance=true)
Set the height for a given object state.
void setAccLat(ObjectState &state, const double val, const bool reset_covariance=true)
Set the lateral acceleration for a given object state.
void setRollRate(ObjectState &state, const double val, const bool reset_covariance=true)
Set the roll-rate for a given object state.
void setSteeringAngleRateAck(ObjectState &state, const double val, const bool reset_covariance=true)
Set the ackermann steering angle rate for a given object state.
void setWidth(ObjectState &state, const double val, const bool reset_covariance=true)
Set the width for a given object state.
void setTrafficLightType(ObjectState &state, const uint8_t val)
Set the traffic light type for a given object state.
void setAccLon(ObjectState &state, const double val, const bool reset_covariance=true)
Set the longitudinal acceleration for a given object state.
void setVelLon(ObjectState &state, const double val, const bool reset_covariance=true)
Set the longitdunial velocity for a given object state.
void setSteeringAngleAck(ObjectState &state, const double val, const bool reset_covariance=true)
Set the ackermann steering angle for a given object state.
void setX(ObjectState &state, const double val, const bool reset_covariance=true)
Set the x-position for a given object state.
void setY(ObjectState &state, const double val, const bool reset_covariance=true)
Set the y-position for a given object state.
void setVelLat(ObjectState &state, const double val, const bool reset_covariance=true)
Set the lateral velocity for a given object state.
void setTurnIndicator(ObjectState &state, const uint8_t val)
Set the turn indicator for a given object state.
void setYaw(ObjectState &state, const double val, const bool reset_covariance=true)
Set the yaw for a given object state.
void setTrafficLightState(ObjectState &state, const uint8_t val)
Set the traffic light state for a given object state.
void setRoll(ObjectState &state, const double val, const bool reset_covariance=true)
Set the roll for a given object state.
void setLength(ObjectState &state, const double val, const bool reset_covariance=true)
Set the length for a given object state.
void setPitch(ObjectState &state, const double val, const bool reset_covariance=true)
Set the pitch for a given object state.
void setBrakeLight(ObjectState &state, const uint8_t val)
Set the brake light for a given object state.
void setPitchRate(ObjectState &state, const double val, const bool reset_covariance=true)
Set the pitch-rate for a given object state.
void setStandstill(ObjectState &state, const bool val)
Set the standstill indication for a given object state.
void setZ(ObjectState &state, const double val, const bool reset_covariance=true)
Set the z-position for a given object state.
void setSteeringAngleFront(ObjectState &state, const double val, const bool reset_covariance=true)
Set the front wheel angle for a given object state.
Object state utility functions.
void setContinuousStateCovarianceToUnknownAt(ObjectState &state, const unsigned int i, const unsigned int j)
Set the continuous state covariance to unknown at (i,j) for a given object state.
Definition utils.h:153