The FixedTurn Behavior
Maintained by: mikerb@mit.edu Get PDF
src: project-pavlab/bhvdocs/bhv_fixedturn
1 The FixedTurn Behavior
1.1 Intended Mission Use
1.2 The Core Algorithm
1.3 Configuration and Operation Mechanics
1.3.1 Configuring the Turns
1.4 Configuration Parameters
1.5 Variables Published
1.6 Flags and Macros
1 The FixedTurn Behavior
The FixedTurn behavior allows a vehicle to execute a turn with parameters for configuring the duration of the turn (in degrees), and the commanded changes in desired heading during the turn. The behavior is primarily motivated by supporting surface vehicle shake-out tests, but may be used in any mission where this pattern is desired. The behavior can be configured with varying number of turns, order of turns, and the number of degrees for each turn, and the manner in which the turn is requested.


Figure 1.1: FixedTurn Behavior: A vehicle executes a FixedTurn behavior, with a single turn shown. The behavior starts and finishes within a pause of the LegRun behavior using the basic LegRun ability to initiate an event at given point in a leg. (From demo mission missions-auto/04-fixedturn).


Turns in a FixedTurn behavior are accomplished by continuously requesting a heading change of a configured fixed value, monitoring the number of degrees in a turn, until the turn completion criteria is reached. Completion criteria is in number of degrees, e.g, a 180 degree turn, or a 270 degree turn.

1.1 Intended Mission Use [top]
A FixedTurn behavior is configured with a sequence of parameterized turns. A turn configuration will prescribe the turn speed, the fixed delta heading, the total number of degrees for the turn, and the turn direction. For example, the following two turns only differ in direction.


turn_spec = spd=1.5, mhdg=10, fix=355, turn=star turn_spec = spd=1.5, mhdg=10, fix=355, turn=port



Once the turn has been completed, an end flag is published, presumably resulting in the FixedTurn behavior becoming idle. The next time the FixedTurn behavior enters the running state, the next turn in the list of turns will be executed. Presumably, in the meanwhile, while in the idle state, other behaviors in the mission will maneuver the vehicle to a position where the nexted turn is safe for execution. In the intended use case for this behavior, there is typically no obstacle or collision avoidance behaviors running during the turn. The mission author of course is free to do otherwise. However, the behavior was conceived to support the goal of conducting a controlled turn in a safe, hazard-free space, to gauge vehicle performance.


1.2 The Core Algorithm [top]
The basic FixedTurn behavior will be configured with a sequence of turns, where each turn can be configured in terms of turn direction and size. The intended use for this behavior is for it to be run as a mission interuption of sorts, while the behavior is otherwise transiting. In the example in Figure 1.3, the turn is executing in the middle of the long straight leg of the vehicle running the LegRun behavior. This is from Example Mission N.

OnRunState() Flow Chart [top]
The primary operation of the behavior is contained within the OnRunState() function. This is shown the flow chart and the pseudocode that follows. Step 1 of this sequence is to update the current value of ownship position and heading, a common first step in many behaviors. For this behavior, ownship heading is the key value for reasoning about turn completion.


Figure 1.2: FixedTurn Behavior Loop Flow Chart: Each iteration of the FixedTurn behavior will proceed through the steps shown, with branching determined by sensed events and the behavior configuration. Details of each step are discuss in their own sections as indicated.




OnRunState() Pseudo Code [top]




In Step 2, the behavior checks to see if there is a timeout threshold specified for this turn. If there is, the timer is started as soon as the behavior transitions into the running state. The elapsed time since then is compared to the timeout threshold and, if it is exceeded, the behavior regards the turn as completed. In Step 3, the turn is checked for completion based on the turn degrees specified, and how much the vehicle has turned thus far. Although a full 360 degree turn is common, the specified turn may be any value, even beyond 360 degrees.

In Step 4, a behavior completion sequence is conducted. This includes the posting of end flags and inactive flags, if they are provided by the user in the behavior configuration. As well as turn flags, which are separate flags supported uniquely for this behavior, posted whenever a turn has been completed.

In Step 5, depending on whether the current turn is to the port or starboard, the desired heading set point θsp, is set to be offset from ownship current heading θOS by the number of degrees, prescribed in the configuration parameter mod_hdg. This heading set point is passed, in Step 6 to the function where the IvP objective function (ipf) is created. See Section ???.

In Step 7, finally the run flags and active flags are posted this at this stage the behavior is in both the running (non-idle) and active (generates an IvP Function) state. The IvP function is returned to the helm to contribute to the selection of the heading and speed for the current helm iteration.



1.3 Configuration and Operation Mechanics [top]

1.3.1 Configuring the Turns [top]
The FixedTurn behavior is configured with one or more turns, constituting a turn sequence. A single turn is comprised of the following turn elements:

- turn length: number of degrees constituting a turn
- heading offset: requested change of heading during the turn
- turn speed: desired speed during the turn
- turn direction: port or starboard
- turn timeout: a max time, in seconds, allowed for the turn
- turn flags: one or more flags to be posted at turn completion.



turn_spec = spd=2.5, mhdg=20, fix=360, turn=star, timeout=60 turn_spec = spd=2.5, mhdg=20, fix=360, turn=port, timeout=60 turn_spec = spd=4.0, mhdg=10, fix=180, turn=star, flag=STAGE=complete turn_spec = spd=4.0, mhdg=10, fix=180, turn=port, flag=STAGE=complete




Figure 1.3: Back-to-back Turns: A vehicle executes a FixedTurn mission s6_legrun).





1.4 Configuration Parameters [top]

Listing 1.1 - Configuration Parameters for the FixedTurn Behavior.

Parameter | Description |
fix_turn: | The default turn threshold for any turn that does not provide one. The default value is 0 degrees. Section 1.3.1. |
mod_hdg: | The default heading offset, ![]() |
turn_dir: | The default turn direction for any turn that does specify a direction. The default direction is port. Section 1.3.1. |
speed: | The default speed for any turn that does not specify a turn speed. The default value is 1 meter per second. Section 1.3.1. |
timeout: | The default timeout duration, in seconds, for any turn that does not specify one. The default value is -1, indicating there is not timeout for the turn. Section 1.3.1. |
turn_delay: | Duration in seconds at the start of turn before requesting a heading change, presumably to allow for a speed adjustment befor turning. |
turn_spec: | A full specification for a scheduled turn. Section 1.3.1. |
stale_nav_thresh: | The number of seconds, after which an update nav position and heading has not been received, befor the behavior throws a warning. Section 1.3.1. |
schedule_repeat: | The number of times the full list of turns in the turn schedule will be repeated. The default is zero. Section 1.3.1. |
visual_hints: | Color and other settings for posted visual artifacts. Section 1.3.1. |


Listing 1.2 - Example Configuration Block.

Behavior = BHV_FixedTurn { name = zig pwt = 100 condition = MODE==FTURNING endflag = FIX_TURN = false updates = FTURN_UPDATE perpetual = true fix_turn = tbd mod_hdg = 20 turn_dir = star speed = 2 timeout = 60 turn_delay = 10 turn_spec = spd=auto, mhdg=10, fix=355, turn=auto, flag=FIX_TURN=false turn_spec = spd=auto, mhdg=30, fix=355, turn=port, flag=FIX_TURN=false stale_nav_thresh = 5 schedule_repeat = true visual_hints = vertex_color=dodger_blue visual_hints = vertex_size=4 }



1.5 Variables Published [top]
The below MOOS variables will be published by the behavior during normal operation, in addition to any configured flags.

- VIEW_SEGLIST: A visual cue for rendering the requested zig angle, if either draw_set_hdg=true or draw_req_hdg=true in the visual_hints.
- FT_REPORT: A report posted at the end of each turn, with parameter for the turn and observed turn radius information. An example is given below.



FT_REPORT = spd=0.88,mod_hdg=10,rudder_avg=10.7,avg_rad=55.5,min_rad=54.23,max_rad=56.1}



1.6 Flags and Macros [top]
The FixedTurn behavior supports all the normal behavior flags, and a custom flag(s) can be added to the end of each turn.

The folowing macros are supported in the FixedTurn behavior. These macros will be expanded in any event flag, including event flags defined for all IvP behaviors as well as event flags defined only for the FixedTurn behavior.


- TURN_DIST: Total odometry in the current or most recent turn.
- TURN_TIME: Total time since the beginning of the current or most recent turn.



Document Maintained by: mikerb@mit.edu
Page built from LaTeX source using texwiki, developed at MIT. Errata to issues@moos-ivp.org.
Get PDF