Struct aspen::std_nodes::ActiveSequence [] [src]

pub struct ActiveSequence { /* fields omitted */ }

A node that will tick its children in order as long as they succeed.

This node will tick all of its children in order until one of them returns either Status::Running or Status::Failed. If none do, this node succeeds.

The difference between this node and the normal Sequence is that this node will always begin ticking from its first child, where as the normal version will resume ticking with the node that previously returned that it was running. This makes the active version better for things that must be checked each tick (e.g., if motors are too hot) and the normal version better for completing series of actions.

Due to the reticking, some nodes that succeeded on previous ticks may fail on later ticks.

This node is equivalent to an "and" statement.

State

Initialized: Before being ticked after being created or reset.

Running: The latest ticked child node return that it was running.

Succeeded: All child nodes succeeded.

Failed: All child nodes failed.

Children

Any number of children. A child node will be ticked every time this node is ticked as long as all the sibling nodes to the left succeeded.

Note that, if a node is running and a sibling to the left returned either failure or running, the child node will be reset. Additionally, the children will be reset each time the parent is.

Examples

A node that returns success:

let mut node = ActiveSequence::new(vec![
    AlwaysSucceed::new(),
    AlwaysSucceed::new(),
    AlwaysSucceed::new()
]);
assert_eq!(node.tick(), Status::Succeeded);

A node that returns it is running:

let mut node = ActiveSequence::new(vec![
    AlwaysSucceed::new(),
    AlwaysRunning::new(),
    AlwaysFail::new()
]);
assert_eq!(node.tick(), Status::Running);

A node that returns it failed:

let mut node = ActiveSequence::new(vec![
    AlwaysSucceed::new(),
    AlwaysSucceed::new(),
    AlwaysFail::new()
]);
assert_eq!(node.tick(), Status::Failed);

Methods

impl ActiveSequence
[src]

Creates a new ActiveSequence node from a vector of Nodes.

Trait Implementations

impl Internals for ActiveSequence
[src]

Ticks the internal state of the node a single time. Read more

Resets the internal state of the node. Read more

Returns a vector of references to this node's children. Read more

Returns the string "ActiveSequence".