Tin

Examples · namespaces · 328 of 339

arm

Imported with import "./arm.tin" as arm: everything here is arm.name to the importer.

examples/namespaces/arm.tintin run examples/namespaces/arm.tin
// Imported with `import "./arm.tin" as arm`: everything here is arm.name to the importer.
// Inside this file, the names are used as they are.

let REACH = 0.55

type Joint = { name: string, angle: float, limit: float }

fn Joint.over(j: Joint): bool => abs(j.angle) > j.limit

/// The joints that are past their limit.
fn overLimit(joints: Joint[]): string[] => joints.filter(j => j.over()).map(j => j.name)

/// Can the arm reach a point this far away, in metres?
tool fn canReach(distance: float): bool => distance <= REACH

agent Planner {
  model: "mock"
  tools: [canReach]
}