Example #1
0
    void Update()
    {
        // check for robot movement
        RobotController robotController = robot.GetComponent <RobotController>();

        for (int i = 0; i < robotController.joints.Length; i++)
        {
            float inputVal = Input.GetAxis(robotController.joints[i].inputAxis);
            if (Mathf.Abs(inputVal) > 0)
            {
                RotationDirection direction = GetRotationDirection(inputVal);
                robotController.RotateJoint(i, direction);
                return;
            }
        }
        robotController.StopAllJointRotations();

        //check for robot reset
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("Pressed reset!");
            float[] defaultRotations = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
            robotController.ForceJointsToRotations(defaultRotations);
        }
    }
    // AGENT

    public override void OnEpisodeBegin()
    {
        //float[] defaultRotations = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
        float[] defaultRotations = { 0.0f, 0.0f, -91.5f, 0.0f, 40.8f, -90.0f, 0.0f };
        robotController.ForceJointsToRotations(defaultRotations);
        touchDetector.hasTouchedTarget = false;
        pinchDetector.hasPinchedTarget = false; // Added
        tablePositionRandomizer.Move();

        Debug.Log(Vector3.Distance(robot.transform.position, pincherController.CurrentGraspCenter()));
        Debug.Log("CurrentGraspCenter: " + pincherController.CurrentGraspCenter());
    }