Mantis Rover
  • 🔡Mantis Rover Documentation
  • Supported Devices
  • Assembly Guide
    • 📺Video Tutorials
    • 📰Printed Instructions
      • Wheel Assembly using Improved Coupler
    • 📺3D CAD Model
    • 📺3D Model File Download
    • 📺Packing Guide
    • 🚫General Care/Precautions
    • 🚫Charging your Rover
  • 3D Printing
    • 🐺Designing your Part (TinkerCAD)
    • 🐺MODi Adapter 3D Print
    • ⌚Printing your Part
  • PWM Control
    • 🤖PWM Controls-Scratch
    • 🚗PWM Setup-JavaScript
    • 🚗Man-In-The-Loop Obstacle Avoidance Tutorial-JavaScript
    • 🚕PWM Motor Drive-Python
  • MODI Sensor
    • Product Specification Sheet
    • Quick Start Guide
    • MODi Cart Experiment (Bonus)
    • 🤖MODi Data-Scratch
    • 🤖MODi CSV-Scratch
    • 🚗MODi LIDAR Obstacle Avoidance-JavaScript
    • 🍊MODi LIDAR Obstacle Avoidance-Scratch
  • Motor Hat Module
    • Product Specification Sheet
    • Quick Start Guide
  • 🆘Support
Powered by GitBook
On this page
  • Mantis Code
  • Avoid Obstacles
  • Connect Sensors
  • Connecting Modi
  • Connecting Motor Hat Board
  • Controlling Robot using functions and commands
  • Functions

Was this helpful?

  1. MODI Sensor

MODi LIDAR Obstacle Avoidance-Scratch

PreviousMODi LIDAR Obstacle Avoidance-JavaScriptNextProduct Specification Sheet

Last updated 2 months ago

Was this helpful?

The user simply have access to an internet connected device that runs a modern web browser that supports WebBluetooth. Most modern web browsers support this, with the exception of Safari on MacOS, and Firefox. Google Chrome or Edge are recommended for best results. Mobile browsers are not typically not supported.

Mantis Code

MantisCode is a browser-based software, that’s based on the Scratch programming language. With MantisCode, you can connect to MantisEDU sensors for data collection and other experiments.

Using MantisCode does not require any software to be installed. The user must simply have access to an internet connected device that runs a modern web browser that supports WebBluetooth. Most modern web browsers support this, with the exception of Safari on MacOS, and Firefox. Google Chrome or Edge are recommended for best results. Mobile browsers are not typically not supported.

To access MantisCode, visit .

From the home page, click on Mantis Sensors to access the sensor of interest.

To get access to the sample lessons and examples for the Scout robot, follow the Mantis Motor Hat Link

Avoid Obstacles

Once you find an example you want to explore, click on the load project button to open the program. Below is the default program’s interface. This example connects both the MODI and MTH board to enable an autonomous obstacle avoidance use case.

Connect Sensors

Unlike the previous examples, this program will connect to two sensors simultaneously. As a result, we won’t initiate connection from the Green Flag as we have done in previous examples. Instead we introduce the “When Key Pressed” block in scratch.

For this to work, you will notice that this project contains sprites for the MODI, MTH as well as control logic.

Connecting Modi

To connect with the Modi, you will need to use the connection sprite that’s included in the project.

Connecting to any device that’s broadcasting. Once you turn on the device, and press the button to allow connection, pressing the “1” key on your keyboard to initiate a command connect with the MODI.

Once you press the “1” key, the screen will change to say Scanning of Device.

Once you press the connection button on the Motor Hat, the Device will start to broadcast to allow for the program to connect. Upon a successful connection, you program will update to say “Connected.”

Connecting Motor Hat Board

To connect with the MotorHat you will need to use the connection sprite that’s included in the project.

Connecting to any device that’s broadcasting. Once you turn on the device, and press the button to allow connection, pressing the “2” key on your keyboard to initiate a command connect with the Motor Hat

Once you press the “2” key, the screen will change to say Scanning of Device.

Once you press the connection button on the Motor Hat, the Device will start to broadcast to allow for the program to connect. Upon a successful connection, you program will update to say “Connected.”

Controlling Robot using functions and commands

Now that we have a basic both sensors connected, we can start introducing coding commands to control the Mantis Scout robot, based on the MODI sensor values.

Functions

In addition to the programming blocks we have already discussed, Scratch also includes a powerful feature called "My Blocks" that allows you to create custom functions that can be reused throughout your program.

By using the "My Blocks" feature, you can create a set of programming blocks that perform a specific task. For example, you could create a block that makes the robot move forward a certain distance, or a block that turns the robot a specific angle.

Once you have created a custom block, you can reuse it throughout your program, rather than having to write the same code repeatedly. This makes your code easier to read and can also save you time when programming.

To create a custom block in Scratch, simply click on the "Make a Block" button in the "My Blocks" category of the block palette. You can then give your block a name and add any necessary code. Once you have created the block, you can drag it into your program and use it like any other block.

Overall, using custom blocks in Scratch can make your programs more modular and easier to read. By creating reusable blocks for common tasks, you can save time and make your code more efficient.

In our example we want to create a block that represents a stop and forward motion command for the robot, using the commands we learned earlier.

Enable Monitoring

Now that we have our functions, we can use them in our earlier example to move the robot based on the conditions. First, we set a enablemonitoring command to 1. When the “M” key is pressed, this value is set, and the “startmonitoring” command I broadcasted to triggering a monitoring g loop.

Note that you can also stop monitoring at any time by press the “s” key.

When the starting monitoring broadcast is received, the function below is triggered. Here, the check distance function is monitored inside of a forever loop. Note that the function is only called if the MTH and Modi are connected, and monitoring is enabled.

The check distance function is defined below. The stop command is issued if the MODI’s sensor value is less than the threshold of 60. If the distance is greater than 60, the forward command is issued.

To run this example, follow the steps below

  1. Open the link

  2. Press the green flag

  3. Press 1 to connect the MODI sensor

  4. Press 2 to connect the MTH board

  5. Make sure your robot in an appropriate area with obstacles (i.e. a wall)

  6. Press S to enable monitoring

The full code is available here,

🍊
https://mantiscode.azurewebsites.net/app/scratch3/index.html?project=MTH_Avoid_Obstacles.sb3
https://mantiscode.azurewebsites.net/app/