// Update is called once per frame
    void Update()
    {
        robotEnable.IsStateLocked = !zmqClient.isComms() && !enableWithoutComms;

        if (pastZMQIsComms != zmqClient.isComms())
        {
            robotEnable.SetRobotState(false);
        }

        robotState = robotEnable.RobotState;

        if (robotState)
        {
            if (!pastRobotState)
            {
                robotMode.SetDropdownLockState(true);
                robotRigidbody.isKinematic = false;
            }

            SetPacketRobotMode(robotMode.RobotState + 1);
        }
        else
        {
            offsetTime = Time.time;

            if (pastRobotState)
            {
                if (!lockRobotMode)
                {
                    robotMode.SetDropdownLockState(false);
                }
                softReset();
            }

            if (zmqClient.isComms())
            {
                zmqClient.zmqThread.unityPacket.robotMode = 0;
            }

            SetPacketRobotMode(0);
        }

        pastRobotState = robotState;
        pastZMQIsComms = zmqClient.isComms();

        timeNow = Time.time - offsetTime;

        elapsedTime.text = "T+" + timeNow.ToString("000.0");
    }
    private void FixedUpdate()
    {
        if (!(zmqClient.zmqThread is null) && !(zmqClient.zmqThread.unityPacket is null) &&
            zmqClient.zmqThread.unityPacket.hardware.Count != hardware.Count)
        {
            zmqClient.unityPacket.hardware.Clear();

            zmqClient.unityPacket.hardware.AddRange(hardware);
        }

        if (zmqClient.isComms())
        {
            for (int i = 0; i < hardware.Count; i++)
            {
                // TODO: Fix indexOutOfBoundsException, likely has to do with multithreading
                try
                {
                    hardware[i].CopyRelValues(zmqClient.zmqThread.robotPacket.hardware[i]);
                }
                catch
                {
                    return;
                }
            }

            zmqClient.zmqThread.unityPacket.hardware = this.hardware;
        }
    }
示例#3
0
 private void Update()
 {
     if (zmqClient.isComms())
     {
         RawImage.color = Green;
     }
     else
     {
         RawImage.color = Red;
     }
 }
示例#4
0
    private void Update()
    {
        robotEnable.YellowMode = !zmqClient.isComms();

        if (zmqClient.isComms())
        {
            return;
        }

        if (simpleDriveEnabled && robotEnable.RobotState)
        {
            float linearPower = drivebaseController.maxMotorTorque * Input.GetAxis("Vertical");
            float turnPower   = 0.5f * drivebaseController.maxSteeringPower * Input.GetAxis("Horizontal");

            drivebaseController.ArcadeDrive(linearPower, turnPower);
        }
        else
        {
            drivebaseController.TankDrive(0f, 0f);
        }
    }
示例#5
0
    // Update is called once per frame
    void Update()
    {
        if (zmqClient.isComms())
        {
            commsStatusImage.color = green;
        }
        else
        {
            commsStatusImage.color = red;
        }

        if (Input.GetJoystickNames().Length == 0 || Input.GetJoystickNames()[0].Equals(""))
        {
            joyStatusImage.color = red;
        }
        else
        {
            joyStatusImage.color = green;
        }

        if (Input.GetKeyDown(KeyCode.Space) && (zmqClient.isComms()))// || drivebase.simpleDriveEnabled))
        {
            robotState = !robotState;
        }

        if (pastZMQIsComms != zmqClient.isComms())
        {
            robotState = false;
        }

        if (robotState)
        {
            if (!pastRobotState)
            {
                robotRigidbody.isKinematic = false;
            }
            enableArea.color = green;
            enableText.text  = "Disable";
            if (zmqClient.isComms())
            {
                zmqClient.zmqThread.unityPacket.robotMode = robotMode + 1;
            }
        }
        else
        {
            offsetTime = Time.time;
            if (pastRobotState)
            {
                softReset();
                //SceneManager.LoadScene(SceneManager.GetActiveScene().name, LoadSceneMode.Single);
            }
            enableArea.color = red;
            enableText.text  = "Enable";
            if (zmqClient.isComms())
            {
                zmqClient.zmqThread.unityPacket.robotMode = 0;
            }
        }

        if (modeChangingEnabled)
        {
            arrowTop.enabled          = true;
            modeCover.enabled         = false;
            modeDropdown.interactable = true;
        }
        else
        {
            arrowTop.enabled          = false;
            modeCover.enabled         = true;
            modeDropdown.interactable = false;
        }

        if (!modeChangingLock)
        {
            modeChangingEnabled = !robotState;
        }

        pastRobotState = robotState;
        pastZMQIsComms = zmqClient.isComms();

        timeNow = Time.time - offsetTime;

        elapsedTime.text = "Elapsed Time " + timeNow.ToString("000.0");
    }