private void OnCarGameBtnClick()
    {
        isCarGame           = false;
        timerInit           = new System.Timers.Timer();
        timerInit.Interval  = 10000;        //Wait for 10 seconds
        timerInit.Elapsed  += CarGameStart; //Hook up the elapsed event for the timer
        timerInit.AutoReset = false;        //Have the timer fire repeated events(true is the default)
        timerInit.Enabled   = false;
        timerInit.Start();

        float M2_SIZE_X = (float)(0.551 + 0.022) / 2;

        DynaLinkHS.CmdPassiveMovementControl((-0.022f + 0.551f) / 2, (0.02f + 0.2417f) / 2, (float)0.05);
    }
Ejemplo n.º 2
0
    public static void Cmd2Robot()
    {
        // CMD: M2 move to starting point
        string taskPointKey = SetYaml.taskNames[blockNum];

        float[] taskPointValue = new float[2];
        SetYaml.startPointDic.TryGetValue(taskPointKey, out taskPointValue);
        print(taskPointKey);
        DynaLinkHS.CmdPassiveMovementControl(taskPointValue[0], taskPointValue[1], (float)0.08);

        timeLine += Time.deltaTime;
        csvContent.AppendLine((float)timeLine + "," + trials + "," + "CMDM2Reset" + "," + DynaLinkHS.StatusRobot.PositionDataJoint1 + "," + DynaLinkHS.StatusRobot.PositionDataJoint2);
        RunFSM.currState = RunFSM.GameState_Enum.STATE_MOVE2START;

        RunFSM.EMG.StartRecording();// start record sEMG
    }
Ejemplo n.º 3
0
// Use this for initialization
    void Start()
    {
        DynaLinkHS.CmdTransparentControl(5f, 5f, 10f, 10f, 10f, 10f, 10f, 10f);
        //DynaLinkHS.CmdServoOff();

        ///*
        // Initiate Hand Effector Position
        ///*
        screenSize = Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height)); // 尺寸的一半
        print(screenSize);                                                                     // screen size
        float M2_SIZE_X = (M2_AXIS_X[1] - M2_AXIS_X[0]) / 2;
        float M2_SIZE_Y = (M2_AXIS_Y[1] - M2_AXIS_Y[0]) / 2;

        xOffset = (screenSize.x) / M2_SIZE_X;
        yOffset = (screenSize.y) / M2_SIZE_Y;
        DynaLinkHS.CmdPassiveMovementControl((M2_AXIS_X[1] + M2_AXIS_X[0]) / 2, (M2_AXIS_Y[1] + M2_AXIS_Y[0]) / 2, (float)0.05);

        ///*
        // Initiate Control Mode(mass/damping/spring)
        /// for M2, the parameters are
        ///     - origin/target position x [原始/目标位置 x 轴] (type : float, unit : m, range : )
        ///     - origin/target position y [原始/目标位置 y 轴] (type : float, unit : m, range : )
        ///     - M (mass) x [模拟质量 x 轴] (type : float, unit : kg, range : )
        ///     - M (mass) y [模拟质量 y 轴] (type : float, unit : kg, range : )
        ///     - B (damping) x [模拟阻尼 x 轴] (type : float, unit : N/(m/s), range : )
        ///     - B (damping) y [模拟阻尼 y 轴] (type : float, unit : N/(m/s), range : )
        ///     - K (spring) x [模拟弹簧 x 轴] (type : float, unit : N/m, range : )
        ///     - K (spring) y [模拟弹簧 y 轴] (type : float, unit : N/m, range : )
        ///*

        ///*
        ///  Renew/Load .yaml
        ///*

        //SetYaml.IniTaskInfo();// initiate .yaml
        SetYaml.LoadTaskInfo();// load .yaml

        timerStart           = new Timer();
        timerStart.Interval  = 10000;     //Wait for 10 seconds
        timerStart.Elapsed  += GameStart; //Hook up the elapsed event for the timer
        timerStart.AutoReset = false;     //Have the timer fire repeated events(true is the default)
        timerStart.Enabled   = false;
        timerStart.Start();
    }