Talos docs

RoadClosest

Since 0.6

Where a position is relative to a road's centre line: what {@link RoadLine.closest} returns.

Plain text

Signature

export interface RoadClosest {
  /** Distance along the road of the nearest point on the centre line. */
  s: number
  /** Signed sideways distance from the centre line, metres: positive is to the right. */
  offset: number
  /** Straight-line distance to the centre line, metres. */
  distance: number
}

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

Members

MemberSignatureDescription
ss: numberDistance along the road of the nearest point on the centre line.
offsetoffset: numberSigned sideways distance from the centre line, metres: positive is to the right.
distancedistance: numberStraight-line distance to the centre line, metres.

Example

The tested fixture fixtures/app/agent.ts.

import type { Behavior } from "@argus/api"

// Sends a nav agent to `props.target` once, then reports arrival through ctx.state so the
// test can read it without polling the crowd directly.
export default {
  init(ctx) {
    ctx.state.arrived = false
    ctx.nav?.goTo(ctx.props.target as [number, number, number])
  },
  update(ctx) {
    if (ctx.nav?.arrived) ctx.state.arrived = true
  },
} satisfies Behavior