Writing a Myro3 program

From IPRE Wiki
Jump to: navigation, search

For more details, please see PyjamaDevelopment.


This tutorial explains how to get started writing your own Myro3 program. This tutorial assumes you are familiar with previous versions of Myro. Currently, I am writing this in C#, so that I know it's correct, but I believe this should translate to IronPython (IronPython tutorial coming soon :).

Look at a sample project

Open the project Demos\SimTestSuite. The interesting file to look at is Program.cs. As you can see, this is a small class with a ScribblerBrain member variable. ScribblerBrain is the class that you will talk to, and which implements the Myro3 API.

In the start() method, a new ScribblerBrain is created with

scribbler = new ScribblerBrain("Config\\IPRE.Scribbler.standard.config.xml");

This line tells the brain to use the config file corresponding to the real scribbler robot (not the simulation).

In Program.cs, the bumperLoop() method is an example of querying a sensor, and the driveLoop() method is an example of controlling the motors.

Additionally, the file TestPanel.cs provides more examples of controlling the robot and querying sensors, which is a simple matter of calling the appropriate methods on the RobotBrain object (which is the parent class of ScribblerBrain). The brain is passed in as a constructor argument when the TestPanel class is created.

Create your own project

In order to create your own Myro3 project, there are two steps you must take to make sure Visual Studio can find all the files:

  1. Add references to IPREFoundationClasses and MyroInterfaces
  2. Set the working directory of your project when it runs to your IPRE directory. The reason to do this is so that you can use relative config file paths, e.g. new ScribblerBrain("Config\\IPRE.Scribbler.standard.config.xml");.

After that, you should be able to use ScribblerBrain or RobotBrain in the same way described above.