Running code on MiRo from PyCharm - MiRo-projects/MDK-Installation GitHub Wiki

If you have access to a MiRo robot then you can run code on the robot hardware from any platform instead of using Gazebo. This requires PyCharm Professional, which you are able to download for free as a University student.

Configure remote interpreter

First, you'll need to add the MiRo as a remote interpreter so that your code will execute on the robot instead of your computer.

  1. From Preferences, go to Project → Project Interpreter
  2. In the Project Interpreter window, select Show all… and add a new interpreter
  3. Choose 'SSH Interpreter' and enter the IP address and username ('miro') of the MiRo robot. Hit 'Next', enter the password (also 'miro'), and leave other options as default.

pycharm_add-interpreter

Configure deployment

As you're using a remote interpreter you'll need to upload your code to the robot after you've made changes. The easiest way to do this is to go to Preferences → Deployment → Options and ensure that 'Upload changed filed automatically…' is set to 'Always'.

pycharm_deployment

Alternatively, if this proves to be an annoyance you can set it to 'Never' and upload your code manually by right-clicking the file(s) in PyCharm's Project pane and selecting Deployment → Upload to…

Run configurations

Finally, you'll need to set the parameters for running your code.

  1. Press the 'Add Configuration' button near the top-right of the PyCharm window, or 'Edit Configurations…' from the dropdown if you've set up previous run configurations.

  2. Under Templates, select Python and click the 'Browse' button at the right of the 'Environment variables' text box to set up the variables to be used in all run configurations. Copy all the variables from this page and paste them into the top half of the window with the button that looks like a clipboard. pycharm_variables Note that you will have to update MIRO_STATIC_IP, MIRO_ROBOT_NAME, and ROS_IP according to your specific robot and network settings. You should be able to find these using the Android MiRoAPP, and MiRo should also announce its IP address upon booting up. Also make sure that 'Python interpreter' is set to use the remote interpreter you just configured.

  3. Add a new Python configuration, and it should inherit the default settings you just set up. Set 'Script path' to point to the code you want to run on MiRo, and click 'OK' to exit the window.

Running this configuration should now run your code directly on the robot.

Create a compound configuration (Demo code only)

Running the demo code requires running three instances of client_demo.py. PyCharm can be configured to do this as well.

In the Run/Debug Configurations window, add three 'Python' configurations. All three should point to the client_demo.py file, and two of them should have either - caml or - camr entered in the 'Parameters' field - note there must be a space before and after the hyphen.

pycharm_config-caml

Now add a new 'Compound' configuration. Here you can select and add each of the three individual configurations you just set up (the order shouldn't matter). This compound configuration will show up in the configuration selector in the top-right of the main PyCharm window, and running it will execute three copies of client_demo.py on the robot to start the demo code.

pycharm_config-compound