Knowledge Base

Find user guides, support articles and FAQs to get started quickly and make the most of your Marty the Robot.

Marty Images



Table of Contents

Distance Sensor

This page will help you get started with Marty's distance sensor add on using the python library. Before we get started, make sure you have python installed and have set up your distance sensor.

Step 1

Import Martypy and establish connection to your Marty. Follow the code below to connect your Marty.

from martypy import Marty
my_marty = Marty("wifi", "192.168.0.42")  # Replace 192.168.0.42 by your Marty's IP

You should now be able to play with your distance sensor using the function below.

Let's Code!

The function get_distance_sensor() returns an integer of the distance of the closest object (in mm). Try this function using the code below:

my_marty.get_distance_sensor()