コード例 #1
0
        public override void Start()
        {
            if (currentID != -1)
            {
                return;
            }

            var response = connection.execute(command).Trim();

            try
            {
                currentID = int.Parse(response);
            }
            catch (FormatException)
            {
                currentID = -1;
            }
        }
コード例 #2
0
        public override void Start()
        {
            if (active)
            {
                return;
            }

            active = true;

            WalkControl.x_speed   += this.deltaSpeed;
            WalkControl.stepAngle += this.deltaAngle;
            WalkControl.frequency += this.deltaFrequency;

            connection.execute("motion.setWalkArmsEnabled(True, True)");

            var command = String.Format("motion.setWalkTargetVelocity({0}, 0, {1}, {2})", toString(WalkControl.x_speed), toString(WalkControl.stepAngle), toString(WalkControl.frequency));

            connection.execute(command);
        }
コード例 #3
0
 protected void say(string msg)
 {
     if (msg.Contains("\""))
     {
         throw new ArgumentException("The message must not contain quotes!");
     }
     commandConnection.execute(String.Format("tts.post.say(\"{0}\")", msg));
 }
コード例 #4
0
    protected void OnConnectionToggleToggled(object sender, EventArgs e)
    {
        bool active = connectionToggle.Active;

        if (active)
        {
            commandConnection = new PythonConnection(ipEntry.Text, userNameEntry.Text, passwordEntry.Text);

            // Open a separate data connection:
            // Has to be done before sending prep_code.py as it defines necessary variables for prep_code.py
            videoChannel = new InputChannel(commandConnection, ipEntry.Text, 4711);

            using (var sr = new System.IO.StreamReader("prep_code.py"))
            {
                String line;
                while ((line = sr.ReadLine()) != null)
                {
                    commandConnection.execute(line);
                }
            }
        }
        else
        {
            controlToggle.Active = false;
            cameraToggle.Active  = false;
            commandConnection.execute("close()");
            commandConnection.Dispose();
            videoChannel.Dispose();
            commandConnection = null;
            videoChannel      = null;
        }

        stiffnessToggle.Sensitive = active;
        cameraToggle.Sensitive    = active;
        ttsButton.Sensitive       = active;

        ipEntry.Sensitive       = !active;
        userNameEntry.Sensitive = !active;
        passwordEntry.Sensitive = !active;
    }