/// <summary> /// Loop through some head, arm, image and led actions /// </summary> /// <param name="parameters"></param> public void OnStart(object sender, IDictionary <string, object> parameters) { try { //These calls assume system assets on the robot at the time of writing, //update as needed for new or different assets or as an exercise to allow user to pass in asset names :) //This loop could also be accomplished with a timed callback while (_misty.Wait(5000)) { _misty.PlayAudio("s_Acceptance.wav", 100, null); _misty.MoveHead(45, 25, 0, 50, AngularUnit.Degrees, null); _misty.MoveArms(0, 45, 25, 60, null, AngularUnit.Degrees, null); _misty.ChangeLED(0, 255, 0, null); _misty.DisplayImage("e_Disoriented.jpg", 1, null); //Pause for 4 seconds, if the cancellation token is set during this time, exit the pause and the method if (!_misty.Wait(4000)) { return; } _misty.PlayAudio("s_Awe2.wav", 100, null); _misty.MoveHead(-10, 15, 30, 50, AngularUnit.Degrees, null); _misty.MoveArms(-45, 0, 60, 60, null, AngularUnit.Degrees, null); _misty.ChangeLED(0, 255, 255, null); _misty.DisplayImage("e_ContentRight.jpg", 1, null); //Pause for 3.5 seconds, if the cancellation token is set during this time, exit the pause and the method if (!_misty.Wait(3500)) { return; } _misty.PlayAudio("s_Joy.wav", 100, null); _misty.MoveHead(75, 25, 10, 50, AngularUnit.Degrees, null); _misty.MoveArms(-45, 45, 60, 60, null, AngularUnit.Degrees, null); _misty.ChangeLED(255, 255, 255, null); _misty.DisplayImage("e_ContentLeft.jpg", 1, null); //Pause for 2.5 seconds, if the cancellation token is set during this time, exit the pause and the method if (!_misty.Wait(2500)) { return; } _misty.PlayAudio("s_Joy.wav", 100, null); _misty.MoveHead(65, 0, -10, 50, AngularUnit.Degrees, null); _misty.MoveArms(0, -45, 60, 60, null, AngularUnit.Degrees, null); _misty.ChangeLED(0, 0, 255, null); _misty.DisplayImage("e_Joy.jpg", 1, null); } } catch (Exception ex) { _misty.SkillLogger.Log($"HelloAgainWorldSkill : OnStart: => Exception", ex); } }
private void MoveArmCallback(object info) { _misty.MoveArms(_randomGenerator.Next(-90, 90), _randomGenerator.Next(-90, 90), 100, 100, null, AngularUnit.Degrees, null); }
private void ProcessQueryResult(object sender, string stringResult) { JObject dynamicResponse = JObject.Parse(stringResult); string color = ((string)dynamicResponse["queryResult"]?["parameters"]?["Color"])?.ToLower(); string position = ((string)dynamicResponse["queryResult"]?["parameters"]?["Direction"])?.ToLower(); string outputAudioString = (string)dynamicResponse["outputAudio"]; byte[] outputAudio = Convert.FromBase64String(outputAudioString); try { JsonConverter[] converters = new JsonConverter[2] { new ProtoByteStringConverter(), new OutputAudioEncodingConverter() }; DetectIntentResponse response = JsonConvert.DeserializeObject <DetectIntentResponse>(stringResult, converters); string intent = response?.QueryResult?.Intent?.DisplayName; string defaultResponse = response?.QueryResult?.FulfillmentText; switch (intent) { case "ChangeLED": if (color != null) { Color argbColor = Color.FromName(color); _misty.ChangeLED(argbColor.R, argbColor.G, argbColor.B, null); } break; case "Joke": _misty.PlayAudio(defaultResponse, 30, null); break; case "Move your arms": if (position == "up") { _misty.MoveArms(-90, -90, 50, 50, null, AngularUnit.Degrees, null); } if (position == "down") { _misty.MoveArms(90, 90, 50, 50, null, AngularUnit.Degrees, null); } _misty.Halt(null, null); break; case "MoveHeadPosition": if (position == "up") { _misty.MoveHead(-100, 0, 0, 50, AngularUnit.Degrees, null); } if (position == "down") { _misty.MoveHead(100, 0, 0, 50, AngularUnit.Degrees, null); } if (position == "right") { _misty.MoveHead(0, 0, -100, 50, AngularUnit.Degrees, null); } if (position == "left") { _misty.MoveHead(0, 0, 100, 50, AngularUnit.Degrees, null); } break; default: _misty.SaveAudio("tts.wav", outputAudio, true, true, null); break; } } catch (Exception ex) { } }
public void MoveArmCallback(object timerData) { _misty.MoveArms(_randomGenerator.Next(MinimumArmDegreesInclusive, MaximumArmDegreesExclusive), _randomGenerator.Next(MinimumArmDegreesInclusive, MaximumArmDegreesExclusive), _randomGenerator.Next(MinimumArmSpeedInclusive, MaximumArmSpeedExclusive), _randomGenerator.Next(MinimumArmSpeedInclusive, MaximumArmSpeedExclusive), null, AngularUnit.Degrees, null); }
/// <summary> /// Called on the timer tick to send a random move arm command to the robot /// </summary> /// <param name="info"></param> public void MoveArmCallback(object info) { _misty.MoveArms(_randomGenerator.Next(-90, 90), _randomGenerator.Next(-90, 90), _randomGenerator.Next(10, 40), _randomGenerator.Next(10, 40), null, AngularUnit.Degrees, null); }