Skip to Content

Tennis feed

A feeder hand-feeds a ball over the net and the receiver drives it back with a forehand.

Loading the take.

Each person is a chain of typed actions from @automovie/motions. This is what an agent writes for the scene; Composing motion explains the parts.

import type { IAutoMovieMotionHumanBody, IAutoMovieMotionHumanPerformance } from "@automovie/interface";
import { HumanChain, HumanObject, HumanPerformance, HumanPrecisionSport, HumanSport } from "@automovie/motions";
import * as archetypes from "@automovie/archetypes";

const ana_bench = archetypes.createBench({ height: 0.44, kind: "flat" });
const ana_benchAt = { at: { x: -0.36, y: 0, z: 0.75 }, yaw: 0, fixed: true };
const bea_bench = archetypes.createBench({ height: 0.44, kind: "flat" });
const bea_benchAt = { at: { x: 0.35, y: 0, z: 5.2 }, yaw: 0, fixed: true };
const ana_racket = archetypes.createRacket({ kind: "tennis" });
const ana_racketAt = { position: { x: -0.36, y: 0.452, z: 0.19 }, rotation: { x: 0.7071067811865476, y: 0, z: 0, w: 0.7071067811865476 } };
const bea_racket = archetypes.createRacket({ kind: "tennis" });
const bea_racketAt = { position: { x: 0.35, y: 0.452, z: 5.76 }, rotation: {
  x: -0.7071067811865476,
  y: 0,
  z: 0,
  w: 0.7071067811865476,
} };
const tennis_ball = archetypes.createBall({ kind: "tennis" });
const tennis_ballAt = { at: { x: 0.25, y: 0.474, z: 5.68 }, yaw: 0 };
const court_net = archetypes.createGoal({ kind: "tennisNet" });
const court_netAt = { at: { x: 0, y: 0, z: 3 }, yaw: 0, fixed: true };

// bea: body f2, at (0, 6) m, facing 180°, trained
const bea = HumanChain.subject("bea")
  .act("bend", {
      toward: { kind: "prop", subject: "tennis-ball", point: "grip" },
      side: "left",
    })
  .act("pickUp", {
      prop: "tennis-ball",
      hand: "left",
      handle: "grip",
      lift: 0.14,
    })
  .act("pickUp", {
      prop: "bea-racket",
      handle: "grip",
      lift: 0.1,
      use: { tip: "sweetSpot", line: "oblique" },
    })
  .act("stand", { seconds: 1.5 })
  .act("ballSport", {
      kind: "handballThrow",
      side: "left",
      prop: "tennis-ball",
      at: { x: -0.81, y: 1.28, z: 0.55 },
      flightSeconds: 0.85,
    }, "tennis-feed")
  .act("racket", {
      kind: "readyPosition",
      seconds: 0.4,
      implement: "bea-racket",
    })
  .act("step", { direction: "left", steps: 1 })
  .act("step", { direction: "right", steps: 1 })
  .act("racket", {
      kind: "readyPosition",
      seconds: 0.4,
      implement: "bea-racket",
    })
  .act("step", { direction: "right", steps: 1 })
  .act("step", { direction: "left", steps: 1 })
  .act("racket", {
      kind: "readyPosition",
      seconds: 0.4,
      implement: "bea-racket",
    });

// ana: body f1, at (0, 0) m, facing 0°, trained
const ana = HumanChain.subject("ana")
  .act("pickUp", {
      prop: "ana-racket",
      handle: "grip",
      lift: 0.11,
      use: { tip: "sweetSpot", line: "oblique" },
    })
  .act("racket", {
      kind: "readyPosition",
      seconds: 0.25,
      implement: "ana-racket",
    })
  .act("step", { direction: "right", steps: 1 })
  .act("step", { direction: "left", steps: 1 })
  .registered("bounce", { beats: 4 })
  .registered("tennisForehandReturn", {
      tool: "ana-racket",
      ball: "tennis-ball",
      toward: {
        kind: "point",
        frame: "world",
        at: { x: 0.8, y: 0, z: 5.6 },
      },
      impact: 0.55,
      speed: 8.9,
    }, "tennis-return")
  .sync({
      of: "tennis-feed",
      event: "stroke",
      offset: 0.29999999999999993,
    })
  .act("racket", { kind: "splitStep", seconds: 0.2, implement: "ana-racket" })
  .act("step", { direction: "right", steps: 1 })
  .act("step", { direction: "left", steps: 1 })
  .act("racket", {
      kind: "readyPosition",
      seconds: 0.4,
      implement: "ana-racket",
    })
  .act("racket", { kind: "splitStep", seconds: 0.2, implement: "ana-racket" })
  .act("step", { direction: "left", steps: 1 })
  .act("step", { direction: "right", steps: 1 });

const scene = bea.with(ana);

// The lexicon's laws this scene's rows perform, registered with the performance.
const laws = [HumanSport.bounce, HumanPrecisionSport.tennisForehandReturn];

const props = [
  HumanObject.prop("ana-bench", ana_bench, ana_benchAt),
  HumanObject.prop("bea-bench", bea_bench, bea_benchAt),
  HumanObject.prop("ana-racket", ana_racket, ana_racketAt),
  HumanObject.prop("bea-racket", bea_racket, bea_racketAt),
  HumanObject.prop("tennis-ball", tennis_ball, tennis_ballAt),
  HumanObject.prop("court-net", court_net, court_netAt),
];

// Each body id's motion body, prepared from the site's measures.
declare const bodies: Record<string, IAutoMovieMotionHumanBody>;

const input: IAutoMovieMotionHumanPerformance.IInput = {
  seed: "tennis",
  performers: [
    { subject: "bea", body: bodies["f2"]!, at: { x: 0, y: 0, z: 6 }, yaw: 180, proficiency: { level: "trained" } },
    { subject: "ana", body: bodies["f1"]!, at: { x: 0, y: 0, z: 0 }, yaw: 0, proficiency: { level: "trained" } },
  ],
  composition: scene.node,
  props,
  laws,
};
const performance = new HumanPerformance(input);