TrajectoryFollower Derived Type

type, public :: TrajectoryFollower

Follows trajectories (see the module documentation).


Inherits

type~~trajectoryfollower~~InheritsGraph type~trajectoryfollower TrajectoryFollower type~datasource DataSource type~trajectoryfollower->type~datasource sources_ type~trajectorypointer TrajectoryPointer type~trajectoryfollower->type~trajectorypointer trajs type~trajectory Trajectory type~trajectorypointer->type~trajectory p

Inherited by

type~~trajectoryfollower~~InheritedByGraph type~trajectoryfollower TrajectoryFollower type~referenceframe ReferenceFrame type~referenceframe->type~trajectoryfollower follower_ type~referenceframe->type~referenceframe follow_frame_ type~framepointer FramePointer type~referenceframe->type~framepointer children, parents type~coordinateaxes CoordinateAxes type~coordinateaxes->type~referenceframe type~customlinesegments CustomLineSegments type~customlinesegments->type~referenceframe type~draghandle DragHandle type~draghandle->type~referenceframe type~drawabletrajectory DrawableTrajectory type~drawabletrajectory->type~referenceframe data_frame_ type~drawabletrajectory->type~referenceframe type~artistpointer ArtistPointer type~drawabletrajectory->type~artistpointer artists type~framemanager FrameManager type~framemanager->type~referenceframe root type~framepointer->type~referenceframe p type~latlongrid LatLonGrid type~latlongrid->type~referenceframe type~model Model type~model->type~referenceframe type~pickhit PickHit type~pickhit->type~referenceframe frame type~polyhedralcone PolyhedralCone type~polyhedralcone->type~referenceframe type~polyhedron Polyhedron type~polyhedron->type~referenceframe type~radialplane RadialPlane type~radialplane->type~referenceframe type~shadowcones ShadowCones type~shadowcones->type~referenceframe body_, light_ type~shadowcones->type~referenceframe type~sphere Sphere type~sphere->type~referenceframe type~terrainbody TerrainBody type~terrainbody->type~referenceframe type~trajectoryartist TrajectoryArtist type~trajectoryartist->type~referenceframe shown_in, data_frame, seen_data_frame type~view View type~view->type~referenceframe root, frame, lookat type~artistpointer->type~trajectoryartist p type~cameraflight CameraFlight type~cameraflight->type~view from, to type~chainartist ChainArtist type~chainartist->type~trajectoryartist type~ellipticcone EllipticCone type~ellipticcone->type~polyhedralcone type~markerartist MarkerArtist type~markerartist->type~trajectoryartist type~rectangularcone RectangularCone type~rectangularcone->type~polyhedralcone type~segmentartist SegmentArtist type~segmentartist->type~trajectoryartist type~timehandle TimeHandle type~timehandle->type~draghandle type~vectorhandle VectorHandle type~vectorhandle->type~draghandle type~viewpointer ViewPointer type~viewpointer->type~view p type~windowproxy WindowProxy type~windowproxy->type~draghandle hovered_handle, dragged_handle type~windowproxy->type~framemanager scene type~windowproxy->type~view default_view, shown type~windowproxy->type~cameraflight flight type~windowproxy->type~viewpointer views type~curveartist CurveArtist type~curveartist->type~chainartist type~ribbonartist RibbonArtist type~ribbonartist->type~chainartist

Components

Type Visibility Attributes Name Initial
integer, private :: current = 0

index (in trajs) of the trajectory last followed

integer, private :: data_ = FOLLOW_POSITION+FOLLOW_ATTITUDE

what is followed (FOLLOW_* combined with ior)

logical, private :: default_data = .true.

(true: sources_ are the trajectories' positions)

logical, private :: follow_time = .true.

(true: simulation time + time_value; false: time_value)

real(kind=wp), private :: last_time_ = 0.0_wp

time (after looping) at the last update (s)

integer, private :: mode_ = FOLLOW_LOOP

FOLLOW_LOOP or FOLLOW_LIMIT

integer, private :: n = 0

number of followed trajectories

type(DataSource), private :: sources_(3)

where the followed position's x, y, z come from

integer, private :: stamp_ = 0

motion stamp of the last change of settings (next_motion_stamp)

real(kind=wp), private :: time_value = 0.0_wp

time offset or fixed time (s)

type(TrajectoryPointer), private, allocatable :: trajs(:)

(capacity): the followed trajectories


Type-Bound Procedures

procedure, public :: add_trajectory

  • private subroutine add_trajectory(self, traj)

    Also follow traj (no effect if it is already followed).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self
    type(Trajectory), intent(in), pointer :: traj

    the trajectory to add (not owned; null: none)

procedure, public :: data_revision

  • private pure function data_revision(self)

    The sum of the followed trajectories' revisions and generations: it grows with any change to their data (the set of trajectories itself changes the motion_stamp).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self

    Return Value integer

procedure, public :: data_sources

  • private pure function data_sources(self) result(s)

    Where the followed position's x, y and z come from.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self

    Return Value type(DataSource), (3)

procedure, public :: data_valid

  • private pure function data_valid(self)

    True if every followed trajectory has the data the position sources use.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self

    Return Value logical

procedure, public :: follow_data

  • private pure function follow_data(self)

    What is followed: FOLLOW_POSITION and/or FOLLOW_ATTITUDE (combined with ior).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self

    Return Value integer

procedure, public :: follow_mode

  • private pure function follow_mode(self)

    How time outside the trajectories is handled: FOLLOW_LOOP or FOLLOW_LIMIT.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self

    Return Value integer

procedure, public :: is_following_time

  • private pure function is_following_time(self)

    True if following the simulation time plus an offset, false for a fixed time.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self

    Return Value logical

procedure, public :: last_time

  • private pure function last_time(self)

    The time (after looping) at the last update.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self

    Return Value real(kind=wp)

procedure, public :: last_trajectory

  • private function last_trajectory(self) result(traj)

    The trajectory followed at the last update (null if none).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self

    Return Value type(Trajectory), pointer

procedure, public :: motion_stamp

  • private pure function motion_stamp(self)

    The stamp of the last change of the follower's settings (the trajectories followed, what and how, the time); 0 if never changed.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self

    Return Value integer

procedure, public :: num_trajectories

  • private pure function num_trajectories(self)

    Number of trajectories followed.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self

    Return Value integer

procedure, public :: remove_all

  • private subroutine remove_all(self)

    Stop following all trajectories.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self

procedure, public :: remove_trajectory

  • private subroutine remove_trajectory(self, traj)

    Stop following traj.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self
    type(Trajectory), intent(in), pointer :: traj

    the trajectory to stop following

procedure, public :: set_default_data

  • private subroutine set_default_data(self)

    Use the trajectories' positions (per the first trajectory's DOF).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self

procedure, public :: set_follow_type

  • private subroutine set_follow_type(self, data, mode)

    What to follow (FOLLOW_POSITION and/or FOLLOW_ATTITUDE, combined with ior) and how (FOLLOW_LOOP or FOLLOW_LIMIT).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self
    integer, intent(in) :: data

    FOLLOW_POSITION and/or FOLLOW_ATTITUDE (ior)

    integer, intent(in) :: mode

    FOLLOW_LOOP or FOLLOW_LIMIT

procedure, public :: set_offset_time

  • private subroutine set_offset_time(self, offset)

    Follow at the simulation time plus offset (the default, offset 0).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self
    real(kind=wp), intent(in) :: offset

    added to the simulation time (s)

procedure, public :: set_time

  • private subroutine set_time(self, t)

    Follow at a fixed time (independent of the simulation time).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self
    real(kind=wp), intent(in) :: t

    the time (s)

procedure, public :: set_trajectory

  • private subroutine set_trajectory(self, traj)

    Follow only traj (none if it is not associated).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self
    type(Trajectory), intent(in), pointer :: traj

    the trajectory to follow (not owned; null: none)

procedure, public :: set_x_data

  • private function set_x_data(self, src) result(valid)

    Where the x, y and z of the followed position come from (default: the trajectories' positions). Returns whether all followed trajectories have those data.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self
    type(DataSource), intent(in) :: src

    where the x comes from

    Return Value logical

procedure, public :: set_y_data

  • private function set_y_data(self, src) result(valid)

    Where the y of the followed position comes from (see set_x_data).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self
    type(DataSource), intent(in) :: src

    where the y comes from

    Return Value logical

procedure, public :: set_z_data

  • private function set_z_data(self, src) result(valid)

    Where the z of the followed position comes from (see set_x_data).

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self
    type(DataSource), intent(in) :: src

    where the z comes from

    Return Value logical

procedure, public :: state_at

  • private subroutine state_at(self, sim_time, position, attitude, has_position, has_attitude, time, chosen)

    The position and attitude followed at simulation time sim_time, as update (the same time mapping, choice of trajectory and interpolation) but without changing the follower: for any time, e.g. a frame's pose at a trajectory point's own time.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(in) :: self
    real(kind=wp), intent(in) :: sim_time

    simulation time (s)

    real(kind=wp), intent(inout) :: position(3)

    the followed position (in the trajectories' frame; unchanged if none)

    real(kind=wp), intent(inout) :: attitude(4)

    the followed attitude (quaternion [x, y, z, w]; unchanged if none)

    logical, intent(out) :: has_position

    (true: position / attitude set)

    logical, intent(out) :: has_attitude

    (true: position / attitude set)

    real(kind=wp), intent(out), optional :: time

    the trajectories' time used (after the offset and looping)

    integer, intent(out), optional :: chosen

    the trajectory used (index in the followed ones)

procedure, public :: update

  • private subroutine update(self, sim_time, position, attitude, has_position, has_attitude)

    The position and attitude at simulation time sim_time. has_position and has_attitude say whether each could be computed (and is being followed); otherwise position / attitude are left unchanged.

    Arguments

    Type IntentOptional Attributes Name
    class(TrajectoryFollower), intent(inout) :: self
    real(kind=wp), intent(in) :: sim_time

    simulation time (s)

    real(kind=wp), intent(inout) :: position(3)

    the followed position (in the trajectories' frame)

    real(kind=wp), intent(inout) :: attitude(4)

    the followed attitude (quaternion [x, y, z, w])

    logical, intent(out) :: has_position

    (true: position / attitude set)

    logical, intent(out) :: has_attitude

    (true: position / attitude set)

procedure, public :: using_default_data

Source Code

    type, public :: TrajectoryFollower
        private
        type(TrajectoryPointer), allocatable :: trajs(:)    !! (capacity): the followed trajectories
        integer :: n = 0                            !! number of followed trajectories
        integer :: current = 0                      !! index (in trajs) of the trajectory last followed
        integer :: mode_ = FOLLOW_LOOP              !! FOLLOW_LOOP or FOLLOW_LIMIT
        integer :: data_ = FOLLOW_POSITION + FOLLOW_ATTITUDE    !! what is followed (FOLLOW_* combined with ior)
        type(DataSource) :: sources_(3)             !! where the followed position's x, y, z come from
        logical :: default_data = .true.            !! (true: sources_ are the trajectories' positions)
        logical :: follow_time = .true.             !! (true: simulation time + time_value; false: time_value)
        real(wp) :: time_value = 0.0_wp             !! time offset or fixed time (s)
        real(wp) :: last_time_ = 0.0_wp             !! time (after looping) at the last update (s)
        integer :: stamp_ = 0                       !! motion stamp of the last change of settings (next_motion_stamp)
    contains
        procedure :: set_trajectory, add_trajectory, remove_trajectory, remove_all
        procedure :: num_trajectories
        procedure :: set_follow_type, follow_mode, follow_data
        procedure :: set_x_data, set_y_data, set_z_data, data_sources
        procedure :: set_default_data, using_default_data, data_valid
        procedure :: set_time, set_offset_time, is_following_time
        procedure :: last_time, last_trajectory
        procedure :: update, state_at
        procedure :: motion_stamp, data_revision
    end type TrajectoryFollower