ExcavatorTemplate is Physics3D.System:
    boom_swing is HeavyMachineBundle.MachineComponents.CraneSystemComponentNoVisuals:
        length: 0.2
        ground_along: -boom_swing.length * 0.6 * 0.5
    boom is HeavyMachineBundle.MachineComponents.CraneSystemComponentNoVisuals:
        length: 2
    stick is HeavyMachineBundle.MachineComponents.CraneSystemComponentNoVisuals:
        length: 2

    boom_cylinder is HeavyMachineBundle.MachineComponents.HydraulicCylinder:
        motor.min_effort: -1E7
        motor.max_effort: 1E7
        max_length: 1.4
        stroke_length: 0.7
    stick_cylinder is HeavyMachineBundle.MachineComponents.HydraulicCylinder:
        motor.min_effort: -1E7
        motor.max_effort: 1E7
        max_length: 2.0
        stroke_length: 1.0

    swing_boom_connection is HeavyMachineBundle.Connections.PivotBoomConnection:
        boom_1: boom_swing
        boom_2: boom
        cylinder: boom_cylinder

    boom_stick_connection is HeavyMachineBundle.Connections.PivotBoomConnection:
        boom_1: boom
        boom_2: stick
        cylinder: stick_cylinder

    # Make the bearings align
    # Can't be done on the BoomConnection,
    # since then we would modify a template
    boom_cylinder.piston.bearing_separation: boom_swing.ground_separation
    boom.input_separation: boom_swing.output_separation
    boom_cylinder.rod.bearing_separation: boom.drive_separation
    stick_cylinder.piston.bearing_separation: boom.ground_separation
    stick.input_separation: boom.output_separation
    stick_cylinder.rod.bearing_separation: stick.drive_separation

    # Disable internal collisions
    no_collision_group is Simulation.CollisionGroup:
        systems: [boom_cylinder, stick_cylinder, boom_swing, boom, stick]
    geometry_pair is Simulation.DisableCollisionPair:
        group1: no_collision_group
        group2: no_collision_group

ExcavatorTemplateComponentVisuals is ExcavatorTemplate:
    boom_swing becomes HeavyMachineBundle.MachineComponents.CraneSystemComponent:
        local_transform.position: {0,0,0}
        body.is_dynamic: false
    boom becomes HeavyMachineBundle.MachineComponents.CraneSystemComponent
    stick becomes HeavyMachineBundle.MachineComponents.CraneSystemComponent
    swing_boom_connection.boom_1_boom_2_connection.snap_hinge.initial_angle: 0.0
    boom_stick_connection.boom_1_boom_2_connection.snap_hinge.initial_angle: 0.0
