state_at Subroutine

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.

Type Bound

TrajectoryFollower

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)


Calls

proc~~state_at~~CallsGraph proc~state_at TrajectoryFollower%state_at proc~chosen_trajectory chosen_trajectory proc~state_at->proc~chosen_trajectory proc~data_valid TrajectoryFollower%data_valid proc~state_at->proc~data_valid proc~interpolate_attitude interpolate_attitude proc~state_at->proc~interpolate_attitude proc~interpolate_position interpolate_position proc~state_at->proc~interpolate_position proc~time_index Trajectory%time_index proc~state_at->proc~time_index proc~wrapped_time wrapped_time proc~state_at->proc~wrapped_time proc~time_distance Trajectory%time_distance proc~chosen_trajectory->proc~time_distance proc~verify_data Trajectory%verify_data proc~data_valid->proc~verify_data proc~attitude~3 Trajectory%attitude proc~interpolate_attitude->proc~attitude~3 proc~num_attitudes Trajectory%num_attitudes proc~interpolate_attitude->proc~num_attitudes proc~quat_slerp quat_slerp proc~interpolate_attitude->proc~quat_slerp proc~num_points Trajectory%num_points proc~interpolate_position->proc~num_points proc~point_between Trajectory%point_between proc~interpolate_position->proc~point_between proc~point~2 Trajectory%point proc~interpolate_position->proc~point~2 proc~time_index->proc~time_distance proc~time_range~3 Trajectory%time_range proc~wrapped_time->proc~time_range~3 proc~point_between->proc~num_points proc~point_between->proc~point~2 proc~time_fraction Trajectory%time_fraction proc~point_between->proc~time_fraction

Called by

proc~~state_at~~CalledByGraph proc~state_at TrajectoryFollower%state_at proc~followed_pose followed_pose proc~followed_pose->proc~state_at proc~world_matrix_at ReferenceFrame%world_matrix_at proc~followed_pose->proc~world_matrix_at proc~update~2 TrajectoryFollower%update proc~update~2->proc~state_at proc~local_matrix_at ReferenceFrame%local_matrix_at proc~local_matrix_at->proc~followed_pose proc~update ReferenceFrame%update proc~update->proc~followed_pose proc~update->proc~update~2 proc~drawable_update DrawableTrajectory%drawable_update proc~drawable_update->proc~update proc~fm_update FrameManager%fm_update proc~fm_update->proc~update proc~sphere_update Sphere%sphere_update proc~sphere_update->proc~update proc~terrain_update TerrainBody%terrain_update proc~terrain_update->proc~update proc~world_matrix_at->proc~local_matrix_at proc~world_matrix_at->proc~world_matrix_at proc~data_to_shown data_to_shown proc~data_to_shown->proc~world_matrix_at proc~to_shown to_shown proc~to_shown->proc~data_to_shown proc~art_point_between art_point_between proc~art_point_between->proc~to_shown proc~to_shown_at to_shown_at proc~to_shown_at->proc~to_shown proc~art_point art_point proc~art_point->proc~to_shown_at proc~art_points art_points proc~art_points->proc~to_shown_at proc~intermediates_by_time intermediates_by_time proc~intermediates_by_time->proc~art_point_between proc~marker_point marker_point proc~marker_point->proc~to_shown_at proc~marker_point->proc~art_point proc~update_ribbon_tail RibbonArtist%update_ribbon_tail proc~update_ribbon_tail->proc~art_point_between proc~update_ribbon_tail->proc~art_point proc~update_tail CurveArtist%update_tail proc~update_tail->proc~art_point_between proc~update_tail->proc~art_point proc~write_segments write_segments proc~write_segments->proc~to_shown_at proc~add_intermediates add_intermediates proc~add_intermediates->proc~intermediates_by_time proc~intermediates_by_data intermediates_by_data proc~add_intermediates->proc~intermediates_by_data proc~intermediates_by_distance intermediates_by_distance proc~add_intermediates->proc~intermediates_by_distance proc~curve_pick curve_pick proc~curve_pick->proc~art_point proc~intermediates_by_data->proc~art_point proc~intermediates_by_distance->proc~art_point proc~marker_update MarkerArtist%marker_update proc~marker_update->proc~marker_point proc~marker_update->proc~add_intermediates proc~update_bounds update_bounds proc~marker_update->proc~update_bounds proc~segment_update SegmentArtist%segment_update proc~segment_update->proc~write_segments proc~update_bounds->proc~art_points proc~write_curve CurveArtist%write_curve proc~write_curve->proc~art_points proc~write_ribbon RibbonArtist%write_ribbon proc~write_ribbon->proc~art_points proc~drawable_pick DrawableTrajectory%drawable_pick proc~drawable_pick->proc~curve_pick

Source Code

    subroutine state_at(self, sim_time, position, attitude, has_position, has_attitude, time, chosen)
        class(TrajectoryFollower), intent(in) :: self
        real(wp), intent(in) :: sim_time            !! simulation time (s)
        real(wp), intent(inout) :: position(3)      !! the followed position (in the trajectories' frame; unchanged if none)
        real(wp), intent(inout) :: attitude(4)      !! the followed attitude (quaternion [x, y, z, w]; unchanged if none)
        logical, intent(out) :: has_position, has_attitude !! (true: position / attitude set)
        real(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)
        type(Trajectory), pointer :: traj
        real(wp) :: t
        integer :: status, i, k
        has_position = .false.
        has_attitude = .false.
        if (present(time)) time = 0.0_wp
        if (present(chosen)) chosen = 0
        if (self%n == 0) return
        if (self%follow_time) then
            t = sim_time + self%time_value
        else
            t = self%time_value
        end if
        t = wrapped_time(self, t)
        k = chosen_trajectory(self, t)
        if (present(time)) time = t
        if (present(chosen)) chosen = k
        traj => self%trajs(k)%p
        status = traj%time_index(t, i)                      ! (once, for the position and the attitude)
        if (iand(self%data_, FOLLOW_POSITION) /= 0 .and. self%data_valid()) &
            call interpolate_position(traj, self%sources_, t, status, i, position, has_position)
        if (iand(self%data_, FOLLOW_ATTITUDE) /= 0) &
            call interpolate_attitude(traj, t, status, i, attitude, has_attitude)
    end subroutine state_at