diff --git a/.gitignore b/.gitignore index 04f7cc6..1ca126a 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,6 @@ assets/_downloads/ # Validation outreach drafts (kept local) outreach/ + +# Replay renders (assets/blender/render_replay.py): frames and videos +renders/ diff --git a/README.md b/README.md index fb33d46..73ef8f7 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Only licenses that allow redistribution, modification and commercial use are acc - Operator models beyond the scripted cycle (learned or recorded operator inputs), and checking heaped bucket loads against field data - Converged soil solves: loads still depend on the MPM iteration count -- A living site: the haul cycle, the D37 dozer spreading the spoil, two carriers sharing the road, track–soil contact, compaction of the spread layers, a roller, a fill area in two cells (one spread while the other is rolled) and a buffer between them are done. The operator now chooses each cut where the soil is, so loading holds steady over a long shift in loam and clay. Long shifts hold steady in all three soils. Density is recorded for each lift as it is covered, and the machines keep clear of each other (routes, a clearance check and give-way). The roller now finishes the cell the dozer waits for (it leaves a lane after 12 passes, and the waiting dozer makes way), and waits for any soil there, spill included, so every lift is covered at least 91 % rolled. The benchmark now produces a time study in the field format (cycle elements, means and spreads): the excavator's net cycle, 17–18 s at a 103° swing, matches the published range, and an optional human operator (pauses, part-open levers, varying cuts) spreads each element as much as in the field and brings the cycle to the field study's 20.8 s. A second carrier halves the excavator's wait; the 26–30 s that remain are the exchange at the one-lane loading spot. The swing back no longer stalls on spill between the carrier and the pit. With a second loading spot on the other side of the excavator, it no longer waits at all, and six loads go out 5–19 % sooner. Next: a field time study of the real machines to fit it to +- A living site: the haul cycle, the D37 dozer spreading the spoil, two carriers sharing the road, track–soil contact, compaction of the spread layers, a roller, a fill area in two cells (one spread while the other is rolled) and a buffer between them are done. The operator now chooses each cut where the soil is, so loading holds steady over a long shift in loam and clay. Long shifts hold steady in all three soils. Density is recorded for each lift as it is covered, and the machines keep clear of each other (routes, a clearance check and give-way). The roller now finishes the cell the dozer waits for (it leaves a lane after 12 passes, and the waiting dozer makes way), and waits for any soil there, spill included, so every lift is covered at least 91 % rolled. The benchmark now produces a time study in the field format (cycle elements, means and spreads): the excavator's net cycle, 17–18 s at a 103° swing, matches the published range, and an optional human operator (pauses, part-open levers, varying cuts) spreads each element as much as in the field and brings the cycle to the field study's 20.8 s. A second carrier halves the excavator's wait; the 26–30 s that remain are the exchange at the one-lane loading spot. The swing back no longer stalls on spill between the carrier and the pit. With a second loading spot on the other side of the excavator, it no longer waits at all, and six loads go out 5–19 % sooner. When a carrier comes, the dozer now finishes its push and waits clear at the lane's end instead of parking, which cuts the carrier's wait at the dump in clay from 108 to 63 s. Next: a field time study of the real machines to fit it to - Research APIs: the Gymnasium environment, the lidar, depth camera and IMU, and the ROS 2 bridge are done (the carrier and the dozer are in all three). Next: a `ros2_control` hardware interface, sensor noise models, and several environments per GPU - Measured ZX200 masses, swing torque and pressure logs for validation - Measured pressure logs, port relief and house inertia to validate the hydraulics diff --git a/assets/README.md b/assets/README.md index d8a6dd5..aee3eba 100644 --- a/assets/README.md +++ b/assets/README.md @@ -64,4 +64,44 @@ assets/ fetch_assets.py downloads "fetched" assets and checks licenses are recorded machinery/ machines (excavators, trucks, loaders, cranes, ...) site/ site equipment, people, materials + blender/ machines modelled in code, and the replay renderer (Blender 4.0) ``` + +## Machines modelled in Blender + +`assets/blender/` builds detailed models procedurally with Blender's Python API, so they can be rebuilt, +reviewed and changed like code. Install Blender (`sudo apt install blender` on Ubuntu, ARM included), then: + +``` +blender -b -t 4 --python assets/blender/zx200_hd.py # -> assets/machinery/zx200_hd.glb +blender -b -t 4 --python assets/blender/roller_hd.py # -> assets/machinery/roller_hd.glb +blender -b -t 4 --python assets/blender/ic120_hd.py # -> assets/machinery/ic120_hd.glb +blender -b -t 4 --python assets/blender/d37_hd.py # -> assets/machinery/d37_hd.glb +``` + +- `blendkit.py`: shapes, bevelled parts, box-projected UVs, tileable procedural textures (paint, worn paint, + steel, track, rubber: colour variation, chips, scratches, grime, roughness and normal maps), glTF export. +- `zx200_hd.py`: 20 t excavator to the dimensions and pins of PWRI's OPERA ZX200. It keeps the node names, + link frames, joint extras and free parts of `opera_zx200.glb`, so it replaces it without code changes + (the browser loads it in place of the OPERA model). `-- --beauty --render out/prefix` renders review + images with EEVEE. +- `roller_hd.py`: 10.6 t single-drum roller to `phase2/roller.py`; the drum and rear wheels are nodes that + turn as it moves. +- `ic120_hd.py`: rubber-tracked crawler carrier on the joint frames of PWRI's OPERA IC120; the vessel follows + the server's vessel boxes so the load sits on its floor. Replaces `opera_ic120.glb` in the browser. +- `d37_hd.py`: crawler dozer with a power-angle-tilt blade on the joint frames of PWRI's OPERA D37PXi, lift + and angle cylinders on the source's joints. Replaces `opera_d37pxi.glb` in the browser. + +## Rendering a replay + +`assets/blender/render_replay.py` renders a recording (`phase2/record_replay.py`) with EEVEE: the site +terrain, the soil surfaces, the grains and every machine posed as the browser poses them. Frames and an MP4 +go to `renders/` (git-ignored). Long renders load the CPU and GPU for a while: watch the temperature. + +``` +blender -b -t 4 --python assets/blender/render_replay.py -- --still --from 150 --camera overview +blender -b -t 4 --python assets/blender/render_replay.py -- --from 140 --to 160 --camera excavator --res 1280x720 +``` + +Cameras: `overview`, `excavator`, `spread`. Ubuntu's Blender has no Cycles (path tracing) on ARM; EEVEE takes +a few seconds a frame. diff --git a/assets/blender/blendkit.py b/assets/blender/blendkit.py new file mode 100644 index 0000000..ae8f9a8 --- /dev/null +++ b/assets/blender/blendkit.py @@ -0,0 +1,571 @@ +"""Small modelling kit for building machines procedurally in Blender (bpy + bmesh), shared by the machine +scripts in this folder. Everything is in metres, Z up, in the frame of whatever object a part is parented to. + +Shapes are added to a bmesh (add_*), then turned into an object with make(); make() adds a bevel modifier +(applied on glTF export) and smooth shading with sharp edges kept by the auto-smooth angle. +""" + +import json +import math +import struct + +import bmesh +import bpy +import numpy as np +from mathutils import Matrix, Vector + +# ------------------------------------------------------------------ scene + + +def reset(): + bpy.ops.wm.read_factory_settings(use_empty=True) + + +def coll(): + return bpy.context.scene.collection + + +def empty(name, parent=None, matrix=None, size=0.15): + e = bpy.data.objects.new(name, None) + coll().objects.link(e) + e.empty_display_size = size + if parent is not None: + e.parent = parent + if matrix is not None: + e.matrix_basis = matrix + return e + + +def srgb(hexstr): + """'#rrggbb' -> linear RGB (Blender colour values are linear).""" + h = hexstr.lstrip("#") + c = [int(h[i : i + 2], 16) / 255 for i in (0, 2, 4)] + return tuple(x / 12.92 if x <= 0.04045 else ((x + 0.055) / 1.055) ** 2.4 for x in c) + + +def material(name, color, rough=0.5, metal=0.0, coat=0.0, alpha=1.0, emit=None, emit_strength=2.0): + m = bpy.data.materials.new(name) + m.use_nodes = True + p = m.node_tree.nodes["Principled BSDF"] + p.inputs["Base Color"].default_value = (*srgb(color), 1) + p.inputs["Roughness"].default_value = rough + p.inputs["Metallic"].default_value = metal + if coat: + p.inputs["Coat Weight"].default_value = coat + p.inputs["Coat Roughness"].default_value = 0.08 + if alpha < 1: + p.inputs["Alpha"].default_value = alpha + m.blend_method = "BLEND" + m.shadow_method = "NONE" + if emit: + p.inputs["Emission Color"].default_value = (*srgb(emit), 1) + p.inputs["Emission Strength"].default_value = emit_strength + m.diffuse_color = (*srgb(color), alpha) # what the Workbench preview shows + m.metallic, m.roughness = metal, rough + return m + + +UV_TILE = 2.0 # metres per texture tile + + +def box_uv(bm): + """Box-projected UVs (each face takes the plane its normal faces most), one tile per UV_TILE metres, in the + part's own frame, so the tiling textures keep a constant size on every part.""" + uv = bm.loops.layers.uv.verify() + bm.normal_update() + for f in bm.faces: + n = f.normal + ax = max(range(3), key=lambda k: abs(n[k])) + for loop in f.loops: + c = loop.vert.co + u, v = ((c.y, c.z), (c.x, c.z), (c.x, c.y))[ax] + loop[uv].uv = (u / UV_TILE, v / UV_TILE) + + +# ------------------------------------------------------------------ procedural textures (tileable, numpy) + + +def _fbm(n, beta, rng, lo=1.0): + """Tileable fractal noise in [0, 1]: white noise shaped to a 1/f^beta spectrum.""" + w = np.fft.fft2(rng.standard_normal((n, n))) + f = np.fft.fftfreq(n) * n + r = np.sqrt(f[:, None] ** 2 + f[None, :] ** 2) + r[0, 0] = 1.0 + h = np.real(np.fft.ifft2(w / np.maximum(r, lo) ** beta)) + return (h - h.min()) / (h.max() - h.min() + 1e-9) + + +def _blur(a, sigma): + n = a.shape[0] + f = np.fft.fftfreq(n) + g = np.exp(-2 * (math.pi * sigma) ** 2 * (f[:, None] ** 2 + f[None, :] ** 2)) + return np.real(np.fft.ifft2(np.fft.fft2(a) * g)) + + +def _scratches(n, count, rng, length=(0.008, 0.04), bias=None): + """Thin random scratches (wrapping), as a [0, 1] mask.""" + m = np.zeros((n, n)) + for _ in range(count): + x, y = rng.uniform(0, n, 2) + a = rng.uniform(0, math.pi) if bias is None else bias + rng.normal(0, 0.25) + L = rng.uniform(*length) * n + t = np.arange(0, L, 0.5) + xs = (x + t * math.cos(a)).astype(int) % n + ys = (y + t * math.sin(a)).astype(int) % n + m[ys, xs] = np.maximum(m[ys, xs], rng.uniform(0.4, 1.0)) + return np.clip(_blur(m, 0.6) * 2.5, 0, 1) + + +def _hex01(h): + h = h.lstrip("#") + return np.array([int(h[i : i + 2], 16) / 255 for i in (0, 2, 4)]) + + +SURFACES = { + # kind: colour variation, chipping (share of area), scratch count, grime, rough base and spread, metal, bump + "paint": dict(var=0.05, chips=0.035, chip_color="#3b3936", chip_rough=0.55, chip_metal=0.6, scratches=45, grime=0.10, rough=(0.36, 0.08), metal=0.0, bump=0.35), + "paint_worn": dict(var=0.07, chips=0.08, chip_color="#4a4744", chip_rough=0.5, chip_metal=0.7, scratches=70, grime=0.28, rough=(0.42, 0.1), metal=0.0, bump=0.5), + "steel": dict(var=0.12, chips=0.0, scratches=160, grime=0.3, rough=(0.55, 0.15), metal=0.6, bump=0.8, rust="#5b3b24", rust_share=0.10), + "track": dict(var=0.18, chips=0.0, scratches=60, grime=0.45, rough=(0.72, 0.1), metal=0.55, bump=1.0, rust="#6a4126", rust_share=0.3), + "worn_edge": dict(var=0.1, chips=0.0, scratches=260, grime=0.1, rough=(0.38, 0.12), metal=0.9, bump=0.7), + "rubber": dict(var=0.06, chips=0.0, scratches=15, grime=0.3, rough=(0.82, 0.06), metal=0.0, bump=0.6), +} + + +def texture_set(name, color, kind, size=1024, seed=0): + """Albedo (sRGB), ORM (R 1, G roughness, B metalness) and normal map images for one material.""" + s = SURFACES[kind] + rng = np.random.default_rng(seed) + n = size + base = _hex01(color) + lo, mid, hi = _fbm(n, 2.4, rng), _fbm(n, 1.6, rng), _fbm(n, 1.0, rng) + alb = np.ones((n, n, 3)) * base + alb *= (1 + s["var"] * (lo - 0.5) * 2 + 0.3 * s["var"] * (hi - 0.5))[..., None] + grime = np.clip((lo * 0.7 + mid * 0.3 - 0.45) * 2.2, 0, 1) * s["grime"] + alb = alb * (1 - grime[..., None]) + _hex01("#4d4234") * grime[..., None] + rough = s["rough"][0] + s["rough"][1] * (mid - 0.5) * 2 + 0.25 * grime + metal = np.full((n, n), s["metal"]) + height = 0.15 * (hi - 0.5) # orange peel / cast texture + if s.get("rust"): + rust = np.clip((_fbm(n, 1.8, rng) - (1 - s["rust_share"])) * 6, 0, 1) + alb = alb * (1 - rust[..., None]) + _hex01(s["rust"]) * rust[..., None] + rough = rough + 0.2 * rust + metal = metal * (1 - 0.7 * rust) + height += 0.3 * rust * hi + if s["chips"]: + cn = _fbm(n, 1.3, rng) * 0.6 + hi * 0.4 + chips = np.clip((cn - (1 - s["chips"])) * 25, 0, 1) + alb = alb * (1 - chips[..., None]) + _hex01(s["chip_color"]) * chips[..., None] + rough = rough * (1 - chips) + s["chip_rough"] * chips + metal = metal * (1 - chips) + s["chip_metal"] * chips + height -= 0.6 * chips + sc = _scratches(n, s["scratches"], rng) + alb = alb * (1 - 0.1 * sc[..., None]) + (base * 0.7 + 0.15) * 0.1 * sc[..., None] # faint: mostly a gloss and bump change + rough = rough * (1 - 0.5 * sc) + 0.25 * sc + height -= 0.1 * sc + h = height * s["bump"] + gx = (np.roll(h, -1, 1) - np.roll(h, 1, 1)) * 0.5 + gy = (np.roll(h, -1, 0) - np.roll(h, 1, 0)) * 0.5 + nrm = np.dstack([-gx * 3.5, -gy * 3.5, np.ones_like(h)]) + nrm /= np.linalg.norm(nrm, axis=2, keepdims=True) + imgs = {} + for key, arr, srgb_space in ( + ("albedo", np.clip(alb, 0, 1), True), + ("orm", np.dstack([np.ones_like(rough), np.clip(rough, 0.03, 1), np.clip(metal, 0, 1)]), False), + ("normal", nrm * 0.5 + 0.5, False), + ): + img = bpy.data.images.new(f"{name}_{key}", n, n, alpha=False) + img.colorspace_settings.name = "sRGB" if srgb_space else "Non-Color" + rgba = np.dstack([arr, np.ones((n, n))]).astype(np.float32) + img.pixels.foreach_set(rgba.ravel()) + img.file_format = "JPEG" + img.pack() + imgs[key] = img + return imgs + + +def textured(mat, imgs): + """Wire a texture set into a Principled material (glTF-exportable layout).""" + nt = mat.node_tree + p = nt.nodes["Principled BSDF"] + a = nt.nodes.new("ShaderNodeTexImage") + a.image = imgs["albedo"] + nt.links.new(a.outputs["Color"], p.inputs["Base Color"]) + o = nt.nodes.new("ShaderNodeTexImage") + o.image = imgs["orm"] + sep = nt.nodes.new("ShaderNodeSeparateColor") + nt.links.new(o.outputs["Color"], sep.inputs["Color"]) + nt.links.new(sep.outputs["Green"], p.inputs["Roughness"]) + nt.links.new(sep.outputs["Blue"], p.inputs["Metallic"]) + nm = nt.nodes.new("ShaderNodeTexImage") + nm.image = imgs["normal"] + nmap = nt.nodes.new("ShaderNodeNormalMap") + nmap.inputs["Strength"].default_value = 1.0 + nt.links.new(nm.outputs["Color"], nmap.inputs["Color"]) + nt.links.new(nmap.outputs["Normal"], p.inputs["Normal"]) + return mat + + +def surface(name, color, kind, size=1024, seed=0, coat=0.0): + """A textured material in one call.""" + s = SURFACES[kind] + m = material(name, color, rough=s["rough"][0], metal=s["metal"], coat=coat) + return textured(m, texture_set(name, color, kind, size, seed)) + + +def make(name, parent, mat, build, bevel=0.0, segs=2, smooth=True, matrix=None, angle=40, mesh=None): + """Object from a bmesh builder (or an existing mesh, shared). Bevel is a modifier, applied on export.""" + if mesh is None: + bm = bmesh.new() + build(bm) + bmesh.ops.remove_doubles(bm, verts=bm.verts[:], dist=1e-6) + bmesh.ops.recalc_face_normals(bm, faces=bm.faces[:]) + box_uv(bm) + mesh = bpy.data.meshes.new(name) + bm.to_mesh(mesh) + bm.free() + for p in mesh.polygons: + p.use_smooth = smooth + mesh.use_auto_smooth = True + mesh.auto_smooth_angle = math.radians(35) + mesh.materials.append(mat) + ob = bpy.data.objects.new(name, mesh) + coll().objects.link(ob) + if parent is not None: + ob.parent = parent + if matrix is not None: + ob.matrix_basis = matrix + if bevel > 0: + m = ob.modifiers.new("bevel", "BEVEL") + m.width = bevel + m.segments = segs + m.limit_method = "ANGLE" + m.angle_limit = math.radians(angle) + m.harden_normals = True + m.miter_outer = "MITER_ARC" + return ob + + +# ------------------------------------------------------------------ shapes + + +def add_box(bm, lo, hi): + lo, hi = Vector(lo), Vector(hi) + c, s = (lo + hi) / 2, hi - lo + bmesh.ops.create_cube(bm, size=1.0, matrix=Matrix.Translation(c) @ Matrix.Diagonal((*s, 1))) + + +def add_obox(bm, center, axes, half): + """Oriented box: centre, three axis vectors (unit), half sizes along them.""" + M = Matrix.Identity(4) + for k in range(3): + a = Vector(axes[k]).normalized() * (2 * half[k]) + M[0][k], M[1][k], M[2][k] = a + M.translation = Vector(center) + bmesh.ops.create_cube(bm, size=1.0, matrix=M) + + +def add_cyl(bm, r, p0, p1, segs=32, r1=None): + """Closed cylinder (or cone, radius r at p0 and r1 at p1) between two points.""" + p0, p1 = Vector(p0), Vector(p1) + d = p1 - p0 + q = Vector((0, 0, 1)).rotation_difference(d.normalized()) + M = Matrix.Translation((p0 + p1) / 2) @ q.to_matrix().to_4x4() + bmesh.ops.create_cone(bm, cap_ends=True, cap_tris=False, segments=segs, radius1=r, radius2=r if r1 is None else r1, depth=d.length, matrix=M) + + +def add_sphere(bm, r, c, segs=16, rings=8): + bmesh.ops.create_uvsphere(bm, u_segments=segs, v_segments=rings, radius=r, matrix=Matrix.Translation(Vector(c))) + + +def _dedupe(pts, eps=1e-5): + out = [] + for p in pts: + if not out or math.dist(p, out[-1]) > eps: + out.append(tuple(p)) + if len(out) > 2 and math.dist(out[0], out[-1]) <= eps: + out.pop() + return out + + +def add_prism_y(bm, pts, y0, y1): + """Polygon in the x-z plane, extruded along y from y0 to y1.""" + pts = _dedupe(pts) + a = [bm.verts.new((x, y0, z)) for x, z in pts] + b = [bm.verts.new((x, y1, z)) for x, z in pts] + bm.faces.new(a[::-1]) + bm.faces.new(b) + n = len(pts) + for i in range(n): + j = (i + 1) % n + bm.faces.new((a[i], a[j], b[j], b[i])) + + +def add_prism_z(bm, pts, z0, z1): + """Polygon in the x-y plane, extruded along z.""" + pts = _dedupe(pts) + a = [bm.verts.new((x, y, z0)) for x, y in pts] + b = [bm.verts.new((x, y, z1)) for x, y in pts] + bm.faces.new(a[::-1]) + bm.faces.new(b) + n = len(pts) + for i in range(n): + j = (i + 1) % n + bm.faces.new((a[i], a[j], b[j], b[i])) + + +def add_prism_frame(bm, pts, origin, u, v, w0, w1): + """Polygon given in a plane spanned by u, v (2D coords), extruded along u x v from w0 to w1.""" + pts = _dedupe(pts) + o, u, v = Vector(origin), Vector(u).normalized(), Vector(v).normalized() + w = u.cross(v).normalized() + pts = [(float(x), float(y)) for x, y in pts] + a = [bm.verts.new(o + x * u + y * v + w0 * w) for x, y in pts] + b = [bm.verts.new(o + x * u + y * v + w1 * w) for x, y in pts] + bm.faces.new(a[::-1]) + bm.faces.new(b) + n = len(pts) + for i in range(n): + j = (i + 1) % n + bm.faces.new((a[i], a[j], b[j], b[i])) + + +def add_tube(bm, pts, r, segs=12, caps=True): + """Sweep a circle along a polyline (parallel-transport frames).""" + pts = [Vector(p) for p in _dedupe(pts)] + rings, n_prev = [], None + for i, p in enumerate(pts): + t = (pts[min(i + 1, len(pts) - 1)] - pts[max(i - 1, 0)]).normalized() + if n_prev is None: + ref = Vector((0, 0, 1)) if abs(t.z) < 0.9 else Vector((1, 0, 0)) + n = t.cross(ref).normalized() + else: + n = (n_prev - t * n_prev.dot(t)).normalized() + b = t.cross(n) + n_prev = n + rings.append([bm.verts.new(p + r * (math.cos(a) * n + math.sin(a) * b)) for a in (2 * math.pi * k / segs for k in range(segs))]) + for A, B in zip(rings, rings[1:]): + for k in range(segs): + bm.faces.new((A[k], A[(k + 1) % segs], B[(k + 1) % segs], B[k])) + if caps: + bm.faces.new(rings[0][::-1]) + bm.faces.new(rings[-1]) + + +def add_gear(bm, center, axis_y_half, r_root, r_tip, teeth, y0, y1): + """Spur-gear-like sprocket in the x-z plane at centre (x, z), extruded along y.""" + cx, cz = center + pts = [] + for k in range(teeth): + a0 = 2 * math.pi * k / teeth + da = 2 * math.pi / teeth + for f, r in ((0.0, r_root), (0.22, r_tip), (0.42, r_tip), (0.64, r_root)): + a = a0 + f * da + pts.append((cx + r * math.cos(a), cz + r * math.sin(a))) + add_prism_y(bm, pts, y0, y1) + + +# ------------------------------------------------------------------ 2D helpers + + +def catmull(pts, n=8, closed=False): + """Catmull-Rom spline through points (2D or 3D), n samples per segment.""" + P = [np.array(p, float) for p in pts] + if closed: + P = [P[-1]] + P + [P[0], P[1]] + else: + P = [2 * P[0] - P[1]] + P + [2 * P[-1] - P[-2]] + out = [] + for i in range(1, len(P) - 2): + p0, p1, p2, p3 = P[i - 1], P[i], P[i + 1], P[i + 2] + for k in range(n): + t = k / n + out.append(0.5 * ((2 * p1) + (-p0 + p2) * t + (2 * p0 - 5 * p1 + 4 * p2 - p3) * t * t + (-p0 + 3 * p1 - 3 * p2 + p3) * t**3)) + if not closed: + out.append(P[-2]) + return [tuple(x) for x in out] + + +def fillet(pts, r, n=5): + """Round every corner of a closed polygon with a quadratic arc of up to radius r.""" + out = [] + N = len(pts) + for i in range(N): + p0, p, p1 = (np.array(pts[(i + k) % N], float) for k in (-1, 0, 1)) + e0, e1 = p0 - p, p1 - p + a = p + e0 / np.linalg.norm(e0) * min(r, np.linalg.norm(e0) * 0.45) + b = p + e1 / np.linalg.norm(e1) * min(r, np.linalg.norm(e1) * 0.45) + for k in range(n + 1): + t = k / n + out.append(tuple((1 - t) ** 2 * a + 2 * (1 - t) * t * p + t**2 * b)) + return out + + +def hull(points): + """Convex hull (counter-clockwise) of 2D points.""" + P = sorted(set((round(x, 6), round(y, 6)) for x, y in points)) + if len(P) < 3: + return P + + def cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + lo, up = [], [] + for p in P: + while len(lo) >= 2 and cross(lo[-2], lo[-1], p) <= 0: + lo.pop() + lo.append(p) + for p in reversed(P): + while len(up) >= 2 and cross(up[-2], up[-1], p) <= 0: + up.pop() + up.append(p) + return lo[:-1] + up[:-1] + + +def circle(c, r, n=24, a0=0.0, a1=2 * math.pi): + return [(c[0] + r * math.cos(a0 + (a1 - a0) * k / n), c[1] + r * math.sin(a0 + (a1 - a0) * k / n)) for k in range(n + 1)] + + +def circle_hull(circles, extra=(), n=28): + pts = list(extra) + for c, r in circles: + pts += circle(c, r, n) + return hull(pts) + + +def offset_polyline(pts, d): + """Offset an open 2D polyline by d along its left normal.""" + P = np.array(pts, float) + out = [] + for i in range(len(P)): + t = P[min(i + 1, len(P) - 1)] - P[max(i - 1, 0)] + t /= np.linalg.norm(t) + out.append(tuple(P[i] + d * np.array([-t[1], t[0]]))) + return out + + +# ------------------------------------------------------------------ tracks: a belt wrapped round wheels + + +def belt_path(wheels, n=360): + """Closed path (x-z, counter-clockwise seen from +y... as returned by hull) of a belt pulled tight round + wheels [((x, z), r), ...], resampled to n points evenly by length. Returns points and total length.""" + h = np.array(circle_hull(wheels, n=96)) + h = np.vstack([h, h[:1]]) + seg = np.linalg.norm(np.diff(h, axis=0), axis=1) + s = np.concatenate([[0], np.cumsum(seg)]) + t = np.linspace(0, s[-1], n, endpoint=False) + pts = np.stack([np.interp(t, s, h[:, 0]), np.interp(t, s, h[:, 1])], axis=1) + return pts, s[-1] + + +def belt_frames(pts, length, count, phase=0.0): + """count evenly spaced (position, tangent, outward normal) along a closed belt path (x-z).""" + n = len(pts) + c = pts.mean(axis=0) + out = [] + for k in range(count): + u = ((k + phase) / count) * n + i = int(u) % n + f = u - int(u) + p = pts[i] * (1 - f) + pts[(i + 1) % n] * f + t = pts[(i + 1) % n] - pts[i - 1] + t = t / np.linalg.norm(t) + nrm = np.array([t[1], -t[0]]) + if np.dot(nrm, p - c) < 0: + nrm = -nrm + out.append((p, t, nrm)) + return out + + +def add_ring_y(bm, inner, outer, y0, y1): + """Closed band between two closed x-z outlines (same point count), extruded along y.""" + rings = [] + for pts in (inner, outer): + rings.append([[bm.verts.new((x, y, z)) for x, z in pts] for y in (y0, y1)]) + (i0, i1), (o0, o1) = rings + n = len(inner) + for k in range(n): + j = (k + 1) % n + bm.faces.new((i0[k], i0[j], i1[j], i1[k])) + bm.faces.new((o0[k], o1[k], o1[j], o0[j])) + bm.faces.new((i0[k], o0[k], o0[j], i0[j])) + bm.faces.new((i1[k], i1[j], o1[j], o1[k])) + + +def frame_matrix(p, t, nrm, y): + """Object matrix for a part on a belt: x along the belt, z outward, at (p.x, y, p.z).""" + X = Vector((t[0], 0, t[1])) + Z = Vector((nrm[0], 0, nrm[1])) + Y = Z.cross(X) + m = Matrix.Identity(4) + for c, v in enumerate((X, Y, Z)): + m[0][c], m[1][c], m[2][c] = v + m.translation = (p[0], y, p[1]) + return m + + +# ------------------------------------------------------------------ hydraulic cylinder (barrel + rod) + + +def cylinder_meshes(bm_barrel, bm_rod, origin, axis, r, rod_r, barrel_len, rod_from, rod_to, eye_r=0.06, eye_w=0.1, ycs=(0.0,), eye_axis=(0, 1, 0)): + """A cylinder along `axis` from `origin`: barrel (head eye at the origin) into bm_barrel, chrome rod + from rod_from to rod_to (eye at rod_to) into bm_rod. Several copies side by side at offsets ycs (y).""" + o, d = Vector(origin), Vector(axis).normalized() + ea = Vector(eye_axis).normalized() + side = d.cross(ea).normalized() if abs(d.dot(ea)) < 0.95 else d.orthogonal().normalized() + for yc in ycs: + c = o + Vector((0, yc, 0)) + add_cyl(bm_barrel, eye_r, c - ea * eye_w / 2, c + ea * eye_w / 2, 20) + add_cyl(bm_barrel, r + 0.012, c + d * 0.04, c + d * 0.12, 28) + add_cyl(bm_barrel, r, c + d * 0.12, c + d * (barrel_len - 0.06), 28) + add_cyl(bm_barrel, r + 0.014, c + d * (barrel_len - 0.06), c + d * barrel_len, 28) + for s in (0.2, barrel_len - 0.16): + add_obox(bm_barrel, c + d * s + side * (r + 0.015), (d, ea, side), (0.025, 0.022, 0.02)) + if bm_rod is not None: + add_cyl(bm_rod, rod_r, c + d * rod_from, c + d * (rod_to - 0.07), 24) + add_cyl(bm_rod, rod_r + 0.01, c + d * (rod_to - 0.08), c + d * (rod_to - 0.04), 24) + add_cyl(bm_rod, eye_r, c + d * rod_to - ea * eye_w / 2, c + d * rod_to + ea * eye_w / 2, 20) + + +# ------------------------------------------------------------------ glTF post-processing + + +def read_glb(path): + b = open(path, "rb").read() + n = struct.unpack("= 8: + ln = struct.unpack(" Y up) / base_link / body_link / blade_arm_link (lift) / blade_angle_link (angle) / + blade_link (tilt); blade_arm_link / blade_angle_piston_{left,right}_link (angle cylinders); + body_link / blade_arm_cylinder_link / blade_arm_piston_link (lift cylinders) +The lift cylinders' rod eyes sit where the soil view's lift approximation (soil.js: cylinder turns 0.9 x lift, +rod extends 0.54 x lift) puts them on the C-frame. No manufacturer marks or livery. + + blender -b -t 4 --python assets/blender/d37_hd.py [-- --render out/prefix [--lift -0.3]] +""" + +import math +import pathlib +import sys + +import bmesh +import numpy as np +from mathutils import Matrix, Vector + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) +import blendkit as K # noqa: E402 + +ROOT = pathlib.Path(__file__).resolve().parents[2] +REF = ROOT / "assets/machinery/opera_d37pxi.glb" +OUT = ROOT / "assets/machinery/d37_hd.glb" +ARGS = sys.argv[sys.argv.index("--") + 1 :] if "--" in sys.argv else [] +REFJ, _ = K.read_glb(REF) +REFN = {n["name"]: n for n in REFJ["nodes"]} + + +def ref_matrix(name): + m = REFN[name].get("matrix") + return Matrix(np.array(m).reshape(4, 4).T.tolist()) if m else Matrix.Identity(4) + + +def joint_axis(name): + return Vector(REFN[name]["extras"]["urdf_joint"]["axis_local"]).normalized() + + +K.reset() +import bpy # noqa: E402 + +M = { + "paint": K.surface("paint_yellow", "#e2a91c", "paint", 1024, seed=31, coat=0.35), + "blade": K.surface("blade_paint", "#e2a91c", "paint_worn", 1024, seed=32, coat=0.2), + "frame": K.surface("frame_graphite", "#24272a", "paint_worn", 1024, seed=33), + "track": K.surface("track_steel", "#38312a", "track", 1024, seed=34), + "wear": K.surface("wear_steel", "#6a665f", "worn_edge", 512, seed=35), + "cab": K.surface("cab_dark", "#2e3236", "paint", 512, seed=36, coat=0.25), + "steel": K.material("steel_machined", "#9a9da0", rough=0.3, metal=1.0), + "chrome": K.material("chrome_rod", "#e6e8ea", rough=0.08, metal=1.0), + "glass": K.material("glass_tinted", "#16222a", rough=0.04, alpha=0.55), + "plastic": K.material("plastic_black", "#0d0e0f", rough=0.55), + "white": K.material("antenna_white", "#e8e8e4", rough=0.35), + "lens": K.material("lamp_lens", "#f4f1e4", rough=0.1, emit="#fff4dc", emit_strength=0.6), + "red": K.material("lamp_red", "#c4161c", rough=0.2, emit="#ff2010", emit_strength=0.4), + "green": K.material("lamp_green", "#1e9a3c", rough=0.2, emit="#20ff60", emit_strength=0.4), + "amber": K.material("lamp_amber", "#f0a020", rough=0.2, emit="#ffa000", emit_strength=0.5), + "hazard_y": K.material("hazard_yellow", "#f0c010", rough=0.45, coat=0.2), + "hazard_k": K.material("hazard_black", "#141414", rough=0.5, coat=0.2), +} + +# ------------------------------------------------------------------ hierarchy (as the OPERA model) +base = K.empty("base_link") +body = K.empty("body_link", base, ref_matrix("body_link")) +arm = K.empty("blade_arm_link", body, ref_matrix("blade_arm_link")) +angle = K.empty("blade_angle_link", arm, ref_matrix("blade_angle_link")) +blade = K.empty("blade_link", angle, ref_matrix("blade_link")) +apist = {s: K.empty(f"blade_angle_piston_{s}_link", arm, ref_matrix(f"blade_angle_piston_{s}_link")) for s in ("left", "right")} +lcyl = K.empty("blade_arm_cylinder_link", body, ref_matrix("blade_arm_cylinder_link")) +lpis = K.empty("blade_arm_piston_link", lcyl, ref_matrix("blade_arm_piston_link")) + +ARM_O = ref_matrix("blade_arm_link").translation +CYL_O = ref_matrix("blade_arm_cylinder_link").translation +LIFT_AXIS = joint_axis("blade_arm_piston_link") if "extras" in REFN["blade_arm_piston_link"] else Vector((1.0055, 0, -0.056785)).normalized() +LIFT_REACH, LIFT_Y = 0.98, 0.47 +LIFT_EYE_ARM = CYL_O + LIFT_AXIS * LIFT_REACH - ARM_O # lift cylinder rod eye on the C-frame (arm frame) +ANGLE_REACH = 1.0 +BLADE_O = ref_matrix("blade_angle_link").translation # in the arm frame + +# ------------------------------------------------------------------ undercarriage (body frame, ground z = 0) +SPROCKET = ((-1.05, 0.46), 0.33) +IDLER = ((1.25, 0.37), 0.3) +ROLLERS = [((x, 0.2), 0.11) for x in (-0.72, -0.28, 0.16, 0.6, 0.98)] +GAUGE, SHOE_W = 1.7, 0.6 + + +def build_shoe(bm, pitch): + h = pitch * 0.5 + K.add_box(bm, (-h * 0.96, -SHOE_W / 2, 0.045), (h * 0.96, SHOE_W / 2, 0.062)) + K.add_prism_frame(bm, [(-0.012, 0.062), (0.012, 0.062), (0.006, 0.09), (-0.006, 0.09)], (0, -SHOE_W / 2, 0), (1, 0, 0), (0, 0, 1), 0, -SHOE_W) + for s in (-1, 1): + K.add_prism_frame(bm, [(-h, -0.03), (h, -0.03), (h * 1.02, 0.015), (h * 0.7, 0.045), (-h * 0.7, 0.045), (-h * 1.02, 0.015)], (0, s * 0.2 - 0.025, 0), (1, 0, 0), (0, 0, 1), 0, -0.05) + K.add_cyl(bm, 0.028, (h, -0.18, 0), (h, 0.18, 0), 10) + for bx in (-0.04, 0.04): + for by in (-0.24, -0.16, 0.16, 0.24): + K.add_cyl(bm, 0.01, (bx, by, 0.045), (bx, by, 0.037), 6) + + +def undercarriage(): + inner, length = K.belt_path([SPROCKET, IDLER] + ROLLERS, 600) + n = int(round(length / 0.155)) + pitch = length / n + shoe_mesh = None + for side, yc in (("L", GAUGE / 2), ("R", -GAUGE / 2)): + for k, (p, t, nrm) in enumerate(K.belt_frames(inner, length, n)): + ob = K.make(f"track_shoe_{side}_{k:02d}", body, M["track"], lambda bm: build_shoe(bm, pitch), matrix=K.frame_matrix(p, t, nrm, yc), mesh=shoe_mesh) + shoe_mesh = ob.data + + def wheels(bm, yc=yc): + (ix, iz), ir = IDLER + K.add_cyl(bm, ir - 0.05, (ix, yc - 0.22, iz), (ix, yc + 0.22, iz), 36) + K.add_cyl(bm, ir - 0.02, (ix, yc - 0.05, iz), (ix, yc + 0.05, iz), 36) + for (x, z), r in ROLLERS: + for e in (-1, 1): + K.add_cyl(bm, r - 0.01, (x, yc + e * 0.13, z), (x, yc + e * 0.23, z), 20) + K.add_cyl(bm, r + 0.015, (x, yc + e * 0.23, z), (x, yc + e * 0.25, z), 20) + K.add_cyl(bm, 0.05, (x, yc - 0.13, z), (x, yc + 0.13, z), 12) + K.add_prism_y(bm, K.fillet([(-0.85, 0.3), (1.0, 0.3), (1.12, 0.42), (0.95, 0.58), (-0.8, 0.58), (-0.95, 0.45)], 0.05), yc - 0.17, yc + 0.17) + K.add_box(bm, (0.75, yc - 0.12, 0.32), (1.12, yc + 0.12, 0.45)) + + K.make(f"track_frame_{side}", body, M["frame"], wheels, bevel=0.01) + + def sprocket(bm, yc=yc): + (sx, sz), sr = SPROCKET + sgn = 1 if yc > 0 else -1 + K.add_gear(bm, (sx, sz), 0, sr - 0.04, sr + 0.025, 23, yc - 0.04, yc + 0.04) + K.add_cyl(bm, 0.22, (sx, yc - 0.08, sz), (sx, yc + 0.08, sz), 32) + K.add_cyl(bm, 0.28, (sx, yc - sgn * 0.08, sz), (sx, yc - sgn * 0.36, sz), 36) # final drive + for k in range(12): + a = 2 * math.pi * k / 12 + K.add_cyl(bm, 0.013, (sx + 0.17 * math.cos(a), yc + sgn * 0.08, sz + 0.17 * math.sin(a)), (sx + 0.17 * math.cos(a), yc + sgn * 0.095, sz + 0.17 * math.sin(a)), 6) + + K.make(f"sprocket_{side}", body, M["frame"], sprocket, bevel=0.005) + + +undercarriage() + +# ------------------------------------------------------------------ body: frame, fenders, hood, cab, rear + + +def body_parts(): + K.make("main_frame", body, M["frame"], lambda bm: (K.add_box(bm, (-1.45, -0.55, 0.32), (1.55, 0.55, 0.78)), K.add_box(bm, (ARM_O.x - 0.18, -0.72, 0.22), (ARM_O.x + 0.18, 0.72, 0.55))), bevel=0.02) + for s in (-1, 1): + K.make(f"fender_{'l' if s > 0 else 'r'}", body, M["paint"], lambda bm, s=s: K.add_prism_y(bm, [(-1.5, 0.78), (1.15, 0.78), (1.5, 0.66), (1.5, 0.7), (1.15, 0.82), (-1.5, 0.82)], s * 0.55, s * 1.16), bevel=0.008) + # hood: narrow and sloped toward the blade so the operator sees its corners + hood = K.fillet([(0.3, 0.8), (1.72, 0.8), (1.72, 1.2), (1.55, 1.38), (0.3, 1.6)], 0.08, 4) + K.make("hood", body, M["paint"], lambda bm: K.add_prism_y(bm, hood, -0.38, 0.38), bevel=0.035, segs=3) + + def grille(bm): + K.add_box(bm, (1.72, -0.3, 0.86), (1.73, 0.3, 1.16)) + for k in range(7): + z = 0.88 + k * 0.04 + K.add_box(bm, (1.73, -0.28, z), (1.75, 0.28, z + 0.018)) + for s in (-1, 1): + for k in range(6): + x = 0.6 + k * 0.12 + K.add_obox(bm, (x, s * 0.385, 1.15), ((math.cos(0.4), 0, math.sin(0.4)), (0, 1, 0), (-math.sin(0.4), 0, math.cos(0.4))), (0.04, 0.008, 0.16)) + + K.make("grilles", body, M["frame"], grille, bevel=0.002) + K.make("lift_brackets", body, M["frame"], lambda bm: [K.add_prism_y(bm, K.circle_hull([((CYL_O.x, CYL_O.z), 0.08)], extra=[(CYL_O.x - 0.18, 0.8), (CYL_O.x + 0.18, 0.8)]), s * LIFT_Y + e * 0.07 - 0.015, s * LIFT_Y + e * 0.07 + 0.015) for s in (-1, 1) for e in (-1, 1)], bevel=0.006) + K.make("lift_pins", body, M["steel"], lambda bm: [K.add_cyl(bm, 0.035, (CYL_O.x, s * LIFT_Y - 0.1, CYL_O.z), (CYL_O.x, s * LIFT_Y + 0.1, CYL_O.z), 14) for s in (-1, 1)]) + # cab + x0, x1, y0, z0, z1 = -1.18, 0.3, 0.78, 0.82, 2.72 + xr = x1 - 0.1 + prof = K.fillet([(x0, z0), (x1, z0), (x1, 1.45), (xr, z1), (x0, z1)], 0.07, 4) + K.make("cab_shell", body, M["paint"], lambda bm: K.add_prism_y(bm, prof, -y0, y0), bevel=0.025, segs=3) + K.make("cab_roof", body, M["paint"], lambda bm: K.add_box(bm, (x0 - 0.06, -y0 - 0.06, z1 - 0.01), (xr + 0.1, y0 + 0.06, z1 + 0.07)), bevel=0.02) + fx = lambda z: x1 if z <= 1.45 else x1 - (x1 - xr) * (z - 1.45) / (z1 - 1.45) # noqa: E731 + + def glass(bm): + e = 0.006 + p0, p1 = Vector((fx(1.5), 0, 1.5)), Vector((fx(2.62), 0, 2.62)) + u = (p1 - p0).normalized() + n = Vector((u.z, 0, -u.x)) + mid = (p0 + p1) / 2 + n * 0.003 + K.add_obox(bm, mid, (u, (0, 1, 0), n), ((p1 - p0).length / 2, y0 - 0.08, e / 2)) + K.add_box(bm, (x1, -y0 + 0.08, 0.95), (x1 + e, y0 - 0.08, 1.4)) + for s in (-1, 1): + y = y0 if s > 0 else -y0 - e + K.add_prism_y(bm, [(x0 + 0.08, 1.15), (x1 - 0.07, 1.15), (fx(2.62) - 0.07, 2.62), (x0 + 0.08, 2.62)], y, y + e) + K.add_box(bm, (x0 - e, -y0 + 0.1, 1.3), (x0, y0 - 0.1, 2.6)) + + K.make("cab_glass", body, M["glass"], glass, smooth=False) + K.make("cab_interior", body, M["plastic"], lambda bm: (K.add_box(bm, (-0.95, -0.3, 0.82), (-0.65, 0.3, 1.75)), K.add_box(bm, (-0.45, -0.6, 0.82), (-0.15, -0.4, 1.3)), K.add_box(bm, (-0.45, 0.4, 0.82), (-0.15, 0.6, 1.3))), bevel=0.02) + + def pillars(bm): + for s in (-1, 1): + y = s * (y0 - 0.03) + K.add_tube(bm, [(x1 + 0.004, y, 0.86), (x1 + 0.004, y, 1.45), (xr + 0.004, y, z1 - 0.04)], 0.03, 8) + K.add_tube(bm, [(x0 - 0.004, y, 0.86), (x0 - 0.004, y, z1 - 0.04)], 0.03, 8) + K.add_tube(bm, [(-0.3, y + s * 0.004, 0.86), (-0.3, y + s * 0.004, z1 - 0.04)], 0.02, 8) + K.add_tube(bm, [(x1, s * (y0 + 0.02), 2.3), (x1 + 0.15, s * (y0 + 0.2), 2.35)], 0.012, 6) + K.add_box(bm, (x1 + 0.13, s * (y0 + 0.2) - 0.08, 2.15), (x1 + 0.17, s * (y0 + 0.2) + 0.08, 2.4)) + K.add_tube(bm, [(-0.9, s * 1.17, 0.82), (-0.9, s * 1.17, 1.35), (0.0, s * 1.17, 1.35), (0.0, s * 1.17, 0.82)], 0.016, 8) # grab rails + + K.make("cab_pillars", body, M["frame"], pillars) + K.make("roof_lamps", body, M["lens"], lambda bm: [K.add_box(bm, (xr + 0.1, s * 0.5 - 0.07, z1 + 0.01), (xr + 0.105, s * 0.5 + 0.07, z1 + 0.06)) for s in (-1, 1)]) + # rear: fuel tank, lamps, drawbar + rear = K.fillet([(-1.62, 0.78), (-1.15, 0.78), (-1.15, 1.6), (-1.5, 1.6), (-1.62, 1.45)], 0.08, 4) + K.make("rear_tank", body, M["paint"], lambda bm: K.add_prism_y(bm, rear, -0.95, 0.95), bevel=0.035, segs=3) + K.make("tail_lamps", body, M["red"], lambda bm: [K.add_box(bm, (-1.64, s * 0.75 - 0.06, 1.25), (-1.62, s * 0.75 + 0.06, 1.35)) for s in (-1, 1)]) + K.make("drawbar", body, M["frame"], lambda bm: (K.add_box(bm, (-1.85, -0.25, 0.42), (-1.45, 0.25, 0.55)), K.add_cyl(bm, 0.05, (-1.75, 0, 0.35), (-1.75, 0, 0.62), 16)), bevel=0.01) + K.make("rear_chevron_band", body, M["hazard_k"], lambda bm: K.add_box(bm, (-1.63, -0.72, 0.94), (-1.622, 0.72, 1.12))) + K.make("rear_chevrons", body, M["hazard_y"], lambda bm: [K.add_prism_frame(bm, [(y, 0), (y + 0.09, 0), (y + 0.16, 0.16), (y + 0.07, 0.16)], (-1.632, 0, 0.95), (0, -1, 0), (0, 0, 1), 0, 0.004) for y in np.arange(-0.62, 0.5, 0.2)], smooth=False) + K.make("fuel_cap", body, M["frame"], lambda bm: K.add_cyl(bm, 0.07, (-1.38, 0.55, 1.6), (-1.38, 0.55, 1.66), 20), bevel=0.01) + # exhaust and pre-cleaner on the hood + K.make("exhaust", body, M["frame"], lambda bm: (K.add_tube(bm, K.catmull([(1.05, -0.2, 1.4), (1.05, -0.2, 1.95), (1.0, -0.2, 2.05), (0.9, -0.2, 2.08)], 4), 0.05, 14), K.add_cyl(bm, 0.07, (1.05, -0.2, 1.4), (1.05, -0.2, 1.48), 16))) + K.make("pre_cleaner", body, M["plastic"], lambda bm: (K.add_cyl(bm, 0.04, (0.75, 0.18, 1.48), (0.75, 0.18, 1.75), 16), K.add_cyl(bm, 0.1, (0.75, 0.18, 1.75), (0.75, 0.18, 1.86), 24, r1=0.055)), bevel=0.01) + # PWRI automation retrofit: GNSS antennas and a signal tower on the roof + for y in (-0.5, 0.5): + K.make(f"gnss_{'l' if y > 0 else 'r'}", body, M["white"], lambda bm, y=y: (K.add_cyl(bm, 0.02, (-0.9, y, z1 + 0.06), (-0.9, y, z1 + 0.24), 10), K.add_cyl(bm, 0.09, (-0.9, y, z1 + 0.24), (-0.9, y, z1 + 0.3), 32, r1=0.065)), bevel=0.01) + for k, col in enumerate(("green", "amber", "red")): + K.make(f"signal_{col}", body, M[col], lambda bm, k=k: (K.add_cyl(bm, 0.04, (-0.4, -0.15 + 0.15 * k, z1 + 0.06), (-0.4, -0.15 + 0.15 * k, z1 + 0.15), 20), K.add_sphere(bm, 0.04, (-0.4, -0.15 + 0.15 * k, z1 + 0.15), 20, 8))) + + +body_parts() + +# ------------------------------------------------------------------ C-frame (blade_arm_link frame) + + +def c_frame(): + bx, bz = BLADE_O.x, BLADE_O.z + ex, ez = LIFT_EYE_ARM.x, LIFT_EYE_ARM.z + for s in (-1, 1): + beam = K.fillet([(-0.12, -0.12), (bx - 0.15, bz - 0.12), (bx - 0.05, bz + 0.12), (0.35, 0.16), (0.0, 0.12)], 0.06) + K.make(f"push_arm_{'l' if s > 0 else 'r'}", arm, M["paint"], lambda bm, s=s, beam=beam: K.add_prism_y(bm, beam, s * 0.45, s * 0.56), bevel=0.02) + br = K.circle_hull([((ex, ez), 0.075)], extra=[(ex - 0.28, 0.08), (ex + 0.22, 0.04)]) + for e in (-1, 1): + K.make(f"lift_ear_{'l' if s > 0 else 'r'}_{e + 1}", arm, M["paint"], lambda bm, s=s, e=e, br=br: K.add_prism_y(bm, br, s * LIFT_Y + e * 0.07 - 0.015, s * LIFT_Y + e * 0.07 + 0.015), bevel=0.006) + K.make("c_frame_front", arm, M["paint"], lambda bm: K.add_box(bm, (bx - 0.32, -0.56, bz - 0.14), (bx - 0.1, 0.56, bz + 0.1)), bevel=0.02) + K.make("trunnions", arm, M["frame"], lambda bm: [K.add_cyl(bm, 0.11, (0, s * 0.42, 0), (0, s * 0.62, 0), 24) for s in (-1, 1)], bevel=0.008) + K.make("arm_pins", arm, M["steel"], lambda bm: [K.add_cyl(bm, 0.035, (ex, s * LIFT_Y - 0.1, ez), (ex, s * LIFT_Y + 0.1, ez), 14) for s in (-1, 1)] + [K.add_cyl(bm, 0.09, (bx - 0.1, -0.12, bz), (bx + 0.02, 0.12, bz), 20)]) + + +c_frame() + +# ------------------------------------------------------------------ cylinders + + +def cylinder(name, parent_barrel, parent_rod, origin, axis, ycs, r, rod_r, barrel_len, rod_from, reach, rod_origin=None): + bb, br = bmesh.new(), bmesh.new() + K.cylinder_meshes(bb, br, origin, axis, r, rod_r, barrel_len, rod_from, reach, eye_r=0.05, eye_w=0.1, ycs=ycs) + if rod_origin is not None: # rod node frame differs from the barrel's: move the rod's verts into it + bmesh.ops.translate(br, verts=br.verts, vec=-Vector(rod_origin)) + for nm, bmx, parent, mat in ((f"{name}_barrel", bb, parent_barrel, M["paint"]), (f"{name}_rod", br, parent_rod, M["chrome"])): + K.box_uv(bmx) + me = bpy.data.meshes.new(nm) + bmx.to_mesh(me) + bmx.free() + for p in me.polygons: + p.use_smooth = True + me.use_auto_smooth = True + me.materials.append(mat) + K.make(nm, parent, mat, None, mesh=me, bevel=0.004) + + +# lift: barrel on the cylinder link (origin at its pin), rod on the piston link (same frame at rest) +cylinder("lift_cyl", lcyl, lpis, (0, 0, 0), LIFT_AXIS, (-LIFT_Y, LIFT_Y), 0.065, 0.035, 0.62, 0.38, LIFT_REACH) +# angle: barrels on the C-frame from the piston links' origins, rods on the piston links +for s in ("left", "right"): + o = ref_matrix(f"blade_angle_piston_{s}_link").translation + ax = joint_axis(f"blade_angle_piston_{s}_link") + cylinder(f"angle_cyl_{s}", arm, apist[s], o, ax, (0.0,), 0.055, 0.03, 0.55, 0.32, ANGLE_REACH, rod_origin=o) + +# ------------------------------------------------------------------ blade (blade_link frame) +FACE = [(0.41, -0.29), (0.3, -0.12), (0.22, 0.08), (0.18, 0.3), (0.2, 0.52), (0.28, 0.7), (0.37, 0.79)] +BW = 1.6 + + +def blade_parts(): + face = K.catmull(FACE, 6) + back = K.offset_polyline(face, 0.035) + if np.mean([p[0] for p in back]) > np.mean([p[0] for p in face]): + back = K.offset_polyline(face, -0.035) + K.make("moldboard", blade, M["blade"], lambda bm: K.add_prism_y(bm, face + back[::-1], -BW, BW), bevel=0.006) + side = face + [(-0.08, 0.79), (-0.08, -0.25)] + for s in (-1, 1): + K.make(f"blade_end_{'l' if s > 0 else 'r'}", blade, M["blade"], lambda bm, s=s: K.add_prism_y(bm, side, s * (BW - 0.03), s * (BW + 0.015)), bevel=0.008) + + def frame(bm): + K.add_box(bm, (-0.1, -BW + 0.05, -0.05), (0.15, BW - 0.05, 0.2)) # box beam + K.add_box(bm, (-0.06, -BW + 0.05, 0.55), (0.18, BW - 0.05, 0.66)) + rib = [(x - 0.005, z) for x, z in back if -0.22 <= z <= 0.7] # ribs end at the moldboard's back face + for y in np.linspace(-BW + 0.2, BW - 0.2, 7): + K.add_prism_y(bm, rib + [(-0.06, rib[-1][1]), (-0.08, rib[0][1])], y - 0.02, y + 0.02) + K.add_box(bm, (-0.2, -0.28, -0.14), (0.02, 0.28, 0.18)) # ball socket and tilt mount + for s in (-1, 1): # angle cylinder ears + for e in (-0.06, 0.06): + K.add_prism_y(bm, K.circle_hull([((-0.08, 0.23), 0.06)], extra=[(0.05, 0.1), (0.05, 0.35)]), s * 0.5 + e - 0.012, s * 0.5 + e + 0.012) + + K.make("blade_frame", blade, M["blade"], frame, bevel=0.008) + K.make("cutting_edge", blade, M["wear"], lambda bm: (K.add_prism_y(bm, [(0.37, -0.3), (0.45, -0.3), (0.38, -0.17), (0.3, -0.17)], -BW + 0.2, BW - 0.2), [K.add_prism_y(bm, [(0.37, -0.3), (0.47, -0.3), (0.4, -0.12), (0.3, -0.15)], s * (BW - 0.2), s * (BW + 0.02)) for s in (-1, 1)]), bevel=0.004) + K.make("spill_lip", blade, M["blade"], lambda bm: K.add_prism_y(bm, [(0.3, 0.76), (0.45, 0.82), (0.43, 0.86), (0.28, 0.8)], -BW, BW), bevel=0.005) + + +blade_parts() + +# ------------------------------------------------------------------ export +K.export_glb(OUT) +js, binchunk = K.read_glb(OUT) +roots = js["scenes"][0]["nodes"] +js["nodes"].append({"name": "d37pxi", "matrix": REFN["d37pxi"]["matrix"], "children": roots}) +js["scenes"][0]["nodes"] = [len(js["nodes"]) - 1] +names = {n.get("name"): i for i, n in enumerate(js["nodes"])} +for name, ref in REFN.items(): + if name in names and ref.get("extras"): + js["nodes"][names[name]]["extras"] = ref["extras"] +js["asset"]["copyright"] = ( + "Small crawler dozer with a power-angle-tilt blade, modelled procedurally in Blender (assets/blender/d37_hd.py) by the " + "construction-site-simulation project to the joint frames of PWRI's OPERA D37PXi model (https://github.com/pwri-opera/d37pxi_ros2, Apache-2.0). Apache-2.0." +) +js["asset"]["extras"] = {"source": "assets/blender/d37_hd.py", "reference": "https://github.com/pwri-opera/d37pxi_ros2", "license": "Apache-2.0"} +K.write_glb(OUT, js, binchunk) +print(f"EXPORTED {OUT} nodes={len(js['nodes'])}") + +if "--render" in ARGS: + out = ARGS[ARGS.index("--render") + 1] + lift = float(ARGS[ARGS.index("--lift") + 1]) if "--lift" in ARGS else 0.0 + # pose as soil.js does: arm turns by lift, cylinder by 0.9 x lift, rod out 0.54 x lift + arm.matrix_basis = ref_matrix("blade_arm_link") @ Matrix.Rotation(lift, 4, "Y") + lcyl.matrix_basis = ref_matrix("blade_arm_cylinder_link") @ Matrix.Rotation(0.9 * lift, 4, "Y") + lpis.matrix_basis = Matrix.Translation(Vector((1.0055, 0, -0.056785)).normalized() * 0.54 * lift) + sc = bpy.context.scene + sc.render.engine = "BLENDER_EEVEE" + ee = sc.eevee + ee.taa_render_samples = 48 + ee.use_gtao = True + ee.use_ssr = True + ee.use_soft_shadows = True + ee.shadow_cascade_size = "4096" + sc.view_settings.view_transform = "AgX" + sun = bpy.data.objects.new("sun", bpy.data.lights.new("sun", "SUN")) + sc.collection.objects.link(sun) + sun.data.energy = 4.0 + sun.rotation_euler = (math.radians(50), 0, math.radians(200)) + w = bpy.data.worlds.new("sky") + sc.world = w + w.use_nodes = True + sky = w.node_tree.nodes.new("ShaderNodeTexSky") + w.node_tree.links.new(sky.outputs["Color"], w.node_tree.nodes["Background"].inputs["Color"]) + w.node_tree.nodes["Background"].inputs["Strength"].default_value = 0.25 + b = bmesh.new() + K.add_box(b, (-30, -30, -0.05), (30, 30, 0.0)) + me = bpy.data.meshes.new("ground") + b.to_mesh(me) + me.materials.append(K.material("dirt", "#8a7a62", rough=0.95)) + sc.collection.objects.link(bpy.data.objects.new("ground", me)) + sc.render.resolution_x, sc.render.resolution_y = 1600, 1000 + cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam")) + sc.collection.objects.link(cam) + sc.camera = cam + cam.data.lens = 35 + for vname, loc in {"front_left": (6.0, 4.5, 2.6), "rear_right": (-5.5, -5.0, 3.0), "side": (0.4, -8.5, 1.1)}.items(): + cam.location = loc + cam.rotation_euler = (Vector((0.3, 0, 0.8)) - Vector(loc)).to_track_quat("-Z", "Y").to_euler() + sc.render.filepath = f"{out}_{vname}.png" + bpy.ops.render.render(write_still=True) diff --git a/assets/blender/ic120_hd.py b/assets/blender/ic120_hd.py new file mode 100644 index 0000000..45c438a --- /dev/null +++ b/assets/blender/ic120_hd.py @@ -0,0 +1,347 @@ +"""Rubber-tracked crawler carrier (11 t payload class), built procedurally in Blender, exported as +assets/machinery/ic120_hd.glb: a drop-in replacement for assets/machinery/opera_ic120.glb (PWRI OPERA IC120). + +Same node names, link frames (read from that file) and joint extras, so the simulator, the soil view and the +showcase take it unchanged: + ic120 (Z up -> Y up) / base_link / body_link / vessel_pin_link (tip joint), cylinder_head_link / + cylinder_rod_link (tip cylinder), left/right_sprocket_link; base_link / six wheel links (empty, as the source) +The vessel's floor, sides, headboard and tail lip follow the server's vessel boxes (phase2/excavator_server.py, +hello.geometry.carrier.vessel_boxes) so the load sits on the floor the physics uses. No manufacturer marks. + + blender -b -t 4 --python assets/blender/ic120_hd.py [-- --render out/prefix [--beauty] [--tip 0.6]] +""" + +import math +import pathlib +import sys + +import numpy as np +from mathutils import Matrix, Vector + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) +import blendkit as K # noqa: E402 + +ROOT = pathlib.Path(__file__).resolve().parents[2] +REF = ROOT / "assets/machinery/opera_ic120.glb" +OUT = ROOT / "assets/machinery/ic120_hd.glb" +ARGS = sys.argv[sys.argv.index("--") + 1 :] if "--" in sys.argv else [] +REFJ, _ = K.read_glb(REF) +REFN = {n["name"]: n for n in REFJ["nodes"]} + + +def ref_matrix(name): + m = REFN[name].get("matrix") + return Matrix(np.array(m).reshape(4, 4).T.tolist()) if m else Matrix.Identity(4) + + +K.reset() +import bpy # noqa: E402 + +M = { + "paint": K.surface("paint_blue", "#2c5f8c", "paint", 1024, seed=21, coat=0.35), + "vessel": K.surface("vessel_paint", "#2c5f8c", "paint_worn", 1024, seed=22, coat=0.2), + "liner": K.surface("vessel_liner", "#5a5650", "steel", 1024, seed=23), + "frame": K.surface("frame_graphite", "#24272a", "paint_worn", 1024, seed=24), + "cab": K.surface("cab_grey", "#8a9095", "paint", 512, seed=25, coat=0.25), + "rubber": K.surface("track_rubber", "#141414", "rubber", 1024, seed=26), + "steel": K.material("steel_machined", "#9a9da0", rough=0.3, metal=1.0), + "chrome": K.material("chrome_rod", "#e6e8ea", rough=0.08, metal=1.0), + "glass": K.material("glass_tinted", "#16222a", rough=0.04, alpha=0.55), + "plastic": K.material("plastic_black", "#0d0e0f", rough=0.55), + "white": K.material("antenna_white", "#e8e8e4", rough=0.35), + "lens": K.material("lamp_lens", "#f4f1e4", rough=0.1, emit="#fff4dc", emit_strength=0.6), + "red": K.material("lamp_red", "#c4161c", rough=0.2, emit="#ff2010", emit_strength=0.4), + "amber": K.material("lamp_amber", "#f0a020", rough=0.2, emit="#ffa000", emit_strength=0.5), + "hazard_y": K.material("hazard_yellow", "#f0c010", rough=0.45, coat=0.2), + "hazard_k": K.material("hazard_black", "#141414", rough=0.5, coat=0.2), +} + +# ------------------------------------------------------------------ hierarchy (as the OPERA model) +base = K.empty("base_link") +body = K.empty("body_link", base, ref_matrix("body_link")) +for n in ("left_middle_wheel_link", "left_front_wheel_link", "left_rear_wheel_link", "right_middle_wheel_link", "right_front_wheel_link", "right_rear_wheel_link"): + K.empty(n, base, ref_matrix(n)) +spro = {s: K.empty(f"{s}_sprocket_link", body, ref_matrix(f"{s}_sprocket_link")) for s in ("left", "right")} +vessel = K.empty("vessel_pin_link", body, ref_matrix("vessel_pin_link")) +cyl_head = K.empty("cylinder_head_link", body, ref_matrix("cylinder_head_link")) +cyl_rod = K.empty("cylinder_rod_link", cyl_head, ref_matrix("cylinder_rod_link")) + +# ------------------------------------------------------------------ undercarriage (body frame, ground z = 0) +SPROCKET = ((-2.35, 0.65), 0.33) # at the sprocket links +IDLER = ((1.62, 0.47), 0.38) +ROLLERS = [((x, 0.24), 0.15) for x in (-1.9, -1.3, -0.7, -0.1, 0.5, 1.05)] +BELT_T, LUG_H, TW = 0.05, 0.04, 0.6 # belt thickness, lug height, track width + + +def tracks(): + inner, length = K.belt_path([SPROCKET, IDLER] + ROLLERS, 480) + c = inner.mean(axis=0) + outer = [] + for p, t, n in K.belt_frames(inner, length, len(inner)): + outer.append(tuple(p + n * BELT_T)) + inner_l = [tuple(p) for p in inner] + n_lugs = int(length / 0.14) + for side, yc in (("l", 1.0), ("r", -1.0)): + K.make(f"track_belt_{side}", body, M["rubber"], lambda bm, yc=yc: K.add_ring_y(bm, inner_l, outer, yc - TW / 2, yc + TW / 2), bevel=0.01) + + def lugs(bm, yc=yc): + for k, (p, t, n) in enumerate(K.belt_frames(inner, length, n_lugs)): + o = 0.11 if k % 2 else -0.11 + ctr = p + n * (BELT_T + LUG_H / 2) + for dy, hw in ((o, 0.17), (-o * 1.9, 0.05)): + K.add_obox(bm, (ctr[0], yc + dy, ctr[1]), ((t[0], 0, t[1]), (0, 1, 0), (n[0], 0, n[1])), (0.035, hw, LUG_H / 2)) + + K.make(f"track_lugs_{side}", body, M["rubber"], lugs, bevel=0.008) + + def wheels(bm, yc=yc): + (ix, iz), ir = IDLER + K.add_cyl(bm, ir - 0.02, (ix, yc - 0.27, iz), (ix, yc - 0.06, iz), 40) + K.add_cyl(bm, ir - 0.02, (ix, yc + 0.06, iz), (ix, yc + 0.27, iz), 40) + K.add_cyl(bm, 0.12, (ix, yc - 0.3, iz), (ix, yc + 0.3, iz), 20) + for (x, z), r in ROLLERS: + K.add_cyl(bm, r - 0.01, (x, yc - 0.25, z), (x, yc - 0.06, z), 24) + K.add_cyl(bm, r - 0.01, (x, yc + 0.06, z), (x, yc + 0.25, z), 24) + K.add_cyl(bm, 0.06, (x, yc - 0.28, z), (x, yc + 0.28, z), 12) + # track frame between the wheels, and the tensioner housing behind the idler + K.add_prism_y(bm, K.fillet([(-2.05, 0.36), (1.2, 0.36), (1.35, 0.5), (1.15, 0.72), (-1.95, 0.72), (-2.15, 0.55)], 0.06), yc - 0.2, yc + 0.2) + K.add_box(bm, (1.0, yc - 0.15, 0.4), (1.4, yc + 0.15, 0.56)) + + K.make(f"track_frame_{side}", body, M["frame"], wheels, bevel=0.012) + + for s, yc in (("left", 1.0), ("right", -1.0)): + sgn = 1 if yc > 0 else -1 + + def sprocket(bm, sgn=sgn): + # in the sprocket frame (axle along y): gear between the rubber's guide lugs, hub, drive motor inboard + K.add_gear(bm, (0.0, 0.0), 0, SPROCKET[1] - 0.05, SPROCKET[1] + 0.005, 13, -0.05, 0.05) + K.add_cyl(bm, 0.2, (0, -0.16, 0), (0, 0.16, 0), 32) + K.add_cyl(bm, 0.24, (0, -sgn * 0.16, 0), (0, -sgn * 0.42, 0), 32) + for k in range(10): + a = 2 * math.pi * k / 10 + K.add_cyl(bm, 0.014, (0.15 * math.cos(a), sgn * 0.16, 0.15 * math.sin(a)), (0.15 * math.cos(a), sgn * 0.175, 0.15 * math.sin(a)), 6) + + K.make(f"sprocket_{s}", spro[s], M["frame"], sprocket, bevel=0.006) + + +tracks() + +# ------------------------------------------------------------------ chassis, cab, engine bay + + +def chassis(): + K.make("frame_rails", body, M["frame"], lambda bm: (K.add_box(bm, (-3.1, -0.62, 0.72), (3.3, -0.4, 1.0)), K.add_box(bm, (-3.1, 0.4, 0.72), (3.3, 0.62, 1.0)), K.add_box(bm, (-2.6, -1.0, 0.7), (-2.2, 1.0, 0.95)), K.add_box(bm, (0.2, -1.0, 0.7), (0.6, 1.0, 0.95))), bevel=0.015) + K.make("deck", body, M["frame"], lambda bm: K.add_box(bm, (0.45, -1.32, 1.0), (3.3, 1.32, 1.1)), bevel=0.02) + # front bumper with tow hook and lamps + K.make("bumper", body, M["frame"], lambda bm: (K.add_box(bm, (3.25, -1.28, 0.72), (3.45, 1.28, 1.08)), K.add_tube(bm, [(3.45, 0.0 + 0.09 * math.sin(a), 0.84 - 0.09 * math.cos(a)) for a in np.linspace(0, math.pi, 9)], 0.022, 8)), bevel=0.02) + for s in (-1, 1): + K.make(f"bumper_chevrons_{'l' if s > 0 else 'r'}", body, M["hazard_y"], lambda bm, s=s: [K.add_prism_frame(bm, [(y0, 0), (y0 + 0.09, 0), (y0 + 0.09 + 0.07, 0.2), (y0 + 0.07, 0.2)], (3.452, 0, 0.8), (0, -1, 0), (0, 0, 1), 0, 0.005) for y0 in np.arange(0.35, 1.05, 0.18) * s if True], smooth=False) + K.make("front_lamps", body, M["lens"], lambda bm: [K.add_box(bm, (3.45, s * 1.05 - 0.08, 0.95), (3.46, s * 1.05 + 0.08, 1.04)) for s in (-1, 1)]) + + # engine bay (right): stepped hood, louvres, grille, exhaust, pre-cleaner + eb = K.fillet([(0.5, 1.1), (3.25, 1.1), (3.25, 1.75), (3.05, 2.02), (0.5, 2.02)], 0.06, 3) + K.make("engine_bay", body, M["paint"], lambda bm: K.add_prism_y(bm, eb, -1.32, 0.04), bevel=0.035, segs=3) + + def louvres(bm): + y = -1.32 + for k in range(10): + z = 1.25 + k * 0.055 + K.add_obox(bm, (1.6, y - 0.012, z), ((1, 0, 0), (0, -math.cos(0.5), -math.sin(0.5)), (0, -math.sin(0.5), math.cos(0.5))), (0.6, 0.016, 0.006)) + K.add_box(bm, (1.0, y - 0.004, 1.2), (2.2, y + 0.004, 1.85)) + for x in np.arange(0.75, 2.95, 0.09): # top grille bars + K.add_box(bm, (x, -1.15, 2.02), (x + 0.035, -0.15, 2.04)) + + K.make("engine_grilles", body, M["frame"], louvres, bevel=0.003) + K.make("exhaust", body, M["frame"], lambda bm: (K.add_tube(bm, K.catmull([(0.85, -0.95, 2.0), (0.85, -0.95, 2.55), (0.9, -0.95, 2.78), (1.05, -0.95, 2.85)], 4), 0.06, 16), K.add_cyl(bm, 0.085, (0.85, -0.95, 2.0), (0.85, -0.95, 2.1), 16))) + K.make("pre_cleaner", body, M["plastic"], lambda bm: (K.add_cyl(bm, 0.045, (1.5, -1.0, 2.02), (1.5, -1.0, 2.35), 16), K.add_cyl(bm, 0.11, (1.5, -1.0, 2.35), (1.5, -1.0, 2.47), 24, r1=0.06)), bevel=0.01) + + def rails(bm): + y = -1.27 + for x in (0.6, 1.5, 2.4, 3.1): + K.add_tube(bm, [(x, y, 2.02), (x, y, 2.62)], 0.02, 10) + K.add_tube(bm, [(0.6, y, 2.62), (3.1, y, 2.62)], 0.02, 10) + K.add_tube(bm, [(0.6, y, 2.32), (3.1, y, 2.32)], 0.016, 10) + + K.make("handrails", body, M["hazard_y"], rails) + + # cab (left): raked windscreen, glazing, roof, door, mirrors, steps + x0, x1, y0, y1, z0, z1 = 1.12, 3.02, 0.14, 1.3, 1.1, 2.78 + xr = x1 - 0.12 + prof = K.fillet([(x0, z0), (x1, z0), (x1, 1.55), (xr, z1), (x0, z1)], 0.07, 4) + K.make("cab_shell", body, M["cab"], lambda bm: K.add_prism_y(bm, prof, y0, y1), bevel=0.025, segs=3) + K.make("cab_roof", body, M["cab"], lambda bm: K.add_box(bm, (x0 - 0.04, y0 - 0.04, z1 - 0.01), (xr + 0.08, y1 + 0.04, z1 + 0.05)), bevel=0.015) + fx = lambda z: x1 if z <= 1.55 else x1 - (x1 - xr) * (z - 1.55) / (z1 - 1.55) # noqa: E731 + + def glass(bm): + e = 0.006 + p0, p1 = Vector((fx(1.6), 0, 1.6)), Vector((fx(2.7), 0, 2.7)) + u = (p1 - p0).normalized() + n = Vector((u.z, 0, -u.x)) + mid = (p0 + p1) / 2 + n * 0.003 + mid.y = (y0 + y1) / 2 + K.add_obox(bm, mid, (u, (0, 1, 0), n), ((p1 - p0).length / 2, (y1 - y0) / 2 - 0.08, e / 2)) + K.add_box(bm, (x1, y0 + 0.08, 1.2), (x1 + e, y1 - 0.08, 1.5)) + K.add_prism_y(bm, [(1.95, 1.3), (fx(1.3) - 0.07, 1.3), (fx(2.7) - 0.07, 2.7), (1.95, 2.7)], y1, y1 + e) # door + K.add_prism_y(bm, [(1.2, 1.7), (1.85, 1.7), (1.85, 2.7), (1.2, 2.7)], y1, y1 + e) + K.add_box(bm, (x0 - e, y0 + 0.1, 1.75), (x0, y1 - 0.1, 2.68)) # rear (over the headboard) + + K.make("cab_glass", body, M["glass"], glass, smooth=False) + K.make("cab_interior", body, M["plastic"], lambda bm: (K.add_box(bm, (1.4, 0.45, 1.1), (1.75, 1.0, 2.0)), K.add_box(bm, (2.3, 0.3, 1.1), (2.85, 1.15, 1.6))), bevel=0.02) + + def cab_trim(bm): + K.add_box(bm, (1.9, y1, 1.15), (1.92, y1 + 0.008, 2.74)) + K.add_box(bm, (2.55, y1 + 0.008, 1.95), (2.67, y1 + 0.03, 1.98)) + for y in (y0 + 0.035, y1 - 0.035): + K.add_tube(bm, [(x1 + 0.004, y, 1.15), (x1 + 0.004, y, 1.55), (xr + 0.004, y, z1 - 0.04)], 0.022, 8) + for s, y in ((1, y1), (-1, -1.32)): + K.add_tube(bm, [(3.0, y, 2.2), (3.2, y + s * 0.15, 2.3), (3.25, y + s * 0.22, 2.35)], 0.014, 8) + K.add_box(bm, (3.22, y + s * 0.22 - 0.1, 2.2), (3.26, y + s * 0.22 + 0.1, 2.5)) + for z in (0.55, 0.85): # steps up to the door + K.add_box(bm, (2.05, y1 + 0.0, z), (2.5, y1 + 0.17, z + 0.03)) + K.add_box(bm, (2.03, y1, 0.45), (2.06, y1 + 0.17, 1.05)) + K.add_box(bm, (2.49, y1, 0.45), (2.52, y1 + 0.17, 1.05)) + + K.make("cab_trim", body, M["plastic"], cab_trim, bevel=0.004) + + # PWRI automation retrofit: GNSS antennas and whips on the cab roof, signal tower, sensor bar + for x in (1.35, 2.6): + K.make(f"gnss_{x:.0f}", body, M["white"], lambda bm, x=x: (K.add_cyl(bm, 0.02, (x, 0.72, z1 + 0.05), (x, 0.72, z1 + 0.25), 10), K.add_cyl(bm, 0.1, (x, 0.72, z1 + 0.25), (x, 0.72, z1 + 0.31), 32, r1=0.07)), bevel=0.01) + K.make("whips", body, M["plastic"], lambda bm: [K.add_cyl(bm, 0.008, (x, 0.3, z1 + 0.05), (x, 0.3, z1 + 0.75), 6) for x in (1.6, 2.2)]) + for k, col in enumerate(("red", "amber")): + K.make(f"signal_{col}", body, M[col], lambda bm, k=k: (K.add_cyl(bm, 0.045, (1.25, 1.0 + 0.12 * k, z1 + 0.05), (1.25, 1.0 + 0.12 * k, z1 + 0.15), 20), K.add_sphere(bm, 0.045, (1.25, 1.0 + 0.12 * k, z1 + 0.15), 20, 8))) + K.make("tail_lamps", body, M["red"], lambda bm: [K.add_box(bm, (-3.12, s * 0.5 - 0.06, 0.8), (-3.1, s * 0.5 + 0.06, 0.9)) for s in (-1, 1)]) + + # tip cylinder bracket on the chassis cross member + hx, hz = ref_matrix("cylinder_head_link").translation.x, ref_matrix("cylinder_head_link").translation.z + K.make("tip_cyl_bracket", body, M["frame"], lambda bm: [K.add_prism_y(bm, K.circle_hull([((hx, hz), 0.09)], extra=[(hx - 0.25, 0.72), (hx + 0.25, 0.72)]), y - 0.02, y + 0.02) for y in (-0.08, 0.08)], bevel=0.008) + + +chassis() + +# ------------------------------------------------------------------ tip cylinder (frames of the source) +TIP_AXIS = Vector((-1.4989, 0, 0.51788)).normalized() # cylinder_rod_prismatic_joint axis +TIP_REACH = 1.25 # rod eye along the axis at rest: under the vessel floor + + +def tip_cylinder(): + import bmesh + + bb, br = bmesh.new(), bmesh.new() + K.cylinder_meshes(bb, br, (0, 0, 0), TIP_AXIS, 0.085, 0.048, 0.72, 0.42, TIP_REACH, eye_r=0.06, eye_w=0.12) + for name, bmx, parent, mat in (("tip_cyl_barrel", bb, cyl_head, M["paint"]), ("tip_cyl_rod", br, cyl_rod, M["chrome"])): + me = bpy.data.meshes.new(name) + K.box_uv(bmx) + bmx.to_mesh(me) + bmx.free() + for p in me.polygons: + p.use_smooth = True + me.use_auto_smooth = True + me.materials.append(mat) + K.make(name, parent, mat, None, mesh=me, bevel=0.004) + + +tip_cylinder() + +# ------------------------------------------------------------------ vessel (vessel_pin_link frame; server boxes) +FLOOR_TOP, X0, X1, HW_IN, HW_OUT, SIDE_TOP, HEAD_TOP = 0.354, -0.405, 3.555, 1.175, 1.255, 1.154, 1.654 + + +def vessel_parts(): + K.make("vessel_floor", vessel, M["liner"], lambda bm: K.add_box(bm, (X0, -HW_OUT, 0.314), (X1, HW_OUT, FLOOR_TOP)), bevel=0.008) + for s in (-1, 1): + K.make(f"vessel_side_{'l' if s > 0 else 'r'}", vessel, M["vessel"], lambda bm, s=s: K.add_prism_y(bm, [(X0 - 0.45, FLOOR_TOP + 0.2), (X0, FLOOR_TOP), (X1, FLOOR_TOP), (X1, SIDE_TOP), (X0 - 0.45, SIDE_TOP)], s * HW_IN, s * HW_OUT), bevel=0.01) + K.make(f"vessel_side_liner_{'l' if s > 0 else 'r'}", vessel, M["liner"], lambda bm, s=s: K.add_box(bm, (X0, s * (HW_IN - 0.004), FLOOR_TOP), (X1 - 0.08, s * HW_IN, SIDE_TOP - 0.04))) + + def ribs(bm): + for s in (-1, 1): + for x in np.arange(0.0, 3.5, 0.58): + K.add_box(bm, (x - 0.03, s * HW_OUT, FLOOR_TOP - 0.04), (x + 0.03, s * (HW_OUT + 0.05), SIDE_TOP - 0.02)) + K.add_tube(bm, [(X0 - 0.45, s * (HW_OUT - 0.04), SIDE_TOP), (X1, s * (HW_OUT - 0.04), SIDE_TOP)], 0.045, 10) # top rail + K.add_box(bm, (X0 - 0.4, s * HW_OUT, FLOOR_TOP - 0.06), (X1, s * (HW_OUT + 0.06), FLOOR_TOP + 0.04)) # bottom rail + + K.make("vessel_ribs", vessel, M["vessel"], ribs, bevel=0.008) + # headboard, higher over the cab, with stiffeners + K.make("vessel_headboard", vessel, M["vessel"], lambda bm: K.add_prism_y(bm, [(X1 - 0.08, FLOOR_TOP), (X1, FLOOR_TOP), (X1 + 0.15, 1.93), (X1 + 0.07, 1.93)], -HW_OUT, HW_OUT), bevel=0.012) + K.make("vessel_headboard_ribs", vessel, M["vessel"], lambda bm: [K.add_prism_y(bm, [(X1, FLOOR_TOP + 0.05), (X1 + 0.12, 1.2), (X1 + 0.2, 1.9), (X1 + 0.15, 1.93), (X1 + 0.02, 1.0)], y - 0.03, y + 0.03) for y in (-0.9, -0.3, 0.3, 0.9)], bevel=0.006) + # tail lip rising to the rear (the server's sloped tail box) + a = math.radians(25) + p0 = np.array([-0.325, 0.314]) + p1 = p0 + 0.6 * np.array([-math.cos(a), math.sin(a)]) + nrm = np.array([math.sin(a), math.cos(a)]) + K.make("vessel_tail", vessel, M["liner"], lambda bm: K.add_prism_y(bm, [tuple(p0), tuple(p1), tuple(p1 + nrm * 0.08), tuple(p0 + nrm * 0.08 + np.array([0.08, 0]))], -HW_OUT, HW_OUT), bevel=0.01) + # underframe: two beams to the hinge, cross members, the tip cylinder's bracket + eye = (ref_matrix("cylinder_head_link").translation + TIP_AXIS * TIP_REACH) - ref_matrix("vessel_pin_link").translation + + def under(bm): + for y in (-0.78, 0.78): + K.add_prism_y(bm, K.fillet([(-0.12, -0.08), (0.2, -0.1), (3.4, 0.22), (3.4, 0.314), (-0.3, 0.314)], 0.05), y - 0.07, y + 0.07) + for x in (0.9, 1.9, 2.9): + K.add_box(bm, (x - 0.05, -0.85, 0.22), (x + 0.05, 0.85, 0.314)) + for y in (-0.08, 0.08): + K.add_prism_y(bm, K.circle_hull([((eye.x, eye.z), 0.08)], extra=[(eye.x - 0.25, 0.314), (eye.x + 0.25, 0.314)]), y - 0.02, y + 0.02) + + K.make("vessel_underframe", vessel, M["frame"], under, bevel=0.01) + K.make("vessel_hinge", vessel, M["steel"], lambda bm: [K.add_cyl(bm, 0.07, (0, y - 0.1, 0), (0, y + 0.1, 0), 20) for y in (-0.78, 0.78)]) + K.make("vessel_chevrons", vessel, M["hazard_y"], lambda bm: [K.add_prism_frame(bm, [(y0, 0), (y0 + 0.1, 0), (y0 + 0.18, 0.18), (y0 + 0.08, 0.18)], (X0 - 0.47, 0, SIDE_TOP - 0.3), (0, 1, 0), (0, 0, 1), 0, -0.005) for y0 in np.arange(-1.1, 1.0, 0.24)], smooth=False) + + +vessel_parts() + +# ------------------------------------------------------------------ export +K.export_glb(OUT) +js, binchunk = K.read_glb(OUT) +roots = js["scenes"][0]["nodes"] +js["nodes"].append({"name": "ic120", "matrix": REFN["ic120"]["matrix"], "children": roots}) +js["scenes"][0]["nodes"] = [len(js["nodes"]) - 1] +names = {n.get("name"): i for i, n in enumerate(js["nodes"])} +for name, ref in REFN.items(): + if name in names and ref.get("extras"): + js["nodes"][names[name]]["extras"] = ref["extras"] +js["asset"]["copyright"] = ( + "Rubber-tracked crawler carrier (11 t class), modelled procedurally in Blender (assets/blender/ic120_hd.py) by the " + "construction-site-simulation project to the joint frames of PWRI's OPERA IC120 model (https://github.com/pwri-opera/ic120_ros2, Apache-2.0). Apache-2.0." +) +js["asset"]["extras"] = {"source": "assets/blender/ic120_hd.py", "reference": "https://github.com/pwri-opera/ic120_ros2", "license": "Apache-2.0"} +K.write_glb(OUT, js, binchunk) +print(f"EXPORTED {OUT} nodes={len(js['nodes'])}") + +if "--render" in ARGS: + out = ARGS[ARGS.index("--render") + 1] + tip = float(ARGS[ARGS.index("--tip") + 1]) if "--tip" in ARGS else 0.0 + vessel.matrix_basis = ref_matrix("vessel_pin_link") @ Matrix.Rotation(-tip, 4, "Y") + sc = bpy.context.scene + sc.render.engine = "BLENDER_EEVEE" + ee = sc.eevee + ee.taa_render_samples = 48 + ee.use_gtao = True + ee.use_ssr = True + ee.use_soft_shadows = True + ee.shadow_cascade_size = "4096" + sc.view_settings.view_transform = "AgX" + sun = bpy.data.objects.new("sun", bpy.data.lights.new("sun", "SUN")) + sc.collection.objects.link(sun) + sun.data.energy = 4.0 + sun.rotation_euler = (math.radians(50), 0, math.radians(200)) + w = bpy.data.worlds.new("sky") + sc.world = w + w.use_nodes = True + sky = w.node_tree.nodes.new("ShaderNodeTexSky") + w.node_tree.links.new(sky.outputs["Color"], w.node_tree.nodes["Background"].inputs["Color"]) + w.node_tree.nodes["Background"].inputs["Strength"].default_value = 0.25 + import bmesh as _bm + + b = _bm.new() + K.add_box(b, (-30, -30, -0.05), (30, 30, 0.0)) + me = bpy.data.meshes.new("ground") + b.to_mesh(me) + me.materials.append(K.material("dirt", "#8a7a62", rough=0.95)) + sc.collection.objects.link(bpy.data.objects.new("ground", me)) + sc.render.resolution_x, sc.render.resolution_y = 1600, 1000 + cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam")) + sc.collection.objects.link(cam) + sc.camera = cam + cam.data.lens = 35 + for vname, loc in {"front_left": (8.5, 7.5, 4.0), "rear_right": (-9.0, -7.5, 4.5), "side": (0, -13, 1.6)}.items(): + cam.location = loc + cam.rotation_euler = (Vector((0, 0, 1.2)) - Vector(loc)).to_track_quat("-Z", "Y").to_euler() + sc.render.filepath = f"{out}_{vname}.png" + bpy.ops.render.render(write_still=True) diff --git a/assets/blender/render_replay.py b/assets/blender/render_replay.py new file mode 100644 index 0000000..c3afab3 --- /dev/null +++ b/assets/blender/render_replay.py @@ -0,0 +1,460 @@ +"""Render a simulator replay (assets/replay/*.bin.gz, phase2/record_replay.py) in Blender with EEVEE: PNG frames +and an MP4. The scene is the one the browser builds (phase1/web/site.js + soil.js): the site terrain, the soil +surfaces from the heightmaps (pit, carrier load, spoil), the moving grains, and the machines from their glTF +models posed exactly as soil.js poses them (excavator links and cylinders, carriers and vessels, dozer blade and +lift cylinder, roller with turning drum and wheels). + +Poses in a replay are in the viewer's world frame (Y up); the scene root turns them to Blender's Z up. + + blender -b -t 4 --python assets/blender/render_replay.py -- [options] + --replay assets/replay/site_cycle.bin.gz recording (default) + --out out/dir frames, video (default renders/) + --from 0 --to 60 simulated seconds to render + --every 1 use every n-th recorded frame + --camera overview|excavator|spread camera preset + --res 1920x1080 --samples 32 --fps 24 output + --still one frame only (the --from time), no video + +The recording's frames are about 1/6 s of simulated time apart; at --fps 24 the video runs about 4x real time. +""" + +import math +import pathlib +import re +import shutil +import subprocess +import sys + +import bmesh +import bpy +import numpy as np +from mathutils import Matrix, Quaternion, Vector + +HERE = pathlib.Path(__file__).resolve().parent +sys.path.insert(0, str(HERE)) +import blendkit as K # noqa: E402 +import replay_io as R # noqa: E402 + +ROOT = HERE.parents[1] +ARGS = sys.argv[sys.argv.index("--") + 1 :] if "--" in sys.argv else [] + + +def arg(name, default=None, cast=str): + return cast(ARGS[ARGS.index(name) + 1]) if name in ARGS else default + + +REPLAY = ROOT / arg("--replay", "assets/replay/site_cycle.bin.gz") +OUT = pathlib.Path(arg("--out", str(ROOT / "renders" / REPLAY.name.split(".")[0]))) +T_FROM, T_TO = arg("--from", 0.0, float), arg("--to", 1e9, float) +EVERY = arg("--every", 1, int) +CAMERA = arg("--camera", "overview") +W, H = (int(v) for v in arg("--res", "1920x1080").split("x")) +SAMPLES = arg("--samples", 32, int) +FPS = arg("--fps", 24, int) +STILL = "--still" in ARGS + +# upgraded models (assets/blender), as soil.js loads them +UPGRADES = { + "assets/machinery/opera_zx200.glb": "assets/machinery/zx200_hd.glb", + "assets/machinery/opera_ic120.glb": "assets/machinery/ic120_hd.glb", + "assets/machinery/opera_d37pxi.glb": "assets/machinery/d37_hd.glb", +} +CB = Matrix.Rotation(math.radians(90), 4, "X") # viewer (Y up) -> Blender (Z up) +ZUP = Matrix.Rotation(math.radians(-90), 4, "X") # soil.js wrapZup / the models' root: URDF Z up -> Y up + + +def T3(pos, quat): + x, y, z, w = quat + return Matrix.Translation(Vector(pos)) @ Quaternion((w, x, y, z)).to_matrix().to_4x4() + + +def place(pos, quat): + """A soil.js group posed at (pos, quat) holding wrapZup(URDF frame) -> Blender world of that URDF frame.""" + return CB @ T3(pos, quat) @ ZUP + + +# ------------------------------------------------------------------ models + + +class Model: + """An imported glTF with its mesh objects grouped by owner node; pose() sets every mesh from owner frames. + + The importer turns glTF Y up into Blender Z up, which with the models' Z-up -> Y-up root leaves each object's + world matrix as (URDF world) @ ZUP; U(o) below is the URDF world of an object, rel = U(owner)^-1 U(mesh).""" + + def __init__(self, path, owners, skip=()): + before = set(bpy.data.objects) + bpy.ops.import_scene.gltf(filepath=str(path)) + bpy.context.view_layer.update() + self.objs = [o for o in bpy.data.objects if o not in before] + self.by = {re.sub(r"\.\d{3}$", "", o.name): o for o in self.objs} + U = lambda o: o.matrix_world @ ZUP.inverted() # noqa: E731 + self.U = {n: U(o) for n, o in self.by.items()} + self.items = [] + for o in self.objs: + if o.type != "MESH": + continue + p, owner, hidden = o, None, False + while p is not None: + n = re.sub(r"\.\d{3}$", "", p.name) + if n in skip: + hidden = True + break + if n in owners: + owner = n + break + p = p.parent + if hidden or owner is None: + o.hide_render = o.hide_viewport = True + continue + self.items.append((o, owner, self.U[owner].inverted() @ U(o))) + for o in self.objs: # free the meshes from the hierarchy so each can take its own world matrix + if o.type == "MESH": + mw = o.matrix_world.copy() + o.parent = None + o.matrix_world = mw + + def clone(self): + c = Model.__new__(Model) + c.U, c.items = self.U, [] + for o, owner, rel in self.items: + d = o.copy() + bpy.context.scene.collection.objects.link(d) + c.items.append((d, owner, rel)) + return c + + def rel(self, a, b): + return self.U[a].inverted() @ self.U[b] + + def pose(self, frames): + """frames: owner name -> Blender world matrix of its URDF frame.""" + for o, owner, rel in self.items: + m = frames.get(owner) + if m is None: + o.hide_render = True + continue + o.hide_render = False + o.matrix_world = m @ rel @ ZUP + + def hide(self): + for o, _, _ in self.items: + o.hide_render = True + + +# ------------------------------------------------------------------ static scene + + +def terrain_height(x, z): + """phase1/web/site.js terrainHeight (viewer frame: x, z ground plane).""" + + def smooth(e0, e1, v): + t = np.clip((v - e0) / (e1 - e0), 0, 1) + return t * t * (3 - 2 * t) + + dx = np.maximum(np.maximum(-x - 30, x - 62), 0) + dz = np.maximum(np.abs(z) - 22, 0) + out = np.hypot(dx, dz) + hills = 0.9 * np.sin(x * 0.11) * np.cos(z * 0.13) + 0.6 * np.sin(x * 0.27 + z * 0.19) + 0.35 * np.cos(x * 0.53 - z * 0.41) + h = smooth(0, 14, out) * (3.5 + hills + 1.2) + road = 1 - smooth(4, 7, np.abs(x + 11)) + h = np.where(z > 22, h * (1 - road) + road * np.minimum((z - 22) / 12, 4), h) + sr = np.hypot(x + 22, z + 15) + h = h + 3.2 * (1 - smooth(1.5, 6.5, sr)) + px = np.maximum(np.abs(x - 24) - 3, 0) + pz = np.maximum(np.abs(z - 12) - 2.5, 0) + h = h - np.maximum(2.5 - np.hypot(px, pz) / 1.5, 0) + return h + + +def grid_mesh(name, nx, ny, xs, zs, heights, mat, colors=None): + """Grid in the viewer frame (x, y = height, z); the object carries the frame change.""" + me = bpy.data.meshes.new(name) + X, Z = np.meshgrid(xs, zs) + verts = np.dstack([X, heights, Z]).reshape(-1, 3) + idx = np.arange(nx * ny).reshape(ny, nx) + a, b, c, d = idx[:-1, :-1].ravel(), idx[:-1, 1:].ravel(), idx[1:, 1:].ravel(), idx[1:, :-1].ravel() + faces = np.stack([a, d, c, b], axis=1) + me.from_pydata(verts.tolist(), [], faces.tolist()) + me.polygons.foreach_set("use_smooth", [True] * len(me.polygons)) + if colors is not None: + attr = me.color_attributes.new("Col", "FLOAT_COLOR", "POINT") + attr.data.foreach_set("color", np.hstack([colors, np.ones((len(colors), 1))]).astype(np.float32).ravel()) + me.materials.append(mat) + ob = bpy.data.objects.new(name, me) + bpy.context.scene.collection.objects.link(ob) + ob.matrix_world = CB + return ob + + +def set_heights(ob, heights): + co = np.empty(len(ob.data.vertices) * 3, np.float32) + ob.data.vertices.foreach_get("co", co) + co = co.reshape(-1, 3) + co[:, 1] = heights.ravel() + ob.data.vertices.foreach_set("co", co.ravel()) + ob.data.update() + + +def ground_material(name, base_hex=None, vertex_colors=False, scale=6.0, bump=0.25): + m = bpy.data.materials.new(name) + m.use_nodes = True + nt = m.node_tree + p = nt.nodes["Principled BSDF"] + p.inputs["Roughness"].default_value = 0.97 + noise = nt.nodes.new("ShaderNodeTexNoise") + noise.inputs["Scale"].default_value = scale + noise.inputs["Detail"].default_value = 12 + ramp = nt.nodes.new("ShaderNodeMath") + ramp.operation = "MULTIPLY_ADD" + ramp.inputs[1].default_value = 0.35 + ramp.inputs[2].default_value = 0.82 + nt.links.new(noise.outputs["Fac"], ramp.inputs[0]) + mix = nt.nodes.new("ShaderNodeMix") + mix.data_type = "RGBA" + mix.blend_type = "MULTIPLY" + mix.inputs["Factor"].default_value = 1.0 + if vertex_colors: + ca = nt.nodes.new("ShaderNodeVertexColor") + ca.layer_name = "Col" + nt.links.new(ca.outputs["Color"], mix.inputs[6]) + else: + mix.inputs[6].default_value = (*K.srgb(base_hex), 1) + nt.links.new(ramp.outputs[0], mix.inputs[7]) + nt.links.new(mix.outputs[2], p.inputs["Base Color"]) + b = nt.nodes.new("ShaderNodeBump") + b.inputs["Strength"].default_value = bump + b.inputs["Distance"].default_value = 0.02 + n2 = nt.nodes.new("ShaderNodeTexNoise") + n2.inputs["Scale"].default_value = 60 + n2.inputs["Detail"].default_value = 8 + nt.links.new(n2.outputs["Fac"], b.inputs["Height"]) + nt.links.new(b.outputs["Normal"], p.inputs["Normal"]) + return m + + +def build_terrain(): + n, size = 256, 128.0 + xs = np.linspace(-size / 2, size / 2, n) + X, Z = np.meshgrid(xs, xs) + Hh = terrain_height(X, Z) + pad, dirt, pit, grass = (np.array(K.srgb(c)) for c in ("#b3a68f", "#a3815c", "#7d5f44", "#8d9a5e")) + outside = np.hypot(np.maximum(np.abs(X) - 30, 0), np.maximum(np.abs(Z) - 22, 0)) > 9 + col = np.where((Hh < -0.15)[..., None], pit, np.where((np.abs(Hh) < 0.05)[..., None], pad, np.where(outside[..., None], grass, dirt))) + col = col * np.random.default_rng(1).uniform(0.94, 1.06, Hh.shape)[..., None] * 0.72 # the viewer's colours, toned for a physical sky + gm = ground_material("ground", vertex_colors=True) + grid_mesh("site_terrain", n, n, xs, xs, Hh, gm, col.reshape(-1, 3)) + # rolling country beyond the site out to the horizon (the site terrain is 128 m across) + far = np.linspace(-700, 700, 141) + FX, FZ = np.meshgrid(far, far) + r = np.maximum(np.abs(FX), np.abs(FZ)) + FH = np.where(r < 60, -8.0, 3.6 + 2.5 * np.sin(FX * 0.013) * np.cos(FZ * 0.017) + 1.5 * np.sin(FX * 0.031 + FZ * 0.023)) + fcol = np.tile(np.array(K.srgb("#7f8c55")) * 0.72, (FX.size, 1)) + grid_mesh("country", 141, 141, far, far, FH, gm, fcol) + + +def setup_world(): + sc = bpy.context.scene + sc.render.engine = "BLENDER_EEVEE" + ee = sc.eevee + ee.taa_render_samples = SAMPLES + ee.use_gtao = True + ee.gtao_distance = 0.8 + ee.use_ssr = True + ee.use_soft_shadows = True + ee.shadow_cascade_size = "4096" + ee.use_bloom = False + sc.view_settings.view_transform = "AgX" + sc.view_settings.look = "AgX - Medium High Contrast" + sc.render.resolution_x, sc.render.resolution_y = W, H + sc.render.image_settings.file_format = "PNG" + sun = bpy.data.objects.new("sun", bpy.data.lights.new("sun", "SUN")) + sc.collection.objects.link(sun) + sun.data.energy = 4.2 + sun.data.angle = math.radians(1.2) + sun.rotation_euler = (math.radians(48), 0, math.radians(-35)) + sun.data.shadow_cascade_max_distance = 120 + sun.data.shadow_cascade_count = 4 + w = bpy.data.worlds.new("sky") + sc.world = w + w.use_nodes = True + sky = w.node_tree.nodes.new("ShaderNodeTexSky") + sky.sun_elevation = math.radians(42) + sky.sun_rotation = math.radians(-35 + 180) + sky.sun_disc = False + w.node_tree.links.new(sky.outputs["Color"], w.node_tree.nodes["Background"].inputs["Color"]) + w.node_tree.nodes["Background"].inputs["Strength"].default_value = 0.22 + + +CAMERAS = { + # Blender frame: x as the viewer's x, y = -viewer z, z up + "overview": ((20.0, -38.0, 21.0), (44.0, -8.0, 0.0), 28), + "excavator": ((23.5, -1.0, 6.5), (30.5, -9.0, 1.4), 30), + "spread": ((39.0, 13.0, 10.0), (53.0, -4.0, 0.5), 30), +} + + +def setup_camera(): + loc, tgt, lens = CAMERAS[CAMERA] + cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam")) + bpy.context.scene.collection.objects.link(cam) + bpy.context.scene.camera = cam + cam.location = loc + cam.rotation_euler = (Vector(tgt) - Vector(loc)).to_track_quat("-Z", "Y").to_euler() + cam.data.lens = lens + cam.data.clip_end = 600 + + +# ------------------------------------------------------------------ build + + +def main(): + print(f"REPLAY {REPLAY}") + hello, raw = R.load(REPLAY) + frames = [R.decode(b) for b in raw] + geom = hello["geometry"] + soil = hello.get("soil", {}) + K.reset() + setup_world() + setup_camera() + build_terrain() + + soil_mat = ground_material("soil", soil.get("color", "#c9a774"), scale=14, bump=0.5) + load_mat = ground_material("soil_load", soil.get("color", "#c9a774"), scale=14, bump=0.5) + grain_mat = K.material("grains", soil.get("grain", "#b08a55"), rough=0.95) + + f0 = frames[0] + hm = f0["hm"] + xs = hm["x0"] + np.arange(hm["nx"]) * hm["cell"] + zs = hm["z0"] - np.arange(hm["ny"]) * hm["cell"] + pit = grid_mesh("soil_pit", hm["nx"], hm["ny"], xs, zs, hm["h"], soil_mat) + truck = spoil = None + if "truck_hm" in f0: + t = f0["truck_hm"] + truck = grid_mesh("soil_load", t["nx"], t["ny"], t["x0"] + np.arange(t["nx"]) * t["cell"], t["z0"] - np.arange(t["ny"]) * t["cell"], t["h"], load_mat) + if "spoil_hm" in f0: + t = f0["spoil_hm"] + spoil = grid_mesh("soil_spoil", t["nx"], t["ny"], t["x0"] + np.arange(t["nx"]) * t["cell"], t["z0"] - np.arange(t["ny"]) * t["cell"], np.where(t["h"] > -3.4, t["h"], -0.4), soil_mat) + grains = bpy.data.objects.new("grains", bpy.data.meshes.new("grains")) + bpy.context.scene.collection.objects.link(grains) + grains.matrix_world = CB + grains.data.materials.append(grain_mat) + ico = bmesh.new() + bmesh.ops.create_icosphere(ico, subdivisions=1, radius=0.04) + ico_v = np.array([v.co[:] for v in ico.verts]) + ico_f = np.array([[v.index for v in f.verts] for f in ico.faces]) + ico.free() + + # machines + m = geom["model"] + exc = Model(ROOT / UPGRADES.get(m["file"], m["file"]), set(m["links"].values()) | {m["crawler"]["node"]} | set(m.get("parts", []))) + crawler = place(m["crawler"]["pos"], m["crawler"]["quat"]) + cars = [] + if "carrier" in geom: + c = geom["carrier"] + car = Model(ROOT / UPGRADES.get(c["file"], c["file"]), {"base_link", c["vessel_node"]}, skip=set(c.get("hide_nodes", []))) + cars = [car] + [car.clone() for _ in range(c.get("count", 1) - 1)] + parked_pin = T3(c["parked_pin"][:3], c["parked_pin"][3:]) + doz = None + if "dozer" in geom: + d = geom["dozer"] + doz = Model(ROOT / UPGRADES.get(d["file"], d["file"]), {"base_link", d["arm_node"], d["cylinder_node"], d["piston_node"]}) + piston_axis = Vector((1.0055, 0, -0.056785)).normalized() # soil.js pistonAxis (blade_arm_piston_joint) + rol = None + if "roller" in geom and (ROOT / "assets/machinery/roller_hd.glb").exists(): + rol = Model(ROOT / "assets/machinery/roller_hd.glb", {"base_link", "drum", "wheel_l", "wheel_r"}) + spin_r = {"drum": geom["roller"]["drum_r"], "wheel_l": geom["roller"]["wheel_r"], "wheel_r": geom["roller"]["wheel_r"]} + # roll distance over the whole recording (the drum turns by distance / radius), as soil.js spinRoller + travel, prev = [0.0], None + for f in frames: + r = f.get("roller") + d_ = 0.0 + if r is not None and prev is not None: + q = Quaternion((r["base"][1][3], *r["base"][1][:3])) + fwd = q @ Vector((1, 0, 0)) + step = Vector(r["base"][0]) - prev + d_ = step.dot(fwd) if step.length < 2 else 0.0 + travel.append(travel[-1] + d_) + prev = Vector(r["base"][0]) if r is not None else prev + travel = travel[1:] + + sel = [k for k, f in enumerate(frames) if T_FROM <= f["sim_t"] <= T_TO][::EVERY] + if STILL: + sel = sel[:1] + if not sel: + raise SystemExit(f"no frames between {T_FROM} and {T_TO} s (recording runs {frames[0]['sim_t']:.1f}..{frames[-1]['sim_t']:.1f} s)") + OUT.mkdir(parents=True, exist_ok=True) + for old in OUT.glob("frame_*.png"): + old.unlink() + sc = bpy.context.scene + print(f"RENDER {len(sel)} frames, sim {frames[sel[0]]['sim_t']:.1f}..{frames[sel[-1]]['sim_t']:.1f} s, camera {CAMERA}, {W}x{H}, {SAMPLES} samples") + for i, k in enumerate(sel): + f = frames[k] + set_heights(pit, f["hm"]["h"]) + # excavator + fr = {m["links"][n]: place(*f["links"][n]) for n in ("house", "boom", "stick", "bucket")} + fr[m["crawler"]["node"]] = crawler + for name, p in zip(m.get("parts", []), f.get("parts", [])): + fr[name] = place(*p) + exc.pose(fr) + # carriers and the load in the one being loaded + for u, cf in zip(cars, f.get("carriers", [])): + u.pose({"base_link": place(*cf["base"]), c["vessel_node"]: place(*cf["pin"])}) + if truck is not None: + owner = f.get("load_owner", -1) + if f.get("carriers") and 0 <= owner < len(f["carriers"]): + truck.hide_render = False + set_heights(truck, f["truck_hm"]["h"]) + truck.matrix_world = CB @ T3(*f["carriers"][owner]["pin"]) @ parked_pin.inverted() + else: + truck.hide_render = True + if spoil is not None and "spoil_hm" in f: + h = f["spoil_hm"]["h"] + set_heights(spoil, np.where(h > -3.4, h, -0.4)) + # dozer: blade arm turns about its lift joint, the lift cylinder follows (soil.js) + if doz is not None: + if "dozer" in f: + z = f["dozer"] + b = place(*z["base"]) + cyl = b @ doz.rel("base_link", d["cylinder_node"]) @ Matrix.Rotation(0.9 * z["lift"], 4, "Y") + doz.pose({ + "base_link": b, + d["arm_node"]: b @ doz.rel("base_link", d["arm_node"]) @ Matrix.Rotation(z["lift"], 4, "Y"), + d["cylinder_node"]: cyl, + d["piston_node"]: cyl @ Matrix.Translation(piston_axis * 0.54 * z["lift"]) @ doz.rel(d["cylinder_node"], d["piston_node"]), + }) + else: + doz.hide() + if rol is not None: + if "roller" in f: + b = place(*f["roller"]["base"]) + pose = {"base_link": b} + for n, rr in spin_r.items(): + pose[n] = b @ rol.rel("base_link", n) @ Matrix.Rotation(travel[k] / rr, 4, "Y") + rol.pose(pose) + else: + rol.hide() + # grains + g = f["grains"] + me = grains.data + me.clear_geometry() + if len(g): + v = (g[:, None, :] + ico_v[None, :, :]).reshape(-1, 3) + fc = (ico_f[None, :, :] + (np.arange(len(g)) * len(ico_v))[:, None, None]).reshape(-1, 3) + me.from_pydata(v.tolist(), [], fc.tolist()) + me.update() + sc.render.filepath = str(OUT / f"frame_{i:05d}.png") + bpy.ops.render.render(write_still=True) + if i % 10 == 0: + print(f"FRAME {i + 1}/{len(sel)} sim {f['sim_t']:.1f} s", flush=True) + if STILL: + shutil.copy(OUT / "frame_00000.png", OUT / f"still_{CAMERA}_{frames[sel[0]]['sim_t']:.0f}s.png") + print(f"STILL {OUT}") + return + ffmpeg = shutil.which("ffmpeg") + if ffmpeg: + video = OUT / f"{REPLAY.name.split('.')[0]}_{CAMERA}.mp4" + subprocess.run([ffmpeg, "-y", "-loglevel", "error", "-framerate", str(FPS), "-i", str(OUT / "frame_%05d.png"), "-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "18", "-movflags", "+faststart", str(video)], check=True) + print(f"VIDEO {video}") + + +main() diff --git a/assets/blender/replay_io.py b/assets/blender/replay_io.py new file mode 100644 index 0000000..529dda8 --- /dev/null +++ b/assets/blender/replay_io.py @@ -0,0 +1,120 @@ +"""Read the simulator's replay recordings (phase2/record_replay.py, version 2) into numpy, frame by frame. + +Mirrors the browser's decoder (phase1/web/soil.js: startReplay, handleFrame, readTail): all poses are in the +viewer's world frame (three.js, Y up), quaternions xyzw; heightmaps are rows along -z from z0. + + hello, frames = load("assets/replay/site_cycle.bin.gz") + f = decode(frames[k]) # dict: sim_t, links, parts, carriers, dozer, roller, hm, truck_hm, spoil_hm, grains +""" + +import gzip +import json +import struct + +import numpy as np + +MAGIC = {"SOIL": 0x4C494F53, "EXC2": 0x32435845, "EXC3": 0x33435845, "CAR1": 0x31524143, "CARS": 0x53524143, "DOZ1": 0x315A4F44, "ROL1": 0x314C4F52} +HM_HEADER, P_HEADER = 16, 20 + + +def load(path): + """Header JSON and the list of raw frames (bytes), un-XORed.""" + raw = open(path, "rb").read() + if raw[:2] == b"\x1f\x8b": + raw = gzip.decompress(raw) + magic, version, hl = struct.unpack_from("= 2: + lh, lg, lt = struct.unpack_from(" 0 else c["y0"] - e + K.add_prism_y(bm, [(c["x0"] + 0.08, 0.7), (c["x1"] - 0.02, 0.7), (c["x1"] - 0.05, 2.1), (c["x0"] + 0.08, 2.1)], y, y + e) + p0, p1 = Vector((c["x1"] + 0.05, 0, 1.15)), Vector((c["x1"] - 0.03, 0, 2.1)) + u = (p1 - p0).normalized() + n = Vector((u.z, 0, -u.x)) + mid = (p0 + p1) / 2 + n * 0.003 + K.add_obox(bm, mid, (u, (0, 1, 0), n), ((p1 - p0).length / 2, c["y1"] - 0.08, e / 2)) # front + K.add_box(bm, (c["x0"] - e, c["y0"] + 0.08, 1.15), (c["x0"], c["y1"] - 0.08, 2.1)) # rear + + K.make("cab_glass", base, M["glass"], glass, smooth=False) + K.make("cab_interior", base, M["plastic"], lambda bm: (K.add_box(bm, (-0.75, -0.3, 0.45), (-0.45, 0.3, 1.35)), K.add_box(bm, (-0.25, -0.4, 0.45), (0.0, 0.4, 1.05))), bevel=0.02) + + def pillars(bm): + for x in (c["x0"] + 0.03, c["x1"] - 0.0): + for s in (-1, 1): + top = c["x1"] - 0.03 if x > c["x0"] + 0.1 else x + K.add_tube(bm, [(x, s * (c["y1"] - 0.02), 0.5), (x + (0.05 if x > c["x0"] + 0.1 else 0), s * (c["y1"] - 0.02), 1.1), (top, s * (c["y1"] - 0.02), c["z1"] - 0.02)], 0.03, 8) + + K.make("cab_pillars", base, M["frame"], pillars) + + def rails_mirrors(bm): + for s in (-1, 1): + K.add_tube(bm, [(-1.1, s * 0.93, 0.45), (-1.1, s * 0.93, 1.25), (-0.2, s * 0.93, 1.25), (-0.2, s * 0.93, 0.45)], 0.018, 8) + K.add_tube(bm, [(c["x1"] + 0.05, s * (c["y1"] + 0.05), c["z1"] - 0.05), (c["x1"] + 0.15, s * (c["y1"] + 0.3), c["z1"] - 0.1)], 0.012, 6) + K.add_box(bm, (c["x1"] + 0.12, s * (c["y1"] + 0.3) - 0.1, c["z1"] - 0.45), (c["x1"] + 0.16, s * (c["y1"] + 0.3) + 0.1, c["z1"] - 0.1)) + for k, z in enumerate((-0.05, 0.2)): # entry steps on the left + K.add_box(bm, (-0.95, 0.95, z), (-0.45, 1.12, z + 0.03)) + K.add_box(bm, (-0.96, 0.95, -0.1), (-0.93, 1.12, 0.35)) + K.add_box(bm, (-0.47, 0.95, -0.1), (-0.44, 1.12, 0.35)) + + K.make("rails_steps_mirrors", base, M["frame"], rails_mirrors, bevel=0.004) + K.make("beacon", base, M["amber"], lambda bm: (K.add_cyl(bm, 0.07, (-0.5, 0.45, c["z1"] + 0.07), (-0.5, 0.45, c["z1"] + 0.2), 24), K.add_sphere(bm, 0.07, (-0.5, 0.45, c["z1"] + 0.2), 24, 8))) + K.make("roof_lamps", base, M["lens"], lambda bm: [K.add_box(bm, (c["x1"] + 0.1, s * 0.5 - 0.07, c["z1"] + 0.01), (c["x1"] + 0.105, s * 0.5 + 0.07, c["z1"] + 0.06)) for s in (-1, 1)]) + + +cab() + +# ------------------------------------------------------------------ export +K.export_glb(OUT) +js, binchunk = K.read_glb(OUT) +roots = js["scenes"][0]["nodes"] +js["nodes"].append({"name": "roller", "matrix": [1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1], "children": roots}) # Z up -> Y up +js["scenes"][0]["nodes"] = [len(js["nodes"]) - 1] +names = {n.get("name"): i for i, n in enumerate(js["nodes"])} +js["nodes"][names["base_link"]]["extras"] = {"drum_x": DRUM_X, "drum_r": DRUM_R, "axle_x": AXLE_X, "wheel_r": WHEEL_R, "spin_nodes": {"drum": DRUM_R, "wheel_l": WHEEL_R, "wheel_r": WHEEL_R}, "_note": "spin_nodes turn about their local y by distance / radius as the roller moves along +x"} +js["asset"]["copyright"] = "Single-drum vibratory roller (10.6 t class), modelled procedurally in Blender (assets/blender/roller_hd.py) by the construction-site-simulation project. Apache-2.0." +js["asset"]["extras"] = {"source": "assets/blender/roller_hd.py", "license": "Apache-2.0"} +K.write_glb(OUT, js, binchunk) +print(f"EXPORTED {OUT} nodes={len(js['nodes'])}") + +if "--render" in ARGS: + out = ARGS[ARGS.index("--render") + 1] + sc = bpy.context.scene + if "--beauty" in ARGS: + sc.render.engine = "BLENDER_EEVEE" + ee = sc.eevee + ee.taa_render_samples = 64 + ee.use_gtao = True + ee.use_ssr = True + ee.use_soft_shadows = True + ee.shadow_cascade_size = "4096" + sc.view_settings.view_transform = "AgX" + sun = bpy.data.objects.new("sun", bpy.data.lights.new("sun", "SUN")) + sc.collection.objects.link(sun) + sun.data.energy = 4.0 + sun.rotation_euler = (math.radians(50), 0, math.radians(200)) + w = bpy.data.worlds.new("sky") + sc.world = w + w.use_nodes = True + sky = w.node_tree.nodes.new("ShaderNodeTexSky") + w.node_tree.links.new(sky.outputs["Color"], w.node_tree.nodes["Background"].inputs["Color"]) + w.node_tree.nodes["Background"].inputs["Strength"].default_value = 0.25 + import bmesh as _bm + + b = _bm.new() + K.add_box(b, (-20, -20, GROUND - 0.05), (20, 20, GROUND)) + me = bpy.data.meshes.new("ground") + b.to_mesh(me) + me.materials.append(K.material("dirt", "#8a7a62", rough=0.95)) + g = bpy.data.objects.new("ground", me) + sc.collection.objects.link(g) + else: + sc.render.engine = "BLENDER_WORKBENCH" + sc.display.shading.light = "STUDIO" + sc.display.shading.color_type = "MATERIAL" + sc.display.shading.show_cavity = True + sc.render.resolution_x, sc.render.resolution_y = 1600, 1000 + cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam")) + sc.collection.objects.link(cam) + sc.camera = cam + cam.data.lens = 35 + for vname, loc in {"front_left": (6.5, 5.5, 2.5), "rear_right": (-6.5, -5.5, 2.8), "side": (0, -8.5, 0.8)}.items(): + cam.location = loc + cam.rotation_euler = (Vector((0, 0, 0.3)) - Vector(loc)).to_track_quat("-Z", "Y").to_euler() + sc.render.filepath = f"{out}_{vname}.png" + bpy.ops.render.render(write_still=True) diff --git a/assets/blender/zx200_hd.py b/assets/blender/zx200_hd.py new file mode 100644 index 0000000..05484f9 --- /dev/null +++ b/assets/blender/zx200_hd.py @@ -0,0 +1,1013 @@ +"""Detailed, articulated 20 t class hydraulic excavator built procedurally in Blender, exported as +assets/machinery/zx200_hd.glb. + +It is a drop-in replacement for assets/machinery/opera_zx200.glb (PWRI OPERA ZX200 meshes): the same node +names, link frames (read from that file), joint extras and free parts, so the simulator (phase2), the soil +view (phase1/web/soil.js) and the showcase linkage (phase1/web/linkage.js) take it unchanged: + + zx200 (Z up -> Y up) / base_link / track_link / body_link / boom_link / arm_link / bucket_link / bucket_end_link + free parts at the root, posed from the pins: boom_barrel, boom_rod, arm_barrel, arm_rod, bucket_barrel, + bucket_rod, side_link, guide_link (mesh frames as phase2/hydraulics.py CYLINDER_MESH and LINK_MESH) + +Dimensions follow the OPERA model (which follows the machine) and its pin table; the parts themselves are +modelled here: box-section boom and arm, bucket with teeth and wear strips, cylinders with glands, ports and +chrome rods, an undercarriage with individual track shoes, rollers, idlers and sprockets, the house with cab +glazing, counterweight, louvres, rails, mirrors, and PWRI's automation retrofit (GNSS antennas, signal tower). +No manufacturer marks or livery. + + blender -b -t 4 --python assets/blender/zx200_hd.py # build and export + blender -b -t 4 --python assets/blender/zx200_hd.py -- --render out/prefix # also render review images + blender -b -t 4 --python assets/blender/zx200_hd.py -- --pose 0.3,-0.6,2.1,2.2 --render out/prefix +""" + +import math +import pathlib +import sys + +import numpy as np +from mathutils import Matrix, Vector + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) +import blendkit as K # noqa: E402 + +ROOT = pathlib.Path(__file__).resolve().parents[2] +REF = ROOT / "assets/machinery/opera_zx200.glb" +OUT = ROOT / "assets/machinery/zx200_hd.glb" +ARGS = sys.argv[sys.argv.index("--") + 1 :] if "--" in sys.argv else [] + +REFJ, _ = K.read_glb(REF) +REFN = {n["name"]: n for n in REFJ["nodes"]} + + +def ref_matrix(name): + m = REFN[name].get("matrix") + return Matrix(np.array(m).reshape(4, 4).T.tolist()) if m else Matrix.Identity(4) + + +# ------------------------------------------------------------------ pins (phase2/hydraulics.py) +PINS = { + "boom_head": ("house", 0.686, 0.247), + "boom_rod": ("boom", 1.776, 2.249), + "arm_head": ("boom", 2.276, 2.789), + "arm_rod": ("stick", -0.778, -0.367), + "bucket_head": ("stick", -0.248, 0.733), + "guide": ("stick", 1.577, 1.878), + "side": ("bucket", -0.328, 0.548), +} +GUIDE_LEN, SIDE_LEN = 0.561, 0.583 +# mesh frames of the free parts: head eye at the origin, axis in x-z, pin-to-pin length as modelled +CYL = { + # axis dir l_mesh y centres barrel r rod r barrel len rod len (strokes over the joint limits) + "boom": ((0.3425, 0.9395), 2.73, (-0.32, 0.32), 0.085, 0.0425, 1.94, 1.60), # L 2.07..3.35 m + "arm": ((0.9486, 0.3165), 1.70, (0.0,), 0.095, 0.0475, 1.75, 1.72), # L 1.88..3.35 m + "bucket": ((0.6761, 0.7368), 2.16, (0.0,), 0.080, 0.040, 1.54, 1.35), # L 1.67..2.71 m +} +LINK_MESH = {"side": ((0.0, 0.0), (-0.328, 0.482)), "guide": ((0.0, 0.0), (-0.338, -0.448))} +BOOM_FOOT, ARM_PIN = (0.0, 0.0), (4.84, 3.0023) # boom frame +BUCKET_PIN = (1.9155, 2.1737) # arm frame +BUCKET_TIP = (1.13012, 0.93856) # bucket frame (bucket_end_link) + +# ------------------------------------------------------------------ materials +K.reset() +M = { + "paint": K.surface("paint_orange", "#e2741c", "paint", 1024, seed=1, coat=0.35), + "paint_dark": K.surface("paint_graphite", "#2b2e31", "paint", 512, seed=2, coat=0.2), + "cab": K.surface("paint_cab_grey", "#7b8186", "paint", 512, seed=3, coat=0.25), + "frame": K.surface("steel_frame", "#1e2023", "paint_worn", 1024, seed=4), + "track": K.surface("track_steel", "#38312a", "track", 1024, seed=5), + "steel": K.material("steel_machined", "#9a9da0", rough=0.3, metal=1.0), + "chrome": K.material("chrome_rod", "#e6e8ea", rough=0.08, metal=1.0), + "bucket": K.surface("bucket_steel", "#2a2c2f", "steel", 1024, seed=6), + "wear": K.surface("wear_steel", "#6a665f", "worn_edge", 512, seed=7), + "glass": K.material("glass_tinted", "#16222a", rough=0.04, alpha=0.55), + "rubber": K.surface("rubber_black", "#151515", "rubber", 512, seed=8), + "plastic": K.material("plastic_black", "#0d0e0f", rough=0.55), + "white": K.material("antenna_white", "#e8e8e4", rough=0.35), + "lens": K.material("lamp_lens", "#f4f1e4", rough=0.1, emit="#fff4dc", emit_strength=0.6), + "red": K.material("lamp_red", "#c4161c", rough=0.2, emit="#ff2010", emit_strength=0.4), + "amber": K.material("lamp_amber", "#f0a020", rough=0.2, emit="#ffa000", emit_strength=0.4), + "green": K.material("lamp_green", "#1e9a3c", rough=0.2, emit="#20ff60", emit_strength=0.4), + "blue": K.material("lamp_blue", "#1c58c8", rough=0.2, emit="#2070ff", emit_strength=0.4), + "hazard_y": K.material("hazard_yellow", "#f0c010", rough=0.45, coat=0.2), + "hazard_k": K.material("hazard_black", "#141414", rough=0.5, coat=0.2), +} + +# ------------------------------------------------------------------ hierarchy (as the OPERA model) +base = K.empty("base_link") +track = K.empty("track_link", base, ref_matrix("track_link")) +body = K.empty("body_link", track, ref_matrix("body_link")) +boom = K.empty("boom_link", body, ref_matrix("boom_link")) +arm = K.empty("arm_link", boom, ref_matrix("arm_link")) +bucket = K.empty("bucket_link", arm, ref_matrix("bucket_link")) +K.empty("bucket_end_link", bucket, ref_matrix("bucket_end_link")) +FREE = {n: K.empty(n) for n in ("boom_barrel", "boom_rod", "arm_barrel", "arm_rod", "bucket_barrel", "bucket_rod", "side_link", "guide_link")} + + +def pin_y(parent, name, mat, c, r, y0, y1, segs=24, bevel=0.006): + """A cross pin or boss along y at (x, z) = c.""" + K.make(name, parent, mat, lambda bm: K.add_cyl(bm, r, (c[0], y0, c[1]), (c[0], y1, c[1]), segs), bevel=bevel) + + +def pin_with_caps(parent, name, c, r, half): + """Steel pin through a joint, with retaining end plates and bolts.""" + + def build(bm): + K.add_cyl(bm, r, (c[0], -half, c[1]), (c[0], half, c[1]), 20) + for s in (-1, 1): + K.add_cyl(bm, r * 1.6, (c[0], s * half, c[1]), (c[0], s * (half + 0.018), c[1]), 20) + K.add_cyl(bm, 0.012, (c[0] + r * 0.9, s * (half + 0.018), c[1]), (c[0] + r * 0.9, s * (half + 0.03), c[1]), 6) + + K.make(name, parent, M["steel"], build, bevel=0.003) + + +# ================================================================== undercarriage (track_link: ground z = 0) +GAUGE, SHOE_W = 2.2, 0.8 +XS, XI, RP, ZP = -1.62, 1.75, 0.36, 0.10 # sprocket and idler x, pitch radius, bottom pitch line +ZC, ZT = ZP + RP, ZP + 2 * RP +LOOP = 2 * (XI - XS) + 2 * math.pi * RP +N_SHOES = 47 +PITCH = LOOP / N_SHOES + + +def loop_pose(s): + """Point, tangent and outward normal (x-z) along the track loop at arc length s.""" + s %= LOOP + a = XI - XS + arc = math.pi * RP + if s < a: + return (XS + s, ZP), (1, 0), (0, -1) + s -= a + if s < arc: + f = s / RP + return (XI + RP * math.sin(f), ZC - RP * math.cos(f)), (math.cos(f), math.sin(f)), (math.sin(f), -math.cos(f)) + s -= arc + if s < a: + return (XI - s, ZT), (-1, 0), (0, 1) + s -= a + f = s / RP + return (XS - RP * math.sin(f), ZC + RP * math.cos(f)), (-math.cos(f), -math.sin(f)), (-math.sin(f), math.cos(f)) + + +def build_shoe(bm): + """One track shoe and its chain link, local frame: x along the track, y across, z outward.""" + h = PITCH * 0.5 + K.add_box(bm, (-h * 0.96, -SHOE_W / 2, 0.055), (h * 0.96, SHOE_W / 2, 0.075)) # plate + for gx in (-0.055, 0.0, 0.055): # triple grouser + K.add_prism_frame(bm, [(gx - 0.012, 0.075), (gx + 0.012, 0.075), (gx + 0.006, 0.1), (gx - 0.006, 0.1)], (0, -SHOE_W / 2, 0), (1, 0, 0), (0, 0, 1), 0, -SHOE_W) + for s in (-1, 1): # link rails + y = s * 0.25 + K.add_prism_frame(bm, [(-h, -0.03), (h, -0.03), (h * 1.02, 0.02), (h * 0.7, 0.055), (-h * 0.7, 0.055), (-h * 1.02, 0.02)], (0, y - 0.03, 0), (1, 0, 0), (0, 0, 1), 0, -0.06) + K.add_cyl(bm, 0.034, (h, -0.22, 0), (h, 0.22, 0), 10) # bushing + for s in (-1, 1): + K.add_cyl(bm, 0.022, (h, s * 0.28, 0), (h, s * 0.29, 0), 8) # pin ends + for bx in (-0.045, 0.045): # shoe bolts + for by in (-0.29, -0.21, 0.21, 0.29): + K.add_cyl(bm, 0.011, (bx, by, 0.055), (bx, by, 0.045), 6) + + +def undercarriage(): + import bpy + + shoe_mesh = None + shoes = {} + for side, s in (("L", 1), ("R", -1)): + yc = s * GAUGE / 2 + names = [] + for k in range(N_SHOES): + (px, pz), (tx, tz), (nx, nz) = loop_pose(k * PITCH) + X, Z = Vector((tx, 0, tz)), Vector((nx, 0, nz)) + Y = Z.cross(X) + mat = Matrix.Identity(4) + for c, v in enumerate((X, Y, Z)): + mat[0][c], mat[1][c], mat[2][c] = v + mat.translation = (px, yc, pz) + name = f"track_shoe_{side}_{k:02d}" + ob = K.make(name, track, M["track"], build_shoe, matrix=mat, mesh=shoe_mesh) + shoe_mesh = ob.data + names.append(name) + shoes[side] = names + + # side frame: box section between the idler and sprocket, sloped top to shed spoil + K.make(f"track_frame_{side}", track, M["frame"], lambda bm, yc=yc: K.add_prism_y(bm, K.fillet([(-1.42, 0.36), (1.42, 0.36), (1.62, 0.47), (1.48, 0.64), (-1.3, 0.64), (-1.46, 0.52)], 0.05), yc - 0.24, yc + 0.24), bevel=0.02) + K.make(f"track_frame_top_{side}", track, M["frame"], lambda bm, yc=yc: K.add_prism_frame(bm, [(-1.25, 0.0), (1.38, 0.0), (1.38, 0.05), (-1.25, 0.05)], (0, yc - 0.25, 0.64), (1, 0, 0), (0, 0, 1), 0, -0.5), bevel=0.015) + + def rollers(bm, yc=yc): + for x in np.linspace(-1.2, 1.3, 7): # track rollers, double flange running on the rails + zr = ZP + 0.055 + 0.09 + for e in (-1, 1): + K.add_cyl(bm, 0.09, (x, yc + e * 0.215, zr), (x, yc + e * 0.285, zr), 20) + K.add_cyl(bm, 0.112, (x, yc + e * 0.285, zr), (x, yc + e * 0.305, zr), 20) + K.add_cyl(bm, 0.112, (x, yc + e * 0.195, zr), (x, yc + e * 0.215, zr), 20) + K.add_cyl(bm, 0.07, (x, yc - 0.195, zr), (x, yc + 0.195, zr), 16) + K.add_box(bm, (x - 0.07, yc - 0.33, zr + 0.03), (x + 0.07, yc - 0.3, 0.37)) # mounting brackets + K.add_box(bm, (x - 0.07, yc + 0.3, zr + 0.03), (x + 0.07, yc + 0.33, 0.37)) + for x in (-0.45, 0.75): # carrier rollers under the top run + zr = ZT - 0.055 - 0.075 + K.add_cyl(bm, 0.075, (x, yc - 0.13, zr), (x, yc + 0.13, zr), 20) + K.add_cyl(bm, 0.09, (x, yc - 0.02, zr), (x, yc + 0.02, zr), 20) + K.add_box(bm, (x - 0.05, yc - 0.16, 0.6), (x + 0.05, yc + 0.16, zr - 0.03)) + + K.make(f"track_rollers_{side}", track, M["frame"], rollers, bevel=0.008) + + def idler(bm, yc=yc): + K.add_cyl(bm, RP - 0.055, (XI, yc - 0.3, ZC), (XI, yc + 0.3, ZC), 40) + K.add_cyl(bm, RP - 0.02, (XI, yc - 0.05, ZC), (XI, yc + 0.05, ZC), 40) + K.add_cyl(bm, 0.1, (XI, yc - 0.34, ZC), (XI, yc + 0.34, ZC), 16) + K.add_box(bm, (XI - 0.55, yc - 0.2, ZC - 0.08), (XI - 0.1, yc + 0.2, ZC + 0.08)) # yoke to the recoil spring + + K.make(f"track_idler_{side}", track, M["frame"], idler, bevel=0.01) + + def sprocket(bm, yc=yc, s=s): + K.add_gear(bm, (XS, ZC), 0, RP - 0.035, RP + 0.03, 21, yc - 0.045, yc + 0.045) + K.add_cyl(bm, 0.2, (XS, yc - 0.12, ZC), (XS, yc + 0.12, ZC), 32) + # travel motor and reduction housing, inboard + K.add_cyl(bm, 0.3, (XS, yc - s * 0.12, ZC), (XS, yc - s * 0.45, ZC), 40) + K.add_cyl(bm, 0.22, (XS, yc - s * 0.45, ZC), (XS, yc - s * 0.6, ZC), 32) + for k in range(16): + a = 2 * math.pi * k / 16 + x, z = XS + 0.25 * math.cos(a), ZC + 0.25 * math.sin(a) + K.add_cyl(bm, 0.016, (x, yc - s * 0.45, z), (x, yc - s * 0.47, z), 6) + for k in range(12): # sprocket bolts + a = 2 * math.pi * k / 12 + x, z = XS + 0.16 * math.cos(a), ZC + 0.16 * math.sin(a) + K.add_cyl(bm, 0.015, (x, yc + s * 0.12, z), (x, yc + s * 0.14, z), 6) + + K.make(f"track_sprocket_{side}", track, M["frame"], sprocket, bevel=0.006) + + # recoil spring housing cover behind the idler + K.make(f"track_recoil_cover_{side}", track, M["frame"], lambda bm, yc=yc: K.add_box(bm, (0.95, yc - 0.22, 0.42), (1.45, yc + 0.22, 0.62)), bevel=0.01) + + def carbody(bm): + K.add_prism_z(bm, K.fillet([(-1.05, -0.88), (1.05, -0.88), (1.05, 0.88), (-1.05, 0.88)], 0.1), 0.52, 0.84) + K.add_prism_z(bm, K.fillet([(-0.7, -0.75), (0.7, -0.75), (0.7, 0.75), (-0.7, 0.75)], 0.25), 0.84, 0.94) + K.add_cyl(bm, 0.92, (0, 0, 0.94), (0, 0, 1.04), 64) # swing bearing outer race + for k in range(36): + a = 2 * math.pi * k / 36 + K.add_cyl(bm, 0.018, (0.82 * math.cos(a), 0.82 * math.sin(a), 0.94), (0.82 * math.cos(a), 0.82 * math.sin(a), 0.965), 6) + K.add_cyl(bm, 0.18, (0, 0, 0.3), (0, 0, 0.55), 24) # centre swivel joint + + K.make("carbody", track, M["frame"], carbody, bevel=0.02) + return shoes + + +SHOES = undercarriage() +import bpy # noqa: E402 + +# ================================================================== house (body_link: swing bearing top at z = 0) +HW = 1.33 # half width +CAB = dict(x0=-0.06, x1=1.62, y0=0.44, y1=HW, z0=0.2, z1=1.83) + + +def house(): + K.make("upper_race", body, M["frame"], lambda bm: K.add_cyl(bm, 0.9, (0, 0, -0.08), (0, 0, 0.0), 64), bevel=0.01) + K.make("revolving_frame", body, M["frame"], lambda bm: K.add_prism_z(bm, K.fillet([(-1.95, -HW), (1.72, -HW), (1.78, -0.6), (1.78, 0.6), (1.72, HW), (-1.95, HW)], 0.08), 0.0, 0.2), bevel=0.02) + + # counterweight: rear face on the tail-swing radius, rubber-edged lower band, lifting eyes, tail lamps + R = 2.72 + ys = np.linspace(HW, -HW, 28) + cw = [(-1.9, -HW)] + [(-math.sqrt(R * R - y * y), y) for y in ys[::-1]] + [(-1.9, HW)] + cw = cw[::-1] + K.make("counterweight", body, M["paint"], lambda bm: K.add_prism_z(bm, cw, -0.07, 1.0), bevel=0.09, segs=4) + band = [(x * 1.004, y * 1.004) for x, y in cw] + K.make("counterweight_band", body, M["paint_dark"], lambda bm: K.add_prism_z(bm, band, -0.075, 0.1), bevel=0.02) + + def eyes(bm): + for y in (-0.75, 0.75): + K.add_tube(bm, [(-2.25 + 0.09 * math.cos(a), y, 1.0 + 0.09 * math.sin(a)) for a in np.linspace(0, math.pi, 10)], 0.018, 8) + + K.make("counterweight_eyes", body, M["steel"], eyes) + for y, name in ((1.05, "tail_lamp_l"), (-1.05, "tail_lamp_r")): + x = -math.sqrt(R * R - y * y) + K.make(name, body, M["red"], lambda bm, x=x, y=y: K.add_obox(bm, (x - 0.0, y, 0.75), ((x, y, 0), (-y, x, 0), (0, 0, 1)), (0.02, 0.07, 0.035)), bevel=0.008) + + # engine and cooling compartment + K.make("engine_room", body, M["paint"], lambda bm: K.add_box(bm, (-1.93, -HW, 0.2), (-0.08, HW, 1.0)), bevel=0.05, segs=3) + K.make("engine_hood", body, M["paint_dark"], lambda bm: K.add_box(bm, (-1.85, -1.22, 1.0), (-0.32, 0.3, 1.13)), bevel=0.05, segs=3) + + def hood_ribs(bm): + for y in (-0.95, -0.45, 0.05): + K.add_box(bm, (-1.75, y - 0.02, 1.13), (-0.42, y + 0.02, 1.15)) + + K.make("engine_hood_ribs", body, M["paint_dark"], hood_ribs, bevel=0.008) + + def louvres(bm): + for side in (1, -1): + y = side * HW + for k in range(9): + z = 0.38 + k * 0.055 + K.add_obox(bm, (-1.05, y + side * 0.012, z), ((1, 0, 0), (0, side * math.cos(0.5), -math.sin(0.5)), (0, side * math.sin(0.5), math.cos(0.5))), (0.5, 0.016, 0.006)) + K.add_box(bm, (-1.6, y - 0.004, 0.33), (-0.5, y + 0.004, 0.86)) + + K.make("louvres", body, M["frame"], louvres, bevel=0.003) + + def seams(bm): # door shut lines and hinges on both sides of the engine room + for side in (1, -1): + y = side * (HW + 0.002) + for x in (-1.7, -0.45): + K.add_box(bm, (x - 0.006, y - 0.004, 0.24), (x + 0.006, y + 0.004, 0.96)) + K.add_box(bm, (-1.7, y - 0.004, 0.955), (-0.45, y + 0.004, 0.965)) + for z in (0.35, 0.85): + K.add_cyl(bm, 0.018, (-0.47, y, z - 0.06), (-0.47, y, z + 0.06), 10) + K.add_box(bm, (-1.66, y - side * 0.0, 0.6), (-1.6, y + side * 0.025, 0.64)) # handle + + K.make("engine_room_seams", body, M["frame"], seams) + + # right front: hydraulic and fuel tanks under a stepped cover, with anti-slip plates and a filler cap + tank = K.fillet([(-0.08, 0.2), (1.72, 0.2), (1.72, 0.78), (1.56, 0.98), (-0.08, 0.98)], 0.04) + K.make("tank_cover", body, M["paint"], lambda bm: K.add_prism_y(bm, tank, -HW, -0.42), bevel=0.04, segs=3) + + def antislip(bm): + for x0, x1 in ((0.0, 0.7), (0.78, 1.48)): + K.add_box(bm, (x0, -1.26, 0.98), (x1, -0.5, 0.988)) + for x in np.arange(x0 + 0.04, x1 - 0.02, 0.08): + for y in np.arange(-1.22, -0.52, 0.08): + K.add_box(bm, (x - 0.012, y - 0.012, 0.988), (x + 0.012, y + 0.012, 0.995)) + + K.make("anti_slip", body, M["frame"], antislip) + K.make("filler_cap", body, M["frame"], lambda bm: K.add_cyl(bm, 0.07, (-0.0 + 0.2, -0.95, 1.13 - 0.15), (0.2, -0.95, 1.03), 24), bevel=0.01) + + def steps(bm): + for z in (0.36, 0.66): + K.add_box(bm, (1.25, -HW - 0.16, z), (1.62, -HW - 0.0, z + 0.03)) + for x in np.arange(1.28, 1.6, 0.05): + K.add_box(bm, (x, -HW - 0.15, z + 0.03), (x + 0.02, -HW - 0.01, z + 0.04)) + K.add_box(bm, (1.25, -HW - 0.02, 0.2), (1.28, -HW, 0.7)) + K.add_box(bm, (1.59, -HW - 0.02, 0.2), (1.62, -HW, 0.7)) + + K.make("steps", body, M["frame"], steps, bevel=0.004) + + # handrails along the top of the tank cover and the hood (operators walk there for service) + def rails(bm): + y = -HW + 0.06 + posts = [(0.05, 0.98), (0.8, 0.98), (1.5, 0.98), (-0.4, 1.13), (-1.1, 1.13), (-1.75, 1.13)] + for x, z in posts: + K.add_tube(bm, [(x, y, z), (x, y, 1.7)], 0.02, 10) + K.add_tube(bm, [(1.5, y, 1.7), (0.05, y, 1.7), (-0.4, y, 1.7), (-1.75, y, 1.7)], 0.02, 10) + K.add_tube(bm, [(1.5, y, 1.35), (0.05, y, 1.35)], 0.016, 10) + + K.make("handrails", body, M["paint"], rails) + + # cab: frame, tinted glazing on every face, roof, wiper, door handle, mirrors, interior shadow box + c = CAB + # side profile: vertical lower front, windscreen raked back 0.1 m, rounded roof line + XR = c["x1"] - 0.1 # front of the roof + ZK = 0.56 # where the rake starts + prof = K.fillet([(c["x0"], c["z0"]), (c["x1"], c["z0"]), (c["x1"], ZK), (XR, c["z1"]), (c["x0"], c["z1"])], 0.07, 4) + K.make("cab_shell", body, M["cab"], lambda bm: K.add_prism_y(bm, prof, c["y0"], c["y1"]), bevel=0.025, segs=3) + roof = K.fillet([(c["x0"] - 0.03, c["z1"] - 0.01), (XR + 0.07, c["z1"] - 0.01), (XR + 0.07, c["z1"] + 0.035), (c["x0"] - 0.03, c["z1"] + 0.045)], 0.015, 2) + K.make("cab_roof", body, M["cab"], lambda bm: K.add_prism_y(bm, roof, c["y0"] - 0.03, c["y1"] + 0.03), bevel=0.012) + + def front_x(z): # cab front at height z + return c["x1"] if z <= ZK else c["x1"] - (c["x1"] - XR) * (z - ZK) / (c["z1"] - ZK) + + e = 0.006 + + def glass(bm): + # windscreen on the raked face + z0, z1 = 0.62, 1.74 + p0, p1 = Vector((front_x(z0), 0, z0)), Vector((front_x(z1), 0, z1)) + u = (p1 - p0).normalized() + n = Vector((u.z, 0, -u.x)) + mid = (p0 + p1) / 2 + n * 0.003 + mid.y = (c["y0"] + c["y1"]) / 2 + K.add_obox(bm, mid, (u, (0, 1, 0), n), ((p1 - p0).length / 2, (c["y1"] - c["y0"]) / 2 - 0.08, e / 2)) + K.add_box(bm, (c["x1"], c["y0"] + 0.08, 0.28), (c["x1"] + e, c["y1"] - 0.08, 0.52)) # lower front + side_front = lambda z: front_x(z) - 0.07 # noqa: E731 + door = [(0.62, 0.58), (side_front(0.58), 0.58), (side_front(1.75), 1.75), (0.62, 1.75)] + K.add_prism_y(bm, door, c["y1"], c["y1"] + e) + K.add_prism_y(bm, [(0.04, 0.95), (0.54, 0.95), (0.54, 1.75), (0.04, 1.75)], c["y1"], c["y1"] + e) # left rear quarter + K.add_prism_y(bm, [(0.3, 0.95), (side_front(0.95), 0.95), (side_front(1.75), 1.75), (0.3, 1.75)], c["y0"] - e, c["y0"]) # right side + K.add_box(bm, (c["x0"] - e, c["y0"] + 0.1, 1.1), (c["x0"], c["y1"] - 0.1, 1.72)) # rear + K.add_box(bm, (0.45, c["y0"] + 0.15, c["z1"] + 0.035), (1.2, c["y1"] - 0.15, c["z1"] + 0.05)) # roof hatch + + K.make("cab_glass", body, M["glass"], glass, smooth=False) + + def cab_trim(bm): + K.add_box(bm, (0.58, c["y1"], 0.25), (0.6, c["y1"] + 0.008, 1.78)) # door shut line + K.add_box(bm, (1.2, c["y1"] + 0.008, 1.0), (1.32, c["y1"] + 0.03, 1.03)) # handle + K.add_tube(bm, [(front_x(0.66) + 0.012, 0.62, 0.66), (front_x(1.62) + 0.012, 1.05, 1.62)], 0.008, 6) # wiper + K.add_box(bm, (front_x(0.6) + 0.004, 0.6, 0.6), (front_x(0.6) + 0.03, 0.66, 0.66)) + for y in (c["y0"] + 0.035, c["y1"] - 0.035): # front pillars + K.add_tube(bm, [(c["x1"] + 0.004, y, 0.24), (c["x1"] + 0.004, y, ZK), (XR + 0.004, y, c["z1"] - 0.04)], 0.022, 8) + + K.make("cab_trim", body, M["plastic"], cab_trim) + + def interior(bm): # dark mass behind the glass: seat back, consoles + K.add_box(bm, (0.25, 0.7, 0.3), (0.55, 1.1, 1.25)) + K.add_box(bm, (0.5, 0.55, 0.3), (1.0, 0.68, 0.85)) + K.add_box(bm, (0.5, 1.12, 0.3), (1.0, 1.25, 0.85)) + K.add_tube(bm, [(0.95, 0.62, 0.85), (1.0, 0.62, 1.0)], 0.018, 8) + K.add_tube(bm, [(0.95, 1.18, 0.85), (1.0, 1.18, 1.0)], 0.018, 8) + + K.make("cab_interior", body, M["plastic"], interior, bevel=0.02) + + def mirrors(bm): + K.add_tube(bm, [(1.6, HW + 0.02, 1.3), (1.72, HW + 0.12, 1.42), (1.72, HW + 0.2, 1.5)], 0.014, 8) + K.add_box(bm, (1.69, HW + 0.12, 1.5), (1.73, HW + 0.32, 1.78)) + K.add_tube(bm, [(1.62, -HW + 0.08, 0.98), (1.66, -HW - 0.04, 1.3), (1.66, -HW - 0.08, 1.55)], 0.016, 8) + K.add_box(bm, (1.64, -HW - 0.2, 1.55), (1.68, -HW + 0.0, 1.85)) + + K.make("mirrors", body, M["plastic"], mirrors, bevel=0.01) + + def work_lamps(bm): + for y in (0.6, 1.15): + K.add_box(bm, (1.44, y - 0.07, c["z1"] + 0.035), (1.57, y + 0.07, c["z1"] + 0.13)) + + K.make("work_lamps", body, M["plastic"], work_lamps, bevel=0.015) + K.make("work_lamp_lenses", body, M["lens"], lambda bm: [K.add_box(bm, (1.57, y - 0.055, c["z1"] + 0.05), (1.575, y + 0.055, c["z1"] + 0.115)) for y in (0.6, 1.15)]) + + # PWRI automation retrofit: four-colour signal tower on the cab roof, two GNSS antennas on the counterweight + K.make("signal_bar", body, M["plastic"], lambda bm: K.add_box(bm, (0.05, 0.55, c["z1"] + 0.045), (0.2, 1.22, c["z1"] + 0.09)), bevel=0.01) + for k, col in enumerate(("green", "blue", "red", "amber")): + y = 0.65 + k * 0.17 + K.make(f"signal_{col}", body, M[col], lambda bm, y=y: (K.add_cyl(bm, 0.045, (0.125, y, c["z1"] + 0.09), (0.125, y, c["z1"] + 0.19), 20), K.add_sphere(bm, 0.045, (0.125, y, c["z1"] + 0.19), 20, 8)), bevel=0.0) + for y in (-0.95, 0.95): + K.make(f"gnss_mast_{'l' if y > 0 else 'r'}", body, M["frame"], lambda bm, y=y: K.add_tube(bm, [(-2.2, y, 1.0), (-2.2, y, 1.62)], 0.022, 10)) + K.make(f"gnss_antenna_{'l' if y > 0 else 'r'}", body, M["white"], lambda bm, y=y: K.add_cyl(bm, 0.1, (-2.2, y, 1.62), (-2.2, y, 1.68), 32, r1=0.07), bevel=0.012) + + # exhaust stack and pre-cleaner + K.make("exhaust", body, M["frame"], lambda bm: (K.add_tube(bm, [(-1.25, -0.72, 1.12), (-1.25, -0.72, 1.45), (-1.27, -0.72, 1.55)], 0.055, 16), K.add_cyl(bm, 0.075, (-1.25, -0.72, 1.12), (-1.25, -0.72, 1.18), 16)), bevel=0.0) + K.make("pre_cleaner", body, M["plastic"], lambda bm: (K.add_cyl(bm, 0.045, (-0.7, -1.0, 1.12), (-0.7, -1.0, 1.4), 16), K.add_cyl(bm, 0.11, (-0.7, -1.0, 1.4), (-0.7, -1.0, 1.52), 24, r1=0.06)), bevel=0.01) + + # boom foot brackets and the boom cylinder head brackets + foot = K.fillet([(-0.55, 0.2), (0.45, 0.2), (0.33, 0.68), (0.2, 0.93), (-0.05, 0.99), (-0.3, 0.88), (-0.48, 0.55)], 0.08) + for s in (-1, 1): + K.make(f"boom_foot_bracket_{'l' if s > 0 else 'r'}", body, M["paint"], lambda bm, s=s: K.add_prism_y(bm, foot, s * 0.235, s * 0.3), bevel=0.012) + pin_with_caps(body, "boom_foot_pin", (0.0547, 0.7249), 0.065, 0.34) + + def cyl_brackets(bm): + hx, hz = PINS["boom_head"][1:] + br = K.circle_hull([((hx, hz), 0.11)], extra=[(hx - 0.2, 0.2), (hx + 0.2, 0.2)]) + for yc in CYL["boom"][2]: + for e in (-1, 1): + y = yc + e * 0.07 + K.add_prism_y(bm, br, y - 0.015, y + 0.015) + + K.make("boom_cylinder_brackets", body, M["paint"], cyl_brackets, bevel=0.008) + + def head_pins(bm): + hx, hz = PINS["boom_head"][1:] + for yc in CYL["boom"][2]: + K.add_cyl(bm, 0.04, (hx, yc - 0.1, hz), (hx, yc + 0.1, hz), 16) + for e in (-1, 1): + K.add_cyl(bm, 0.06, (hx, yc + e * 0.085, hz), (hx, yc + e * 0.1, hz), 16) + + K.make("boom_head_pins", body, M["steel"], head_pins, bevel=0.003) + + # hoses from the house to the boom: two pairs leaving the valve block beside the boom foot + def hoses(bm): + for y in (-0.16, -0.08, 0.08, 0.16): + K.add_tube(bm, K.catmull([(0.6, y, 0.25), (0.45, y, 0.5), (0.25, y, 0.95), (0.4, y, 1.25)], 6), 0.022, 10) + + K.make("house_hoses", body, M["rubber"], hoses) + + +house() + +# ================================================================== boom (boom_link) +BOOM_C = [(0.0, 0.0), (0.45, 1.05), (1.0, 1.85), (1.6, 2.35), (2.2, 2.68), (3.3, 2.84), (4.84, 3.0023)] +BOOM_D = [0.42, 0.62, 0.80, 0.70, 0.52, 0.42, 0.36] # section depth at those points + + +def boom_outline(): + center = K.catmull(BOOM_C, 10) + n = len(center) + depth = np.interp(np.linspace(0, len(BOOM_D) - 1, n), np.arange(len(BOOM_D)), BOOM_D) + top, bot = [], [] + for i, p in enumerate(center): + t = np.array(center[min(i + 1, n - 1)]) - np.array(center[max(i - 1, 0)]) + t /= np.linalg.norm(t) + nv = np.array([-t[1], t[0]]) + top.append(tuple(np.array(p) + nv * depth[i] / 2)) + bot.append(tuple(np.array(p) - nv * depth[i] / 2)) + t0 = np.array(center[1]) - np.array(center[0]) + t0 /= np.linalg.norm(t0) + n0 = np.array([-t0[1], t0[0]]) + t1 = np.array(center[-1]) - np.array(center[-2]) + t1 /= np.linalg.norm(t1) + n1 = np.array([-t1[1], t1[0]]) + r0, r1 = depth[0] / 2, depth[-1] / 2 + tip = [tuple(np.array(center[-1]) + r1 * (math.cos(f) * t1 + math.sin(f) * n1)) for f in np.linspace(-math.pi / 2, math.pi / 2, 14)] + foot = [tuple(np.array(center[0]) + r0 * (math.cos(f) * -t0 + math.sin(f) * -n0)) for f in np.linspace(-math.pi / 2, math.pi / 2, 14)] + return center, top, bot, tip, foot + + +def boom_parts(): + center, top, bot, tip, foot = boom_outline() + n = len(center) + cut = next(i for i, p in enumerate(center) if p[0] > 4.25) # the nose narrows to fit inside the arm + main = bot[: cut + 1] + top[: cut + 1][::-1] + foot + nose = bot[cut:] + tip + top[cut:][::-1] + K.make("boom_body", boom, M["paint"], lambda bm: K.add_prism_y(bm, main, -0.23, 0.23), bevel=0.03, segs=3) + K.make("boom_nose", boom, M["paint"], lambda bm: K.add_prism_y(bm, nose, -0.145, 0.145), bevel=0.02, segs=3) + + # top and bottom flange plates proud of the side plates: the box-section look + def flanges(bm): + for edge, sgn in ((top, -1), (bot, 1)): + e = edge[2 : cut + 1] + inner = K.offset_polyline(e, sgn * 0.03 * (1 if edge is bot else 1)) + band = list(e) + inner[::-1] + K.add_prism_y(bm, band, -0.245, 0.245) + + K.make("boom_flanges", boom, M["paint"], flanges, bevel=0.008) + + # side stiffener plates across the bend + def stiffeners(bm): + for s in (-1, 1): + pts = K.fillet([(0.75, 1.25), (1.9, 2.1), (2.35, 2.85), (1.55, 2.55), (0.55, 1.7)], 0.12) + K.add_prism_y(bm, pts, s * 0.23, s * 0.242) + + K.make("boom_stiffeners", boom, M["paint"], stiffeners, bevel=0.005) + + # bosses and brackets: boom cylinder rod pin (under the bend), arm cylinder head bracket (on top) + cx, cz = PINS["boom_rod"][1:] + K.make("boom_cyl_boss", boom, M["paint"], lambda bm: K.add_prism_y(bm, K.circle_hull([((cx, cz), 0.12)], extra=[(cx - 0.3, cz + 0.25), (cx + 0.25, cz + 0.32)]), -0.235, 0.235), bevel=0.015) + pin_with_caps(boom, "boom_rod_pin", (cx, cz), 0.05, 0.4) + ax, az = PINS["arm_head"][1:] + ab = K.circle_hull([((ax, az), 0.12)], extra=[(ax - 0.35, az - 0.2), (ax + 0.3, az - 0.15)]) + for s in (-1, 1): + K.make(f"arm_cyl_bracket_{'l' if s > 0 else 'r'}", boom, M["paint"], lambda bm, s=s: K.add_prism_y(bm, ab, s * 0.065, s * 0.105), bevel=0.01) + pin_with_caps(boom, "arm_head_pin", (ax, az), 0.045, 0.125) + K.make("boom_foot_boss", boom, M["paint"], lambda bm: K.add_cyl(bm, 0.19, (0, -0.235, 0), (0, 0.235, 0), 32), bevel=0.012) + K.make("boom_tip_boss", boom, M["paint"], lambda bm: K.add_cyl(bm, 0.15, (ARM_PIN[0], -0.145, ARM_PIN[1]), (ARM_PIN[0], 0.145, ARM_PIN[1]), 32), bevel=0.01) + pin_with_caps(boom, "arm_pin", ARM_PIN, 0.06, 0.215) + + # hydraulic lines along the top: two to the arm cylinder, two on to the bucket cylinder (over the nose) + def lines(bm): + e = top[3:] + for y, end in ((-0.07, None), (0.07, None), (-0.16, 0), (0.16, 0)): + pts = [(x, y, z + 0.045) for x, z in K.offset_polyline(e, 0.0)] + if end is None: # arm cylinder lines end at its head bracket + pts = [p for p in pts if p[0] < ax - 0.25] + else: + pts = [p for p in pts if p[0] < 4.5] + K.add_tube(bm, pts, 0.017, 8) + for k in range(2, len(pts) - 1, 7): # clamps + x, yy, z = pts[k] + K.add_box(bm, (x - 0.025, yy - 0.03, z - 0.03), (x + 0.025, yy + 0.03, z + 0.03)) + + K.make("boom_lines", boom, M["steel"], lines) + + def boom_hoses(bm): + p0 = [p for p in top if p[0] < ax - 0.25][-1] + for y in (-0.07, 0.07): + K.add_tube(bm, K.catmull([(p0[0], y, p0[1] + 0.045), (p0[0] + 0.15, y * 1.4, p0[1] + 0.18), (ax - 0.05, y * 1.2, az + 0.15)], 6), 0.022, 10) + for y in (-0.16, 0.16): + q = [p for p in top if p[0] < 4.5][-1] + K.add_tube(bm, K.catmull([(q[0], y, q[1] + 0.045), (4.75, y, 3.35), (5.05, y * 0.6, 3.3)], 6), 0.022, 10) + + K.make("boom_hoses", boom, M["rubber"], boom_hoses) + + # work lamp on the left of the boom + K.make("boom_lamp", boom, M["plastic"], lambda bm: K.add_box(bm, (1.25, 0.24, 1.65), (1.4, 0.32, 1.78)), bevel=0.012) + K.make("boom_lamp_lens", boom, M["lens"], lambda bm: K.add_box(bm, (1.4, 0.25, 1.66), (1.405, 0.31, 1.77))) + + +boom_parts() + + +# ================================================================== details: hazard chevrons, weld beads, labels +def details(): + # yellow-black chevrons across the counterweight's rear face (it swings over people) + R = 2.72 + z0, z1, w, lean = 0.48, 0.7, 0.11, 0.09 + + def stripes(bm, parity): + for k in range(-7, 7): + if (k % 2 == 0) != parity: + continue + y0 = k * w + q = [(y0, z0), (y0 + w, z0), (y0 + w + lean, z1), (y0 + lean, z1)] + if max(abs(y) for y, _ in q) > 0.85: + continue + vs = [] + for r in (R - 0.004, R + 0.006): + vs.append([bm.verts.new((-math.sqrt(r * r - y * y), y, z)) for y, z in q]) + a, b = vs + bm.faces.new(a[::-1]) + bm.faces.new(b) + for i in range(4): + j = (i + 1) % 4 + bm.faces.new((a[i], a[j], b[j], b[i])) + + K.make("counterweight_chevrons_y", body, M["hazard_y"], lambda bm: stripes(bm, True), smooth=False) + K.make("counterweight_chevrons_k", body, M["hazard_k"], lambda bm: stripes(bm, False), smooth=False) + + # weld beads where the boom's flange plates meet its side plates + center, top, bot, tip, foot = boom_outline() + cut = next(i for i, p in enumerate(center) if p[0] > 4.25) + + def welds(bm): + for edge in (top, bot): + e = edge[2 : cut + 1] + inward = K.offset_polyline(e, 0.03) + cen = np.mean(np.array(center), axis=0) + if np.linalg.norm(np.mean(inward, axis=0) - cen) > np.linalg.norm(np.mean(e, axis=0) - cen): + inward = K.offset_polyline(e, -0.03) + for y in (-0.233, 0.233): + K.add_tube(bm, [(x, y, z) for x, z in inward], 0.007, 6) + + K.make("boom_welds", boom, M["paint"], welds) + + # warning labels: crush zone on both boom sides, pinch points at the bucket linkage, no-step on the hood + def label_plates(bm, which): + spots = [(boom, 0.95, 1.55, 0.236), (boom, 0.95, 1.55, -0.236)] + for _, x, z, y in spots: + s = 1 if y > 0 else -1 + if which == "y": + K.add_box(bm, (x - 0.09, y, z - 0.09), (x + 0.09, y + s * 0.003, z + 0.09)) + else: + K.add_box(bm, (x - 0.1, y - s * 0.001, z - 0.1), (x + 0.1, y + s * 0.002, z + 0.1)) + K.add_prism_y(bm, [(x - 0.055, z - 0.045), (x + 0.055, z - 0.045), (x, z + 0.06)], y + s * 0.003, y + s * 0.0045) + + K.make("boom_labels_y", boom, M["hazard_y"], lambda bm: label_plates(bm, "y"), smooth=False) + K.make("boom_labels_k", boom, M["hazard_k"], lambda bm: label_plates(bm, "k"), smooth=False) + + +details() + +# ================================================================== arm (stick, arm_link) +R_PIN = PINS["arm_rod"][1:] +H_PIN = PINS["bucket_head"][1:] +G_PIN = PINS["guide"][1:] + + +def arm_parts(): + # the top runs about 0.2 m under the bucket cylinder's head pin, so the cylinder rides on top of the arm + # on its bracket (H) instead of between the side plates + hp = np.array(BUCKET_PIN) - np.array(H_PIN) + up = np.array([-hp[1], hp[0]]) / np.linalg.norm(hp) + top_pt = tuple(np.array(H_PIN) - 0.2 * up) + outline = K.circle_hull([(R_PIN, 0.16), ((0.0, 0.0), 0.21), (BUCKET_PIN, 0.15)], extra=[top_pt], n=32) + outline = K.fillet(outline, 0.04, 2) + # box section: two side plates, cover plates around the edge except where the boom nose and the + # cylinder eyes come in (they sit between the side plates) + for s in (-1, 1): + K.make(f"arm_side_{'l' if s > 0 else 'r'}", arm, M["paint"], lambda bm, s=s: K.add_prism_y(bm, outline, s * 0.155, s * 0.19), bevel=0.01) + + def covers(bm): + P = outline + n = len(P) + keep = [] + for i in range(n): + mid = ((P[i][0] + P[(i + 1) % n][0]) / 2, (P[i][1] + P[(i + 1) % n][1]) / 2) + near = min(math.dist(mid, (0, 0)) - 0.42, math.dist(mid, R_PIN) - 0.3, math.dist(mid, H_PIN) - 0.3) + keep.append(near > 0) + # contiguous runs of kept edges -> bands + runs, cur = [], [] + for i in range(n): + if keep[i]: + cur.append(i) + elif cur: + runs.append(cur) + cur = [] + if cur: + if runs and runs[0][0] == 0: + runs[0] = cur + runs[0] + else: + runs.append(cur) + for run in runs: + pts = [P[i] for i in run] + [P[(run[-1] + 1) % n]] + if len(pts) < 2: + continue + # inward = toward the outline centroid + cxz = np.mean(np.array(P), axis=0) + off = K.offset_polyline(pts, 0.03) + if np.linalg.norm(np.mean(off, axis=0) - cxz) > np.linalg.norm(np.mean(pts, axis=0) - cxz): + off = K.offset_polyline(pts, -0.03) + K.add_prism_y(bm, pts + off[::-1], -0.19, 0.19) + + K.make("arm_covers", arm, M["paint"], covers, bevel=0.006) + + # bosses between the side plates, pins with retainers, tip boss for the bucket ears + K.make("arm_bosses", arm, M["paint"], lambda bm: [K.add_cyl(bm, r, (x, -0.19, z), (x, 0.19, z), 28) for (x, z), r in ((R_PIN, 0.11), (G_PIN, 0.085))], bevel=0.008) + hb = K.circle_hull([(H_PIN, 0.11)], extra=[tuple(np.array(top_pt) - 0.25 * hp / np.linalg.norm(hp) - 0.04 * up), tuple(np.array(top_pt) + 0.3 * hp / np.linalg.norm(hp) - 0.04 * up)]) + for s in (-1, 1): + K.make(f"bucket_cyl_bracket_{'l' if s > 0 else 'r'}", arm, M["paint"], lambda bm, s=s: K.add_prism_y(bm, hb, s * 0.06, s * 0.1), bevel=0.01) + K.make("arm_tip_boss", arm, M["paint"], lambda bm: K.add_cyl(bm, 0.14, (BUCKET_PIN[0], -0.255, BUCKET_PIN[1]), (BUCKET_PIN[0], 0.255, BUCKET_PIN[1]), 32), bevel=0.012) + K.make("arm_foot_boss", arm, M["paint"], lambda bm: [K.add_cyl(bm, 0.2, (0, s * 0.155, 0), (0, s * 0.21, 0), 32) for s in (-1, 1)], bevel=0.01) + pin_with_caps(arm, "arm_rod_pin", R_PIN, 0.045, 0.2) + pin_with_caps(arm, "bucket_head_pin", H_PIN, 0.045, 0.115) + pin_with_caps(arm, "guide_pin", G_PIN, 0.045, 0.26) + pin_with_caps(arm, "bucket_pin", BUCKET_PIN, 0.055, 0.34) + + # grease lines to the tip pins, clipped along the side plates + def lines(bm): + for s in (-1, 1): + y = s * 0.2 + a = np.array(top_pt) + 0.15 * hp / np.linalg.norm(hp) - 0.08 * up + b = np.array(BUCKET_PIN) - 0.25 * hp / np.linalg.norm(hp) - 0.05 * up + K.add_tube(bm, [(a[0], y, a[1]), (b[0], y, b[1])], 0.008, 6) + for t in (0.3, 0.7): + p = a + (b - a) * t + K.add_box(bm, (p[0] - 0.015, y - 0.01 * s, p[1] - 0.015), (p[0] + 0.015, y + 0.012 * s, p[1] + 0.015)) + + K.make("arm_grease_lines", arm, M["steel"], lines) + + +arm_parts() + +# ================================================================== bucket (bucket_link) +SHELL = [(0.32, -0.06), (0.05, -0.08), (-0.18, 0.07), (-0.29, 0.42), (-0.28, 0.8), (-0.18, 1.03), (0.02, 1.15), (0.35, 1.17), (0.68, 1.08), (0.94, 0.985)] +BW = 0.53 # half width inside the side plates + + +def bucket_parts(): + outer = K.catmull(SHELL, 8) + cen = np.array([0.4, 0.55]) + inner = K.offset_polyline(outer, 0.028) + if np.linalg.norm(np.mean(inner, axis=0) - cen) > np.linalg.norm(np.mean(outer, axis=0) - cen): + inner = K.offset_polyline(outer, -0.028) + K.make("bucket_shell", bucket, M["bucket"], lambda bm: K.add_prism_y(bm, outer + inner[::-1], -BW, BW), bevel=0.006) + side = outer + [outer[0]] + for s in (-1, 1): + K.make(f"bucket_side_{'l' if s > 0 else 'r'}", bucket, M["bucket"], lambda bm, s=s: K.add_prism_y(bm, side, s * BW, s * (BW + 0.03)), bevel=0.008) + # side cutter along the mouth + cut = [(0.32, -0.06), (0.94, 0.985), (0.97, 0.94), (0.36, -0.09)] + K.make(f"bucket_side_cutter_{'l' if s > 0 else 'r'}", bucket, M["wear"], lambda bm, s=s, cut=cut: K.add_prism_y(bm, cut, s * (BW - 0.005), s * (BW + 0.04)), bevel=0.005) + + # cutting edge, tooth adapters and teeth pointing at the bucket tip frame + tip = np.array(BUCKET_TIP) + base = np.array([0.95, 0.975]) + d = (tip - base) / np.linalg.norm(tip - base) + nrm = np.array([-d[1], d[0]]) + + def edge(bm): + a, b = base - d * 0.17, base + d * 0.01 + K.add_prism_y(bm, [tuple(a + nrm * 0.03), tuple(b + nrm * 0.025), tuple(b - nrm * 0.02), tuple(a - nrm * 0.03)], -BW - 0.03, BW + 0.03) + + K.make("bucket_cutting_edge", bucket, M["wear"], edge, bevel=0.005) + + def teeth(bm): + L = np.linalg.norm(tip - base) + for y in (-0.42, -0.21, 0.0, 0.21, 0.42): + # adapter wrapping the lip + a0 = base - d * 0.04 + K.add_obox(bm, (a0[0], y, a0[1]), ((d[0], 0, d[1]), (0, 1, 0), (nrm[0], 0, nrm[1])), (0.11, 0.055, 0.05)) + # tooth: tapered, flattening to a chisel at the tip + v = [] + for t, hw, ht in ((0.0, 0.05, 0.045), (L * 0.55, 0.045, 0.03), (L, 0.035, 0.008)): + p = base + d * t + for sy, sz in ((-1, -1), (1, -1), (1, 1), (-1, 1)): + q = p + nrm * sz * ht + v.append(bm.verts.new((q[0], y + sy * hw, q[1]))) + for r in range(2): + A, B = v[4 * r : 4 * r + 4], v[4 * r + 4 : 4 * r + 8] + for k in range(4): + bm.faces.new((A[k], A[(k + 1) % 4], B[(k + 1) % 4], B[k])) + bm.faces.new(v[0:4][::-1]) + bm.faces.new(v[8:12]) + + K.make("bucket_teeth", bucket, M["wear"], teeth, bevel=0.004, angle=50) + + # wear strips under the floor + def strips(bm): + o = [p for p in outer if 0.3 < p[0] < 0.9] + out = K.offset_polyline(o, -0.018) + if np.linalg.norm(np.mean(out, axis=0) - cen) < np.linalg.norm(np.mean(o, axis=0) - cen): + out = K.offset_polyline(o, 0.018) + for y in (-0.36, 0.0, 0.36): + K.add_prism_y(bm, o + out[::-1], y - 0.035, y + 0.035) + + K.make("bucket_wear_strips", bucket, M["wear"], strips, bevel=0.004) + + # ears: outer pair on the bucket pin (outside the arm tip), inner pair on the link pin (inside the side links) + ears_o = K.circle_hull([((0, 0), 0.13)], extra=[(0.3, -0.05), (-0.17, 0.06)]) + ears_k = K.circle_hull([(PINS["side"][1:], 0.11)], extra=[(-0.27, 0.3), (-0.26, 0.75)]) + for s in (-1, 1): + K.make(f"bucket_ear_pin_{'l' if s > 0 else 'r'}", bucket, M["bucket"], lambda bm, s=s: K.add_prism_y(bm, ears_o, s * 0.265, s * 0.31), bevel=0.01) + K.make(f"bucket_ear_link_{'l' if s > 0 else 'r'}", bucket, M["bucket"], lambda bm, s=s: K.add_prism_y(bm, ears_k, s * 0.1, s * 0.145), bevel=0.01) + pin_with_caps(bucket, "bucket_link_pin", PINS["side"][1:], 0.045, 0.21) + + # lifting eye on the back + K.make("bucket_lift_eye", bucket, M["bucket"], lambda bm: K.add_tube(bm, [(-0.29 - 0.05 * math.sin(a), 0, 0.62 + 0.06 * math.cos(a)) for a in np.linspace(0, math.pi, 10)], 0.018, 8)) + + +bucket_parts() + +# ================================================================== free parts: cylinders and linkage + + +def cylinder_parts(name): + (dx, dz), l_mesh, ycs, R, Rr, Lb, Lr = CYL[name] + d = Vector((dx, 0, dz)).normalized() + nv = Vector((-d.z, 0, d.x)) # perpendicular in the x-z plane + Y = Vector((0, 1, 0)) + P = lambda s, y=0.0, o=0.0: d * s + Y * y + nv * o # noqa: E731 + + def barrel(bm): + for yc in ycs: + K.add_cyl(bm, 0.075, P(0, yc - 0.055), P(0, yc + 0.055), 24) # head eye + K.add_cyl(bm, R * 0.7, P(0.05, yc), P(0.12, yc), 24) + K.add_cyl(bm, R + 0.014, P(0.1, yc), P(0.2, yc), 32) # head cap + K.add_cyl(bm, R, P(0.2, yc), P(Lb - 0.08, yc), 32) + K.add_cyl(bm, R + 0.016, P(Lb - 0.08, yc), P(Lb - 0.01, yc), 32) # gland + for s in (0.28, Lb - 0.2): # ports + K.add_obox(bm, P(s, yc, R + 0.02), (d, Y, nv), (0.035, 0.03, 0.025)) + # steel line from the rod-end port back along the barrel to the head + K.add_tube(bm, [P(Lb - 0.2, yc, R + 0.045), P(0.32, yc, R + 0.045), P(0.28, yc, R + 0.04)], 0.013, 8) + for s in np.linspace(0.6, Lb - 0.4, 2): + K.add_obox(bm, P(s, yc, R + 0.03), (d, Y, nv), (0.02, 0.025, 0.03)) + + def rod(bm): + for yc in ycs: + K.add_cyl(bm, Rr, P(l_mesh - Lr, yc), P(l_mesh - 0.1, yc), 28) + K.add_cyl(bm, Rr + 0.012, P(l_mesh - 0.11, yc), P(l_mesh - 0.06, yc), 28) + K.add_cyl(bm, 0.07, P(l_mesh, yc - 0.05), P(l_mesh, yc + 0.05), 24) # rod eye + + K.make(f"{name}_barrel_body", FREE[name + "_barrel"], M["paint"], barrel, bevel=0.006) + + def rod_steel(bm): + for yc in ycs: + K.add_cyl(bm, Rr, P(l_mesh - Lr, yc), P(l_mesh - 0.1, yc), 28) + + def rod_end(bm): + for yc in ycs: + K.add_cyl(bm, Rr + 0.012, P(l_mesh - 0.11, yc), P(l_mesh - 0.06, yc), 28) + K.add_cyl(bm, 0.07, P(l_mesh, yc - 0.05), P(l_mesh, yc + 0.05), 24) + K.add_obox(bm, P(l_mesh - 0.06, yc), (d, Y, nv), (0.04, 0.05, 0.055)) + + K.make(f"{name}_rod_chrome", FREE[name + "_rod"], M["chrome"], rod_steel) + K.make(f"{name}_rod_eye", FREE[name + "_rod"], M["paint"], rod_end, bevel=0.006) + + +for c in CYL: + cylinder_parts(c) + + +def link_parts(name, ys, thick, r_end, pin_half=None): + (p0, p1) = LINK_MESH[name] + plate = K.circle_hull([(p0, r_end), (p1, r_end)], n=24) + for y in ys: + K.make(f"{name}_plate_{'l' if y > 0 else 'r'}", FREE[name + "_link"], M["paint"], lambda bm, y=y: K.add_prism_y(bm, plate, y - thick / 2, y + thick / 2), bevel=0.008) + if pin_half: + pin_with_caps(FREE[name + "_link"], f"{name}_link_pin", p0, 0.045, pin_half) + + +link_parts("side", (-0.175, 0.175), 0.04, 0.09, 0.24) # carries the pin where the links meet the bucket cylinder +link_parts("guide", (-0.22, 0.22), 0.035, 0.095) # its arm pin is the arm's guide_pin + +# ================================================================== pose (for review renders only) + + +def Ry(q): + return Matrix.Rotation(q, 4, "Y") + + +def pose(q): + """Joint angles (swing, boom, arm, bucket), URDF sense, and place the free parts from the pins.""" + body.matrix_basis = ref_matrix("body_link") @ Matrix.Rotation(q[0], 4, "Z") + boom.matrix_basis = ref_matrix("boom_link") @ Ry(q[1]) + arm.matrix_basis = ref_matrix("arm_link") @ Ry(q[2]) + bucket.matrix_basis = ref_matrix("bucket_link") @ Ry(q[3]) + bpy.context.view_layer.update() + H = body.matrix_world.inverted() + F = {"house": Matrix.Identity(4), "boom": H @ boom.matrix_world, "stick": H @ arm.matrix_world, "bucket": H @ bucket.matrix_world} + P = lambda p: (F[p[0]] @ Vector((p[1], 0, p[2]))).to_3d() # noqa: E731 + pts = {k: P(v) for k, v in PINS.items()} + g, k = pts["guide"], pts["side"] + dd = math.hypot(k.x - g.x, k.z - g.z) + a = (GUIDE_LEN**2 - SIDE_LEN**2 + dd**2) / (2 * dd) + h = math.sqrt(max(GUIDE_LEN**2 - a * a, 0)) + ux, uz = (k.x - g.x) / dd, (k.z - g.z) / dd + pts["bucket_rod"] = Vector((g.x + a * ux - h * uz, g.y, g.z + a * uz + h * ux)) + Yax = Vector((0, 1, 0)) + + def frame(p0, p1, dirx): + u = (p1 - p0).normalized() + w = (Yax - u * Yax.dot(u)).normalized() + world = Matrix((u, w, u.cross(w))).transposed() + dv = Vector((dirx[0], 0, dirx[1])).normalized() + local = Matrix((dv, Yax, dv.cross(Yax))).transposed() + return world @ local.transposed() + + def place(name, R3, p): + m = R3.to_4x4() + m.translation = p + FREE[name].matrix_basis = body.matrix_world @ m + + for name in CYL: + head, rod = pts[name + "_head"], pts[name + "_rod"] + R3 = frame(head, rod, CYL[name][0]) + L = (rod - head).length + place(name + "_barrel", R3, head) + place(name + "_rod", R3, head + (rod - head) / L * (L - CYL[name][1])) + for name, (m0, m1), (a0, a1) in (("side", LINK_MESH["side"], (pts["bucket_rod"], k)), ("guide", LINK_MESH["guide"], (g, pts["bucket_rod"]))): + R3 = frame(a0, a1, (m1[0] - m0[0], m1[1] - m0[1])) + place(name + "_link", R3, a0 - R3 @ Vector((m0[0], 0, m0[1]))) + bpy.context.view_layer.update() + + +# ================================================================== export +def export(): + q_rest = [0.0, 0.0, 0.0, 0.0] + pose(q_rest) # rest frames for the links + for f in FREE.values(): + f.matrix_basis = Matrix.Identity(4) # free parts at the root origin, as in the OPERA model + K.export_glb(OUT) + js, binchunk = K.read_glb(OUT) + names = {n.get("name"): i for i, n in enumerate(js["nodes"])} + # wrap the scene in the Y-up root and copy the joint extras of the reference model + roots = js["scenes"][0]["nodes"] + js["nodes"].append({"name": "zx200", "matrix": REFN["zx200"]["matrix"], "children": roots}) + js["scenes"][0]["nodes"] = [len(js["nodes"]) - 1] + for name, ref in REFN.items(): + if name in names and ref.get("extras"): + js["nodes"][names[name]]["extras"] = ref["extras"] + js["nodes"][names["track_link"]]["extras"] = { + "track": { + "_note": "track loop in track_link (URDF) frame: bottom run at pitch line z, idler front, sprocket rear; shoes are spaced by pitch along it", + "sprocket_x": XS, "idler_x": XI, "radius": RP, "pitch_line_z": ZP, "pitch": PITCH, "gauge": GAUGE, + "shoes": SHOES, + } + } + js["asset"]["copyright"] = ( + "20 t class hydraulic excavator, modelled procedurally in Blender (assets/blender/zx200_hd.py) by the " + "construction-site-simulation project to the dimensions and pin geometry of PWRI's OPERA ZX200 model " + "(https://github.com/pwri-opera/zx200_ros2, Apache-2.0). Apache-2.0." + ) + js["asset"]["extras"] = {"source": "assets/blender/zx200_hd.py", "reference": "https://github.com/pwri-opera/zx200_ros2", "license": "Apache-2.0"} + K.write_glb(OUT, js, binchunk) + tris = sum(len(o.data.polygons) for o in bpy.data.objects if o.type == "MESH") + print(f"EXPORTED {OUT} nodes={len(js['nodes'])} meshes={len(js.get('meshes', []))} faces(pre-bevel)={tris}") + + +if "--no-export" not in ARGS: + export() + +if "--print-free" in ARGS: # where the free parts land in a pose (debugging the pin solve) + pose([float(v) for v in ARGS[ARGS.index("--print-free") + 1].split(",")]) + for n in FREE: + o = bpy.data.objects[n] + print("FREE", n, [round(v, 3) for v in o.matrix_world.translation]) + for n in ("arm_link", "bucket_link"): + print("LINK", n, [round(v, 3) for v in bpy.data.objects[n].matrix_world.translation]) + +# ================================================================== review renders +if "--render" in ARGS: + out = ARGS[ARGS.index("--render") + 1] + q = [0.3, -0.6, 2.1, 2.2] + if "--pose" in ARGS: + q = [float(v) for v in ARGS[ARGS.index("--pose") + 1].split(",")] + pose(q) + sc = bpy.context.scene + # --beauty: EEVEE (this Blender build has no Cycles) with a physical sky, sun, soft shadows, AO and + # screen-space reflections; otherwise Workbench with studio light for checking shapes + engine = "BLENDER_EEVEE" if "--beauty" in ARGS else "BLENDER_WORKBENCH" + sc.render.engine = engine + if engine == "BLENDER_WORKBENCH": + sc.display.shading.light = "STUDIO" + sc.display.shading.color_type = "MATERIAL" + sc.display.shading.show_cavity = True + sc.display.shading.show_shadows = True + else: + ee = sc.eevee + ee.taa_render_samples = 64 + ee.use_gtao = True + ee.gtao_distance = 0.6 + ee.use_ssr = True + ee.use_ssr_refraction = False + ee.use_soft_shadows = True + ee.shadow_cascade_size = "4096" + ee.shadow_cube_size = "2048" + sc.view_settings.view_transform = "AgX" + sc.view_settings.look = "AgX - Medium High Contrast" + sun = bpy.data.objects.new("sun", bpy.data.lights.new("sun", "SUN")) + sc.collection.objects.link(sun) + sun.data.energy = 4.0 + sun.data.angle = math.radians(1.5) + sun.rotation_euler = (math.radians(50), 0, math.radians(200)) + sun.data.shadow_cascade_max_distance = 40 + world = bpy.data.worlds.new("sky") + sc.world = world + world.use_nodes = True + nt = world.node_tree + sky = nt.nodes.new("ShaderNodeTexSky") + sky.sun_elevation = math.radians(40) + sky.sun_rotation = math.radians(200) + nt.links.new(sky.outputs["Color"], nt.nodes["Background"].inputs["Color"]) + nt.nodes["Background"].inputs["Strength"].default_value = 0.25 + ground = bpy.data.meshes.new("ground") + import bmesh as _bm + + b = _bm.new() + K.add_box(b, (-30, -30, -0.05), (30, 30, 0.0)) + b.to_mesh(ground) + g = bpy.data.objects.new("ground", ground) + sc.collection.objects.link(g) + ground.materials.append(K.material("dirt", "#8a7a62", rough=0.95)) + sc.render.resolution_x, sc.render.resolution_y = 1600, 1000 + cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam")) + sc.collection.objects.link(cam) + sc.camera = cam + target = Vector((2.2, 0, 2.3)) + views = {"front_left": (12.5, 10.5, 5.0), "rear_right": (-9.0, -10.5, 6.0), "side_left": (2.5, 16, 2.8), "side_right": (2.5, -16, 2.8), "track": (1.0, -4.2, 0.9), "cab": (4.5, 4.2, 2.6)} + for vname, loc in views.items(): + if "--views" in ARGS and vname not in ARGS[ARGS.index("--views") + 1].split(","): + continue + cam.location = loc + tgt = {"track": Vector((0.0, -1.1, 0.4)), "cab": Vector((0.6, 0.9, 2.0))}.get(vname, target) + cam.rotation_euler = (tgt - Vector(loc)).to_track_quat("-Z", "Y").to_euler() + cam.data.lens = 35 + sc.render.filepath = f"{out}_{vname}.png" + bpy.ops.render.render(write_still=True) diff --git a/assets/machinery/d37_hd.glb b/assets/machinery/d37_hd.glb new file mode 100644 index 0000000..839701c Binary files /dev/null and b/assets/machinery/d37_hd.glb differ diff --git a/assets/machinery/ic120_hd.glb b/assets/machinery/ic120_hd.glb new file mode 100644 index 0000000..9d8dfcd Binary files /dev/null and b/assets/machinery/ic120_hd.glb differ diff --git a/assets/machinery/roller_hd.glb b/assets/machinery/roller_hd.glb new file mode 100644 index 0000000..40eca52 Binary files /dev/null and b/assets/machinery/roller_hd.glb differ diff --git a/assets/machinery/zx200_hd.glb b/assets/machinery/zx200_hd.glb new file mode 100644 index 0000000..e42f0ca Binary files /dev/null and b/assets/machinery/zx200_hd.glb differ diff --git a/assets/registry.json b/assets/registry.json index 335a6ec..cbf8fff 100644 --- a/assets/registry.json +++ b/assets/registry.json @@ -754,6 +754,146 @@ "notes": "Hydraulic cylinder and bucket-linkage meshes exist in the package but have no joints in the URDF, so they are not in this GLB yet. Depicts a trademarked product: the license covers copyright, not trademarks or endorsement.", "added": "2026-11-03" }, + { + "id": "zx200_hd", + "name": "20 t class hydraulic excavator, detailed (ZX200 dimensions)", + "category": "machinery/excavator", + "status": "in-repo", + "files": [ + "assets/machinery/zx200_hd.glb", + "assets/blender/zx200_hd.py", + "assets/blender/blendkit.py" + ], + "source_url": "assets/blender/zx200_hd.py", + "download_url": null, + "license": "Apache-2.0", + "license_url": "https://www.apache.org/licenses/LICENSE-2.0", + "share_alike": false, + "author": "Construction Site Simulation contributors", + "attribution": "\"20 t class hydraulic excavator\" modelled procedurally by the Construction Site Simulation contributors to the dimensions and pin geometry of PWRI's OPERA ZX200 description package (Apache-2.0)", + "modifications": "Original model, generated by assets/blender/zx200_hd.py (Blender 4.0). Link frames, joint extras and free-part frames copied from opera_zx200.glb so it replaces it without code changes", + "realism": "high", + "articulated": true, + "real_world": { + "reference": "Hitachi ZX200 class (dimensions from the PWRI OPERA model)", + "operating_mass_kg": 20000, + "track_gauge_m": 2.2, + "shoe_width_m": 0.8 + }, + "physics": { + "mass_kg": null, + "mass_source": "use the spec-sheet operating mass, as for opera_zx200", + "joints": [ + "as opera_zx200" + ] + }, + "notes": "No manufacturer marks or livery. Individual track shoes (47 a side) with the loop in track_link extras for animating them. Includes PWRI's automation retrofit (GNSS antennas, signal tower).", + "added": "2026-11-16" + }, + { + "id": "roller_hd", + "name": "Single-drum vibratory soil roller (10.6 t class)", + "category": "machinery/roller", + "status": "in-repo", + "files": [ + "assets/machinery/roller_hd.glb", + "assets/blender/roller_hd.py", + "assets/blender/blendkit.py" + ], + "source_url": "assets/blender/roller_hd.py", + "download_url": null, + "license": "Apache-2.0", + "license_url": "https://www.apache.org/licenses/LICENSE-2.0", + "share_alike": false, + "author": "Construction Site Simulation contributors", + "attribution": "\"Single-drum vibratory soil roller\" modelled procedurally by the Construction Site Simulation contributors", + "modifications": "Original model, generated by assets/blender/roller_hd.py (Blender 4.0) to the dimensions in phase2/roller.py", + "realism": "medium", + "articulated": true, + "real_world": { + "reference": "10.6 t single-drum roller class (phase2/roller.py)", + "operating_mass_kg": 10600, + "drum_width_m": 2.13, + "drum_diameter_m": 1.5 + }, + "physics": { + "mass_kg": 10600, + "mass_source": "phase2/roller.py", + "joints": [ + "drum and rear wheels spin (base_link extras.spin_nodes)" + ] + }, + "notes": "No manufacturer marks or livery. Articulation is not a joint (the simulator turns the roller on the spot).", + "added": "2026-11-16" + }, + { + "category": "machinery/dozer", + "status": "in-repo", + "download_url": null, + "license": "Apache-2.0", + "license_url": "https://www.apache.org/licenses/LICENSE-2.0", + "share_alike": false, + "author": "Construction Site Simulation contributors", + "realism": "high", + "articulated": true, + "added": "2026-11-16", + "id": "d37_hd", + "name": "Crawler dozer with power-angle-tilt blade, detailed (D37PXi joint frames)", + "files": [ + "assets/machinery/d37_hd.glb", + "assets/blender/d37_hd.py", + "assets/blender/blendkit.py" + ], + "source_url": "assets/blender/d37_hd.py", + "attribution": "\"Crawler dozer with power-angle-tilt blade\" modelled procedurally by the Construction Site Simulation contributors to the joint frames of PWRI's OPERA D37PXi description package (Apache-2.0)", + "modifications": "Original model, generated by assets/blender/d37_hd.py (Blender 4.0). Node names, link frames and joint extras copied from opera_d37pxi.glb", + "real_world": { + "reference": "D37PXi class dozer (PWRI OPERA model)", + "operating_mass_kg": 9000 + }, + "physics": { + "mass_kg": null, + "mass_source": "as opera_d37pxi", + "joints": [ + "as opera_d37pxi" + ] + }, + "notes": "No manufacturer marks or livery. Individual steel track shoes; lift and angle cylinders on the source's joints." + }, + { + "category": "machinery/carrier", + "status": "in-repo", + "download_url": null, + "license": "Apache-2.0", + "license_url": "https://www.apache.org/licenses/LICENSE-2.0", + "share_alike": false, + "author": "Construction Site Simulation contributors", + "realism": "high", + "articulated": true, + "added": "2026-11-16", + "id": "ic120_hd", + "name": "Rubber-tracked crawler carrier, detailed (IC120 joint frames)", + "files": [ + "assets/machinery/ic120_hd.glb", + "assets/blender/ic120_hd.py", + "assets/blender/blendkit.py" + ], + "source_url": "assets/blender/ic120_hd.py", + "attribution": "\"Rubber-tracked crawler carrier\" modelled procedurally by the Construction Site Simulation contributors to the joint frames of PWRI's OPERA IC120 description package (Apache-2.0)", + "modifications": "Original model, generated by assets/blender/ic120_hd.py (Blender 4.0). Node names, link frames and joint extras copied from opera_ic120.glb; the vessel follows the server's vessel boxes", + "real_world": { + "reference": "IC120 class crawler carrier (PWRI OPERA model)", + "payload_kg": 11000 + }, + "physics": { + "mass_kg": null, + "mass_source": "as opera_ic120", + "joints": [ + "as opera_ic120" + ] + }, + "notes": "No manufacturer marks or livery. Rubber belt with lugs wrapped round the sprocket, idler and rollers; PWRI retrofit antennas." + }, { "id": "opera_ic120", "name": "IHI (Kato) IC120 crawler dump carrier", diff --git a/assets/screenshots/d37_hd_render.png b/assets/screenshots/d37_hd_render.png new file mode 100644 index 0000000..0278be9 Binary files /dev/null and b/assets/screenshots/d37_hd_render.png differ diff --git a/assets/screenshots/ic120_hd_render.png b/assets/screenshots/ic120_hd_render.png new file mode 100644 index 0000000..6035e63 Binary files /dev/null and b/assets/screenshots/ic120_hd_render.png differ diff --git a/assets/screenshots/ic120_hd_tipped.png b/assets/screenshots/ic120_hd_tipped.png new file mode 100644 index 0000000..a5af080 Binary files /dev/null and b/assets/screenshots/ic120_hd_tipped.png differ diff --git a/assets/screenshots/replay_render_dump.png b/assets/screenshots/replay_render_dump.png new file mode 100644 index 0000000..af31d3c Binary files /dev/null and b/assets/screenshots/replay_render_dump.png differ diff --git a/assets/screenshots/roller_hd_render.png b/assets/screenshots/roller_hd_render.png new file mode 100644 index 0000000..594943c Binary files /dev/null and b/assets/screenshots/roller_hd_render.png differ diff --git a/assets/screenshots/roller_hd_viewer.png b/assets/screenshots/roller_hd_viewer.png new file mode 100644 index 0000000..fa052c7 Binary files /dev/null and b/assets/screenshots/roller_hd_viewer.png differ diff --git a/assets/screenshots/soil_view_hd_models.jpg b/assets/screenshots/soil_view_hd_models.jpg new file mode 100644 index 0000000..a41dfbf Binary files /dev/null and b/assets/screenshots/soil_view_hd_models.jpg differ diff --git a/assets/screenshots/zx200_hd_rear.png b/assets/screenshots/zx200_hd_rear.png new file mode 100644 index 0000000..13b4679 Binary files /dev/null and b/assets/screenshots/zx200_hd_rear.png differ diff --git a/assets/screenshots/zx200_hd_render.png b/assets/screenshots/zx200_hd_render.png new file mode 100644 index 0000000..5de5603 Binary files /dev/null and b/assets/screenshots/zx200_hd_render.png differ diff --git a/assets/screenshots/zx200_hd_viewer.png b/assets/screenshots/zx200_hd_viewer.png new file mode 100644 index 0000000..f3c1501 Binary files /dev/null and b/assets/screenshots/zx200_hd_viewer.png differ diff --git a/phase1/web/linkage.js b/phase1/web/linkage.js new file mode 100644 index 0000000..0953cc2 --- /dev/null +++ b/phase1/web/linkage.js @@ -0,0 +1,175 @@ +// Hydraulic cylinders and linkages, posed from the machine's joints so every part moves as it would on the +// machine: barrels turn about their head pins, rods slide out of them, the bucket four-bar folds. +// +// ZX200: pins and mesh frames from phase2/hydraulics.py (CYLINDERS, GUIDE_PIN, SIDE_PIN, CYLINDER_MESH, +// LINK_MESH); keep the two in step. Pins are (link, x, z) in the URDF link frame, which is the GLB node's own +// frame. The free parts (barrels, rods, link plates) are children of the model root. +// +// Cylinders built as URDF joints (D37PXi blade, IC120 vessel): a revolute head joint and a prismatic rod +// joint below it. The rod's far eye is found at rest from the rod mesh and pinned to the link it pushes. + +const ZX200 = { + links: { house: "body_link", boom: "boom_link", stick: "arm_link", bucket: "bucket_link" }, + cylinders: { + boom: { head: ["house", 0.686, 0.247], rod: ["boom", 1.776, 2.249], mesh: [0.3425, 0.9395], length: 2.73 }, + arm: { head: ["boom", 2.276, 2.789], rod: ["stick", -0.778, -0.367], mesh: [0.9486, 0.3165], length: 1.7 }, + bucket: { head: ["stick", -0.248, 0.733], rod: null, mesh: [0.6761, 0.7368], length: 2.16 }, + }, + guide: ["stick", 1.577, 1.878], + side: ["bucket", -0.328, 0.548], + guideLen: 0.561, + sideLen: 0.583, + linkMesh: { side: [[0, 0], [-0.328, 0.482]], guide: [[0, 0], [-0.338, -0.448]] }, +}; + +export function makeLinkage(THREE, root) { + const byName = {}; + root.traverse((o) => (byName[o.name] ??= o)); + const solvers = []; + if (byName.boom_barrel && byName.body_link) solvers.push(zx200Solver(THREE, root, byName)); + const pairs = cylinderPairs(THREE, root, byName); + if (pairs) solvers.push(pairs); + if (!solvers.length) return null; + for (const name of ["boom_barrel", "boom_rod", "arm_barrel", "arm_rod", "bucket_barrel", "bucket_rod", "side_link", "guide_link"]) { + if (byName[name]) byName[name].visible = true; + } + return { update: () => solvers.forEach((s) => s()), drivenJoints: pairs?.driven ?? [] }; +} + +function zx200Solver(THREE, root, byName) { + const L = ZX200; + const body = byName[L.links.house]; + const toHouse = {}; + const inv = new THREE.Matrix4(); + const tmp = new THREE.Matrix4(); + const point = ([link, x, z]) => new THREE.Vector3(x, 0, z).applyMatrix4(toHouse[link]); + const Y = new THREE.Vector3(0, 1, 0); // pin axes: the house's +y + const R = new THREE.Matrix4(); + const world = new THREE.Matrix4(); + const local = new THREE.Matrix4(); + + // rotation taking the mesh frame (pin direction `dir` in its x-z plane, pin axis y) onto pins p0 -> p1 + function frame(p0, p1, dir) { + const u = p1.clone().sub(p0).normalize(); + const w = Y.clone().addScaledVector(u, -Y.dot(u)).normalize(); + world.makeBasis(u, w, u.clone().cross(w)); + const d = new THREE.Vector3(dir[0], 0, dir[1]).normalize(); + local.makeBasis(d, Y, d.clone().cross(Y)); + return R.multiplyMatrices(world, local.transpose()).clone(); + } + + // place a part: rotation Rh and position ph in the house frame -> the part node's parent frame + const houseToParent = new THREE.Matrix4(); + function place(name, Rh, ph) { + const node = byName[name]; + if (!node) return; + tmp.copy(Rh).setPosition(ph); + houseToParent.copy(node.parent.matrixWorld).invert().multiply(body.matrixWorld); + node.matrix.multiplyMatrices(houseToParent, tmp); + node.matrix.decompose(node.position, node.quaternion, node.scale); + } + + return function update() { + root.updateMatrixWorld(true); + inv.copy(body.matrixWorld).invert(); + for (const [k, n] of Object.entries(L.links)) toHouse[k] = new THREE.Matrix4().multiplyMatrices(inv, byName[n].matrixWorld); + + const pts = {}; + for (const [name, c] of Object.entries(L.cylinders)) { + pts[name + "_head"] = point(c.head); + if (c.rod) pts[name + "_rod"] = point(c.rod); + } + // bucket four-bar: the guide link (on the stick) and side link (on the bucket) meet at the rod eye + const g = point(L.guide); + const k = point(L.side); + const d = Math.hypot(k.x - g.x, k.z - g.z); + const a = (L.guideLen ** 2 - L.sideLen ** 2 + d ** 2) / (2 * d); + const h = Math.sqrt(Math.max(L.guideLen ** 2 - a ** 2, 0)); + const ux = (k.x - g.x) / d; + const uz = (k.z - g.z) / d; + pts.bucket_rod = new THREE.Vector3(g.x + a * ux - h * uz, g.y, g.z + a * uz + h * ux); + + for (const [name, c] of Object.entries(L.cylinders)) { + const head = pts[name + "_head"]; + const rod = pts[name + "_rod"]; + const Rc = frame(head, rod, c.mesh); + const len = rod.distanceTo(head); + place(name + "_barrel", Rc, head); + place(name + "_rod", Rc, head.clone().lerp(rod, (len - c.length) / len)); // the rod slides out of the barrel + } + for (const [name, [p0a, p1a], [a0, a1]] of [ + ["side", L.linkMesh.side, [pts.bucket_rod, k]], + ["guide", L.linkMesh.guide, [g, pts.bucket_rod]], + ]) { + const Rl = frame(a0, a1, [p1a[0] - p0a[0], p1a[1] - p0a[1]]); + place(name + "_link", Rl, a0.clone().sub(new THREE.Vector3(p0a[0], 0, p0a[1]).applyMatrix4(Rl))); + } + }; +} + +// Cylinders modelled as URDF joints: head (revolute) -> rod (prismatic). Each rod's far eye is pinned to the +// link it pushes; per frame the head turns to point at that eye and the rod extends to reach it. +const PUSHES = { + blade_arm_piston_joint: "blade_arm_link", + blade_angle_piston_right_joint: "blade_angle_link", + blade_angle_piston_left_joint: "blade_angle_link", + cylinder_rod_prismatic_joint: "vessel_pin_link", +}; + +function cylinderPairs(THREE, root, byName) { + const items = []; + root.updateMatrixWorld(true); + root.traverse((rodNode) => { + const j = rodNode.userData?.urdf_joint; + if (!j || j.type !== "prismatic" || !PUSHES[j.name]) return; + const target = byName[PUSHES[j.name]]; + // a cylinder barrel is a free-turning (continuous) joint; a rod straight on a link (blade angle) has none + const head = rodNode.parent?.userData?.urdf_joint?.type === "continuous" ? rodNode.parent : null; + const axis = new THREE.Vector3(...j.axis_local).normalize(); // in the rod's parent frame + // far eye: the rod mesh's furthest extent along the axis, in the rod node's frame at rest + let reach = 0; + rodNode.traverse((o) => { + if (!o.isMesh) return; + const pos = o.geometry.attributes.position; + const m = new THREE.Matrix4().copy(rodNode.matrixWorld).invert().multiply(o.matrixWorld); + const v = new THREE.Vector3(); + for (let i = 0; i < pos.count; i++) reach = Math.max(reach, v.fromBufferAttribute(pos, i).applyMatrix4(m).dot(axis)); + }); + const eyeLocal = axis.clone().multiplyScalar(reach); // rod frame + const eyeOnTarget = rodNode.localToWorld(eyeLocal.clone()); // world at rest + target.worldToLocal(eyeOnTarget); + const anchor = head ?? rodNode.parent; // frame the rod's axis lives in + const restDir = axis.clone(); + items.push({ rodNode, head, target, eyeOnTarget, anchor, axis, reach, restDir, restQ: head?.quaternion.clone(), restPos: rodNode.position.clone() }); + }); + if (!items.length) return null; + const driven = items.flatMap((it) => [it.rodNode.userData.urdf_joint.name, it.head?.userData.urdf_joint.name].filter(Boolean)); + const eye = new THREE.Vector3(); + const q = new THREE.Quaternion(); + const update = () => { + for (const it of items) { + // the eye in the head's parent frame (head rotation reset to rest), then the turn and the stroke + if (it.head) it.head.quaternion.copy(it.restQ); + it.rodNode.position.copy(it.restPos); + root.updateMatrixWorld(true); + eye.copy(it.eyeOnTarget); + it.target.localToWorld(eye); + it.anchor.worldToLocal(eye); // anchor frame, at rest rotation + const pivot = it.rodNode.position; // rod origin in the anchor frame (= head pin) + const want = eye.clone().sub(pivot); + if (it.head) { + // turn the head about its joint axis so the rod axis points at the eye + const jAxis = new THREE.Vector3(...it.head.userData.urdf_joint.axis_local).normalize(); + const a0 = it.axis.clone().projectOnPlane(jAxis).normalize(); + const a1 = want.clone().projectOnPlane(jAxis).normalize(); + const ang = Math.atan2(a0.clone().cross(a1).dot(jAxis), a0.dot(a1)); + it.head.quaternion.copy(it.restQ).multiply(q.setFromAxisAngle(jAxis, ang)); + want.applyAxisAngle(jAxis, -ang); + } + const stroke = want.dot(it.axis) - it.reach; + it.rodNode.position.copy(it.restPos).addScaledVector(it.axis, stroke); + } + }; + update.driven = driven; + return update; +} diff --git a/phase1/web/showcase.js b/phase1/web/showcase.js index f88236c..a03e3d4 100644 --- a/phase1/web/showcase.js +++ b/phase1/web/showcase.js @@ -2,9 +2,12 @@ // Machines keep their real joints (from the source URDF) in node extras; "Animate machines" drives // them through their ranges to show the articulation. Static box colliders let site props hit them. +import { makeLinkage } from "./linkage.js"; + export async function addShowcase({ THREE, scene, loader, addStatic, terrainHeight, site, panel }) { const items = site.showcase ?? []; const animated = []; + const linkages = []; for (const item of items) { let gltf; try { @@ -17,15 +20,23 @@ export async function addShowcase({ THREE, scene, loader, addStatic, terrainHeig const [x, y, z] = item.pos; root.position.set(x, terrainHeight(x, z) + (y ?? 0), z); root.rotation.y = THREE.MathUtils.degToRad(item.yaw ?? 0); + scene.add(root); + root.updateMatrixWorld(true); + // cylinders and linkages follow the joints (linkage.js); free parts it can't pose stay hidden + root.traverse((o) => { + if (o.userData?.free_part) o.visible = false; + }); + const linkage = makeLinkage(THREE, root); + if (linkage) linkages.push(linkage); + const driven = new Set(linkage?.drivenJoints ?? []); root.traverse((o) => { - if (o.userData?.free_part) o.visible = false; // cylinders and links the physics server places if (o.isMesh) o.castShadow = o.receiveShadow = true; const j = o.userData?.urdf_joint; - if (j && j.type !== "fixed" && !(item.animate_skip ?? []).includes(j.name)) { - animated.push({ node: o, joint: j, rest: o.quaternion.clone(), restPos: o.position.clone(), phase: Math.random() * Math.PI * 2 }); + if (j && j.type !== "fixed" && !driven.has(j.name) && !(item.animate_skip ?? []).includes(j.name)) { + animated.push({ node: o, joint: j, rest: o.quaternion.clone(), restPos: o.position.clone(), phase: Math.random() * Math.PI * 2, cycle: item.cycle }); } }); - scene.add(root); + linkage?.update(); root.updateMatrixWorld(true); if (item.collider === "parts") { // one axis-aligned box per mesh, in world space (rough, but keeps props out of the machine) @@ -53,21 +64,52 @@ export async function addShowcase({ THREE, scene, loader, addStatic, terrainHeig btn.addEventListener("click", () => { on = !on; btn.textContent = on ? "Stop machines" : "Animate machines"; - if (!on) for (const a of animated) { - a.node.quaternion.copy(a.rest); - a.node.position.copy(a.restPos); + if (!on) { + for (const a of animated) { + a.node.quaternion.copy(a.rest); + a.node.position.copy(a.restPos); + } + for (const l of linkages) l.update(); } }); panel.querySelector(".buttons")?.appendChild(btn); const q = new THREE.Quaternion(); const axis = new THREE.Vector3(); + function setJoint(a, value) { + axis.set(...a.joint.axis_local).normalize(); + if (a.joint.type === "prismatic") a.node.position.copy(a.restPos).addScaledVector(axis, value); + else a.node.quaternion.copy(a.rest).multiply(q.setFromAxisAngle(axis, value)); + } + // item.cycle: a work cycle as keyframes {period, keys: [[time s, {joint: value}], ...]}, eased between keys + function cycleValue(cycle, name, time) { + const keys = cycle.keys.filter(([, v]) => v[name] !== undefined); + if (!keys.length) return undefined; + const tt = time % cycle.period; + for (let k = 0; k < keys.length; k++) { + const [t0, v0] = keys[k]; + const [t1raw, v1] = keys[(k + 1) % keys.length]; + const t1 = k + 1 < keys.length ? t1raw : t1raw + cycle.period; + const tq = tt < keys[0][0] ? tt + cycle.period : tt; + if (tq >= t0 && tq <= t1) { + const u = (tq - t0) / Math.max(t1 - t0, 1e-6); + const e = u * u * (3 - 2 * u); + return v0[name] + (v1[name] - v0[name]) * e; + } + } + return keys[0][1][name]; + } function update(dt) { if (!on) return; t += dt; for (const a of animated) { const j = a.joint; axis.set(...j.axis_local).normalize(); + if (a.cycle) { + const v = cycleValue(a.cycle, j.name, t); + if (v !== undefined) setJoint(a, v); + continue; // joints the cycle doesn't name stay put + } const s = Math.sin(t * 0.6 + a.phase); if (j.type === "prismatic") { const lo = j.lower ?? 0, hi = j.upper ?? 0.2; @@ -83,7 +125,23 @@ export async function addShowcase({ THREE, scene, loader, addStatic, terrainHeig } a.node.quaternion.copy(a.rest).multiply(q.setFromAxisAngle(axis, angle)); } + for (const l of linkages) l.update(); } - window.__showcase = { count: items.length, animated: animated.length, joints: animated.map((a) => a.joint.name) }; + window.__showcase = { + count: items.length, + animated: animated.length, + joints: animated.map((a) => a.joint.name), + linkages: linkages.length, + // test hook: advance the articulation demo by t seconds and pose everything + step(t) { + on = true; + update(t); + }, + // test hook: set joints by name directly, e.g. pose({boom_joint: -0.4}), then pose the linkages + pose(values) { + for (const a of animated) if (values[a.joint.name] !== undefined) setJoint(a, values[a.joint.name]); + for (const l of linkages) l.update(); + }, + }; return { update }; } diff --git a/phase1/web/site.js b/phase1/web/site.js index 178e5a5..570c8e5 100644 --- a/phase1/web/site.js +++ b/phase1/web/site.js @@ -7,6 +7,11 @@ import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js"; import { MeshoptDecoder } from "three/addons/libs/meshopt_decoder.module.js"; import { OrbitControls } from "three/addons/controls/OrbitControls.js"; import { ConvexGeometry } from "three/addons/geometries/ConvexGeometry.js"; +import { Sky } from "three/addons/objects/Sky.js"; +import { EffectComposer } from "three/addons/postprocessing/EffectComposer.js"; +import { RenderPass } from "three/addons/postprocessing/RenderPass.js"; +import { GTAOPass } from "three/addons/postprocessing/GTAOPass.js"; +import { OutputPass } from "three/addons/postprocessing/OutputPass.js"; import initJolt from "https://cdn.jsdelivr.net/npm/jolt-physics@1.1.1/dist/jolt-physics.wasm-compat.js"; const LAYER_STATIC = 0; @@ -28,28 +33,87 @@ renderer.setSize(window.innerWidth, window.innerHeight); renderer.shadowMap.enabled = true; renderer.shadowMap.type = THREE.PCFSoftShadowMap; renderer.toneMapping = THREE.ACESFilmicToneMapping; +renderer.toneMappingExposure = 0.75; renderer.outputColorSpace = THREE.SRGBColorSpace; document.body.appendChild(renderer.domElement); const scene = new THREE.Scene(); -scene.background = new THREE.Color("#b9c4cc"); -scene.fog = new THREE.Fog("#b9c4cc", 60, 140); +const HAZE = "#c3ccd2"; +scene.fog = new THREE.Fog(HAZE, 70, 190); -const camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 400); +const camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 600); camera.position.set(-34, 24, 40); const controls = new OrbitControls(camera, renderer.domElement); controls.target.set(-2, 0, 0); controls.maxPolarAngle = Math.PI * 0.49; controls.update(); -scene.add(new THREE.HemisphereLight("#dfe8ef", "#6b5d4a", 1.1)); -const sun = new THREE.DirectionalLight("#fff4e0", 2.4); -sun.position.set(-20, 35, 15); +// Lighting: a physical sky gives the backdrop and, prefiltered, the image-based light that metal, glass +// and paint reflect (without it metallic PBR materials render near black). The sun is the key light. +const SUN_DIR = new THREE.Vector3(-20, 35, 15).normalize(); +const sky = new Sky(); +sky.scale.setScalar(500); +sky.material.uniforms.turbidity.value = 4; +sky.material.uniforms.rayleigh.value = 1.2; +sky.material.uniforms.mieCoefficient.value = 0.004; +sky.material.uniforms.mieDirectionalG.value = 0.8; +sky.material.uniforms.sunPosition.value.copy(SUN_DIR); +scene.add(sky); +{ + // environment map from the sky alone, plus a ground-coloured disc so reflections see dirt below the horizon + const envScene = new THREE.Scene(); + const envSky = new Sky(); + envSky.scale.setScalar(100); + for (const k of ["turbidity", "rayleigh", "mieCoefficient", "mieDirectionalG"]) envSky.material.uniforms[k].value = sky.material.uniforms[k].value; + envSky.material.uniforms.sunPosition.value.copy(SUN_DIR); + envScene.add(envSky); + const floor = new THREE.Mesh(new THREE.CircleGeometry(60, 32).rotateX(-Math.PI / 2), new THREE.MeshBasicMaterial({ color: "#6f6250" })); + floor.position.y = -2; + envScene.add(floor); + const pmrem = new THREE.PMREMGenerator(renderer); + scene.environment = pmrem.fromScene(envScene, 0.02).texture; + scene.environmentIntensity = 0.55; + pmrem.dispose(); +} + +scene.add(new THREE.HemisphereLight("#dfe8ef", "#6b5d4a", 0.35)); +const sun = new THREE.DirectionalLight("#fff1dc", 3.0); +const SUN_OFFSET = SUN_DIR.clone().multiplyScalar(60); sun.castShadow = true; sun.shadow.mapSize.set(4096, 4096); -Object.assign(sun.shadow.camera, { left: -35, right: 35, top: 30, bottom: -30, near: 1, far: 100 }); -sun.shadow.bias = -0.0004; -scene.add(sun); +// the shadow box follows the orbit target (see tick), so close-ups keep sharp shadows +Object.assign(sun.shadow.camera, { left: -40, right: 40, top: 40, bottom: -40, near: 1, far: 140 }); +sun.shadow.bias = -0.0002; +sun.shadow.normalBias = 0.03; +sun.shadow.radius = 2; +scene.add(sun, sun.target); +function placeSun() { + // snap to shadow texels so the shadow edges don't crawl while orbiting + const texel = 80 / 4096; + const t = controls.target; + const tx = Math.round(t.x / texel) * texel; + const tz = Math.round(t.z / texel) * texel; + sun.target.position.set(tx, 0, tz); + sun.position.set(tx, 0, tz).add(SUN_OFFSET); +} +placeSun(); + +// Post: multisampled HDR scene render, ground-truth ambient occlusion (contact shading in joints, under +// machines and between parts), then tone mapping and sRGB output. +const composer = new EffectComposer(renderer, new THREE.WebGLRenderTarget(1, 1, { type: THREE.HalfFloatType, samples: 4 })); +composer.setPixelRatio(renderer.getPixelRatio()); +composer.setSize(window.innerWidth, window.innerHeight); +composer.addPass(new RenderPass(scene, camera)); +const gtao = new GTAOPass(scene, camera, window.innerWidth, window.innerHeight); +gtao.updateGtaoMaterial({ radius: 0.6, distanceExponent: 1.5, thickness: 1, scale: 1, samples: 8 }); +gtao.updatePdMaterial({ lumaPhi: 10, depthPhi: 2, normalPhi: 3, radius: 4, rings: 2, samples: 8 }); +gtao.blendIntensity = 0.9; +// Ambient occlusion re-renders the scene for normals: ?quality=low turns it off, ?quality=high keeps it on; +// otherwise it turns itself off if the page can't hold 50 fps with it (slow GPU, or one shared with a simulation) +const QUALITY = new URLSearchParams(location.search).get("quality") ?? "auto"; +gtao.enabled = QUALITY !== "low"; +composer.addPass(gtao); +composer.addPass(new OutputPass()); function groundTexture() { const c = document.createElement("canvas"); @@ -655,11 +719,20 @@ function tick() { soil?.update(); showcase?.update(dt); controls.update(); - renderer.render(scene, camera); + placeSun(); + composer.render(dt); frames++; const now = performance.now(); if (now - fpsT > 500) { stats.fps = (frames * 1000) / (now - fpsT); + // judge the frame rate once the site has loaded and settled, only while the page is visible + if (QUALITY === "auto" && gtao.enabled && stats.loadMs > 0 && !document.hidden) { + stats.fpsSamples = [...(stats.fpsSamples ?? []), stats.fps].slice(-6); + if (stats.fpsSamples.length === 6 && Math.max(...stats.fpsSamples) < 50) { + gtao.enabled = false; + console.info(`ambient occlusion off: ${stats.fps.toFixed(0)} fps with it (?quality=high keeps it on)`); + } + } frames = 0; fpsT = now; renderStats(); @@ -670,11 +743,35 @@ window.addEventListener("resize", () => { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); + composer.setSize(window.innerWidth, window.innerHeight); }); // Test hook: positions and speeds of every body window.__site = { stats, + scene, + // draw one frame now (the animation loop pauses while the page is hidden) + frame() { + controls.update(); + placeSun(); + showcase?.update(0); + soil?.update(); + composer.render(0); + }, + // render cost in ms per frame, with and without post-processing (GPU synced with readPixels) + renderTiming(n = 20) { + const gl = renderer.getContext(); + const px = new Uint8Array(4); + const time = (fn) => { + fn(); + gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, px); + const t = performance.now(); + for (let i = 0; i < n; i++) fn(); + gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, px); + return (performance.now() - t) / n; + }; + return { post: time(() => composer.render(0)), plain: time(() => renderer.render(scene, camera)), size: [innerWidth, innerHeight, renderer.getPixelRatio()] }; + }, view(px, py, pz, tx, ty, tz) { camera.position.set(px, py, pz); controls.target.set(tx, ty, tz); diff --git a/phase1/web/site.json b/phase1/web/site.json index b164bb7..1ffdffe 100644 --- a/phase1/web/site.json +++ b/phase1/web/site.json @@ -617,7 +617,7 @@ "showcase": [ { "id": "opera_zx200", - "file": "assets/machinery/opera_zx200.glb", + "file": "assets/machinery/zx200_hd.glb", "pos": [ 3, 0, @@ -627,11 +627,80 @@ "collider": "parts", "animate_skip": [ "bucket_end_joint" - ] + ], + "cycle": { + "_note": "dig cycle: reach, crowd, curl, lift and swing, dump, swing back (joint values in rad, URDF sense)", + "period": 16, + "keys": [ + [ + 0, + { + "swing_joint": 0, + "boom_joint": 0.25, + "arm_joint": 1.0, + "bucket_joint": 0.3 + } + ], + [ + 3, + { + "swing_joint": 0, + "boom_joint": 0.35, + "arm_joint": 1.9, + "bucket_joint": 1.0 + } + ], + [ + 4.5, + { + "swing_joint": 0, + "boom_joint": 0.25, + "arm_joint": 2.2, + "bucket_joint": 2.2 + } + ], + [ + 6.5, + { + "swing_joint": 0.3, + "boom_joint": -0.6, + "arm_joint": 2.1, + "bucket_joint": 2.2 + } + ], + [ + 9, + { + "swing_joint": 1.3, + "boom_joint": -0.7, + "arm_joint": 1.6, + "bucket_joint": 2.1 + } + ], + [ + 10.5, + { + "swing_joint": 1.3, + "boom_joint": -0.7, + "arm_joint": 1.2, + "bucket_joint": -0.3 + } + ], + [ + 13, + { + "swing_joint": 0.3, + "boom_joint": -0.2, + "arm_joint": 0.9, + "bucket_joint": 0.2 + } + ] + ] + } }, { "id": "opera_ic120", - "file": "assets/machinery/opera_ic120.glb", + "file": "assets/machinery/ic120_hd.glb", "pos": [ 16, 0, @@ -642,7 +711,7 @@ }, { "id": "opera_d37pxi", - "file": "assets/machinery/opera_d37pxi.glb", + "file": "assets/machinery/d37_hd.glb", "pos": [ 24, 0, @@ -651,6 +720,17 @@ "yaw": 0, "collider": "parts" }, + { + "id": "roller_hd", + "file": "assets/machinery/roller_hd.glb", + "pos": [ + 32, + 0.75, + -16 + ], + "yaw": 0, + "collider": "parts" + }, { "id": "gazebo_tower_crane", "file": "assets/site/gazebo_tower_crane.glb", @@ -762,4 +842,4 @@ "yaw": 0 } ] -} \ No newline at end of file +} diff --git a/phase1/web/soil.js b/phase1/web/soil.js index e2e9513..9cd8853 100644 --- a/phase1/web/soil.js +++ b/phase1/web/soil.js @@ -231,6 +231,17 @@ export function startSoil({ THREE, scene, loader, Jolt, jolt, bodyInterface, lay "wait at dump", "to queue", "wait to load", "from queue"]; // dozer (dozer.py): base group posed from the "DOZ1" trailer; the blade arm turns about its lift joint const dozer = (window.__dozer = { base: null, arm: null, cylinder: null, piston: null, pistonAxis: null, stages: [], stage: "" }); + // models rebuilt in detail in this repo (assets/blender) with the same nodes and frames as the server's: + // load the detailed one, and the original if it is missing + const MODEL_UPGRADES = { + "assets/machinery/opera_zx200.glb": "assets/machinery/zx200_hd.glb", + "assets/machinery/opera_ic120.glb": "assets/machinery/ic120_hd.glb", + "assets/machinery/opera_d37pxi.glb": "assets/machinery/d37_hd.glb", + }; + const loadModel = (file) => { + const up = MODEL_UPGRADES[file]; + return up ? loader.loadAsync(`../${up}`).catch(() => loader.loadAsync(`../${file}`)) : loader.loadAsync(`../${file}`); + }; // roller (roller.py): drawn from its dimensions, posed from the "ROL1" trailer const roller = (window.__roller = { base: null, stages: [], stage: "" }); function buildRoller(r) { @@ -264,6 +275,41 @@ export function startSoil({ THREE, scene, loader, Jolt, jolt, bodyInterface, lay roller.base.add(wrapZup(g)); roller.base.visible = false; scene.add(roller.base); + if (loader) loadRollerModel(); + } + + // detailed roller (assets/blender/roller_hd.py), same base frame as the boxes; the drum and rear wheels + // turn by distance / radius as it moves + async function loadRollerModel() { + let gltf; + try { + gltf = await loader.loadAsync("../assets/machinery/roller_hd.glb"); + } catch (err) { + console.warn("roller: no detailed model, drawing boxes", err); + return; + } + const base = gltf.scene.getObjectByName("base_link"); + if (!base) return; + base.position.set(0, 0, 0); + base.quaternion.identity(); + const spin = base.userData?.spin_nodes ?? {}; + roller.spinners = Object.entries(spin) + .map(([name, r]) => ({ node: base.getObjectByName(name), r })) + .filter((s) => s.node) + .map((s) => ({ ...s, rest: s.node.quaternion.clone() })); + roller.base.clear(); + roller.base.add(wrapZup(base)); + } + const _rollerFwd = new THREE.Vector3(); + const _rollerQ = new THREE.Quaternion(); + const _yAxis = new THREE.Vector3(0, 1, 0); + function spinRoller(prev) { + if (!roller.spinners?.length || !prev) return; + _rollerFwd.set(1, 0, 0).applyQuaternion(roller.base.quaternion); + const d = roller.base.position.clone().sub(prev).dot(_rollerFwd); + if (Math.abs(d) > 2) return; // a jump (reset, seek): don't spin + roller.travel = (roller.travel ?? 0) + d; + for (const s of roller.spinners) s.node.quaternion.copy(s.rest).multiply(_rollerQ.setFromAxisAngle(_yAxis, roller.travel / s.r)); } function buildExcavator(geom) { for (const name of ["house", "boom", "stick", "bucket"]) { @@ -339,7 +385,7 @@ export function startSoil({ THREE, scene, loader, Jolt, jolt, bodyInterface, lay async function loadDozerModel(d) { let gltf; try { - gltf = await loader.loadAsync(`../${d.file}`); + gltf = await loadModel(d.file); } catch (err) { console.warn(`dozer: could not load ${d.file}, drawing boxes`, err); return; @@ -380,7 +426,7 @@ export function startSoil({ THREE, scene, loader, Jolt, jolt, bodyInterface, lay async function loadCarrierModel(c) { let gltf; try { - gltf = await loader.loadAsync(`../${c.file}`); + gltf = await loadModel(c.file); } catch (err) { console.warn(`carrier: could not load ${c.file}, drawing boxes`, err); return; @@ -419,7 +465,7 @@ export function startSoil({ THREE, scene, loader, Jolt, jolt, bodyInterface, lay async function loadMachineModel(model) { let gltf; try { - gltf = await loader.loadAsync(`../${model.file}`); + gltf = await loadModel(model.file); } catch (err) { console.warn(`excavator: could not load ${model.file}, drawing boxes`, err); return; @@ -898,8 +944,10 @@ export function startSoil({ THREE, scene, loader, Jolt, jolt, bodyInterface, lay } if (f.roller && roller.base) { roller.base.visible = true; + const prev = roller.base.position.clone(); roller.base.position.set(...f.roller.base.slice(0, 3)); roller.base.quaternion.set(...f.roller.base.slice(3)); + spinRoller(prev); roller.stage = roller.stages[f.roller.stage] ?? ""; } if (f.spoilHm) { diff --git a/phase2/RESULTS.md b/phase2/RESULTS.md index 26233cd..e6e908d 100644 --- a/phase2/RESULTS.md +++ b/phase2/RESULTS.md @@ -2213,3 +2213,27 @@ Section 21 left 26–30 s of excavator wait per load: the exchange at the one-la - **Total tonnes barely change**, as in section 21. In loam and clay the pit is dug out, and the excavator is then idle (24–35 % of the run). In dry sand the last passes carry little. The gain shows as time: the same pit dug sooner. - **The fleet is more over-trucked still.** Each carrier spends 76–86 % of its cycle at its spot, much of it waiting while the other one is loaded. A longer haul is where both-side loading pays off fully: there the second carrier's time away fills the other's loading time. - No collisions, give-ways or stuck machines in any soil. + +## A living site, 25: the dozer finishes its push and waits clear + +Section 24 left the dozer as the limit in clay: with the carriers arriving closer together, one waited at the dump up to 108 s a run. Each time a loaded carrier left its spot, the dozer was recalled. It dropped the push it was making, backed up to the heap with the soil left half way, and drove round to its park. The carrier waited at its turn point for all of that. + +Now a push under way is finished. The dozer then stops at the lane's end with the blade up until the carrier has tipped and gone, and backs up and carries on. On an end-dumped fill a dozer works this way. The carrier is let in as soon as the dozer is parked or waiting clear. A dozer recalled before its push has begun, with the blade still at the heap, backs out and parks as before. So does one caught backing up close to the heap. + +- **Where it may wait.** The dozer waits only where its outline keeps 1 m from the outline of a carrier dumping at the dump point, tipped vessel included (`traffic.near`). On the dump line that is from about 29.5 m of base_link x. A push ends at about 30.9 m. A first version used a fixed 4 m past the start of the pushes (26.7 m). In dry sand it stopped the dozer inside the carrier's way: the carrier gave way to the dozer, the dozer waited for the carrier, and both stood for the rest of the run (875 s). +- **Time study.** The dozer has a new element, `wait`: 3–7 % of the run, 46–101 s. + +**Benchmark** (1500 s, scripted operator; logs `logs/haul_bench_waitclear__carrier.json`, before from sections 24 and 21): + +| | Dry sand, 2 sides | Loam, 2 sides | Clay, 2 sides | Loam, 1 carrier | +|---|---|---|---|---| +| Carrier waiting at the dump for the dozer | 29 → 22 s | 56 → 70 s | 108 → 63 s | 31 → 31 s | +| No carrier at either spot | 0 → 0 s | 0 → 10 s | 53 → 0 s | (one carrier) | +| Time to load six carriers | 771 → 753 s | 749 → 699 s | 986 → 949 s | 965 → 959 s | +| Loaded in 1500 s | 76.0 → 77.4 t | 80.1 → 82.8 t | 75.6 → 79.2 t | 80.6 → 79.5 t | +| Spread: RMS from grade, soil left unspread | 0.25 → 0.24 m, 6.9 → 5.0 m³ | 0.41 → 0.41 m, 10.9 → 7.1 m³ | 0.49 → 0.51 m, 13.8 → 16.3 m³ | 0.34 → 0.32 m, 8.1 → 6.5 m³ | + +- **In clay the dump wait falls by 40 %** (108 → 63 s), and the excavator no longer runs out of carriers. Before, for 53 s neither spot had one. +- **Elsewhere it changes little.** Six loads go 1–7 % sooner. Runs diverge on the GPU by about 2 % in dry sand and loam and 7 % in clay, so only the clay change in the dump wait is clearly more than run-to-run spread. In loam the wait rose by 14 s while six loads went 7 % sooner. With one carrier the dozer has time to park between loads anyway. +- **The spread is as good** in the same time, with less soil left over in three of the four setups. A push is no longer dropped half way. +- No collisions, give-ways or stuck machines in any setup. diff --git a/phase2/dozer.py b/phase2/dozer.py index 197eb76..d2106c0 100644 --- a/phase2/dozer.py +++ b/phase2/dozer.py @@ -28,8 +28,10 @@ most HOLD_MAX_S, after which the next lift goes on unrolled soil (counted as lifts_on_unrolled). When the roller's only lanes left there lie beside the dozer's pushes (kept off while it works), the site sets make_way and the dozer waits at its park instead, so the roller can roll them. The carrier -must not dump while the dozer works there: the server holds the carrier at its turn point until the dozer -has parked, and recalls the dozer when the carrier leaves the loading spot. +must not dump while the dozer works there: the server recalls the dozer when the carrier leaves the loading spot, +and holds the carrier at its turn point until the dozer is clear. A push under way is finished, and the dozer waits +at the lane's end with the blade up (where its outline keeps WAIT_CLEAR_GAP from the dumping carrier's, traffic.py) until the carrier has tipped and gone, then +backs up and carries on; one recalled with the blade still at the heap backs out and parks. Geometry from the model (d37pxi_ros2, urdf/d37pxi24.xacro and the meshes): lift arm pivot 0.586 m ahead of base_link and 0.386 m above it, lift range -0.41..0.19 rad (positive lowers the blade); blade frame 1.588 m @@ -42,6 +44,7 @@ import numpy as np import tracks +import traffic ARM_PIVOT = np.array([0.5858, 0.0, 0.38606]) # lift_joint in base_link BLADE_ON_ARM = np.array([1.5881, 0.0, -0.10373]) # blade frame (angle_joint) in the arm frame @@ -77,6 +80,7 @@ FUTILE_M3 = 0.15 # a pass that moves less than this out of its lane's heap part blocks the lane HOLD_MAX_S = 300.0 # longest the dozer waits for the roller before moving to an unrolled cell NEW_LOAD_M3 = 1.0 # the area's soil above grade growing by this much means a new load: blocked lanes reopen +WAIT_CLEAR_GAP = 1.0 # m: the dozer waits for the carrier only where its outline is at least this far from the dumping carrier's def rot_z(a): @@ -141,6 +145,7 @@ def __init__(self, park, area, ground_z, soil="dry-sand"): self.cell_lanes = [[(math.atan2(y - self.y_start, self.x_end - self.x_start), math.hypot(y - self.y_start, self.x_end - self.x_start)) for y in ends] for ends in cells] self.start = np.array([self.x_start - self._edge_ahead(), self.y_start]) # base_link at the start of every push + self.dump_pose = None # (x, y, yaw) of the carrier's base while it dumps, set by the site: where not to wait self.reset() def reset(self): @@ -154,6 +159,7 @@ def reset(self): self.hold_since = None # when the dozer started waiting for the other cell to be rolled self.make_way = False # set by the site: while it waits, the roller's last lanes there lie beside its pushes self.stage, self.stage_time, self.time = "parked", 0.0, 0.0 + self.may_work = True self.plan = [] # moves still to make: ("spin", yaw) | ("drive", x, y, dir, speed, stage) | ("lift", "up"/"raise"/"grade") | ("push", x, y) self.lane = None self.blocked = set() # lanes whose last pass moved nothing @@ -216,6 +222,16 @@ def lift_for_edge(self, z_target): def parked(self): return self.stage == "parked" + @property + def clear_of_dump(self): + """Out of the carrier's way at the dump point: parked, or waiting at a lane's end for it to go.""" + return self.stage in ("parked", "wait clear") + + def _clear_of_dump_point(self): + """Whether the dozer, where it stands, is out of the way of a carrier dumping (its outline, tipped + vessel included, at least WAIT_CLEAR_GAP from the dozer's).""" + return self.dump_pose is None or not traffic.near("dozer", [(self.x, self.y, self.yaw)], "carrier", [self.dump_pose], WAIT_CLEAR_GAP) + @property def grade(self): return self.grades[self.cell] @@ -429,10 +445,20 @@ def update(self, dt, surface, blade_force, may_work): f = max(-float(np.dot(blade_force, heading)), 0.0) self.force += (f - self.force) * min(dt / FORCE_TAU, 1.0) self.counters["parked_s" if self.parked else "working_s"] += dt - if not may_work and self.plan and self.stage in ("lower", "push"): - # the carrier is coming: stop pushing, back out with the blade up, and park + self.may_work = may_work + if not may_work and self.plan and self.stage == "lower": + # the carrier is coming before the push has begun (the blade still at the heap): back out and park self.plan = [("lift", "raise"), ("drive", *self.start, -1, SPEED_REVERSE, "back")] self._end_push() + elif not may_work and self.plan and self.stage == "push" and ("wait clear",) not in self.plan: + # the carrier is coming: finish the push (it carries the soil away from the dump point) and wait at + # the lane's end, blade up, until the carrier has tipped and gone, as a dozer on an end-dumped fill + # does. It used to drop the push, back up to the heap and drive to its park, and the carrier waited + # for all of it (in clay up to 108 s a run with two carriers), the push's soil left half way + self.plan = [self.plan[0], ("lift", "raise"), ("wait clear",), ("drive", *self.start, -1, SPEED_REVERSE, "back")] + elif not may_work and self.plan and self.stage == "back" and self.plan[0][0] == "drive" and self._clear_of_dump_point(): + # backing toward the heap, still clear of the dump: stop here until the carrier has gone + self.plan = [("wait clear",)] + self.plan if not self.plan: self.plan = self._next_job(surface, may_work) if not self.plan and self._at_park(): @@ -464,6 +490,14 @@ def _do(self, move, dt): if move[1] == "raise": self._set("raise") done = self._lift_to(LIFT_LO, dt) + elif kind == "wait clear": + if not self._clear_of_dump_point(): + done = True # the push ended near the heap: not clear there, so back out and park as before + else: + self._set("wait clear") + self.speed = 0.0 + self.counters["wait_clear_s"] = self.counters.get("wait_clear_s", 0.0) + dt + done = self.may_work elif kind == "push": self._set("push") done = self._push(move[1], move[2], dt) diff --git a/phase2/excavator_server.py b/phase2/excavator_server.py index cca5036..dc69fb4 100644 --- a/phase2/excavator_server.py +++ b/phase2/excavator_server.py @@ -745,6 +745,7 @@ def add_boxes(body, boxes, cfg): self.track_counters = {"dozer_pressed": 0, "carrier_pressed": 0} edge_ahead = Dozer._edge_ahead() self.dozer = Dozer((DOZER_X_START - edge_ahead, DOZER_PARK_Y, math.pi / 2), (DOZER_X_START, BED_CENTER[1], DOZER_X_END, DOZER_CELLS), GROUND_Z, soil) + self.dozer.dump_pose = (HAUL_DUMP_X, BED_CENTER[1], math.pi) # the carrier backs in facing -x self.blade_q, self.blade_qd = int(jq[joint_of[self.blade]]), int(jqd[joint_of[self.blade]]) # the roller compacting the spread fill once the dozer has spread it self.use_roller = self.use_dozer and roller @@ -1709,7 +1710,7 @@ def dispatch(self): def _haul(self): """Carriers: move the vessels, and hand each load over to and from the soil zone.""" f = self.fleet - f.gates(self.dozer.parked or not self.use_dozer) + f.gates(self.dozer.clear_of_dump or not self.use_dozer) spot = f.at_spot if self.dispatch_pending and spot is not None and (not self.auto or self.stage_name not in ("swing to truck", "dump")) and self.side_sign * self.q[0] > math.radians(-70): self.dispatch_pending = False diff --git a/phase2/logs/haul_bench_waitclear_clay_2carrier.json b/phase2/logs/haul_bench_waitclear_clay_2carrier.json new file mode 100644 index 0000000..ad6837f --- /dev/null +++ b/phase2/logs/haul_bench_waitclear_clay_2carrier.json @@ -0,0 +1 @@ +{"soil": "clay", "operator": "scripted", "carriers": 2, "haul_m": 0.0, "relocate_m": 0.0, "relocations": [], "sim_s": 1500.0, "stopped_after_passes": null, "realtime_factor": 0.756, "loads": [{"carrier": 0, "departed_s": 155.0, "load_kg": 10270, "loading_s": 155.0, "passes": 8}, {"carrier": 1, "departed_s": 298.6, "load_kg": 10510, "loading_s": 298.6, "passes": 16}, {"carrier": 0, "departed_s": 440.7, "load_kg": 11358, "loading_s": 224.8, "passes": 12}, {"carrier": 1, "departed_s": 653.8, "load_kg": 11837, "loading_s": 284.5, "passes": 15}, {"carrier": 0, "departed_s": 783.5, "load_kg": 9918, "loading_s": 270.9, "passes": 14}, {"carrier": 1, "departed_s": 948.9, "load_kg": 9987, "loading_s": 216.1, "passes": 11}, {"carrier": 0, "departed_s": 1104.4, "load_kg": 10535, "loading_s": 234.1, "passes": 12}, {"carrier": 1, "departed_s": 1184.2, "load_kg": 4829, "loading_s": 154.6, "passes": 9}], "trips": [{"depart_t": 155.0, "stages": {"loading": 155.0, "drive out": 10.78, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 4.77, "lower": 5.0, "return": 4.8, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 298, "away_s": 60.87}, {"depart_t": 298.58, "stages": {"loading": 298.58, "drive out": 6.55, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.83, "lower": 5.0, "return": 4.5, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 333, "away_s": 70.75}, {"depart_t": 440.7, "stages": {"loading": 224.83, "drive out": 10.76, "wait at dump": 9.4, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 6.93, "lower": 5.0, "return": 4.2, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 312, "away_s": 71.82}, {"depart_t": 653.8, "stages": {"loading": 284.47, "drive out": 6.53, "wait at dump": 6.02, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 9.12, "lower": 5.0, "return": 3.48, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 392, "away_s": 79.02}, {"depart_t": 783.47, "stages": {"loading": 270.95, "drive out": 10.76, "wait at dump": 17.58, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 14.48, "lower": 5.0, "return": 3.43, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 373, "away_s": 86.78}, {"depart_t": 948.9, "stages": {"loading": 216.08, "drive out": 6.53, "wait at dump": 8.2, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 8.33, "lower": 5.0, "return": 3.75, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 286, "away_s": 80.68}, {"depart_t": 1104.37, "stages": {"loading": 234.12, "drive out": 10.76, "wait at dump": 8.43, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 10.48, "lower": 5.0, "return": 3.43, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 316, "away_s": 73.63}, {"depart_t": 1184.18, "stages": {"loading": 154.6, "drive out": 6.53, "wait at dump": 13.88, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 8.12, "lower": 5.0, "return": 3.82, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 103, "away_s": 86.22}], "delivered_t": 76.83, "loaded_t": 79.24, "loaded_t_per_hour": 190.2, "mean_departure_interval_s": 147.0, "t_per_hour": 184.4, "mean_load_kg": 9906.0, "mean_loading_s": 229.8, "carry_back_kg": [298, 333, 312, 392, 373, 286, 316, 103], "mean_away_s": 76.2, "excavator_wait_s": 0.0, "passes": 64, "spoil_settled_t": 74.99, "lost_particles": 2382, "pool_short": 92, "skipped": [], "sides": 2, "side_changes": 7, "unblock_lift_s": 0.0, "carrier_wait_at_dump_s": 63.4, "carrier_wait_to_leave_s": 0.0, "carrier_wait_to_load_s": 0.0, "spot_empty_s": 0.0, "pit_left_t": 90.6, "pit_done": true, "faces": [[0.0, 0.0], [10.0, 0.0], [-20.0, 0.0], [-30.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [0.0, 0.0], [-30.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [0.0, 0.0], [0.0, 0.0], [10.0, 0.0], [10.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-30.0, 0.0], [-30.0, 0.0], [-30.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [10.0, 0.0], [10.0, 0.0], [-10.0, 0.0], [0.0, 0.0], [0.0, 0.0], [10.0, 0.0], [10.0, 0.0], [10.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [0.0, 0.0], [-40.0, 0.0], [-40.0, 0.0], [0.0, 0.0], [-30.0, 0.0], [-20.0, 0.0], [10.0, 0.0], [10.0, 0.0]], "curl_gain_kg": 4, "mean_carried_kg": 1232, "mean_dumped_kg": 999, "thin_passes": 6, "pass_log": [{"pass": 0, "t": 0.0, "face": [0.0, 0.0, 1.39], "dig_max_kg": 1179, "early_curl": true, "skips": 0, "at_swing_kg": 1163, "carried_kg": 1172, "left_kg": 87}, {"pass": 1, "t": 16.5, "face": [10.0, 0.0, 1.39], "dig_max_kg": 1238, "early_curl": true, "skips": 0, "at_swing_kg": 1234, "carried_kg": 1223, "left_kg": 94}, {"pass": 2, "t": 32.8, "face": [-20.0, 0.0, 1.38], "dig_max_kg": 1246, "early_curl": true, "skips": 0, "at_swing_kg": 1228, "carried_kg": 1181, "left_kg": 109}, {"pass": 3, "t": 49.4, "face": [-30.0, 0.0, 1.29], "dig_max_kg": 1231, "early_curl": true, "skips": 0, "at_swing_kg": 1166, "carried_kg": 1188, "left_kg": 441}, {"pass": 4, "t": 66.9, "face": [-10.0, 0.0, 1.23], "dig_max_kg": 1311, "early_curl": true, "skips": 0, "at_swing_kg": 1309, "carried_kg": 1300, "left_kg": 71}, {"pass": 5, "t": 83.6, "face": [20.0, 0.0, 1.15], "dig_max_kg": 1366, "early_curl": true, "skips": 0, "at_swing_kg": 1363, "carried_kg": 1309, "left_kg": 45}, {"pass": 6, "t": 101.6, "face": [0.0, 0.0, 0.85], "dig_max_kg": 1363, "early_curl": false, "skips": 0, "at_swing_kg": 979, "carried_kg": 1096, "left_kg": 548}, {"pass": 7, "t": 120.5, "face": [-30.0, 0.0, 0.82], "dig_max_kg": 1026, "early_curl": true, "skips": 0, "at_swing_kg": 1010, "carried_kg": 1058, "left_kg": 570}, {"pass": 8, "t": 138.1, "face": [0.0, 0.0, 0.76], "dig_max_kg": 1235, "early_curl": false, "skips": 0, "at_swing_kg": 1188, "carried_kg": 1301, "left_kg": 603}, {"pass": 9, "t": 156.8, "face": [0.0, 0.0, 1.0], "dig_max_kg": 1193, "early_curl": true, "skips": 0, "at_swing_kg": 1101, "carried_kg": 1122, "left_kg": 60}, {"pass": 10, "t": 174.7, "face": [-20.0, 0.0, 0.64], "dig_max_kg": 1167, "early_curl": false, "skips": 0, "at_swing_kg": 1159, "carried_kg": 1134, "left_kg": 71}, {"pass": 11, "t": 191.8, "face": [-20.0, 0.0, 1.11], "dig_max_kg": 1284, "early_curl": true, "skips": 0, "at_swing_kg": 1273, "carried_kg": 1383, "left_kg": 271}, {"pass": 12, "t": 210.8, "face": [-10.0, 0.0, 0.63], "dig_max_kg": 1279, "early_curl": false, "skips": 0, "at_swing_kg": 1118, "carried_kg": 1227, "left_kg": 80}, {"pass": 13, "t": 227.9, "face": [-10.0, 0.0, 1.13], "dig_max_kg": 1266, "early_curl": true, "skips": 0, "at_swing_kg": 1202, "carried_kg": 1352, "left_kg": 379}, {"pass": 14, "t": 246.8, "face": [0.0, 0.0, 0.59], "dig_max_kg": 1273, "early_curl": false, "skips": 0, "at_swing_kg": 1238, "carried_kg": 1313, "left_kg": 419}, {"pass": 15, "t": 265.9, "face": [0.0, 0.0, 1.16], "dig_max_kg": 1253, "early_curl": true, "skips": 0, "at_swing_kg": 1223, "carried_kg": 1291, "left_kg": 74}, {"pass": 16, "t": 284.4, "face": [10.0, 0.0, 0.51], "dig_max_kg": 1248, "early_curl": false, "skips": 0, "at_swing_kg": 1057, "carried_kg": 1143, "left_kg": 75}, {"pass": 17, "t": 300.7, "face": [10.0, 0.0, 1.04], "dig_max_kg": 1379, "early_curl": true, "skips": 0, "at_swing_kg": 1359, "carried_kg": 1350, "left_kg": 208}, {"pass": 18, "t": 319.2, "face": [0.0, 0.0, 0.52], "dig_max_kg": 1379, "early_curl": false, "skips": 0, "at_swing_kg": 1225, "carried_kg": 1250, "left_kg": 81}, {"pass": 19, "t": 338.0, "face": [0.0, 0.0, 0.97], "dig_max_kg": 1233, "early_curl": true, "skips": 0, "at_swing_kg": 444, "carried_kg": 499, "left_kg": 4}, {"pass": 20, "t": 354.0, "face": [0.0, 0.0, 0.98], "dig_max_kg": 1557, "early_curl": false, "skips": 0, "at_swing_kg": 1530, "carried_kg": 1470, "left_kg": 78}, {"pass": 21, "t": 371.9, "face": [-30.0, 0.0, 0.48], "dig_max_kg": 1539, "early_curl": false, "skips": 0, "at_swing_kg": 1359, "carried_kg": 1413, "left_kg": 114}, {"pass": 22, "t": 389.2, "face": [-30.0, 0.0, 1.04], "dig_max_kg": 1361, "early_curl": true, "skips": 0, "at_swing_kg": 1300, "carried_kg": 1353, "left_kg": 39}, {"pass": 23, "t": 404.5, "face": [-30.0, 0.0, 0.58], "dig_max_kg": 1383, "early_curl": false, "skips": 0, "at_swing_kg": 1379, "carried_kg": 1391, "left_kg": 666}, {"pass": 24, "t": 423.0, "face": [-20.0, 0.0, 0.65], "dig_max_kg": 1380, "early_curl": false, "skips": 0, "at_swing_kg": 1305, "carried_kg": 1459, "left_kg": 552}, {"pass": 25, "t": 442.1, "face": [-20.0, 0.0, 1.13], "dig_max_kg": 1305, "early_curl": true, "skips": 0, "at_swing_kg": 1141, "carried_kg": 1228, "left_kg": 108}, {"pass": 26, "t": 460.5, "face": [-10.0, 0.0, 0.72], "dig_max_kg": 1154, "early_curl": true, "skips": 0, "at_swing_kg": 1122, "carried_kg": 1178, "left_kg": 280}, {"pass": 27, "t": 479.6, "face": [-20.0, 0.0, 0.65], "dig_max_kg": 1209, "early_curl": false, "skips": 0, "at_swing_kg": 1185, "carried_kg": 1231, "left_kg": 470}, {"pass": 28, "t": 499.5, "face": [-20.0, 0.0, 1.01], "dig_max_kg": 1204, "early_curl": true, "skips": 0, "at_swing_kg": 629, "carried_kg": 594, "left_kg": 425}, {"pass": 29, "t": 518.4, "face": [-20.0, 0.0, 1.04], "dig_max_kg": 1463, "early_curl": true, "skips": 0, "at_swing_kg": 1440, "carried_kg": 1391, "left_kg": 386}, {"pass": 30, "t": 538.2, "face": [-10.0, 0.0, 0.67], "dig_max_kg": 1500, "early_curl": false, "skips": 0, "at_swing_kg": 1492, "carried_kg": 1509, "left_kg": 66}, {"pass": 31, "t": 556.5, "face": [-10.0, 0.0, 0.83], "dig_max_kg": 1275, "early_curl": false, "skips": 0, "at_swing_kg": 1260, "carried_kg": 1219, "left_kg": 296}, {"pass": 32, "t": 575.6, "face": [-10.0, 0.0, 0.77], "dig_max_kg": 1864, "early_curl": false, "skips": 0, "at_swing_kg": 1841, "carried_kg": 1849, "left_kg": 630}, {"pass": 33, "t": 596.2, "face": [-10.0, 0.0, 1.05], "dig_max_kg": 1848, "early_curl": true, "skips": 0, "at_swing_kg": 245, "carried_kg": 329, "left_kg": 161}, {"pass": 34, "t": 616.6, "face": [-10.0, 0.0, 1.02], "dig_max_kg": 1360, "early_curl": false, "skips": 0, "at_swing_kg": 1340, "carried_kg": 1385, "left_kg": 450}, {"pass": 35, "t": 636.3, "face": [0.0, 0.0, 0.77], "dig_max_kg": 1730, "early_curl": false, "skips": 0, "at_swing_kg": 1726, "carried_kg": 1674, "left_kg": 510}, {"pass": 36, "t": 655.8, "face": [0.0, 0.0, 1.03], "dig_max_kg": 1730, "early_curl": false, "skips": 0, "at_swing_kg": 1020, "carried_kg": 1020, "left_kg": 49}, {"pass": 37, "t": 674.3, "face": [-20.0, 0.0, 0.52], "dig_max_kg": 1619, "early_curl": false, "skips": 0, "at_swing_kg": 1615, "carried_kg": 1681, "left_kg": 33}, {"pass": 38, "t": 690.5, "face": [-20.0, 0.0, 0.42], "dig_max_kg": 1619, "early_curl": true, "skips": 0, "at_swing_kg": 290, "carried_kg": 379, "left_kg": 94}, {"pass": 39, "t": 708.7, "face": [-20.0, 0.0, 0.45], "dig_max_kg": 1956, "early_curl": false, "skips": 0, "at_swing_kg": 1809, "carried_kg": 1878, "left_kg": 103}, {"pass": 40, "t": 727.4, "face": [20.0, 0.0, 0.42], "dig_max_kg": 1826, "early_curl": false, "skips": 0, "at_swing_kg": 985, "carried_kg": 1053, "left_kg": 10}, {"pass": 41, "t": 745.5, "face": [20.0, 0.0, 0.95], "dig_max_kg": 1246, "early_curl": true, "skips": 0, "at_swing_kg": 1239, "carried_kg": 1259, "left_kg": 81}, {"pass": 42, "t": 764.9, "face": [20.0, 0.0, 0.44], "dig_max_kg": 1266, "early_curl": false, "skips": 0, "at_swing_kg": 1261, "carried_kg": 1254, "left_kg": 266}, {"pass": 43, "t": 785.7, "face": [20.0, 0.0, 0.96], "dig_max_kg": 1266, "early_curl": true, "skips": 0, "at_swing_kg": 1067, "carried_kg": 1110, "left_kg": 19}, {"pass": 44, "t": 803.5, "face": [10.0, 0.0, 0.67], "dig_max_kg": 1061, "early_curl": true, "skips": 0, "at_swing_kg": 1056, "carried_kg": 1173, "left_kg": 67}, {"pass": 45, "t": 820.7, "face": [10.0, 0.0, 0.86], "dig_max_kg": 1193, "early_curl": true, "skips": 0, "at_swing_kg": 1177, "carried_kg": 1289, "left_kg": 96}, {"pass": 46, "t": 839.1, "face": [-10.0, 0.0, 0.65], "dig_max_kg": 1757, "early_curl": false, "skips": 0, "at_swing_kg": 1757, "carried_kg": 1692, "left_kg": 560}, {"pass": 47, "t": 859.4, "face": [0.0, 0.0, 0.47], "dig_max_kg": 1753, "early_curl": false, "skips": 0, "at_swing_kg": 1329, "carried_kg": 1326, "left_kg": 32}, {"pass": 48, "t": 878.1, "face": [0.0, 0.0, 0.88], "dig_max_kg": 1344, "early_curl": false, "skips": 0, "at_swing_kg": 1309, "carried_kg": 1360, "left_kg": 61}, {"pass": 49, "t": 897.0, "face": [10.0, 0.0, 0.45], "dig_max_kg": 1332, "early_curl": false, "skips": 0, "at_swing_kg": 1019, "carried_kg": 1021, "left_kg": 97}, {"pass": 50, "t": 914.5, "face": [10.0, 0.0, 0.97], "dig_max_kg": 745, "early_curl": true, "skips": 0, "at_swing_kg": 199, "carried_kg": 223, "left_kg": 155}, {"pass": 51, "t": 931.2, "face": [10.0, 0.0, 0.96], "dig_max_kg": 1421, "early_curl": true, "skips": 0, "at_swing_kg": 1408, "carried_kg": 1513, "left_kg": 76}, {"pass": 52, "t": 951.8, "face": [20.0, 0.0, 0.47], "dig_max_kg": 1366, "early_curl": false, "skips": 0, "at_swing_kg": 1348, "carried_kg": 1362, "left_kg": 57}, {"pass": 53, "t": 970.1, "face": [20.0, 0.0, 0.8], "dig_max_kg": 1247, "early_curl": false, "skips": 0, "at_swing_kg": 1241, "carried_kg": 1230, "left_kg": 47}, {"pass": 54, "t": 989.3, "face": [20.0, 0.0, 0.9], "dig_max_kg": 1242, "early_curl": true, "skips": 0, "at_swing_kg": 1093, "carried_kg": 1108, "left_kg": 95}, {"pass": 55, "t": 1010.2, "face": [20.0, 0.0, 0.54], "dig_max_kg": 1912, "early_curl": false, "skips": 0, "at_swing_kg": 1861, "carried_kg": 1822, "left_kg": 1256}, {"pass": 56, "t": 1030.5, "face": [0.0, 0.0, 0.35], "dig_max_kg": 1901, "early_curl": false, "skips": 0, "at_swing_kg": 1898, "carried_kg": 1991, "left_kg": 390}, {"pass": 57, "t": 1050.9, "face": [-40.0, 0.0, 0.34], "dig_max_kg": 494, "early_curl": true, "skips": 0, "at_swing_kg": 458, "carried_kg": 518, "left_kg": 67}, {"pass": 58, "t": 1067.2, "face": [-40.0, 0.0, 0.44], "dig_max_kg": 828, "early_curl": false, "skips": 0, "at_swing_kg": 814, "carried_kg": 833, "left_kg": 23}, {"pass": 59, "t": 1083.4, "face": [0.0, 0.0, 0.31], "dig_max_kg": 1258, "early_curl": false, "skips": 0, "at_swing_kg": 1258, "carried_kg": 1714, "left_kg": 927}, {"pass": 60, "t": 1106.0, "face": [-30.0, 0.0, 0.31], "dig_max_kg": 1250, "early_curl": false, "skips": 0, "at_swing_kg": 829, "carried_kg": 902, "left_kg": 60}, {"pass": 61, "t": 1123.9, "face": [-20.0, 0.0, 0.38], "dig_max_kg": 1227, "early_curl": false, "skips": 0, "at_swing_kg": 1227, "carried_kg": 1245, "left_kg": 101}, {"pass": 62, "t": 1143.2, "face": [10.0, 0.0, 0.5], "dig_max_kg": 1219, "early_curl": true, "skips": 0, "at_swing_kg": 363, "carried_kg": 385, "left_kg": 246}, {"pass": 63, "t": 1162.7, "face": [10.0, 0.0, 0.52], "dig_max_kg": 1432, "early_curl": false, "skips": 0, "at_swing_kg": 1410, "carried_kg": 1927, "left_kg": 337}], "dozer": {"passes": 37, "push_m": 227.57, "work_MJ": 3.3, "load_lifts": 108, "lifts_raised": 2, "parked_s": 547.78, "working_s": 952.23, "peak_kN": 78.59, "slip_s": 5.03, "slip_m": 7.07, "futile_passes": 9, "switches": 3, "lifts_on_unrolled": 0, "holds": 4, "held_s": 349.65, "made_way": 2, "wait_clear_s": 100.62, "mean_push_kN": [19.4, 18.8, 12.7, 6.7, 19.2, 17.2, 17.1, 11.0, 11.7, 5.7, 3.9, 16.7, 11.9, 16.2, 11.9, 12.2, 6.0, 15.1, 14.8, 9.0, 4.7, 15.9, 17.3, 18.8, 15.7, 11.3, 9.5, 12.1, 15.7, 18.6, 22.0, 21.7, 16.7, 19.0, 16.0, 8.5, 12.7]}, "spread": {"design_z_above_ground": [0.6, 0.6], "area_m2": 97.7, "covered_m2": 77.5, "rms_from_grade_m": 0.507, "max_above_grade_m": 2.19, "at_grade_fraction": 0.4, "unspread_m3": 16.25}, "tracks": {"dozer_sinkage_cm": 0.23, "dozer_pull_kN": 41.2, "dozer_slip": 0.03, "carrier_sinkage_cm": [0.21, 0.66], "dozer_pressed": 34139, "carrier_pressed": 3458}, "compaction": {"spoil": {"of_bank": 0.7987, "loose_of_bank": 0.7407, "compacted_of_bank": 1.1111, "rolled_6": 0.281, "passed_1": 0.716, "passed_3": 0.667, "passed_6": 0.557}, "road": {"of_bank": 0.7864, "loose_of_bank": 0.7407, "compacted_of_bank": 1.1111, "rolled_6": 0.0, "passed_1": 0.561, "passed_3": 0.474, "passed_6": 0.39}}, "cell_compaction": [{"of_bank": 0.9791, "loose_of_bank": 0.7407, "compacted_of_bank": 1.1111, "rolled_6": 0.825, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.969, "spreading": false}, {"of_bank": 0.7638, "loose_of_bank": 0.7407, "compacted_of_bank": 1.1111, "rolled_6": 0.0, "passed_1": 0.488, "passed_3": 0.473, "passed_6": 0.462, "spreading": true}, {"of_bank": 0.779, "loose_of_bank": 0.7407, "compacted_of_bank": 1.1111, "rolled_6": 0.192, "passed_1": 0.451, "passed_3": 0.447, "passed_6": 0.393, "spreading": false}], "covered_lifts": [{"t": 587.0, "cell": 1, "of_bank": 0.9925, "loose_of_bank": 0.7407, "compacted_of_bank": 1.1111, "rolled_6": 0.919, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.986}, {"t": 865.5, "cell": 0, "of_bank": 1.0384, "loose_of_bank": 0.7407, "compacted_of_bank": 1.1111, "rolled_6": 0.947, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.96}, {"t": 1272.0, "cell": 1, "of_bank": 1.0705, "loose_of_bank": 0.7407, "compacted_of_bank": 1.1111, "rolled_6": 0.967, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.99}], "traffic": {"collision_frames": {}, "carrier0": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "carrier1": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "dozer": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "roller": {"yields": 0, "waited_s": 0.0, "stuck": 0}}, "time_study": {"excavator": {"time_share": {"dig": 0.289, "idle": 0.211, "swing empty": 0.179, "dump": 0.163, "swing loaded": 0.159}, "total_s": 1500.0, "cycles": 63, "cycles_timed": 63, "cycle_s": {"mean": 18.46, "sd": 1.43, "median": 18.55, "p10": 16.37, "p90": 20.35}, "elements": {"dig": {"mean": 6.77, "sd": 0.57, "median": 6.8, "p10": 6.05, "p90": 7.55, "share": 0.366}, "swing empty": {"mean": 4.17, "sd": 0.39, "median": 4.22, "p10": 3.63, "p90": 4.69, "share": 0.226}, "dump": {"mean": 3.81, "sd": 0.78, "median": 3.95, "p10": 2.79, "p90": 4.63, "share": 0.207}, "swing loaded": {"mean": 3.71, "sd": 0.51, "median": 3.68, "p10": 3.08, "p90": 4.36, "share": 0.201}}}, "carrier0": {"time_share": {"load": 0.805, "dump": 0.071, "return": 0.053, "haul loaded": 0.048, "wait": 0.024}, "total_s": 1500.0, "cycles": 4, "cycles_timed": 4, "cycle_s": {"mean": 294.5, "sd": 58.78, "median": 302.2, "p10": 240.09, "p90": 342.74}, "elements": {"load": {"mean": 221.22, "sd": 48.44, "median": 229.48, "p10": 175.94, "p90": 259.9, "share": 0.751}, "dump": {"mean": 26.45, "sd": 4.26, "median": 25.99, "p10": 22.7, "p90": 30.57, "share": 0.09}, "return": {"mean": 19.98, "sd": 0.66, "median": 19.83, "p10": 19.45, "p90": 20.64, "share": 0.068}, "haul loaded": {"mean": 17.99, "sd": 0.01, "median": 17.98, "p10": 17.98, "p90": 18.0, "share": 0.061}, "wait": {"mean": 8.85, "sd": 7.19, "median": 8.92, "p10": 2.53, "p90": 15.13, "share": 0.03}}}, "carrier1": {"time_share": {"load": 0.789, "dump": 0.067, "return": 0.066, "haul loaded": 0.059, "wait": 0.019}, "total_s": 1500.0, "cycles": 4, "cycles_timed": 4, "cycle_s": {"mean": 317.6, "sd": 60.85, "median": 330.13, "p10": 257.6, "p90": 367.57}, "elements": {"load": {"mean": 238.43, "sd": 66.49, "median": 250.28, "p10": 173.05, "p90": 294.34, "share": 0.751}, "dump": {"mean": 25.13, "sd": 1.41, "median": 25.51, "p10": 23.8, "p90": 26.16, "share": 0.079}, "return": {"mean": 24.92, "sd": 0.43, "median": 24.82, "p10": 24.6, "p90": 25.33, "share": 0.078}, "haul loaded": {"mean": 22.09, "sd": 0.01, "median": 22.08, "p10": 22.08, "p90": 22.1, "share": 0.07}, "wait": {"mean": 7.03, "sd": 5.74, "median": 7.11, "p10": 1.8, "p90": 12.18, "share": 0.022}}}, "dozer": {"time_share": {"parked": 0.365, "return": 0.305, "push": 0.263, "wait": 0.067}, "total_s": 1500.0, "cycles": 37, "cycles_timed": 29, "cycle_s": {"mean": 19.51, "sd": 6.64, "median": 17.5, "p10": 12.72, "p90": 28.93}, "elements": {"push": {"mean": 11.0, "sd": 5.18, "median": 9.55, "p10": 6.21, "p90": 18.09, "share": 0.564}, "return": {"mean": 8.51, "sd": 4.03, "median": 7.82, "p10": 6.43, "p90": 9.54, "share": 0.436}}}, "roller": {"time_share": {"roll": 0.495, "parked": 0.299, "travel": 0.206}, "total_s": 1500.0}}, "operator_paused_s": {}, "roller": {"lanes_rolled": 9, "roll_m": 625.48, "parked_s": 448.78, "working_s": 1051.23, "passes": 85, "lanes_left": 0, "rolled": 72585}} diff --git a/phase2/logs/haul_bench_waitclear_dry-sand_2carrier.json b/phase2/logs/haul_bench_waitclear_dry-sand_2carrier.json new file mode 100644 index 0000000..7fa6704 --- /dev/null +++ b/phase2/logs/haul_bench_waitclear_dry-sand_2carrier.json @@ -0,0 +1 @@ +{"soil": "dry-sand", "operator": "scripted", "carriers": 2, "haul_m": 0.0, "relocate_m": 0.0, "relocations": [], "sim_s": 1500.0, "stopped_after_passes": null, "realtime_factor": 0.693, "loads": [{"carrier": 0, "departed_s": 128.6, "load_kg": 10215, "loading_s": 128.6, "passes": 7}, {"carrier": 1, "departed_s": 235.2, "load_kg": 10451, "loading_s": 235.2, "passes": 13}, {"carrier": 0, "departed_s": 356.6, "load_kg": 10549, "loading_s": 168.4, "passes": 9}, {"carrier": 1, "departed_s": 482.4, "load_kg": 10323, "loading_s": 178.2, "passes": 10}, {"carrier": 0, "departed_s": 605.1, "load_kg": 10309, "loading_s": 169.9, "passes": 9}, {"carrier": 1, "departed_s": 752.7, "load_kg": 10285, "loading_s": 199.6, "passes": 11}, {"carrier": 0, "departed_s": 1093.3, "load_kg": 10319, "loading_s": 422.2, "passes": 23}], "trips": [{"depart_t": 128.58, "stages": {"loading": 128.58, "drive out": 10.78, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 3.03, "lower": 5.0, "return": 5.23, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 235, "away_s": 59.57}, {"depart_t": 235.2, "stages": {"loading": 235.2, "drive out": 6.55, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 3.47, "lower": 5.0, "return": 5.12, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 203, "away_s": 69.0}, {"depart_t": 356.57, "stages": {"loading": 168.42, "drive out": 10.76, "wait at dump": 17.73, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 4.73, "lower": 5.0, "return": 4.82, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 228, "away_s": 78.56}, {"depart_t": 482.38, "stages": {"loading": 178.18, "drive out": 6.55, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.78, "lower": 5.0, "return": 4.52, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 793, "away_s": 70.72}, {"depart_t": 605.08, "stages": {"loading": 169.95, "drive out": 10.76, "wait at dump": 4.48, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.72, "lower": 5.0, "return": 4.55, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 411, "away_s": 66.04}, {"depart_t": 752.75, "stages": {"loading": 199.65, "drive out": 6.55, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.92, "lower": 5.0, "return": 4.47, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 454, "away_s": 70.8}, {"depart_t": 1093.28, "stages": {"loading": 422.17, "drive out": 10.78, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.73, "lower": 5.0, "return": 4.53, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 465, "away_s": 61.57}], "delivered_t": 69.66, "loaded_t": 77.41, "loaded_t_per_hour": 185.8, "mean_departure_interval_s": 160.8, "t_per_hour": 167.2, "mean_load_kg": 10350.0, "mean_loading_s": 214.6, "carry_back_kg": [235, 203, 228, 793, 411, 454, 465], "mean_away_s": 68.0, "excavator_wait_s": 0.0, "passes": 83, "spoil_settled_t": 71.17, "lost_particles": 11418, "pool_short": 0, "skipped": [], "sides": 2, "side_changes": 7, "unblock_lift_s": 4.2, "carrier_wait_at_dump_s": 22.2, "carrier_wait_to_leave_s": 0.0, "carrier_wait_to_load_s": 0.0, "spot_empty_s": 0.0, "pit_left_t": 65.6, "pit_done": false, "faces": [[0.0, 0.0], [0.0, 0.0], [-30.0, 0.0], [-30.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [10.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-30.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [0.0, 0.0], [-10.0, 0.0], [0.0, 0.0], [-10.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [10.0, 0.0], [10.0, 0.0], [10.0, 0.0], [0.0, 0.0], [10.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [20.0, 0.0], [10.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [20.0, 0.0], [-10.0, 0.0], [10.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [20.0, 0.0], [-10.0, 0.0], [-20.0, 0.0], [10.0, 0.0], [0.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [-20.0, 0.0], [10.0, 0.0], [0.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [10.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [10.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [10.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [10.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [0.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [10.0, 0.0]], "curl_gain_kg": 0, "mean_carried_kg": 856, "mean_dumped_kg": 853, "thin_passes": 27, "pass_log": [{"pass": 0, "t": 0.0, "face": [0.0, 0.0, 1.39], "dig_max_kg": 902, "early_curl": false, "skips": 0, "at_swing_kg": 894, "carried_kg": 584, "left_kg": 0}, {"pass": 1, "t": 15.7, "face": [0.0, 0.0, 1.48], "dig_max_kg": 1610, "early_curl": false, "skips": 0, "at_swing_kg": 1610, "carried_kg": 1359, "left_kg": 8}, {"pass": 2, "t": 31.1, "face": [-30.0, 0.0, 1.41], "dig_max_kg": 1604, "early_curl": false, "skips": 0, "at_swing_kg": 781, "carried_kg": 537, "left_kg": 0}, {"pass": 3, "t": 46.3, "face": [-30.0, 0.0, 1.44], "dig_max_kg": 1530, "early_curl": false, "skips": 0, "at_swing_kg": 1530, "carried_kg": 1195, "left_kg": 1}, {"pass": 4, "t": 62.5, "face": [0.0, 0.0, 1.39], "dig_max_kg": 1756, "early_curl": false, "skips": 0, "at_swing_kg": 1756, "carried_kg": 1449, "left_kg": 8}, {"pass": 5, "t": 78.4, "face": [0.0, 0.0, 1.46], "dig_max_kg": 1883, "early_curl": false, "skips": 0, "at_swing_kg": 1883, "carried_kg": 1450, "left_kg": 2}, {"pass": 6, "t": 95.3, "face": [0.0, 0.0, 1.45], "dig_max_kg": 1927, "early_curl": false, "skips": 0, "at_swing_kg": 1927, "carried_kg": 1413, "left_kg": 1}, {"pass": 7, "t": 112.9, "face": [0.0, 0.0, 1.56], "dig_max_kg": 1939, "early_curl": false, "skips": 0, "at_swing_kg": 1939, "carried_kg": 1583, "left_kg": 8}, {"pass": 8, "t": 130.3, "face": [0.0, 0.0, 1.54], "dig_max_kg": 1988, "early_curl": false, "skips": 0, "at_swing_kg": 1988, "carried_kg": 1504, "left_kg": 1}, {"pass": 9, "t": 147.9, "face": [0.0, 0.0, 1.52], "dig_max_kg": 1976, "early_curl": false, "skips": 0, "at_swing_kg": 1970, "carried_kg": 1429, "left_kg": 1}, {"pass": 10, "t": 165.8, "face": [0.0, 0.0, 1.53], "dig_max_kg": 2000, "early_curl": false, "skips": 0, "at_swing_kg": 2000, "carried_kg": 1574, "left_kg": 2}, {"pass": 11, "t": 182.9, "face": [0.0, 0.0, 1.53], "dig_max_kg": 2009, "early_curl": false, "skips": 0, "at_swing_kg": 2009, "carried_kg": 1529, "left_kg": 1}, {"pass": 12, "t": 200.8, "face": [0.0, 0.0, 1.53], "dig_max_kg": 1980, "early_curl": false, "skips": 0, "at_swing_kg": 1980, "carried_kg": 1439, "left_kg": 1}, {"pass": 13, "t": 218.9, "face": [0.0, 0.0, 1.56], "dig_max_kg": 1990, "early_curl": false, "skips": 0, "at_swing_kg": 1990, "carried_kg": 1544, "left_kg": 12}, {"pass": 14, "t": 236.8, "face": [0.0, 0.0, 1.5], "dig_max_kg": 1980, "early_curl": false, "skips": 0, "at_swing_kg": 1980, "carried_kg": 1470, "left_kg": 7}, {"pass": 15, "t": 255.0, "face": [10.0, 0.0, 1.54], "dig_max_kg": 1967, "early_curl": false, "skips": 0, "at_swing_kg": 1646, "carried_kg": 1115, "left_kg": 1}, {"pass": 16, "t": 272.7, "face": [0.0, 0.0, 1.56], "dig_max_kg": 1952, "early_curl": false, "skips": 0, "at_swing_kg": 1952, "carried_kg": 1581, "left_kg": 9}, {"pass": 17, "t": 289.8, "face": [0.0, 0.0, 1.53], "dig_max_kg": 2029, "early_curl": false, "skips": 0, "at_swing_kg": 2029, "carried_kg": 1519, "left_kg": 3}, {"pass": 18, "t": 307.5, "face": [-30.0, 0.0, 1.51], "dig_max_kg": 2017, "early_curl": false, "skips": 0, "at_swing_kg": 1509, "carried_kg": 1111, "left_kg": 1}, {"pass": 19, "t": 323.5, "face": [-10.0, 0.0, 1.4], "dig_max_kg": 1622, "early_curl": false, "skips": 0, "at_swing_kg": 1622, "carried_kg": 1340, "left_kg": 0}, {"pass": 20, "t": 339.6, "face": [-10.0, 0.0, 1.72], "dig_max_kg": 1912, "early_curl": false, "skips": 0, "at_swing_kg": 1912, "carried_kg": 1529, "left_kg": 10}, {"pass": 21, "t": 358.2, "face": [0.0, 0.0, 1.64], "dig_max_kg": 1962, "early_curl": false, "skips": 0, "at_swing_kg": 1962, "carried_kg": 1306, "left_kg": 1}, {"pass": 22, "t": 376.5, "face": [-10.0, 0.0, 1.44], "dig_max_kg": 1939, "early_curl": false, "skips": 0, "at_swing_kg": 1837, "carried_kg": 1385, "left_kg": 11}, {"pass": 23, "t": 393.6, "face": [0.0, 0.0, 1.61], "dig_max_kg": 2013, "early_curl": false, "skips": 0, "at_swing_kg": 2013, "carried_kg": 1479, "left_kg": 1}, {"pass": 24, "t": 411.7, "face": [-10.0, 0.0, 1.55], "dig_max_kg": 1984, "early_curl": false, "skips": 0, "at_swing_kg": 1841, "carried_kg": 1280, "left_kg": 1}, {"pass": 25, "t": 430.2, "face": [-20.0, 0.0, 1.42], "dig_max_kg": 1587, "early_curl": false, "skips": 0, "at_swing_kg": 1587, "carried_kg": 1206, "left_kg": 9}, {"pass": 26, "t": 447.1, "face": [-10.0, 0.0, 1.44], "dig_max_kg": 1879, "early_curl": false, "skips": 0, "at_swing_kg": 1879, "carried_kg": 1439, "left_kg": 6}, {"pass": 27, "t": 464.9, "face": [0.0, 0.0, 1.46], "dig_max_kg": 1889, "early_curl": false, "skips": 0, "at_swing_kg": 1889, "carried_kg": 1264, "left_kg": 1}, {"pass": 28, "t": 484.3, "face": [-20.0, 0.0, 1.41], "dig_max_kg": 1869, "early_curl": false, "skips": 0, "at_swing_kg": 1707, "carried_kg": 1445, "left_kg": 3}, {"pass": 29, "t": 500.9, "face": [10.0, 0.0, 1.39], "dig_max_kg": 1699, "early_curl": false, "skips": 0, "at_swing_kg": 1553, "carried_kg": 1151, "left_kg": 14}, {"pass": 30, "t": 518.4, "face": [10.0, 0.0, 1.49], "dig_max_kg": 1741, "early_curl": false, "skips": 0, "at_swing_kg": 1741, "carried_kg": 1247, "left_kg": 10}, {"pass": 31, "t": 536.5, "face": [10.0, 0.0, 1.48], "dig_max_kg": 1867, "early_curl": false, "skips": 0, "at_swing_kg": 1867, "carried_kg": 1469, "left_kg": 7}, {"pass": 32, "t": 553.5, "face": [0.0, 0.0, 1.53], "dig_max_kg": 1920, "early_curl": false, "skips": 0, "at_swing_kg": 1920, "carried_kg": 1477, "left_kg": 6}, {"pass": 33, "t": 571.5, "face": [10.0, 0.0, 1.5], "dig_max_kg": 1893, "early_curl": false, "skips": 0, "at_swing_kg": 1793, "carried_kg": 1219, "left_kg": 1}, {"pass": 34, "t": 589.5, "face": [-10.0, 0.0, 1.36], "dig_max_kg": 1784, "early_curl": false, "skips": 0, "at_swing_kg": 1784, "carried_kg": 1483, "left_kg": 5}, {"pass": 35, "t": 607.3, "face": [20.0, 0.0, 1.24], "dig_max_kg": 1774, "early_curl": false, "skips": 0, "at_swing_kg": 1431, "carried_kg": 1134, "left_kg": 14}, {"pass": 36, "t": 626.0, "face": [20.0, 0.0, 1.37], "dig_max_kg": 1821, "early_curl": false, "skips": 0, "at_swing_kg": 1821, "carried_kg": 1357, "left_kg": 2}, {"pass": 37, "t": 645.2, "face": [10.0, 0.0, 1.42], "dig_max_kg": 1815, "early_curl": false, "skips": 0, "at_swing_kg": 1805, "carried_kg": 1466, "left_kg": 1}, {"pass": 38, "t": 662.6, "face": [0.0, 0.0, 1.23], "dig_max_kg": 1792, "early_curl": false, "skips": 0, "at_swing_kg": 1704, "carried_kg": 1234, "left_kg": 11}, {"pass": 39, "t": 680.8, "face": [-20.0, 0.0, 1.11], "dig_max_kg": 1681, "early_curl": false, "skips": 0, "at_swing_kg": 1525, "carried_kg": 1025, "left_kg": 0}, {"pass": 40, "t": 700.0, "face": [20.0, 0.0, 1.07], "dig_max_kg": 1447, "early_curl": false, "skips": 0, "at_swing_kg": 1447, "carried_kg": 1131, "left_kg": 11}, {"pass": 41, "t": 717.9, "face": [-10.0, 0.0, 0.98], "dig_max_kg": 1481, "early_curl": false, "skips": 0, "at_swing_kg": 1481, "carried_kg": 1111, "left_kg": 9}, {"pass": 42, "t": 736.2, "face": [10.0, 0.0, 0.89], "dig_max_kg": 1466, "early_curl": false, "skips": 0, "at_swing_kg": 1376, "carried_kg": 952, "left_kg": 1}, {"pass": 43, "t": 754.4, "face": [0.0, 0.0, 0.81], "dig_max_kg": 1203, "early_curl": false, "skips": 0, "at_swing_kg": 1203, "carried_kg": 925, "left_kg": 8}, {"pass": 44, "t": 771.6, "face": [-20.0, 0.0, 0.78], "dig_max_kg": 1193, "early_curl": false, "skips": 0, "at_swing_kg": 1123, "carried_kg": 899, "left_kg": 1}, {"pass": 45, "t": 789.4, "face": [20.0, 0.0, 0.75], "dig_max_kg": 1113, "early_curl": false, "skips": 0, "at_swing_kg": 1037, "carried_kg": 687, "left_kg": 1}, {"pass": 46, "t": 808.5, "face": [-10.0, 0.0, 0.74], "dig_max_kg": 1162, "early_curl": false, "skips": 0, "at_swing_kg": 1162, "carried_kg": 888, "left_kg": 8}, {"pass": 47, "t": 825.3, "face": [-20.0, 0.0, 0.64], "dig_max_kg": 921, "early_curl": false, "skips": 0, "at_swing_kg": 921, "carried_kg": 659, "left_kg": 1}, {"pass": 48, "t": 842.7, "face": [10.0, 0.0, 0.63], "dig_max_kg": 957, "early_curl": false, "skips": 0, "at_swing_kg": 957, "carried_kg": 614, "left_kg": 0}, {"pass": 49, "t": 861.0, "face": [0.0, 0.0, 0.67], "dig_max_kg": 1012, "early_curl": false, "skips": 0, "at_swing_kg": 1012, "carried_kg": 708, "left_kg": 0}, {"pass": 50, "t": 878.4, "face": [-10.0, 0.0, 0.64], "dig_max_kg": 991, "early_curl": false, "skips": 0, "at_swing_kg": 913, "carried_kg": 614, "left_kg": 0}, {"pass": 51, "t": 896.5, "face": [20.0, 0.0, 0.62], "dig_max_kg": 911, "early_curl": false, "skips": 0, "at_swing_kg": 769, "carried_kg": 440, "left_kg": 0}, {"pass": 52, "t": 915.3, "face": [-20.0, 0.0, 0.56], "dig_max_kg": 782, "early_curl": false, "skips": 0, "at_swing_kg": 782, "carried_kg": 507, "left_kg": 0}, {"pass": 53, "t": 932.5, "face": [10.0, 0.0, 0.54], "dig_max_kg": 778, "early_curl": false, "skips": 0, "at_swing_kg": 745, "carried_kg": 458, "left_kg": 0}, {"pass": 54, "t": 950.5, "face": [0.0, 0.0, 0.57], "dig_max_kg": 826, "early_curl": false, "skips": 0, "at_swing_kg": 826, "carried_kg": 489, "left_kg": 0}, {"pass": 55, "t": 968.6, "face": [-10.0, 0.0, 0.56], "dig_max_kg": 814, "early_curl": false, "skips": 0, "at_swing_kg": 792, "carried_kg": 520, "left_kg": 0}, {"pass": 56, "t": 986.3, "face": [20.0, 0.0, 0.5], "dig_max_kg": 781, "early_curl": false, "skips": 0, "at_swing_kg": 599, "carried_kg": 329, "left_kg": 0}, {"pass": 57, "t": 1005.5, "face": [10.0, 0.0, 0.48], "dig_max_kg": 604, "early_curl": false, "skips": 0, "at_swing_kg": 602, "carried_kg": 348, "left_kg": 0}, {"pass": 58, "t": 1023.9, "face": [0.0, 0.0, 0.51], "dig_max_kg": 637, "early_curl": false, "skips": 0, "at_swing_kg": 637, "carried_kg": 385, "left_kg": 0}, {"pass": 59, "t": 1041.0, "face": [-20.0, 0.0, 0.48], "dig_max_kg": 687, "early_curl": false, "skips": 0, "at_swing_kg": 687, "carried_kg": 459, "left_kg": 0}, {"pass": 60, "t": 1057.9, "face": [-10.0, 0.0, 0.47], "dig_max_kg": 705, "early_curl": false, "skips": 0, "at_swing_kg": 705, "carried_kg": 403, "left_kg": 0}, {"pass": 61, "t": 1076.5, "face": [20.0, 0.0, 0.43], "dig_max_kg": 701, "early_curl": false, "skips": 0, "at_swing_kg": 472, "carried_kg": 240, "left_kg": 0}, {"pass": 62, "t": 1095.2, "face": [10.0, 0.0, 0.43], "dig_max_kg": 485, "early_curl": false, "skips": 0, "at_swing_kg": 479, "carried_kg": 267, "left_kg": 0}, {"pass": 63, "t": 1113.1, "face": [0.0, 0.0, 0.47], "dig_max_kg": 573, "early_curl": false, "skips": 0, "at_swing_kg": 573, "carried_kg": 307, "left_kg": 1}, {"pass": 64, "t": 1131.7, "face": [-20.0, 0.0, 0.42], "dig_max_kg": 575, "early_curl": false, "skips": 0, "at_swing_kg": 565, "carried_kg": 307, "left_kg": 0}, {"pass": 65, "t": 1149.2, "face": [-10.0, 0.0, 0.44], "dig_max_kg": 661, "early_curl": false, "skips": 0, "at_swing_kg": 661, "carried_kg": 401, "left_kg": 0}, {"pass": 66, "t": 1168.2, "face": [20.0, 0.0, 0.41], "dig_max_kg": 434, "early_curl": false, "skips": 0, "at_swing_kg": 433, "carried_kg": 229, "left_kg": 0}, {"pass": 67, "t": 1187.1, "face": [10.0, 0.0, 0.43], "dig_max_kg": 434, "early_curl": false, "skips": 0, "at_swing_kg": 434, "carried_kg": 267, "left_kg": 0}, {"pass": 68, "t": 1204.5, "face": [0.0, 0.0, 0.45], "dig_max_kg": 513, "early_curl": false, "skips": 0, "at_swing_kg": 507, "carried_kg": 300, "left_kg": 0}, {"pass": 69, "t": 1222.7, "face": [-20.0, 0.0, 0.38], "dig_max_kg": 513, "early_curl": false, "skips": 0, "at_swing_kg": 465, "carried_kg": 215, "left_kg": 0}, {"pass": 70, "t": 1241.0, "face": [-10.0, 0.0, 0.42], "dig_max_kg": 573, "early_curl": false, "skips": 0, "at_swing_kg": 569, "carried_kg": 328, "left_kg": 0}, {"pass": 71, "t": 1259.6, "face": [20.0, 0.0, 0.39], "dig_max_kg": 573, "early_curl": false, "skips": 0, "at_swing_kg": 368, "carried_kg": 187, "left_kg": 1}, {"pass": 72, "t": 1278.3, "face": [10.0, 0.0, 0.41], "dig_max_kg": 390, "early_curl": false, "skips": 0, "at_swing_kg": 382, "carried_kg": 127, "left_kg": 0}, {"pass": 73, "t": 1296.4, "face": [0.0, 0.0, 0.43], "dig_max_kg": 436, "early_curl": false, "skips": 0, "at_swing_kg": 425, "carried_kg": 262, "left_kg": 1}, {"pass": 74, "t": 1314.2, "face": [-20.0, 0.0, 0.34], "dig_max_kg": 436, "early_curl": false, "skips": 0, "at_swing_kg": 367, "carried_kg": 186, "left_kg": 0}, {"pass": 75, "t": 1332.1, "face": [-10.0, 0.0, 0.38], "dig_max_kg": 508, "early_curl": false, "skips": 0, "at_swing_kg": 508, "carried_kg": 249, "left_kg": 0}, {"pass": 76, "t": 1350.5, "face": [0.0, 0.0, 0.38], "dig_max_kg": 502, "early_curl": false, "skips": 0, "at_swing_kg": 392, "carried_kg": 218, "left_kg": 0}, {"pass": 77, "t": 1368.1, "face": [-10.0, 0.0, 0.33], "dig_max_kg": 382, "early_curl": false, "skips": 0, "at_swing_kg": 357, "carried_kg": 191, "left_kg": 0}, {"pass": 78, "t": 1386.2, "face": [-10.0, 0.0, 0.32], "dig_max_kg": 354, "early_curl": false, "skips": 0, "at_swing_kg": 236, "carried_kg": 66, "left_kg": 0}, {"pass": 79, "t": 1405.4, "face": [20.0, 0.0, 0.38], "dig_max_kg": 358, "early_curl": false, "skips": 0, "at_swing_kg": 342, "carried_kg": 149, "left_kg": 0}, {"pass": 80, "t": 1424.4, "face": [20.0, 0.0, 0.34], "dig_max_kg": 349, "early_curl": false, "skips": 0, "at_swing_kg": 349, "carried_kg": 134, "left_kg": 1}, {"pass": 81, "t": 1443.7, "face": [20.0, 0.0, 0.33], "dig_max_kg": 345, "early_curl": false, "skips": 0, "at_swing_kg": 315, "carried_kg": 141, "left_kg": 0}, {"pass": 82, "t": 1463.4, "face": [20.0, 0.0, 0.33], "dig_max_kg": 312, "early_curl": false, "skips": 0, "at_swing_kg": 283, "carried_kg": 169, "left_kg": 0}, {"pass": 83, "t": 1482.6, "face": [20.0, 0.0, 0.31], "dig_max_kg": 251, "early_curl": false, "skips": 0, "at_swing_kg": 237, "carried_kg": 98, "left_kg": 0}], "dozer": {"passes": 32, "push_m": 165.72, "work_MJ": 1.31, "load_lifts": 2, "lifts_raised": 2, "parked_s": 813.0, "working_s": 687.02, "peak_kN": 70.07, "slip_s": 0.02, "slip_m": 0.59, "futile_passes": 9, "switches": 3, "lifts_on_unrolled": 0, "holds": 2, "held_s": 264.57, "made_way": 2, "wait_clear_s": 100.42, "mean_push_kN": [8.0, 3.9, 0.6, 3.2, 3.2, 2.2, 1.9, 8.3, 8.0, 4.9, 13.1, 17.8, 3.2, 2.8, 2.4, 12.2, 5.1, 19.2, 2.6, 16.0, 6.3, 2.8, 2.2, 0.0, 7.5, 5.9, 18.4, 6.0, 4.1, 3.0, 1.1, 0.0]}, "spread": {"design_z_above_ground": [0.6, 0.6], "area_m2": 97.7, "covered_m2": 79.9, "rms_from_grade_m": 0.24, "max_above_grade_m": 0.89, "at_grade_fraction": 0.5, "unspread_m3": 5.03}, "tracks": {"dozer_sinkage_cm": 3.16, "dozer_pull_kN": 68.5, "dozer_slip": 0.004, "carrier_sinkage_cm": [3.01, 5.09], "dozer_pressed": 39231, "carrier_pressed": 1507}, "compaction": {"spoil": {"of_bank": 0.969, "loose_of_bank": 0.8929, "compacted_of_bank": 1.0526, "rolled_6": 0.483, "passed_1": 0.737, "passed_3": 0.722, "passed_6": 0.632}, "road": {"of_bank": 0.9759, "loose_of_bank": 0.8929, "compacted_of_bank": 1.0526, "rolled_6": 0.0, "passed_1": 0.725, "passed_3": 0.596, "passed_6": 0.537}}, "cell_compaction": [{"of_bank": 1.0103, "loose_of_bank": 0.8929, "compacted_of_bank": 1.0526, "rolled_6": 0.921, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.953, "spreading": false}, {"of_bank": 0.9886, "loose_of_bank": 0.8929, "compacted_of_bank": 1.0526, "rolled_6": 0.613, "passed_1": 0.697, "passed_3": 0.688, "passed_6": 0.618, "spreading": true}, {"of_bank": 0.9531, "loose_of_bank": 0.8929, "compacted_of_bank": 1.0526, "rolled_6": 0.473, "passed_1": 0.554, "passed_3": 0.553, "passed_6": 0.543, "spreading": false}], "covered_lifts": [{"t": 567.5, "cell": 1, "of_bank": 1.032, "loose_of_bank": 0.8929, "compacted_of_bank": 1.0526, "rolled_6": 0.913, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.959}, {"t": 567.5, "cell": 0, "of_bank": 0.8932, "loose_of_bank": 0.8929, "compacted_of_bank": 1.0526, "rolled_6": 0.0, "passed_1": 0.032, "passed_3": 0.0, "passed_6": 0.0}, {"t": 941.0, "cell": 1, "of_bank": 1.0349, "loose_of_bank": 0.8929, "compacted_of_bank": 1.0526, "rolled_6": 0.904, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 1.0}], "traffic": {"collision_frames": {}, "carrier0": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "carrier1": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "dozer": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "roller": {"yields": 0, "waited_s": 0.0, "stuck": 0}}, "time_study": {"excavator": {"time_share": {"dig": 0.4, "swing loaded": 0.268, "swing empty": 0.218, "dump": 0.114}, "total_s": 1500.0, "cycles": 83, "cycles_timed": 83, "cycle_s": {"mean": 17.87, "sd": 0.92, "median": 17.95, "p10": 16.73, "p90": 19.05}, "elements": {"dig": {"mean": 7.14, "sd": 0.46, "median": 7.08, "p10": 6.62, "p90": 8.03, "share": 0.399}, "swing loaded": {"mean": 4.79, "sd": 0.46, "median": 4.78, "p10": 4.26, "p90": 5.39, "share": 0.268}, "swing empty": {"mean": 3.91, "sd": 0.4, "median": 3.88, "p10": 3.46, "p90": 4.56, "share": 0.219}, "dump": {"mean": 2.04, "sd": 0.1, "median": 2.02, "p10": 1.9, "p90": 2.17, "share": 0.114}}}, "carrier0": {"time_share": {"load": 0.823, "dump": 0.059, "return": 0.055, "haul loaded": 0.048, "wait": 0.015}, "total_s": 1500.0, "cycles": 4, "cycles_timed": 4, "cycle_s": {"mean": 288.71, "sd": 132.5, "median": 241.48, "p10": 202.49, "p90": 412.71}, "elements": {"load": {"mean": 222.27, "sd": 134.63, "median": 169.18, "p10": 140.52, "p90": 346.5, "share": 0.77}, "dump": {"mean": 22.09, "sd": 1.27, "median": 22.51, "p10": 20.83, "p90": 23.01, "share": 0.077}, "return": {"mean": 20.8, "sd": 0.33, "median": 20.7, "p10": 20.56, "p90": 21.13, "share": 0.072}, "haul loaded": {"mean": 17.99, "sd": 0.01, "median": 17.99, "p10": 17.98, "p90": 18.0, "share": 0.062}, "wait": {"mean": 5.55, "sd": 8.39, "median": 2.24, "p10": 0.0, "p90": 13.76, "share": 0.019}}}, "carrier1": {"time_share": {"load": 0.86, "return": 0.051, "dump": 0.045, "haul loaded": 0.044}, "total_s": 1500.0, "cycles": 3, "cycles_timed": 3, "cycle_s": {"mean": 274.51, "sd": 27.86, "median": 270.45, "p10": 253.21, "p90": 297.44}, "elements": {"load": {"mean": 204.34, "sd": 28.79, "median": 199.65, "p10": 182.48, "p90": 228.08, "share": 0.744}, "return": {"mean": 25.73, "sd": 0.36, "median": 25.55, "p10": 25.51, "p90": 26.03, "share": 0.094}, "dump": {"mean": 22.34, "sd": 1.38, "median": 23.07, "p10": 21.21, "p90": 23.17, "share": 0.081}, "haul loaded": {"mean": 22.1, "sd": 0.0, "median": 22.1, "p10": 22.1, "p90": 22.1, "share": 0.081}}}, "dozer": {"time_share": {"parked": 0.542, "return": 0.242, "push": 0.149, "wait": 0.067}, "total_s": 1500.0, "cycles": 31, "cycles_timed": 24, "cycle_s": {"mean": 14.73, "sd": 2.58, "median": 14.52, "p10": 11.35, "p90": 18.19}, "elements": {"return": {"mean": 7.58, "sd": 0.97, "median": 7.52, "p10": 6.28, "p90": 8.81, "share": 0.515}, "push": {"mean": 7.15, "sd": 1.63, "median": 7.17, "p10": 4.92, "p90": 9.39, "share": 0.485}}}, "roller": {"time_share": {"roll": 0.457, "parked": 0.378, "travel": 0.165}, "total_s": 1500.0}}, "operator_paused_s": {}, "roller": {"lanes_rolled": 6, "roll_m": 576.84, "parked_s": 566.55, "working_s": 933.47, "passes": 79, "lanes_left": 0, "rolled": 66100}} diff --git a/phase2/logs/haul_bench_waitclear_loam_1carrier.json b/phase2/logs/haul_bench_waitclear_loam_1carrier.json new file mode 100644 index 0000000..1ea61a0 --- /dev/null +++ b/phase2/logs/haul_bench_waitclear_loam_1carrier.json @@ -0,0 +1 @@ +{"soil": "loam", "operator": "scripted", "carriers": 1, "haul_m": 0.0, "relocate_m": 0.0, "relocations": [], "sim_s": 1500.0, "stopped_after_passes": null, "realtime_factor": 0.377, "loads": [{"carrier": 0, "departed_s": 114.1, "load_kg": 10797, "loading_s": 114.1, "passes": 6}, {"carrier": 0, "departed_s": 282.8, "load_kg": 10920, "loading_s": 109.0, "passes": 6}, {"carrier": 0, "departed_s": 447.7, "load_kg": 10458, "loading_s": 104.6, "passes": 6}, {"carrier": 0, "departed_s": 604.5, "load_kg": 9829, "loading_s": 93.1, "passes": 5}, {"carrier": 0, "departed_s": 784.6, "load_kg": 11452, "loading_s": 112.5, "passes": 6}, {"carrier": 0, "departed_s": 958.6, "load_kg": 10765, "loading_s": 112.7, "passes": 6}, {"carrier": 0, "departed_s": 1161.3, "load_kg": 11195, "loading_s": 141.3, "passes": 7}, {"carrier": 0, "departed_s": 1295.6, "load_kg": 4119, "loading_s": 61.7, "passes": 4}], "trips": [{"depart_t": 114.07, "stages": {"loading": 114.07, "drive out": 10.78, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 3.2, "lower": 5.0, "return": 5.2, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 235, "away_s": 59.7}, {"depart_t": 282.77, "stages": {"loading": 109.0, "drive out": 10.78, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 4.0, "lower": 5.0, "return": 5.0, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 371, "away_s": 60.3}, {"depart_t": 447.7, "stages": {"loading": 104.63, "drive out": 10.76, "wait at dump": 3.12, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 4.47, "lower": 5.0, "return": 4.88, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 204, "away_s": 63.75}, {"depart_t": 604.53, "stages": {"loading": 93.08, "drive out": 10.76, "wait at dump": 6.35, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.15, "lower": 5.0, "return": 4.7, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 218, "away_s": 67.49}, {"depart_t": 784.57, "stages": {"loading": 112.55, "drive out": 10.78, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.45, "lower": 5.0, "return": 4.62, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 251, "away_s": 61.36}, {"depart_t": 958.65, "stages": {"loading": 112.72, "drive out": 10.78, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.37, "lower": 5.0, "return": 4.63, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 234, "away_s": 61.3}, {"depart_t": 1161.3, "stages": {"loading": 141.35, "drive out": 10.76, "wait at dump": 11.37, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.37, "lower": 5.0, "return": 4.63, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 274, "away_s": 72.65}, {"depart_t": 1295.63, "stages": {"loading": 61.68, "drive out": 10.76, "wait at dump": 9.75, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.65, "lower": 5.0, "return": 4.57, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 88, "away_s": 71.25}], "delivered_t": 77.66, "loaded_t": 79.54, "loaded_t_per_hour": 190.9, "mean_departure_interval_s": 168.8, "t_per_hour": 186.4, "mean_load_kg": 9942.0, "mean_loading_s": 106.1, "carry_back_kg": [235, 371, 204, 218, 251, 234, 274, 88], "mean_away_s": 64.7, "excavator_wait_s": 382.4, "passes": 53, "spoil_settled_t": 75.74, "lost_particles": 1954, "pool_short": 0, "skipped": [], "sides": 1, "side_changes": 0, "unblock_lift_s": 0.0, "carrier_wait_at_dump_s": 30.5, "carrier_wait_to_leave_s": 0.0, "carrier_wait_to_load_s": 0.0, "spot_empty_s": 517.8, "pit_left_t": 91.2, "pit_done": true, "faces": [[0.0, 0.0], [10.0, 0.0], [-20.0, 0.0], [-30.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [20.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-40.0, 0.0], [-30.0, 0.0], [-30.0, 0.0], [-30.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [10.0, 0.0], [10.0, 0.0], [10.0, 0.0], [10.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [10.0, 0.0], [10.0, 0.0], [0.0, 0.0], [10.0, 0.0], [10.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [10.0, 0.0], [-10.0, 0.0], [0.0, 0.0], [0.0, 0.0]], "curl_gain_kg": -269, "mean_carried_kg": 1259, "mean_dumped_kg": 1149, "thin_passes": 4, "pass_log": [{"pass": 0, "t": 0.0, "face": [0.0, 0.0, 1.39], "dig_max_kg": 1113, "early_curl": true, "skips": 0, "at_swing_kg": 1085, "carried_kg": 1154, "left_kg": 39}, {"pass": 1, "t": 15.6, "face": [10.0, 0.0, 1.37], "dig_max_kg": 1205, "early_curl": true, "skips": 0, "at_swing_kg": 1197, "carried_kg": 1241, "left_kg": 81}, {"pass": 2, "t": 30.7, "face": [-20.0, 0.0, 1.37], "dig_max_kg": 1242, "early_curl": true, "skips": 0, "at_swing_kg": 1209, "carried_kg": 1209, "left_kg": 195}, {"pass": 3, "t": 45.7, "face": [-30.0, 0.0, 1.25], "dig_max_kg": 1287, "early_curl": true, "skips": 0, "at_swing_kg": 1267, "carried_kg": 1343, "left_kg": 88}, {"pass": 4, "t": 61.1, "face": [-10.0, 0.0, 1.22], "dig_max_kg": 1285, "early_curl": true, "skips": 0, "at_swing_kg": 931, "carried_kg": 1172, "left_kg": 80}, {"pass": 5, "t": 76.9, "face": [20.0, 0.0, 1.14], "dig_max_kg": 1422, "early_curl": true, "skips": 0, "at_swing_kg": 1384, "carried_kg": 1397, "left_kg": 197}, {"pass": 6, "t": 96.7, "face": [0.0, 0.0, 0.7], "dig_max_kg": 1391, "early_curl": false, "skips": 0, "at_swing_kg": 1112, "carried_kg": 1298, "left_kg": 345}, {"pass": 7, "t": 115.7, "face": [0.0, 0.0, 1.13], "dig_max_kg": 1338, "early_curl": true, "skips": 0, "at_swing_kg": 1434, "carried_kg": 1373, "left_kg": 20}, {"pass": 8, "t": 181.3, "face": [-20.0, 0.0, 0.63], "dig_max_kg": 1338, "early_curl": false, "skips": 0, "at_swing_kg": 962, "carried_kg": 1186, "left_kg": 43}, {"pass": 9, "t": 196.9, "face": [-20.0, 0.0, 1.15], "dig_max_kg": 1306, "early_curl": true, "skips": 0, "at_swing_kg": 1184, "carried_kg": 1277, "left_kg": 50}, {"pass": 10, "t": 212.7, "face": [-10.0, 0.0, 0.73], "dig_max_kg": 1250, "early_curl": false, "skips": 0, "at_swing_kg": 1250, "carried_kg": 1301, "left_kg": 221}, {"pass": 11, "t": 230.3, "face": [-10.0, 0.0, 1.09], "dig_max_kg": 1300, "early_curl": false, "skips": 0, "at_swing_kg": 1089, "carried_kg": 1084, "left_kg": 26}, {"pass": 12, "t": 247.5, "face": [20.0, 0.0, 0.52], "dig_max_kg": 1093, "early_curl": false, "skips": 0, "at_swing_kg": 961, "carried_kg": 1128, "left_kg": 21}, {"pass": 13, "t": 266.1, "face": [20.0, 0.0, 0.97], "dig_max_kg": 1513, "early_curl": true, "skips": 0, "at_swing_kg": 1325, "carried_kg": 1363, "left_kg": 99}, {"pass": 14, "t": 284.5, "face": [0.0, 0.0, 0.49], "dig_max_kg": 1327, "early_curl": false, "skips": 0, "at_swing_kg": 1384, "carried_kg": 1363, "left_kg": 35}, {"pass": 15, "t": 351.1, "face": [0.0, 0.0, 1.15], "dig_max_kg": 1418, "early_curl": true, "skips": 0, "at_swing_kg": 1256, "carried_kg": 1272, "left_kg": 60}, {"pass": 16, "t": 367.7, "face": [-40.0, 0.0, 0.48], "dig_max_kg": 546, "early_curl": false, "skips": 0, "at_swing_kg": 537, "carried_kg": 565, "left_kg": 30}, {"pass": 17, "t": 382.6, "face": [-30.0, 0.0, 0.59], "dig_max_kg": 1322, "early_curl": false, "skips": 0, "at_swing_kg": 1307, "carried_kg": 1353, "left_kg": 70}, {"pass": 18, "t": 398.4, "face": [-30.0, 0.0, 1.16], "dig_max_kg": 1446, "early_curl": true, "skips": 0, "at_swing_kg": 1399, "carried_kg": 1512, "left_kg": 31}, {"pass": 19, "t": 414.6, "face": [-30.0, 0.0, 0.51], "dig_max_kg": 1401, "early_curl": false, "skips": 0, "at_swing_kg": 1377, "carried_kg": 1317, "left_kg": 28}, {"pass": 20, "t": 430.8, "face": [-20.0, 0.0, 0.44], "dig_max_kg": 1049, "early_curl": false, "skips": 0, "at_swing_kg": 1035, "carried_kg": 1361, "left_kg": 399}, {"pass": 21, "t": 449.2, "face": [-20.0, 0.0, 1.19], "dig_max_kg": 1337, "early_curl": true, "skips": 0, "at_swing_kg": 1035, "carried_kg": 987, "left_kg": 46}, {"pass": 22, "t": 519.7, "face": [-10.0, 0.0, 0.53], "dig_max_kg": 1388, "early_curl": false, "skips": 0, "at_swing_kg": 1388, "carried_kg": 1447, "left_kg": 81}, {"pass": 23, "t": 536.3, "face": [-10.0, 0.0, 1.11], "dig_max_kg": 1401, "early_curl": true, "skips": 0, "at_swing_kg": 1168, "carried_kg": 1152, "left_kg": 59}, {"pass": 24, "t": 553.1, "face": [-20.0, 0.0, 0.41], "dig_max_kg": 1311, "early_curl": false, "skips": 0, "at_swing_kg": 1311, "carried_kg": 1405, "left_kg": 61}, {"pass": 25, "t": 569.8, "face": [-20.0, 0.0, 1.16], "dig_max_kg": 1440, "early_curl": true, "skips": 0, "at_swing_kg": 1253, "carried_kg": 1377, "left_kg": 102}, {"pass": 26, "t": 586.8, "face": [-10.0, 0.0, 0.54], "dig_max_kg": 1827, "early_curl": false, "skips": 0, "at_swing_kg": 1821, "carried_kg": 1800, "left_kg": 501}, {"pass": 27, "t": 606.1, "face": [-10.0, 0.0, 1.16], "dig_max_kg": 1469, "early_curl": false, "skips": 0, "at_swing_kg": 1611, "carried_kg": 1535, "left_kg": 25}, {"pass": 28, "t": 680.0, "face": [-10.0, 0.0, 0.61], "dig_max_kg": 1637, "early_curl": false, "skips": 0, "at_swing_kg": 1629, "carried_kg": 1591, "left_kg": 70}, {"pass": 29, "t": 697.1, "face": [-20.0, 0.0, 0.48], "dig_max_kg": 1637, "early_curl": false, "skips": 0, "at_swing_kg": 1555, "carried_kg": 1525, "left_kg": 52}, {"pass": 30, "t": 713.8, "face": [-10.0, 0.0, 0.51], "dig_max_kg": 1567, "early_curl": false, "skips": 0, "at_swing_kg": 1428, "carried_kg": 1462, "left_kg": 39}, {"pass": 31, "t": 733.1, "face": [10.0, 0.0, 0.4], "dig_max_kg": 1428, "early_curl": false, "skips": 0, "at_swing_kg": 584, "carried_kg": 807, "left_kg": 97}, {"pass": 32, "t": 749.4, "face": [10.0, 0.0, 1.05], "dig_max_kg": 1210, "early_curl": false, "skips": 0, "at_swing_kg": 1051, "carried_kg": 1055, "left_kg": 63}, {"pass": 33, "t": 766.4, "face": [10.0, 0.0, 0.47], "dig_max_kg": 1437, "early_curl": false, "skips": 0, "at_swing_kg": 1430, "carried_kg": 1514, "left_kg": 464}, {"pass": 34, "t": 786.5, "face": [10.0, 0.0, 1.12], "dig_max_kg": 1437, "early_curl": true, "skips": 0, "at_swing_kg": 1357, "carried_kg": 1329, "left_kg": 14}, {"pass": 35, "t": 853.3, "face": [0.0, 0.0, 0.68], "dig_max_kg": 1305, "early_curl": false, "skips": 0, "at_swing_kg": 1262, "carried_kg": 1409, "left_kg": 16}, {"pass": 36, "t": 870.4, "face": [0.0, 0.0, 0.99], "dig_max_kg": 1344, "early_curl": false, "skips": 0, "at_swing_kg": 1340, "carried_kg": 1401, "left_kg": 41}, {"pass": 37, "t": 887.7, "face": [0.0, 0.0, 1.02], "dig_max_kg": 1402, "early_curl": false, "skips": 0, "at_swing_kg": 1386, "carried_kg": 1345, "left_kg": 30}, {"pass": 38, "t": 905.0, "face": [0.0, 0.0, 0.56], "dig_max_kg": 1693, "early_curl": false, "skips": 0, "at_swing_kg": 1688, "carried_kg": 1715, "left_kg": 54}, {"pass": 39, "t": 923.5, "face": [10.0, 0.0, 0.37], "dig_max_kg": 1693, "early_curl": false, "skips": 0, "at_swing_kg": 923, "carried_kg": 1057, "left_kg": 109}, {"pass": 40, "t": 941.6, "face": [10.0, 0.0, 1.0], "dig_max_kg": 1030, "early_curl": true, "skips": 0, "at_swing_kg": 870, "carried_kg": 951, "left_kg": 191}, {"pass": 41, "t": 960.4, "face": [0.0, 0.0, 0.41], "dig_max_kg": 1182, "early_curl": false, "skips": 0, "at_swing_kg": 1316, "carried_kg": 1291, "left_kg": 27}, {"pass": 42, "t": 1028.1, "face": [10.0, 0.0, 0.34], "dig_max_kg": 1170, "early_curl": false, "skips": 0, "at_swing_kg": 992, "carried_kg": 1038, "left_kg": 15}, {"pass": 43, "t": 1046.0, "face": [10.0, 0.0, 0.74], "dig_max_kg": 1320, "early_curl": false, "skips": 0, "at_swing_kg": 1320, "carried_kg": 1358, "left_kg": 24}, {"pass": 44, "t": 1063.9, "face": [20.0, 0.0, 0.33], "dig_max_kg": 1318, "early_curl": false, "skips": 0, "at_swing_kg": 736, "carried_kg": 922, "left_kg": 34}, {"pass": 45, "t": 1082.1, "face": [20.0, 0.0, 0.79], "dig_max_kg": 1270, "early_curl": false, "skips": 0, "at_swing_kg": 1252, "carried_kg": 1274, "left_kg": 39}, {"pass": 46, "t": 1101.2, "face": [20.0, 0.0, 0.73], "dig_max_kg": 1365, "early_curl": false, "skips": 0, "at_swing_kg": 1362, "carried_kg": 1438, "left_kg": 77}, {"pass": 47, "t": 1119.8, "face": [20.0, 0.0, 0.78], "dig_max_kg": 1365, "early_curl": false, "skips": 0, "at_swing_kg": 1239, "carried_kg": 1221, "left_kg": 545}, {"pass": 48, "t": 1141.2, "face": [20.0, 0.0, 0.47], "dig_max_kg": 1249, "early_curl": false, "skips": 0, "at_swing_kg": 1170, "carried_kg": 1313, "left_kg": 284}, {"pass": 49, "t": 1163.3, "face": [10.0, 0.0, 0.4], "dig_max_kg": 1170, "early_curl": false, "skips": 0, "at_swing_kg": 1067, "carried_kg": 1058, "left_kg": 82}, {"pass": 50, "t": 1241.1, "face": [-10.0, 0.0, 0.31], "dig_max_kg": 872, "early_curl": false, "skips": 0, "at_swing_kg": 611, "carried_kg": 788, "left_kg": 288}, {"pass": 51, "t": 1258.8, "face": [0.0, 0.0, 0.33], "dig_max_kg": 1154, "early_curl": true, "skips": 0, "at_swing_kg": 489, "carried_kg": 653, "left_kg": 80}, {"pass": 52, "t": 1276.7, "face": [0.0, 0.0, 0.47], "dig_max_kg": 1052, "early_curl": false, "skips": 0, "at_swing_kg": 1052, "carried_kg": 1242, "left_kg": 60}], "dozer": {"passes": 41, "push_m": 278.49, "work_MJ": 3.75, "load_lifts": 44, "lifts_raised": 2, "parked_s": 564.03, "working_s": 935.98, "peak_kN": 85.77, "slip_s": 1.15, "slip_m": 4.68, "futile_passes": 13, "switches": 3, "lifts_on_unrolled": 0, "holds": 3, "held_s": 299.17, "made_way": 2, "wait_clear_s": 45.85, "mean_push_kN": [17.7, 9.9, 1.6, 6.3, 20.0, 6.1, 0.5, 4.4, 13.8, 14.7, 6.0, 6.0, 5.1, 9.8, 7.5, 5.8, 4.8, 24.2, 17.0, 20.4, 16.5, 6.8, 1.7, 2.8, 13.5, 11.6, 9.6, 6.3, 26.8, 22.0, 10.3, 10.6, 12.5, 8.2, 24.4, 9.8, 5.6, 1.3, 26.7, 18.4, 8.5]}, "spread": {"design_z_above_ground": [0.6, 0.6], "area_m2": 97.7, "covered_m2": 82.3, "rms_from_grade_m": 0.32, "max_above_grade_m": 1.62, "at_grade_fraction": 0.46, "unspread_m3": 6.51}, "tracks": {"dozer_sinkage_cm": 0.44, "dozer_pull_kN": 57.0, "dozer_slip": 0.017, "carrier_sinkage_cm": [0.41, 0.93], "dozer_pressed": 42511, "carrier_pressed": 1345}, "compaction": {"spoil": {"of_bank": 0.8886, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.234, "passed_1": 0.857, "passed_3": 0.82, "passed_6": 0.77}, "road": {"of_bank": 0.9235, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.0, "passed_1": 0.633, "passed_3": 0.625, "passed_6": 0.576}}, "cell_compaction": [{"of_bank": 0.967, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.566, "passed_1": 1.0, "passed_3": 0.933, "passed_6": 0.897, "spreading": false}, {"of_bank": 0.8826, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.118, "passed_1": 0.907, "passed_3": 0.904, "passed_6": 0.881, "spreading": true}, {"of_bank": 0.8476, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.001, "passed_1": 0.548, "passed_3": 0.491, "passed_6": 0.489, "spreading": false}], "covered_lifts": [{"t": 388.0, "cell": 1, "of_bank": 1.0493, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.966, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.966}, {"t": 837.1, "cell": 0, "of_bank": 1.0647, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.94, "passed_1": 0.998, "passed_3": 0.998, "passed_6": 0.94}, {"t": 1225.1, "cell": 1, "of_bank": 1.0516, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.952, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.978}], "traffic": {"collision_frames": {}, "carrier0": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "dozer": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "roller": {"yields": 0, "waited_s": 0.0, "stuck": 0}}, "time_study": {"excavator": {"time_share": {"wait": 0.255, "dig": 0.242, "swing empty": 0.137, "idle": 0.136, "swing loaded": 0.127, "dump": 0.102}, "total_s": 1500.0, "cycles": 52, "cycles_timed": 52, "cycle_s": {"mean": 24.56, "sd": 18.16, "median": 17.79, "p10": 15.79, "p90": 66.46}, "elements": {"wait": {"mean": 7.35, "sd": 18.89, "median": 0.0, "p10": 0.0, "p90": 51.44, "share": 0.299}, "dig": {"mean": 6.84, "sd": 0.49, "median": 6.8, "p10": 6.3, "p90": 7.55, "share": 0.279}, "swing empty": {"mean": 3.9, "sd": 0.37, "median": 3.79, "p10": 3.52, "p90": 4.45, "share": 0.159}, "swing loaded": {"mean": 3.58, "sd": 0.77, "median": 3.69, "p10": 2.43, "p90": 4.45, "share": 0.146}, "dump": {"mean": 2.89, "sd": 0.82, "median": 2.62, "p10": 2.14, "p90": 4.5, "share": 0.118}}}, "carrier0": {"time_share": {"load": 0.655, "dump": 0.118, "return": 0.111, "haul loaded": 0.096, "wait": 0.02}, "total_s": 1500.0, "cycles": 8, "cycles_timed": 8, "cycle_s": {"mean": 170.86, "sd": 22.17, "median": 171.52, "p10": 152.28, "p90": 186.01}, "elements": {"load": {"mean": 106.13, "sd": 22.5, "median": 110.77, "p10": 83.66, "p90": 122.24, "share": 0.621}, "dump": {"mean": 22.11, "sd": 0.86, "median": 22.54, "p10": 21.04, "p90": 22.79, "share": 0.129}, "return": {"mean": 20.8, "sd": 0.23, "median": 20.68, "p10": 20.62, "p90": 21.08, "share": 0.122}, "haul loaded": {"mean": 17.99, "sd": 0.01, "median": 17.99, "p10": 17.98, "p90": 18.0, "share": 0.105}, "wait": {"mean": 3.82, "sd": 4.74, "median": 1.56, "p10": 0.0, "p90": 10.24, "share": 0.022}}}, "dozer": {"time_share": {"parked": 0.376, "return": 0.338, "push": 0.256, "wait": 0.031}, "total_s": 1500.0, "cycles": 40, "cycles_timed": 32, "cycle_s": {"mean": 17.93, "sd": 3.97, "median": 17.56, "p10": 13.22, "p90": 23.77}, "elements": {"push": {"mean": 9.4, "sd": 3.0, "median": 8.78, "p10": 6.17, "p90": 14.17, "share": 0.524}, "return": {"mean": 8.53, "sd": 1.09, "median": 8.83, "p10": 7.04, "p90": 9.6, "share": 0.476}}}, "roller": {"time_share": {"roll": 0.551, "parked": 0.239, "travel": 0.209}, "total_s": 1500.0}}, "operator_paused_s": {}, "roller": {"lanes_rolled": 9, "roll_m": 695.71, "parked_s": 358.85, "working_s": 1141.17, "passes": 95, "lanes_left": 2, "rolled": 84257}} diff --git a/phase2/logs/haul_bench_waitclear_loam_2carrier.json b/phase2/logs/haul_bench_waitclear_loam_2carrier.json new file mode 100644 index 0000000..7e2829e --- /dev/null +++ b/phase2/logs/haul_bench_waitclear_loam_2carrier.json @@ -0,0 +1 @@ +{"soil": "loam", "operator": "scripted", "carriers": 2, "haul_m": 0.0, "relocate_m": 0.0, "relocations": [], "sim_s": 1500.0, "stopped_after_passes": null, "realtime_factor": 0.78, "loads": [{"carrier": 0, "departed_s": 110.6, "load_kg": 9824, "loading_s": 110.6, "passes": 6}, {"carrier": 1, "departed_s": 215.9, "load_kg": 10007, "loading_s": 215.9, "passes": 12}, {"carrier": 0, "departed_s": 319.7, "load_kg": 9666, "loading_s": 149.5, "passes": 8}, {"carrier": 1, "departed_s": 446.1, "load_kg": 10159, "loading_s": 149.5, "passes": 8}, {"carrier": 0, "departed_s": 571.0, "load_kg": 9876, "loading_s": 178.0, "passes": 10}, {"carrier": 1, "departed_s": 699.1, "load_kg": 11337, "loading_s": 181.2, "passes": 10}, {"carrier": 0, "departed_s": 820.1, "load_kg": 9700, "loading_s": 170.9, "passes": 9}, {"carrier": 1, "departed_s": 952.1, "load_kg": 10061, "loading_s": 181.2, "passes": 10}, {"carrier": 0, "departed_s": 1029.3, "load_kg": 2205, "loading_s": 141.0, "passes": 6}], "trips": [{"depart_t": 110.63, "stages": {"loading": 110.63, "drive out": 10.78, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 3.03, "lower": 5.0, "return": 5.23, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 169, "away_s": 59.57}, {"depart_t": 215.85, "stages": {"loading": 215.85, "drive out": 6.53, "wait at dump": 11.52, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 3.82, "lower": 5.0, "return": 5.03, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 254, "away_s": 80.77}, {"depart_t": 319.72, "stages": {"loading": 149.52, "drive out": 10.76, "wait at dump": 11.75, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.82, "lower": 5.0, "return": 4.52, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 307, "away_s": 73.36}, {"depart_t": 446.08, "stages": {"loading": 149.47, "drive out": 6.55, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 7.33, "lower": 5.0, "return": 4.07, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 420, "away_s": 71.82}, {"depart_t": 571.05, "stages": {"loading": 177.97, "drive out": 10.76, "wait at dump": 16.02, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 6.47, "lower": 5.0, "return": 4.33, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 264, "away_s": 78.1}, {"depart_t": 699.12, "stages": {"loading": 181.22, "drive out": 6.55, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 7.3, "lower": 5.0, "return": 4.07, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 270, "away_s": 71.78}, {"depart_t": 820.1, "stages": {"loading": 170.95, "drive out": 10.76, "wait at dump": 6.83, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 5.35, "lower": 5.0, "return": 4.65, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 222, "away_s": 68.12}, {"depart_t": 952.12, "stages": {"loading": 181.22, "drive out": 6.53, "wait at dump": 15.97, "to dump": 11.28, "turn to dump": 4.27, "reverse to dump": 4.27, "tip": 8.02, "dump": 6.35, "lower": 5.0, "return": 4.35, "to lane": 11.1, "turn to load": 4.47, "reverse in": 5.47}, "carry_back_kg": 302, "away_s": 87.06}, {"depart_t": 1029.27, "stages": {"loading": 141.05, "drive out": 10.76, "wait at dump": 7.53, "turn to dump": 7.22, "reverse to dump": 4.27, "tip": 8.02, "dump": 3.23, "lower": 5.0, "return": 5.18, "turn to load": 7.22, "reverse in": 8.8}, "carry_back_kg": 60, "away_s": 67.23}], "delivered_t": 80.57, "loaded_t": 82.83, "loaded_t_per_hour": 198.8, "mean_departure_interval_s": 114.8, "t_per_hour": 193.4, "mean_load_kg": 9204.0, "mean_loading_s": 164.2, "carry_back_kg": [169, 254, 307, 420, 264, 270, 222, 302, 60], "mean_away_s": 73.1, "excavator_wait_s": 0.0, "passes": 56, "spoil_settled_t": 81.07, "lost_particles": 2603, "pool_short": 131, "skipped": [], "sides": 2, "side_changes": 8, "unblock_lift_s": 0.0, "carrier_wait_at_dump_s": 69.5, "carrier_wait_to_leave_s": 36.3, "carrier_wait_to_load_s": 0.0, "spot_empty_s": 9.9, "pit_left_t": 81.7, "pit_done": true, "faces": [[0.0, 0.0], [-20.0, 0.0], [10.0, 0.0], [-30.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-30.0, 0.0], [-30.0, 0.0], [-30.0, 0.0], [10.0, 0.0], [10.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [20.0, 0.0], [20.0, 0.0], [10.0, 0.0], [10.0, 0.0], [0.0, 0.0], [10.0, 0.0], [10.0, 0.0], [-30.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [0.0, 0.0], [0.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [-10.0, 0.0], [10.0, 0.0], [0.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [-20.0, 0.0], [-10.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [20.0, 0.0], [10.0, 0.0], [20.0, 0.0], [0.0, 0.0]], "curl_gain_kg": 134, "mean_carried_kg": 1243, "mean_dumped_kg": 1157, "thin_passes": 2, "pass_log": [{"pass": 0, "t": 0.0, "face": [0.0, 0.0, 1.39], "dig_max_kg": 1111, "early_curl": true, "skips": 0, "at_swing_kg": 1086, "carried_kg": 1154, "left_kg": 12}, {"pass": 1, "t": 14.7, "face": [-20.0, 0.0, 1.37], "dig_max_kg": 1245, "early_curl": true, "skips": 0, "at_swing_kg": 1228, "carried_kg": 1219, "left_kg": 43}, {"pass": 2, "t": 29.7, "face": [10.0, 0.0, 1.35], "dig_max_kg": 1261, "early_curl": true, "skips": 0, "at_swing_kg": 1202, "carried_kg": 1325, "left_kg": 65}, {"pass": 3, "t": 45.1, "face": [-30.0, 0.0, 1.24], "dig_max_kg": 1292, "early_curl": true, "skips": 0, "at_swing_kg": 1282, "carried_kg": 1345, "left_kg": 81}, {"pass": 4, "t": 60.7, "face": [-10.0, 0.0, 1.24], "dig_max_kg": 1286, "early_curl": true, "skips": 0, "at_swing_kg": 108, "carried_kg": 112, "left_kg": 85}, {"pass": 5, "t": 75.9, "face": [20.0, 0.0, 1.15], "dig_max_kg": 1742, "early_curl": false, "skips": 0, "at_swing_kg": 1656, "carried_kg": 1621, "left_kg": 37}, {"pass": 6, "t": 94.1, "face": [0.0, 0.0, 0.62], "dig_max_kg": 1663, "early_curl": false, "skips": 0, "at_swing_kg": 911, "carried_kg": 960, "left_kg": 128}, {"pass": 7, "t": 112.3, "face": [0.0, 0.0, 1.07], "dig_max_kg": 1557, "early_curl": false, "skips": 0, "at_swing_kg": 1532, "carried_kg": 1500, "left_kg": 42}, {"pass": 8, "t": 128.7, "face": [0.0, 0.0, 0.99], "dig_max_kg": 1554, "early_curl": false, "skips": 0, "at_swing_kg": 1485, "carried_kg": 1434, "left_kg": 39}, {"pass": 9, "t": 145.5, "face": [0.0, 0.0, 0.73], "dig_max_kg": 1667, "early_curl": false, "skips": 0, "at_swing_kg": 1594, "carried_kg": 1546, "left_kg": 59}, {"pass": 10, "t": 163.0, "face": [0.0, 0.0, 0.96], "dig_max_kg": 1131, "early_curl": true, "skips": 0, "at_swing_kg": 1090, "carried_kg": 1151, "left_kg": 58}, {"pass": 11, "t": 180.3, "face": [-30.0, 0.0, 0.58], "dig_max_kg": 1201, "early_curl": false, "skips": 0, "at_swing_kg": 1201, "carried_kg": 1308, "left_kg": 522}, {"pass": 12, "t": 200.0, "face": [-30.0, 0.0, 1.14], "dig_max_kg": 1304, "early_curl": true, "skips": 0, "at_swing_kg": 1216, "carried_kg": 1261, "left_kg": 24}, {"pass": 13, "t": 218.1, "face": [-30.0, 0.0, 0.6], "dig_max_kg": 1387, "early_curl": false, "skips": 0, "at_swing_kg": 1385, "carried_kg": 1413, "left_kg": 48}, {"pass": 14, "t": 234.3, "face": [10.0, 0.0, 0.55], "dig_max_kg": 1387, "early_curl": false, "skips": 0, "at_swing_kg": 1109, "carried_kg": 1372, "left_kg": 39}, {"pass": 15, "t": 251.2, "face": [10.0, 0.0, 1.05], "dig_max_kg": 1198, "early_curl": true, "skips": 0, "at_swing_kg": 1022, "carried_kg": 1067, "left_kg": 24}, {"pass": 16, "t": 268.1, "face": [0.0, 0.0, 0.53], "dig_max_kg": 1710, "early_curl": false, "skips": 0, "at_swing_kg": 1709, "carried_kg": 1693, "left_kg": 52}, {"pass": 17, "t": 285.2, "face": [0.0, 0.0, 1.11], "dig_max_kg": 1710, "early_curl": true, "skips": 0, "at_swing_kg": 1156, "carried_kg": 1176, "left_kg": 175}, {"pass": 18, "t": 304.1, "face": [0.0, 0.0, 0.54], "dig_max_kg": 1580, "early_curl": false, "skips": 0, "at_swing_kg": 1580, "carried_kg": 1476, "left_kg": 55}, {"pass": 19, "t": 321.5, "face": [0.0, 0.0, 1.16], "dig_max_kg": 1248, "early_curl": true, "skips": 0, "at_swing_kg": 1245, "carried_kg": 1190, "left_kg": 74}, {"pass": 20, "t": 338.9, "face": [0.0, 0.0, 0.67], "dig_max_kg": 1349, "early_curl": false, "skips": 0, "at_swing_kg": 1339, "carried_kg": 1331, "left_kg": 87}, {"pass": 21, "t": 357.0, "face": [0.0, 0.0, 0.67], "dig_max_kg": 1349, "early_curl": false, "skips": 0, "at_swing_kg": 1143, "carried_kg": 1082, "left_kg": 20}, {"pass": 22, "t": 376.4, "face": [20.0, 0.0, 0.48], "dig_max_kg": 1171, "early_curl": false, "skips": 0, "at_swing_kg": 1159, "carried_kg": 1297, "left_kg": 47}, {"pass": 23, "t": 395.1, "face": [20.0, 0.0, 0.94], "dig_max_kg": 1213, "early_curl": true, "skips": 0, "at_swing_kg": 1036, "carried_kg": 1034, "left_kg": 72}, {"pass": 24, "t": 413.9, "face": [10.0, 0.0, 0.48], "dig_max_kg": 1057, "early_curl": false, "skips": 0, "at_swing_kg": 1044, "carried_kg": 1117, "left_kg": 105}, {"pass": 25, "t": 431.3, "face": [10.0, 0.0, 0.97], "dig_max_kg": 1274, "early_curl": false, "skips": 0, "at_swing_kg": 1272, "carried_kg": 1279, "left_kg": 120}, {"pass": 26, "t": 448.1, "face": [0.0, 0.0, 0.64], "dig_max_kg": 1573, "early_curl": false, "skips": 0, "at_swing_kg": 1570, "carried_kg": 1605, "left_kg": 26}, {"pass": 27, "t": 465.8, "face": [10.0, 0.0, 0.65], "dig_max_kg": 1573, "early_curl": false, "skips": 0, "at_swing_kg": 1409, "carried_kg": 1548, "left_kg": 57}, {"pass": 28, "t": 483.9, "face": [10.0, 0.0, 1.03], "dig_max_kg": 1413, "early_curl": false, "skips": 0, "at_swing_kg": 1061, "carried_kg": 1113, "left_kg": 13}, {"pass": 29, "t": 501.3, "face": [-30.0, 0.0, 0.45], "dig_max_kg": 1203, "early_curl": false, "skips": 0, "at_swing_kg": 1182, "carried_kg": 1217, "left_kg": 245}, {"pass": 30, "t": 520.2, "face": [0.0, 0.0, 0.45], "dig_max_kg": 1676, "early_curl": false, "skips": 0, "at_swing_kg": 1676, "carried_kg": 1732, "left_kg": 88}, {"pass": 31, "t": 539.4, "face": [-20.0, 0.0, 0.37], "dig_max_kg": 162, "early_curl": false, "skips": 0, "at_swing_kg": 76, "carried_kg": 104, "left_kg": 10}, {"pass": 32, "t": 554.4, "face": [-20.0, 0.0, 0.76], "dig_max_kg": 1233, "early_curl": false, "skips": 0, "at_swing_kg": 1223, "carried_kg": 1354, "left_kg": 336}, {"pass": 33, "t": 573.0, "face": [-10.0, 0.0, 0.72], "dig_max_kg": 1219, "early_curl": false, "skips": 0, "at_swing_kg": 1219, "carried_kg": 1438, "left_kg": 12}, {"pass": 34, "t": 590.0, "face": [-10.0, 0.0, 0.8], "dig_max_kg": 1222, "early_curl": false, "skips": 0, "at_swing_kg": 1177, "carried_kg": 1178, "left_kg": 30}, {"pass": 35, "t": 607.2, "face": [0.0, 0.0, 0.39], "dig_max_kg": 1346, "early_curl": false, "skips": 0, "at_swing_kg": 1346, "carried_kg": 1514, "left_kg": 11}, {"pass": 36, "t": 625.1, "face": [0.0, 0.0, 0.68], "dig_max_kg": 1372, "early_curl": false, "skips": 0, "at_swing_kg": 1372, "carried_kg": 1431, "left_kg": 69}, {"pass": 37, "t": 643.3, "face": [-10.0, 0.0, 0.51], "dig_max_kg": 1428, "early_curl": false, "skips": 0, "at_swing_kg": 1426, "carried_kg": 1558, "left_kg": 54}, {"pass": 38, "t": 660.7, "face": [-10.0, 0.0, 0.92], "dig_max_kg": 1428, "early_curl": false, "skips": 0, "at_swing_kg": 1057, "carried_kg": 1113, "left_kg": 359}, {"pass": 39, "t": 680.7, "face": [-10.0, 0.0, 0.46], "dig_max_kg": 1748, "early_curl": false, "skips": 0, "at_swing_kg": 1748, "carried_kg": 1721, "left_kg": 655}, {"pass": 40, "t": 701.0, "face": [-10.0, 0.0, 0.39], "dig_max_kg": 1742, "early_curl": false, "skips": 0, "at_swing_kg": 849, "carried_kg": 988, "left_kg": 17}, {"pass": 41, "t": 719.2, "face": [10.0, 0.0, 0.38], "dig_max_kg": 1320, "early_curl": false, "skips": 0, "at_swing_kg": 1320, "carried_kg": 1508, "left_kg": 47}, {"pass": 42, "t": 737.2, "face": [0.0, 0.0, 0.39], "dig_max_kg": 1320, "early_curl": false, "skips": 0, "at_swing_kg": 865, "carried_kg": 1062, "left_kg": 22}, {"pass": 43, "t": 755.5, "face": [-20.0, 0.0, 0.76], "dig_max_kg": 957, "early_curl": false, "skips": 0, "at_swing_kg": 690, "carried_kg": 829, "left_kg": 37}, {"pass": 44, "t": 771.4, "face": [-20.0, 0.0, 0.57], "dig_max_kg": 1442, "early_curl": false, "skips": 0, "at_swing_kg": 1441, "carried_kg": 1401, "left_kg": 87}, {"pass": 45, "t": 787.9, "face": [-20.0, 0.0, 1.03], "dig_max_kg": 1195, "early_curl": true, "skips": 0, "at_swing_kg": 1002, "carried_kg": 984, "left_kg": 54}, {"pass": 46, "t": 804.9, "face": [-10.0, 0.0, 0.46], "dig_max_kg": 1681, "early_curl": false, "skips": 0, "at_swing_kg": 1641, "carried_kg": 1499, "left_kg": 65}, {"pass": 47, "t": 822.0, "face": [-20.0, 0.0, 0.46], "dig_max_kg": 1272, "early_curl": false, "skips": 0, "at_swing_kg": 1262, "carried_kg": 1323, "left_kg": 54}, {"pass": 48, "t": 840.0, "face": [-10.0, 0.0, 0.36], "dig_max_kg": 1214, "early_curl": false, "skips": 0, "at_swing_kg": 1210, "carried_kg": 1255, "left_kg": 49}, {"pass": 49, "t": 860.3, "face": [20.0, 0.0, 0.36], "dig_max_kg": 746, "early_curl": false, "skips": 0, "at_swing_kg": 746, "carried_kg": 813, "left_kg": 14}, {"pass": 50, "t": 878.6, "face": [20.0, 0.0, 0.77], "dig_max_kg": 1167, "early_curl": false, "skips": 0, "at_swing_kg": 1154, "carried_kg": 1227, "left_kg": 22}, {"pass": 51, "t": 897.4, "face": [20.0, 0.0, 0.69], "dig_max_kg": 1382, "early_curl": false, "skips": 0, "at_swing_kg": 1334, "carried_kg": 1353, "left_kg": 16}, {"pass": 52, "t": 916.7, "face": [20.0, 0.0, 0.73], "dig_max_kg": 1345, "early_curl": false, "skips": 0, "at_swing_kg": 1251, "carried_kg": 1354, "left_kg": 28}, {"pass": 53, "t": 934.9, "face": [10.0, 0.0, 0.32], "dig_max_kg": 999, "early_curl": false, "skips": 0, "at_swing_kg": 987, "carried_kg": 1122, "left_kg": 75}, {"pass": 54, "t": 954.9, "face": [20.0, 0.0, 0.32], "dig_max_kg": 993, "early_curl": false, "skips": 0, "at_swing_kg": 813, "carried_kg": 918, "left_kg": 54}, {"pass": 55, "t": 974.1, "face": [0.0, 0.0, 0.3], "dig_max_kg": 805, "early_curl": false, "skips": 0, "at_swing_kg": 784, "carried_kg": 866, "left_kg": 88}], "dozer": {"passes": 29, "push_m": 177.27, "work_MJ": 2.47, "load_lifts": 38, "lifts_raised": 3, "parked_s": 783.62, "working_s": 716.4, "peak_kN": 85.24, "slip_s": 1.37, "slip_m": 3.69, "futile_passes": 6, "switches": 4, "lifts_on_unrolled": 0, "holds": 2, "held_s": 182.13, "made_way": 1, "wait_clear_s": 53.05, "mean_push_kN": [15.5, 7.7, 2.2, 4.1, 14.4, 10.9, 14.5, 8.4, 7.6, 8.8, 5.7, 12.3, 10.1, 12.9, 10.3, 15.4, 18.4, 7.8, 8.2, 19.5, 22.7, 9.9, 23.3, 27.0, 22.0, 12.5, 6.5, 0.8, 0.0]}, "spread": {"design_z_above_ground": [0.9, 0.6], "area_m2": 97.7, "covered_m2": 82.6, "rms_from_grade_m": 0.406, "max_above_grade_m": 1.35, "at_grade_fraction": 0.35, "unspread_m3": 7.13}, "tracks": {"dozer_sinkage_cm": 0.44, "dozer_pull_kN": 57.0, "dozer_slip": 0.02, "carrier_sinkage_cm": [0.41, 0.93], "dozer_pressed": 29082, "carrier_pressed": 1463}, "compaction": {"spoil": {"of_bank": 0.8985, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.475, "passed_1": 0.887, "passed_3": 0.759, "passed_6": 0.686}, "road": {"of_bank": 0.8565, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.0, "passed_1": 0.763, "passed_3": 0.626, "passed_6": 0.544}}, "cell_compaction": [{"of_bank": 0.9487, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.517, "passed_1": 0.995, "passed_3": 0.886, "passed_6": 0.861, "spreading": true}, {"of_bank": 1.0238, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.943, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.958, "spreading": false}, {"of_bank": 0.8533, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.296, "passed_1": 0.581, "passed_3": 0.57, "passed_6": 0.569, "spreading": false}], "covered_lifts": [{"t": 504.8, "cell": 1, "of_bank": 1.044, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.951, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.951}, {"t": 504.9, "cell": 0, "of_bank": 0.8015, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.0, "passed_1": 0.098, "passed_3": 0.008, "passed_6": 0.0}, {"t": 764.9, "cell": 1, "of_bank": 1.044, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.951, "passed_1": 1.0, "passed_3": 1.0, "passed_6": 0.951}, {"t": 1087.7, "cell": 0, "of_bank": 0.925, "loose_of_bank": 0.8, "compacted_of_bank": 1.1111, "rolled_6": 0.619, "passed_1": 0.664, "passed_3": 0.654, "passed_6": 0.637}], "traffic": {"collision_frames": {}, "carrier0": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "carrier1": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "dozer": {"yields": 0, "waited_s": 0.0, "stuck": 0}, "roller": {"yields": 0, "waited_s": 0.0, "stuck": 0}}, "time_study": {"excavator": {"time_share": {"idle": 0.338, "dig": 0.259, "swing empty": 0.154, "swing loaded": 0.143, "dump": 0.106}, "total_s": 1500.0, "cycles": 55, "cycles_timed": 55, "cycle_s": {"mean": 17.72, "sd": 1.35, "median": 17.88, "p10": 15.66, "p90": 19.37}, "elements": {"dig": {"mean": 6.93, "sd": 0.46, "median": 6.88, "p10": 6.34, "p90": 7.62, "share": 0.391}, "swing empty": {"mean": 4.12, "sd": 0.46, "median": 4.0, "p10": 3.64, "p90": 4.98, "share": 0.233}, "swing loaded": {"mean": 3.83, "sd": 0.53, "median": 3.82, "p10": 3.2, "p90": 4.53, "share": 0.216}, "dump": {"mean": 2.84, "sd": 0.72, "median": 2.7, "p10": 2.2, "p90": 4.33, "share": 0.161}}}, "carrier0": {"time_share": {"load": 0.769, "dump": 0.074, "return": 0.069, "haul loaded": 0.06, "wait": 0.028}, "total_s": 1500.0, "cycles": 5, "cycles_timed": 5, "cycle_s": {"mean": 219.3, "sd": 32.75, "median": 222.88, "p10": 185.42, "p90": 249.27}, "elements": {"load": {"mean": 150.02, "sd": 26.7, "median": 149.52, "p10": 122.79, "p90": 175.16, "share": 0.684}, "dump": {"mean": 22.06, "sd": 1.56, "median": 22.63, "p10": 20.4, "p90": 23.49, "share": 0.101}, "return": {"mean": 20.8, "sd": 0.4, "median": 20.67, "p10": 20.42, "p90": 21.23, "share": 0.095}, "haul loaded": {"mean": 17.99, "sd": 0.01, "median": 17.98, "p10": 17.98, "p90": 17.99, "share": 0.082}, "wait": {"mean": 8.43, "sd": 5.98, "median": 7.53, "p10": 2.73, "p90": 14.31, "share": 0.038}}}, "carrier1": {"time_share": {"load": 0.792, "return": 0.068, "dump": 0.063, "haul loaded": 0.059, "wait": 0.018}, "total_s": 1500.0, "cycles": 4, "cycles_timed": 4, "cycle_s": {"mean": 259.79, "sd": 31.39, "median": 260.64, "p10": 230.8, "p90": 288.11}, "elements": {"load": {"mean": 181.93, "sd": 27.11, "median": 181.22, "p10": 158.99, "p90": 205.45, "share": 0.7}, "return": {"mean": 25.41, "sd": 0.46, "median": 25.24, "p10": 25.1, "p90": 25.86, "share": 0.098}, "dump": {"mean": 23.48, "sd": 1.65, "median": 24.11, "p10": 21.86, "p90": 24.61, "share": 0.09}, "haul loaded": {"mean": 22.09, "sd": 0.01, "median": 22.09, "p10": 22.08, "p90": 22.1, "share": 0.085}, "wait": {"mean": 6.87, "sd": 8.14, "median": 5.76, "p10": 0.0, "p90": 14.63, "share": 0.026}}}, "dozer": {"time_share": {"parked": 0.522, "return": 0.266, "push": 0.176, "wait": 0.035}, "total_s": 1500.0, "cycles": 30, "cycles_timed": 22, "cycle_s": {"mean": 17.55, "sd": 4.69, "median": 16.12, "p10": 13.12, "p90": 23.15}, "elements": {"push": {"mean": 9.54, "sd": 3.89, "median": 8.33, "p10": 6.05, "p90": 13.83, "share": 0.544}, "return": {"mean": 8.01, "sd": 1.07, "median": 7.75, "p10": 6.99, "p90": 9.45, "share": 0.456}}}, "roller": {"time_share": {"roll": 0.431, "parked": 0.361, "travel": 0.208}, "total_s": 1500.0}}, "operator_paused_s": {}, "roller": {"lanes_rolled": 9, "roll_m": 543.24, "parked_s": 541.67, "working_s": 958.35, "passes": 75, "lanes_left": 0, "rolled": 74020}} diff --git a/phase2/timestudy.py b/phase2/timestudy.py index 90b537f..e182944 100644 --- a/phase2/timestudy.py +++ b/phase2/timestudy.py @@ -10,7 +10,8 @@ - carrier: load (at the loading spot), haul loaded (to the dump point), dump (back up, tip, lower), return (back to the loading spot), wait (at the dump point, for the loading spot, on the road); a cycle starts as loading starts; -- dozer: push (blade down and pushing), return (blade raised, back and to the next lane), parked; +- dozer: push (blade down and pushing), return (blade raised, back and to the next lane), wait (at a lane's + end for a carrier to tip and go), parked; a cycle starts as the blade lowers; - roller: roll, travel (to and from lanes), parked. """ @@ -27,13 +28,13 @@ "to queue": "return", "from queue": "return", "to dump": "haul loaded", "to lane": "return", "wait at dump": "wait", "wait to load": "wait", "queue on road": "wait"}, "dozer": {"lower": "push", "push": "push", "raise": "return", "back": "return", "to lane": "return", - "to park": "return", "parked": "parked"}, + "to park": "return", "parked": "parked", "wait clear": "wait"}, "roller": {"roll": "roll", "to lane": "travel", "to park": "travel", "parked": "parked"}, } CYCLE_START = {"excavator": "dig", "carrier": "load", "dozer": "push", "roller": None} # elements that are not part of a work cycle: a cycle holding one of these is reported, but kept out of the # cycle statistics (a carrier waiting 300 s for the dozer is a delay, not a slow haul) -DELAYS = {"excavator": ("move on", "idle"), "carrier": (), "dozer": ("parked",), "roller": ("parked",)} +DELAYS = {"excavator": ("move on", "idle"), "carrier": (), "dozer": ("parked", "wait"), "roller": ("parked",)} class Machine: