示例#1
0
    public void Init(capture1 device)
    {
        GetComponent <Rigidbody>().mass       = device.config.ClampMass / 2;
        GetComponent <Rigidbody>().useGravity = device.config.UseGravity;

        transform.localScale = new Vector3(device.config.ClampDiameter, device.config.ClampWidth / 2 / CylinderFullHeight, device.config.ClampDiameter);
        transform.position   = pivotObject.transform.rotation * Quaternion.AngleAxis(90, Vector3.back) * (Vector3.down * (device.config.ClamphingeDiameter / 2 + device.config.ClampWidth / 2 / 2)) + pivotObject.transform.position;
        transform.rotation   = pivotObject.transform.rotation * Quaternion.AngleAxis(90, Vector3.back);

        joint.Config(pivotObject, gameObject, device.config.ClampConnectorKinematic, JointPhysics.Fixed);
    }
示例#2
0
    public void Init(capture1 device)
    {
        GetComponent <Rigidbody>().mass       = device.config.ArmMass;
        GetComponent <Rigidbody>().useGravity = device.config.UseGravity;

        transform.localScale = new Vector3(device.config.ArmDiameter, device.config.ArmLength / CylinderFullHeight, device.config.ArmDiameter);
        transform.position   = pivotObject.transform.rotation * (Vector3.down * (device.config.ConnectorWidth / 4 + device.config.ArmLength / 2)) + pivotObject.transform.position;
        transform.rotation   = pivotObject.transform.rotation;

        joint.Config(pivotObject, gameObject, device.config.ArmKinematic, JointPhysics.Fixed);
    }
示例#3
0
    public void Init(capture1 device)
    {
        GetComponent <Rigidbody>().mass       = device.config.ConnectorMass / 2;
        GetComponent <Rigidbody>().useGravity = device.config.UseGravity;

        transform.localScale = new Vector3(device.config.ConnectorDiameter, device.config.ConnectorWidth / 2 / CylinderFullHeight, device.config.ConnectorDiameter);
        Vector3 ofs = device.pivot.rotation * Vector3.down * device.config.ConnectorWidth / 4;

        transform.position = device.pivot.Object.transform.rotation * (device.pivot.position + ofs) + device.pivot.Object.transform.position;
        transform.rotation = device.pivot.Object.transform.rotation * device.pivot.rotation;

        joint.Config(device.pivot.Object, gameObject, device.config.ArmKinematic, JointPhysics.Fixed);
    }
示例#4
0
    public override void Remove()
    {
        MonoBehaviour.Destroy(chassis);
        MonoBehaviour.Destroy(rotatingplatform);
        MonoBehaviour.Destroy(leverhinge);
        MonoBehaviour.Destroy(lever);
        MonoBehaviour.Destroy(armhinge);
        MonoBehaviour.Destroy(arm);
        MonoBehaviour.Destroy(holder1);
        MonoBehaviour.Destroy(wheelhinge1);
        MonoBehaviour.Destroy(wheel1);
        MonoBehaviour.Destroy(leverhinge1);
        MonoBehaviour.Destroy(lever1);
        MonoBehaviour.Destroy(armhinge1);
        MonoBehaviour.Destroy(holder2);
        MonoBehaviour.Destroy(wheelhinge2);
        MonoBehaviour.Destroy(wheel2);

        capture.Remove();
        for (int i = 0; i < fingers.Count; i++)
        {
            fingers[i].Remove();
        }

        isinited         = false;
        chassis          = null;
        rotatingplatform = null;
        leverhinge       = null;
        lever            = null;
        armhinge         = null;
        arm         = null;
        holder1     = null;
        wheelhinge1 = null;
        wheel1      = null;
        leverhinge1 = null;
        lever1      = null;
        armhinge1   = null;
        holder2     = null;
        wheelhinge2 = null;
        wheel2      = null;

        capture = null;
        fingers.Clear();
    }
示例#5
0
    public void Init(capture1 device)
    {
        GetComponent <Rigidbody>().mass       = device.config.ClampMass / 2;
        GetComponent <Rigidbody>().useGravity = device.config.UseGravity;

        transform.localScale = new Vector3(device.config.ClampDiameter, device.config.ClampWidth / 2 / CylinderFullHeight, device.config.ClampDiameter);
        transform.position   = pivotObject.transform.rotation * (Vector3.down * device.config.ClampWidth / 2) + pivotObject.transform.position;
        transform.rotation   = pivotObject.transform.rotation;

        joint.Config(pivotObject, gameObject, device.config.ClampConnectorKinematic, JointPhysics.Hinge);

        drive.KinematicAngularVelocity = device.config.ClampConnectorKinematicAngularVelocity;
        drive.Proportional             = device.config.ClampConnectorACSProportional;
        drive.Integral     = device.config.ClampConnectorACSIntegral;
        drive.Differential = device.config.ClampConnectorACSDifferential;
        drive.Attach(joint);
        drive.AngleRange.SetLimits(device.config.ClampConnectorAngle0, device.config.ClampConnectorAngle1);
        drive.AngleRange.SetTarget(device.config.ClampConnectorAngle0);
    }
示例#6
0
    public override void Place()
    {
        if (!isinited)
        {
            chassis          = GameObject.Instantiate(Resources.Load("manipulator2/chassis", typeof(GameObject)) as GameObject);
            rotatingplatform = GameObject.Instantiate(Resources.Load("manipulator2/rotatingplatform", typeof(GameObject)) as GameObject);
            leverhinge       = GameObject.Instantiate(Resources.Load("manipulator2/leverhinge", typeof(GameObject)) as GameObject);
            lever            = GameObject.Instantiate(Resources.Load("manipulator2/lever", typeof(GameObject)) as GameObject);
            armhinge         = GameObject.Instantiate(Resources.Load("manipulator2/armhinge", typeof(GameObject)) as GameObject);
            arm         = GameObject.Instantiate(Resources.Load("manipulator2/arm", typeof(GameObject)) as GameObject);
            holder1     = GameObject.Instantiate(Resources.Load("manipulator2/holder1", typeof(GameObject)) as GameObject);
            wheelhinge1 = GameObject.Instantiate(Resources.Load("manipulator2/wheelhinge1", typeof(GameObject)) as GameObject);
            wheel1      = GameObject.Instantiate(Resources.Load("manipulator2/wheel1", typeof(GameObject)) as GameObject);
            leverhinge1 = GameObject.Instantiate(Resources.Load("manipulator2/leverhinge1", typeof(GameObject)) as GameObject);
            lever1      = GameObject.Instantiate(Resources.Load("manipulator2/lever1", typeof(GameObject)) as GameObject);
            armhinge1   = GameObject.Instantiate(Resources.Load("manipulator2/armhinge1", typeof(GameObject)) as GameObject);
            holder2     = GameObject.Instantiate(Resources.Load("manipulator2/holder2", typeof(GameObject)) as GameObject);
            wheelhinge2 = GameObject.Instantiate(Resources.Load("manipulator2/wheelhinge2", typeof(GameObject)) as GameObject);
            wheel2      = GameObject.Instantiate(Resources.Load("manipulator2/wheel2", typeof(GameObject)) as GameObject);

            chassis.GetComponent <HingeJoint>().connectedBody = rotatingplatform.GetComponent <Rigidbody>();
            rotatingplatform.GetComponents <FixedJoint>()[0].connectedBody = holder1.GetComponent <Rigidbody>();
            rotatingplatform.GetComponents <FixedJoint>()[1].connectedBody = holder2.GetComponent <Rigidbody>();
            leverhinge.GetComponent <FixedJoint>().connectedBody           = lever.GetComponent <Rigidbody>();
            lever.GetComponent <HingeJoint>().connectedBody       = armhinge.GetComponent <Rigidbody>();
            armhinge.GetComponent <FixedJoint>().connectedBody    = arm.GetComponent <Rigidbody>();
            arm.GetComponent <HingeJoint>().connectedBody         = armhinge1.GetComponent <Rigidbody>();
            holder1.GetComponent <HingeJoint>().connectedBody     = wheelhinge1.GetComponent <Rigidbody>();
            wheelhinge1.GetComponent <FixedJoint>().connectedBody = wheel1.GetComponent <Rigidbody>();
            wheel1.GetComponent <FixedJoint>().connectedBody      = leverhinge1.GetComponent <Rigidbody>();
            lever1.GetComponents <HingeJoint>()[0].connectedBody  = leverhinge1.GetComponent <Rigidbody>();
            lever1.GetComponents <HingeJoint>()[1].connectedBody  = armhinge1.GetComponent <Rigidbody>();
            holder2.GetComponent <HingeJoint>().connectedBody     = wheelhinge2.GetComponent <Rigidbody>();
            wheelhinge2.GetComponent <FixedJoint>().connectedBody = wheel2.GetComponent <Rigidbody>();
            wheel2.GetComponent <FixedJoint>().connectedBody      = leverhinge.GetComponent <Rigidbody>();

            armhinge.GetComponent <armhingemanipulator2>().wheel1object       = wheel1;
            armhinge.GetComponent <armhingemanipulator2>().armhinge1object    = armhinge1;
            leverhinge1.GetComponent <leverhinge1manipulator2>().lever1object = lever1;
            wheel1.GetComponent <wheel1manipulator2>().lever1object           = lever1;
            wheel1.GetComponent <wheel1manipulator2>().rotatingplatformobject = rotatingplatform;
            wheel2.GetComponent <wheel2manipulator2>().leverobject            = lever;
            wheel2.GetComponent <wheel2manipulator2>().rotatingplatformobject = rotatingplatform;

            capture = new capture1();
            for (int i = 0; i < 4; i++)
            {
                fingers.Add(new finger1());
            }

            isinited = true;
        }

        {
            var b = chassis.GetComponent <chassismanipulator2>();
            b.capture            = capture;
            b.fingers            = fingers;
            b.drive.Proportional = config.RotatingplatformACSProportional;
            b.drive.Integral     = config.RotatingplatformACSIntegral;
            b.drive.Differential = config.RotatingplatformACSDifferential;
            b.x      = config.x;
            b.y      = config.y;
            b.z      = config.z;
            b.angle  = config.angle;
            b.height = config.ChassisHeight;
            b.width  = config.ChassisWidth;
            b.angle0 = config.RotatingplatformAngle0;
            b.angle1 = config.RotatingplatformAngle1;
        }

        {
            rotatingplatform.GetComponent <Rigidbody>().mass = config.RotatingplatformMass;
            var b = rotatingplatform.GetComponent <rotatingplatformmanipulator2>();
            b.diameter = config.RotatingplatformDiameter;
            b.width    = config.RotatingplatformWidth / 2;/*div 2 for cylinder*/
        }

        {
            leverhinge.GetComponent <Rigidbody>().mass = config.LeverhingeMass;
            var b = leverhinge.GetComponent <leverhingemanipulator2>();
            b.diameter = config.LeverhingeDiameter;
        }

        {
            lever.GetComponent <Rigidbody>().mass = config.LeverMass;
            var b = lever.GetComponent <levermanipulator2>();
            b.drive.Proportional = config.ArmACSProportional;
            b.drive.Integral     = config.ArmACSIntegral;
            b.drive.Differential = config.ArmACSDifferential;
            b.width  = config.LeverWidth;
            b.length = config.LeverLength;
            b.angle0 = config.ArmAngle0;
            b.angle1 = config.ArmAngle1;
        }

        {
            armhinge.GetComponent <Rigidbody>().mass = config.ArmhingeMass;
            var b = armhinge.GetComponent <armhingemanipulator2>();
            b.diameter = config.ArmhingeDiameter;
            b.width    = config.ArmhingeWidth / 2;/*div 2 for cylinder*/
        }

        {
            arm.GetComponent <Rigidbody>().mass = config.ArmMass;
            var b = arm.GetComponent <armmanipulator2>();
            b.width  = config.ArmWidth;
            b.length = config.ArmLength;
        }

        {
            holder1.GetComponent <Rigidbody>().mass = config.HolderMass;
            var b = holder1.GetComponent <holder1manipulator2>();
            b.drive.Proportional = config.ArmACSProportional;
            b.drive.Integral     = config.ArmACSIntegral;
            b.drive.Differential = config.ArmACSDifferential;
            b.width  = config.HolderWidth;
            b.length = config.HolderLength;
            b.offset = config.HoldersDistance / 2;
            b.angle0 = config.ArmAngle0 + config.LeverAngle0;
            b.angle1 = config.ArmAngle1 + config.LeverAngle1;
        }

        {
            wheelhinge1.GetComponent <Rigidbody>().mass = config.WheelhingeMass;
            var b = wheelhinge1.GetComponent <wheelhinge1manipulator2>();
            b.diameter = config.LeverhingeDiameter;
            b.width    = config.WheelhingeWidth / 2;/*div 2 for cylinder*/
        }

        {
            wheel1.GetComponent <Rigidbody>().mass = config.WheelMass;
            var b = wheel1.GetComponent <wheel1manipulator2>();
            b.diameter = config.WheelDiameter;
            b.width    = config.WheelWidth / 2;/*div 2 for cylinder*/
            b.lever    = config.WheelLever;
        }

        {
            leverhinge1.GetComponent <Rigidbody>().mass = config.LeverhingeMass;
            var b = leverhinge1.GetComponent <leverhinge1manipulator2>();
            b.diameter = config.LeverhingeDiameter;
        }

        {
            lever1.GetComponent <Rigidbody>().mass = config.LeverMass;
            var b = lever1.GetComponent <lever1manipulator2>();
            b.width  = config.LeverWidth;
            b.length = config.LeverLength;
        }

        {
            armhinge1.GetComponent <Rigidbody>().mass = config.ArmhingeMass;
            var b = armhinge1.GetComponent <armhinge1manipulator2>();
            b.diameter = config.ArmhingeDiameter;
            b.width    = config.ArmhingeWidth / 2;/*div 2 for cylinder*/
        }

        {
            holder2.GetComponent <Rigidbody>().mass = config.HolderMass;
            var b = holder2.GetComponent <holder2manipulator2>();
            b.drive.Proportional = config.LeverACSProportional;
            b.drive.Integral     = config.LeverACSIntegral;
            b.drive.Differential = config.LeverACSDifferential;
            b.width  = config.HolderWidth;
            b.length = config.HolderLength;
            b.offset = config.HoldersDistance / 2;
            b.angle0 = config.LeverAngle0;
            b.angle1 = config.LeverAngle1;
        }

        {
            wheelhinge2.GetComponent <Rigidbody>().mass = config.WheelhingeMass;
            var b = wheelhinge2.GetComponent <wheelhinge2manipulator2>();
            b.diameter = config.LeverhingeDiameter;
            b.width    = config.WheelhingeWidth / 2;/*div 2 for cylinder*/
        }

        {
            wheel2.GetComponent <Rigidbody>().mass = config.WheelMass;
            var b = wheel2.GetComponent <wheel2manipulator2>();
            b.diameter = config.WheelDiameter;
            b.width    = config.WheelWidth / 2;/*div 2 for cylinder*/
        }

        chassis.GetComponent <Rigidbody>().useGravity          = false;
        rotatingplatform.GetComponent <Rigidbody>().useGravity = config.UseGravity;
        leverhinge.GetComponent <Rigidbody>().useGravity       = config.UseGravity;
        lever.GetComponent <Rigidbody>().useGravity            = config.UseGravity;
        armhinge.GetComponent <Rigidbody>().useGravity         = config.UseGravity;
        arm.GetComponent <Rigidbody>().useGravity         = config.UseGravity;
        holder1.GetComponent <Rigidbody>().useGravity     = config.UseGravity;
        wheelhinge1.GetComponent <Rigidbody>().useGravity = config.UseGravity;
        wheel1.GetComponent <Rigidbody>().useGravity      = config.UseGravity;
        leverhinge1.GetComponent <Rigidbody>().useGravity = config.UseGravity;
        lever1.GetComponent <Rigidbody>().useGravity      = config.UseGravity;
        holder2.GetComponent <Rigidbody>().useGravity     = config.UseGravity;
        wheelhinge2.GetComponent <Rigidbody>().useGravity = config.UseGravity;
        wheel2.GetComponent <Rigidbody>().useGravity      = config.UseGravity;

        chassis.GetComponent <Rigidbody>().isKinematic          = true;
        rotatingplatform.GetComponent <Rigidbody>().isKinematic = config.Kinematic;
        leverhinge.GetComponent <Rigidbody>().isKinematic       = config.Kinematic;
        lever.GetComponent <Rigidbody>().isKinematic            = config.Kinematic;
        armhinge.GetComponent <Rigidbody>().isKinematic         = config.Kinematic;
        arm.GetComponent <Rigidbody>().isKinematic         = config.Kinematic;
        holder1.GetComponent <Rigidbody>().isKinematic     = config.Kinematic;
        wheelhinge1.GetComponent <Rigidbody>().isKinematic = config.Kinematic;
        wheel1.GetComponent <Rigidbody>().isKinematic      = config.Kinematic;
        leverhinge1.GetComponent <Rigidbody>().isKinematic = config.Kinematic;
        lever1.GetComponent <Rigidbody>().isKinematic      = config.Kinematic;
        holder2.GetComponent <Rigidbody>().isKinematic     = config.Kinematic;
        wheelhinge2.GetComponent <Rigidbody>().isKinematic = config.Kinematic;
        wheel2.GetComponent <Rigidbody>().isKinematic      = config.Kinematic;

        chassis.GetComponent <chassismanipulator2>().Init();

        {
            capture.config.UseGravity                             = config.UseGravity;
            capture.config.ConnectorMass                          = config.CaptureConnectorMass;
            capture.config.ConnectorDiameter                      = config.CaptureConnectorDiameter;
            capture.config.ConnectorWidth                         = config.CaptureConnectorWidth;
            capture.config.ArmKinematic                           = config.Kinematic;
            capture.config.ArmMass                                = config.CaptureArmMass;
            capture.config.ArmKinematicAngularVelocity            = config.CaptureArmKinematicAngularVelocity;
            capture.config.ArmACSProportional                     = config.CaptureArmACSProportional;
            capture.config.ArmACSIntegral                         = config.CaptureArmACSIntegral;
            capture.config.ArmACSDifferential                     = config.CaptureArmACSDifferential;
            capture.config.ArmAngle0                              = config.CaptureArmAngle0;
            capture.config.ArmAngle1                              = config.CaptureArmAngle1;
            capture.config.ArmDiameter                            = config.CaptureArmDiameter;
            capture.config.ArmLength                              = config.CaptureArmLength;
            capture.config.ClamphingeMass                         = config.CaptureClamphingeMass;
            capture.config.ClamphingeDiameter                     = config.CaptureClamphingeDiameter;
            capture.config.ClamphingeWidth                        = config.CaptureClamphingeWidth;
            capture.config.ClampKinematic                         = config.Kinematic;
            capture.config.ClampMass                              = config.CaptureClampMass;
            capture.config.ClampKinematicAngularVelocity          = config.CaptureClampKinematicAngularVelocity;
            capture.config.ClampACSProportional                   = config.CaptureClampACSProportional;
            capture.config.ClampACSIntegral                       = config.CaptureClampACSIntegral;
            capture.config.ClampACSDifferential                   = config.CaptureClampACSDifferential;
            capture.config.ClampAngle0                            = config.CaptureClampAngle0;
            capture.config.ClampAngle1                            = config.CaptureClampAngle1;
            capture.config.ClampDiameter                          = config.CaptureClampDiameter;
            capture.config.ClampWidth                             = config.CaptureClampWidth;
            capture.config.ClampConnectorKinematicAngularVelocity = config.CaptureClampConnectorKinematicAngularVelocity;
            capture.config.ClampConnectorACSProportional          = config.CaptureClampConnectorACSProportional;
            capture.config.ClampConnectorACSIntegral              = config.CaptureClampConnectorACSIntegral;
            capture.config.ClampConnectorACSDifferential          = config.CaptureClampConnectorACSDifferential;
            capture.config.ClampConnectorAngle0                   = config.CaptureClampConnectorAngle0;
            capture.config.ClampConnectorAngle1                   = config.CaptureClampConnectorAngle1;
            capture.pivot.Object   = arm;
            capture.pivot.position = Vector3.up * arm.transform.localScale.y / 2;
            capture.pivot.rotation = Quaternion.AngleAxis(180, Vector3.forward) * Quaternion.AngleAxis(90, Vector3.down);
            capture.Place();
        }

        {
            for (int i = 0; i < fingers.Count; i++)
            {
                fingers[i].config.Kinematic       = config.FingerKinematic;
                fingers[i].config.ConnectorMass   = config.FingerConnectorMass;
                fingers[i].config.ConnectorHeight = config.FingerConnectorHeight;
                fingers[i].config.RibHeight       = config.FingerRibHeight;
                fingers[i].config.SectionMass     = config.FingerSectionMass;
                fingers[i].config.SectionHeight   = config.FingerSectionHeight;
                fingers[i].config.SectionWidth    = config.FingerSectionWidth;
                fingers[i].config.SectionThick    = config.FingerSectionThick;
                fingers[i].config.SectionKinematicAngularVelocity = config.FingerSectionKinematicAngularVelocity;
                fingers[i].config.SectionACSProportional          = config.FingerSectionACSProportional;
                fingers[i].config.SectionACSIntegral     = config.FingerSectionACSIntegral;
                fingers[i].config.SectionACSDifferential = config.FingerSectionACSDifferential;
                fingers[i].config.SectionAngle0          = config.FingerSectionAngle0;
                fingers[i].config.SectionAngle1          = config.FingerSectionAngle1;
                fingers[i].config.SectionCount           = config.FingerSectionCount;

                GameObject clamp = capture.GetClamp();

                fingers[i].pivot.Object = clamp;

                switch (i)
                {
                case 0:
                    fingers[i].pivot.position = Vector3.down * clamp.transform.localScale.y / 2 * clampcapture1.CylinderFullHeight +
                                                Vector3.left * (config.CaptureClampDiameter / 2 - fingers[i].config.SectionThick / 2);
                    fingers[i].pivot.rotation = Quaternion.identity;
                    break;

                case 1:
                    fingers[i].pivot.position = Vector3.down * clamp.transform.localScale.y / 2 * clampcapture1.CylinderFullHeight +
                                                Vector3.right * (config.CaptureClampDiameter / 2 - fingers[i].config.SectionThick / 2);
                    fingers[i].pivot.rotation = Quaternion.AngleAxis(180, Vector3.up);
                    break;

                case 2:
                    fingers[i].pivot.position = Vector3.down * clamp.transform.localScale.y / 2 * clampcapture1.CylinderFullHeight +
                                                Vector3.forward * (config.CaptureClampDiameter / 2 - fingers[i].config.SectionThick / 2);
                    fingers[i].pivot.rotation = Quaternion.AngleAxis(90, Vector3.up);
                    break;

                case 3:
                    fingers[i].pivot.position = Vector3.down * clamp.transform.localScale.y / 2 * clampcapture1.CylinderFullHeight +
                                                Vector3.back * (config.CaptureClampDiameter / 2 - fingers[i].config.SectionThick / 2);
                    fingers[i].pivot.rotation = Quaternion.AngleAxis(-90, Vector3.up);
                    break;
                }

                fingers[i].oncaught = OnCaught;

                fingers[i].Place();
            }
        }

        if (config.Kinematic)
        {
            kinematicanglerange0.SetLimits(config.RotatingplatformAngle0, config.RotatingplatformAngle1);
            kinematicanglerange1.SetLimits(config.LeverAngle0, config.LeverAngle1);
            kinematicanglerange2.SetLimits(-90 + config.ArmAngle0, -90 + config.ArmAngle1);
            kinematicanglerange0.SetTarget(config.RotatingplatformAngle0);
            kinematicanglerange1.SetTarget(config.LeverAngle0);
            kinematicanglerange2.SetTarget(-90 + config.ArmAngle0);
            chassis.GetComponent <chassismanipulator2>().rotatingplatformkinematicangularvelocity = config.KinematicAngularVelocity != 0 ? config.KinematicAngularVelocity : config.RotatingplatformKinematicAngularVelocity;
            chassis.GetComponent <chassismanipulator2>().leverkinematicangularvelocity            = config.KinematicAngularVelocity != 0 ? config.KinematicAngularVelocity : config.LeverKinematicAngularVelocity;
            chassis.GetComponent <chassismanipulator2>().armkinematicangularvelocity = config.KinematicAngularVelocity != 0 ? config.KinematicAngularVelocity : config.ArmKinematicAngularVelocity;
            chassis.GetComponent <chassismanipulator2>().Kinematic(kinematicanglerange0.GetTarget(), kinematicanglerange1.GetTarget(), kinematicanglerange2.GetTarget());
        }

        capture.SetPos(0, GetPos1() + GetPos2() - 180, GetPos5());//схват вниз
    }