13#include "janus/math/Quaternion.hpp"
113 body_position_ = this->
read_param_vec3(
"body_position", Vec3<Scalar>::Zero());
116 if (config.template Has<std::vector<double>>(
"body_orientation_euler_zyx")) {
117 auto euler_deg = config.template Get<std::vector<double>>(
"body_orientation_euler_zyx",
120 if (euler_deg.size() != 3) {
122 "body_orientation_euler_zyx must have 3 elements [yaw, pitch, roll]");
126 constexpr double deg2rad = M_PI / 180.0;
127 double yaw_rad = euler_deg[0] * deg2rad;
128 double pitch_rad = euler_deg[1] * deg2rad;
129 double roll_rad = euler_deg[2] * deg2rad;
134 static_cast<Scalar
>(roll_rad),
static_cast<Scalar
>(pitch_rad),
135 static_cast<Scalar
>(yaw_rad));
136 }
else if (config.template Has<std::vector<double>>(
"body_orientation")) {
139 config.template Get<std::vector<double>>(
"body_orientation", {1.0, 0.0, 0.0, 0.0});
142 throw ConfigError(
"body_orientation must have 4 elements [w, x, y, z]");
146 static_cast<Scalar
>(q[0]),
147 static_cast<Scalar
>(q[1]),
148 static_cast<Scalar
>(q[2]),
149 static_cast<Scalar
>(q[3])
167 const janus::Quaternion<Scalar> &orientation) {
Base class for all simulation components.
Base class for all simulation components.
Definition Component.hpp:47
const ComponentConfig & GetConfig() const
Get component configuration.
Definition Component.hpp:227
Vec3< Scalar > read_param_vec3(const std::string &key, const Vec3< Scalar > &default_val) const
Read a Vec3 config parameter with automatic double→Scalar conversion.
Definition Component.hpp:272
Configuration/parsing errors with optional file context.
Definition Error.hpp:185
Intermediate class for components with physical body attachment.
Definition PhysicalComponent.hpp:77
janus::Quaternion< Scalar > GetBodyOrientation() const override
Get the component's mounting orientation (body-to-component rotation).
Definition PhysicalComponent.hpp:189
void SetBodyAttachment(const Vec3< Scalar > &position, const janus::Quaternion< Scalar > &orientation)
Set body attachment programmatically (for testing or dynamic mounting).
Definition PhysicalComponent.hpp:166
void ReadAttachmentFromConfig()
Read body attachment from component config.
Definition PhysicalComponent.hpp:109
janus::Quaternion< Scalar > GetComponentToBodyRotation() const
Get rotation from component frame to body frame.
Definition PhysicalComponent.hpp:203
bool has_body_attachment_
True after ReadAttachmentFromConfig() is called.
Definition PhysicalComponent.hpp:86
bool HasBodyAttachment() const override
Whether this component has a body attachment (position/orientation).
Definition PhysicalComponent.hpp:185
Vec3< Scalar > TransformToBodyFrame(const Vec3< Scalar > &v_local) const
Transform a vector from component local frame to body frame.
Definition PhysicalComponent.hpp:212
Vec3< Scalar > GetBodyPosition() const override
Get the component's mounting position in vehicle body frame.
Definition PhysicalComponent.hpp:187
Vec3< Scalar > TransformToLocalFrame(const Vec3< Scalar > &v_body) const
Transform a vector from body frame to component local frame.
Definition PhysicalComponent.hpp:221
void SetBodyPosition(const Vec3< Scalar > &position)
Set body position only (orientation defaults to identity).
Definition PhysicalComponent.hpp:177
Vec3< Scalar > body_position_
Mounting position in vehicle body frame [m].
Definition PhysicalComponent.hpp:80
janus::Quaternion< Scalar > body_orientation_
Rotation from body frame to component local frame (identity by default).
Definition PhysicalComponent.hpp:83
Definition AggregationTypes.hpp:13