Home Community Blog Buy Now
Blog

Misty Community Forum

MoveHead in .NET throwing MissingMethodException

Hi,

I’m new to development on Misty II (working on her for a school project) and am having some issues with getting some basic .NET API calls to work. I was able to successfully deploy and run the “MostlyHarmlessSkill” from the IntroSkills in the Misty Git Repo. However, when I tried to run the HelloWorldSkill, I ran into this MissingMethodException on both MoveHead and DisplayImage.

I added a simple try/catch block to the MostlyHarmlessSkill that included a call to the MoveHead function as seen here (the rest of the code is unchanged from the repository):

	public void OnStart(object sender, IDictionary<string, object> parameters)
	{
		_misty.SkillLogger.LogVerbose($"MostlyHarmlessSkill : OnStart called => Start a loop to change the LED every 250 ms");

		Random randomGenerator = new Random();

		//Pause for 100 ms, if the cancellation token is set during this time, exit the pause and the method

		try
		{
			_misty.MoveHead(45, 25, 0, 50, AngularUnit.Degrees, null);
		}
		catch(Exception ex)
		{
			_misty.SkillLogger.Log($"HelloWorldSkill : OnStart: => Exception", ex);
		}

		while (_misty.Wait(100))
		{
			_misty.ChangeLED((uint)randomGenerator.Next(0, 256), (uint)randomGenerator.Next(0, 256), (uint)randomGenerator.Next(0, 256), null);

		}
	}

Here is the log getting dropped on Misty’s filesystem:

Skill Test Run #1 =>  09/21/2020 04:27:59.268 AM => Connection established with the robot, registering for messages.
Skill Test Run #1 =>  09/21/2020 04:28:01.659 AM => Skill 'MostlyHarmlessSkill' connected to robot using RobotMessenger adapter
Skill Test Run #1 =>  09/21/2020 04:28:01.703 AM => Connecting to robot system events
Skill Test Run #1 =>  09/21/2020 04:29:04.804 AM => Connection established with the robot, registering for messages.
Skill Test Run #1 =>  09/21/2020 04:29:04.808 AM => Skill 'MostlyHarmlessSkill' connected to robot using RobotMessenger adapter
Skill Test Run #1 =>  09/21/2020 04:29:04.809 AM => Connecting to robot system events
Skill Test Run #1 =>  09/21/2020 04:29:05.203 AM => ProcessStartSkill called for 'MostlyHarmlessSkill'
Skill Test Run #1 =>  09/21/2020 04:29:05.467 AM => Starting skill cancellation timer for 'MostlyHarmlessSkill' for 600 seconds.
Skill Test Run #1 =>  09/21/2020 04:29:05.470 AM => Failed to start skill.
==> Exception: System.MissingMethodException: Method not found: 'Void MistyRobotics.SDK.Messengers.IRobotMessenger.MoveHead(Double, Double, Double, Double, MistyRobotics.Common.Types.AngularUnit, MistyRobotics.SDK.Messengers.ProcessCommandResponse)'.
   at SkillLibrary.MostlyHarmlessSkill.OnStart(Object sender, IDictionary`2 parameters)
   at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
   at MistyRobotics.SDK.Messengers.RobotMessenger.ProcessStartSkill(Object sender, IDictionary`2 parameters)
Skill Test Run #1 =>  09/21/2020 04:29:34.383 AM => Starting cancellation of skill 'MostlyHarmlessSkill'
Skill Test Run #1 =>  09/21/2020 04:29:34.386 AM => MostlyHarmlessSkill : OnCancel called => Change LED to Red
Skill Test Run #1 =>  09/21/2020 04:29:35.285 AM => Command Roundtrip: 664 ms - ChangeLED
Skill Test Run #1 =>  09/21/2020 04:29:36.597 AM => Skill has been cancelled, paused or has timed out.
Skill Test Run #1 =>  09/21/2020 04:29:36.611 AM => Shutdown task called - completing task deferral and shutting down 'MostlyHarmlessSkill'.

Any help you can provide is very appreciated!

Tyler F

It looks like that skill was built using an older version of the nuget package, previously there were only 4 double parameters for C#: roll, pitch, yaw, velocity. In Robot version 1.8.8 and nuget package version 0.9.173 a fifth double parameter was added to match all other API calls: roll, pitch, yaw, velocity, and duration. This can be fixed in that skill by adding in a null value prior to the AngularUnits. So _misty.MoveHead(45, 25, 0, 50, AngularUnit.Degrees, null); would become _misty.MoveHead(45, 25, 0, 50, null, AngularUnit.Degrees, null);