Talos docs

FlightState

Since next

What a multirotor did on the last tick ({@link EntityHandle.flight}).

Plain text

Signature

export interface FlightState {
  /** The flight mode it flew. */
  mode: "rate" | "angle" | "velocity"
  /** Whether its motors are on. */
  armed: boolean
  /** Total thrust, newtons. */
  thrust: number
  /** Tilt from level, radians. */
  tilt: number
  /** Heading, radians: 0 facing -Z, positive turned left. */
  heading: number
  /** Speed through the air, m/s (the wind included). */
  airspeed: number
  /** Speed over the ground, m/s. */
  groundSpeed: number
  /** Vertical speed, m/s, up positive. */
  climbRate: number
  /** Battery left, 0..1. */
  charge: number
  /** The battery ran out and the motors stopped. */
  empty: boolean
  /** It holds a point (velocity mode, sticks centred). */
  holdingPosition: boolean
  /** It holds an altitude (lift centred). */
  holdingAltitude: boolean
  /** The rotors could not give everything asked this tick. */
  saturated: boolean
  /** On the ground with its motors idling; a climb takes it off. */
  landed: boolean
  /** Each rotor's speed as a share of full, 0..1. */
  rotorSpeeds: number[]
}

Import: import type { FlightState } from "@argus/api"

Members

MemberSignatureDescription
modemode: "rate" | "angle" | "velocity"The flight mode it flew.
armedarmed: booleanWhether its motors are on.
thrustthrust: numberTotal thrust, newtons.
tilttilt: numberTilt from level, radians.
headingheading: numberHeading, radians: 0 facing -Z, positive turned left.
airspeedairspeed: numberSpeed through the air, m/s (the wind included).
groundSpeedgroundSpeed: numberSpeed over the ground, m/s.
climbRateclimbRate: numberVertical speed, m/s, up positive.
chargecharge: numberBattery left, 0..1.
emptyempty: booleanThe battery ran out and the motors stopped.
holdingPositionholdingPosition: booleanIt holds a point (velocity mode, sticks centred).
holdingAltitudeholdingAltitude: booleanIt holds an altitude (lift centred).
saturatedsaturated: booleanThe rotors could not give everything asked this tick.
landedlanded: booleanOn the ground with its motors idling; a climb takes it off.
rotorSpeedsrotorSpeeds: number[]Each rotor's speed as a share of full, 0..1.

Example

The tested fixture fixtures/host/door.ts.

import type { Behavior } from "@argus/api"
// docs/API.md, "Joints": a door on a hinge that swings open while the player is near and closes
// behind them. Typechecked by packages/api's tests.
export default {
  update(ctx) {
    const player = ctx.world.find("player")
    const near = player !== null && ctx.entity.distanceTo(player) < 2
    ctx.joint?.setMotor(near ? Math.PI / 2 : 0, { mode: "position", maxForce: 200 })
  },
} satisfies Behavior