Talos docs

FlightCommand

Since next

What {@link EntityHandle.fly} asks of a multirotor.

Plain text

A field left out keeps what it flew.

Signature

export interface FlightCommand {
  /** `rate` (acro), `angle` (holds level, heading, altitude) or `velocity` (also holds its point). */
  mode?: "rate" | "angle" | "velocity"
  /** Climb (+) or descent (-) as a share of the limits; in rate mode the throttle, 0..1. */
  lift?: number
  /** Turn rate, +1 left. */
  yaw?: number
  /** +1 forward: a tilt, a rate or a speed, by mode. */
  pitch?: number
  /** +1 right. */
  roll?: number
  /** Velocity mode: a world velocity, m/s, in place of the sticks; null clears it. */
  velocity?: Vec3 | null
  /** Disarmed motors stop and the controller forgets what it held. */
  armed?: boolean
}

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

Members

MemberSignatureDescription
modemode?: "rate" | "angle" | "velocity"rate (acro), angle (holds level, heading, altitude) or velocity (also holds its point).
liftlift?: numberClimb (+) or descent (-) as a share of the limits; in rate mode the throttle, 0..1.
yawyaw?: numberTurn rate, +1 left.
pitchpitch?: number+1 forward: a tilt, a rate or a speed, by mode.
rollroll?: number+1 right.
velocityvelocity?: Vec3 | nullVelocity mode: a world velocity, m/s, in place of the sticks; null clears it.
armedarmed?: booleanDisarmed motors stop and the controller forgets what it held.

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