Talos docs

RoadSample

Since 0.6

One point on a road's centre line: what {@link RoadLine.at} returns.

Plain text

Signature

export interface RoadSample {
  /** Distance along the road, metres (wrapped into `[0, length)` on a closed road, clamped on an open one). */
  s: number
  /** Centre of the road surface here, world-less: in the road entity's own frame. */
  pos: Vec3
  /** Unit vector along the direction of travel. */
  tangent: Vec3
  /** Unit vector up from the surface, banking included. */
  up: Vec3
  /** Unit vector to the right of the direction of travel: `tangent x up`. */
  right: Vec3
  /** 1/m in the ground plane; positive turning right, negative turning left. */
  curvature: number
  /** Half the road width here, metres (the kerbs are outside it). */
  halfWidth: number
  /** Roll about the tangent, radians; positive lowers the right edge. */
  bank: number
}

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

Members

MemberSignatureDescription
ss: numberDistance along the road, metres (wrapped into [0, length) on a closed road, clamped on an open one).
pospos: Vec3Centre of the road surface here, world-less: in the road entity's own frame.
tangenttangent: Vec3Unit vector along the direction of travel.
upup: Vec3Unit vector up from the surface, banking included.
rightright: Vec3Unit vector to the right of the direction of travel: tangent x up.
curvaturecurvature: number1/m in the ground plane; positive turning right, negative turning left.
halfWidthhalfWidth: numberHalf the road width here, metres (the kerbs are outside it).
bankbank: numberRoll about the tangent, radians; positive lowers the right edge.

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