Skip to content

Daody/trajectory-generator

Repository files navigation

Trajectory Generator (MATLAB)

MATLAB Platform License

Synthetic rigid-body trajectory generator in local ENU (East–North–Up) with lever arms (fixed points rigidly attached to the body, e.g., antennas/sensors).
Produces time series of position/velocity/acceleration for the reference point C and additional points A1–A3, plus attitude as quaternion and DCM.


Contents


Features

  • IMU-rate trajectory generation (dt_INS) with optional GNSS-rate support (dt_GPS).

  • Attitude integration on quaternions (robust, no gimbal lock).

  • Correct rigid-body kinematics for lever-arm points:

    • Position: r_i = r_C + C_nb * r_i_body
    • Velocity: v_i = v_C + C_nb * (ω × r_i_body)
    • Acceleration: a_i = a_C + C_nb * (ω̇ × r + ω × (ω × r))
  • Saves results into Traject.mat for further processing.

  • Comet-like 3D animation (simultaneous for all points) using animatedline.


Repository layout

Typical layout (file names may vary depending on your checkout):

  • trajectory_generator.m — main script (trajectory generation + animation + saving Traject.mat)
  • quat_from_rotvec.m — quaternion from rotation vector (scalar-first)
  • quat_mul.m — quaternion multiplication (Hamilton product, scalar-first)
  • quat_to_dcm.m — quaternion → DCM
  • skew.m — skew-symmetric cross-product matrix [w]× (optional helper)
  • utc2gps.m — UTC→GPS time helper (optional)
  • dcm_2vect.m — DCM utility (optional)
  • ecef2llh.m, ecef2enu.m, enu2ecef.m — coordinate transforms (optional)

Some helpers may not be called directly by trajectory_generator.m but are included for common navigation/simulation workflows.


Requirements

  • MATLAB R2016b+ recommended.
  • No toolboxes required (base MATLAB).

Quick start

  1. Clone the repository and open the project folder in MATLAB.
  2. Run the main script:
trajectory_generator

After execution:

  • an animation window appears (if enabled in the script),
  • Traject.mat is saved in the current folder.

Configuration

All configuration is done in trajectory_generator.m via the params structure.

Common parameters:

  • params.dt_INS — IMU integration step (seconds)
  • params.dt_GPS — GNSS step (seconds, optional)
  • params.time_mode — how stage durations are interpreted:
    • 'samples' — durations are IMU sample counts
    • 'seconds' — durations in seconds (converted using dt_INS)
  • params.module_base — lever-arm baseline size (meters)
  • Stage durations:
    • params.Fixed
    • params.Increment_Linear_Velocity
    • params.Without_Increment_Velocity
    • params.Increment_Angular_Velocity
    • params.With_Set_Params
  • Motion commands (example):
    • params.a_lin_body — constant linear acceleration during stage 2
    • params.w_ddot_z — yaw angular acceleration during stage 4
  • Visualization:
    • params.plot_decim, params.tail, params.pause_dt

Axis convention note (important):
The “forward” direction depends on your Body axes. If forward is +X, use acceleration [a;0;0].
If forward is +Y, use [0;a;0].


Outputs

The script writes Traject.mat with (main fields):

  • dt, dt_INS, dt_GPS, count, t, params
  • W_body (3×N) — angular velocity in Body
  • W_dot_body (3×N) — angular acceleration in Body
  • C_bodyframe2inertial (3×3×N)C_nb (Body → ENU)
  • For points C, A1, A2, A3:
    • R_ENU_* (3×N) — position in ENU
    • V_ENU_* (3×N) — velocity in ENU
    • A_ENU_* (3×N) — acceleration in ENU
  • q_nb_hist (4×N) — attitude quaternion (Body → ENU), scalar-first (if saved)

Visualization

By default, trajectory_generator.m includes a comet-like 3D animation using animatedline.

Tuning knobs:

  • params.plot_decim — decimation for plotting
  • params.tail — tail length (points)
  • params.pause_dt — animation speed (seconds)

If your motion is planar (e.g., U = 0), you can switch to a 2D view (plot / comet) for clearer visuals.


Coordinate frames and conventions

  • ENU is used as the navigation frame: E (x), N (y), U (z).
  • Body is a rigid frame attached to the platform.
  • Quaternion q_nb is scalar-first ([w x y z]ᵀ) and maps Body → ENU.
  • DCM C_nb maps Body → ENU and is stored as C_bodyframe2inertial.

Citing

If you use this code in a report or publication, cite it as:

Dmitry Kaleev, Trajectory Generator (MATLAB): Rigid Body in ENU with Lever Arms, 2026.


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages