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

Scout PWM Motor Drive Tutorial

Learn how to command the motors using the Scout board provided in your kit.

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.

To access the program, simply follow this link https://mantiscode.azurewebsites.net/webble/sctjoystick.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.

Note: This example assumes that the Modi Sensor is connected on your Scout Robot.

This Rover GUI code demo contains two files:

sctjoystick.html

o This must be in the same folder as the JavaScript file

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

sctjoystick.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.

Once you have a successful connection, the interface will report that a connection was successful. The connection event also enables the Modi Sensor and prints out the current value to the console.

Issue Motor Commands

After connecting, use the arrow keys to move the motors. Notice how the motors move as your move the commands. Press the stop button to cease all motion.

sctjoystick.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, four buttons in total and one for each direction we desire to move the Scout. There are a number of styles and types that can be used to configure these buttons for a different shape and feel in the future.

sctjoystick.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 sctystick.js javascript 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

To make this experiment go a little smoother for you, we will adapt all speed constants for each button with same PWM strength. See below where we set these values to 40 respectively. Conducting this experiment four times is a good starting point for this exercise: So in order to do so, let's conduct the experiment as follows:

  • Step 1: Save the HTML (sctjoystick.html) and JavaScript (sctjoystick.js) files to your local machine.

  • Step 2: Modify the MTR1_PWM and MTR2_PWM values in each function below and save mthjoystick.js after each edit in your text editor.

  • Step 3: Open the HTML file in Google Chrome and bring up the GUI in your browser and connect your sensor. You can refresh the page it is already opened from a previous experiment.

  • Step 3: Maneuver the complete obstacle course and note your results.

  • Step 4: Record notes regarding, how many times you hit obstacles, how easy was it to keep the Rover on track etc.

  • Repeat steps 2 through 4, while increasing the MTRX_PWM value by 25.

  • This exercise should be repeated with final obstacle course loop being conducted with PWM strengths being set to 100 each respectively.

Last updated

Was this helpful?