๐Ÿ’พLidar Obstacle Avoidance Tutorial

MODi LIDAR Avoidance Tutorial

Learn how to command the motors using the board provided in your Scout kit, along with the LIDAR sensor on the MODi.

This guide requires no prior programming experience and users should focus more on the concepts being introduced versus getting lost in the minutia of the scripting language.

Overview

In this guide you will learn how to manipulate and control the Rover based on the following basic concepts:

  1. How to generate PWM commands for the Scout.

  2. Understand how the different PWM settings affect motor drive and direction.

  3. Visualize PWM concepts with an appreciation for generated outputs.

  4. Interpret the sensor command provided by the Scout sensor.

To access the program, simply follow this link, https://mantiscode.azurewebsites.net/webble/sctobstacle.html

The user 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.

This GUI code demo contains two files:

sctobstacle.html

o This must be in the same folder as the Java script file

o Contains metadata about the extension and how to configure all the Gui items in the browser.

sctobstacle.js

o This module contains the underlying BLE communications.

o We will be iteratively modifying the functions specific to the Joystick buttons above.

Connect SCT Board

Click on the Bluetooth icon and make sure your device is broadcasting. Once broadcasting, click on the pair button to connect to the board.

this example assumes that your MODI sensor is connected to your Scout board.

Once you have a successful connection, the interface will report that a connection was successful and start to show distance values once you press the modi on button.

sctobstacle.html Breakdown

Let's break down the contents of mthjoystick.html file. This code tells your browser how and where to place everything that you see on the screen demonstrated above. You can copy this code directly into a text editor and make sure to name it with the same convention above.

For starters you can see where the buttons are called out here starting on line 1, five buttons in total.

sctobstacle.js Breakdown

The man-in-the-loop experiment calls for manipulating the drive strength of these buttons and observing the results as you maneuver around the obstacle course that you made. It is important when you learn to code that you appreciate certain aspects of the code while focusing your efforts on the specific regions of concern. All other sections in the sctobstacle.js java script file maintain very low level details of the BLE layer that is beyond the scope of this exercise. Before proceeding further go ahead and copy this code into a text editor in its entirety and save it with the exact naming convention above.

man-in-the-loop exercise

This example builds upon the previus Man in the Loop Example.

๐Ÿ’พMan-In-The-Loop Obstacle Avoidance Tutorial

In the ongoing exercise, there's a monitoring function named EnableMonitoring. This function sets motor commands according to the distance value acquired from the MODI sensor. activation or deactivation of this function is accomplished by clicking either the Start or Stop Monitoring buttons.

When Monitoring, the code enables a callback that executes the checkDistanceValue() funtion once every 350ms. When in that function, the code will issue the a stop command if the distance value is below a threshold set on line 2. Otherwise, the code will issue the moveForward() command.

In this experiment, adjust the threshold value and observe the performance of your robot. Additionally, modify the moveForward() command to achieve the desired PWM values for your Scout. Operate the robot in a space with obstacles, and iteratively fine-tune your settings until it can successfully maneuver without collisions.

Last updated

Was this helpful?