Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
f04a76a95f | |||
88969da972 | |||
b19e5c4e4b | |||
15caad8b02 | |||
22ce6a8716 | |||
c288242b9c | |||
a8249e94c5 | |||
92fbc1552b | |||
92f29ef5d6 | |||
c7fabfd994 | |||
df49475a26 | |||
17d8e61ebc | |||
dbdc1810cd | |||
d3b7530b17 | |||
e31f4c934f | |||
b22ec74f7e | |||
cd38f670d2 | |||
8fca537251 | |||
cf39956e2d | |||
9e3a8ab4ed | |||
022a6765bf |
@ -24,7 +24,6 @@ In a common folder,
|
||||
|
||||
```
|
||||
npm install
|
||||
typings install
|
||||
```
|
||||
|
||||
* go to ``pxt-common-packages`` and run
|
||||
|
@ -22,7 +22,7 @@ In nature, creatures use many methods to get around. None of them, however, use
|
||||
|
||||
### Build
|
||||
|
||||
Think about a creature’s movement for inspiration. Will you make the robot walk, crawl, hop, or wiggle? Your mechanism can be attached or unattached to the EV3 brick. You can start by tinkering with the LEGO elements in the picture above and then build on.
|
||||
Think about a creature’s movement for inspiration. Will you make the robot walk, crawl, hop, or wiggle? Your mechanism can be attached or unattached to the EV3 Brick. You can start by tinkering with the LEGO elements in the picture above and then build on.
|
||||
|
||||
### Building Hint
|
||||
|
||||
|
@ -32,7 +32,7 @@ Think about:
|
||||
|
||||
### Build
|
||||
|
||||
Think about a creature’s movement for inspiration. Your mechanism can be attached or unattached to the EV3 brick. You can start by tinkering with the LEGO elements in the picture add then build on.
|
||||
Think about a creature’s movement for inspiration. Your mechanism can be attached or unattached to the EV3 Brick. You can start by tinkering with the LEGO elements in the picture add then build on.
|
||||
|
||||
More building ideas:
|
||||
|
||||
@ -92,7 +92,7 @@ This program checks if the Ultrasonic Sensor senses something near.
|
||||
|
||||
The blocks inside the ``||loops:forever||`` loop have these actions:
|
||||
|
||||
1. Turn on the ``green`` EV3 brick Status Light.
|
||||
1. Turn on the ``green`` EV3 Brick Status Light.
|
||||
2. Wait for Ultrasonic Sensor to detect an object.
|
||||
3. Turn on Motors ``A`` and ``D`` in opposite directions.
|
||||
4. Wait for one quarter of a second (``1500`` milli seconds).
|
||||
|
@ -7,7 +7,7 @@
|
||||
{
|
||||
"name": "Prepare",
|
||||
"imageUrl": "/static/lessons/firmware.png",
|
||||
"description": "To use Microsoft MakeCode with your EV3 brick, you will need to install the latest LEGO MINDSTORMS Education EV3 firmware - version 1.10 or higher. Follow these steps to install the latest firmware from LEGO.",
|
||||
"description": "To use Microsoft MakeCode with your EV3 Brick, you will need to install the latest LEGO MINDSTORMS Education EV3 firmware - version 1.10 or higher. Follow these steps to install the latest firmware from LEGO.",
|
||||
"label": "New? Start Here!",
|
||||
"labelClass": "red ribbon large",
|
||||
"url": "https://makecode.mindstorms.com/troubleshoot"
|
||||
|
@ -1,10 +1,10 @@
|
||||
# Try
|
||||
# Try
|
||||
|
||||
Get a quick introduction to programming with EV3.
|
||||
|
||||

|
||||
|
||||
We are excited to help you get started with @boardname@. In this project we will guide you through connecting your EV3 brick, creating your first program, controlling a Large Motor, a Touch Sensor and a Color Sensor. These steps can take up to 45 minutes.
|
||||
We are excited to help you get started with @boardname@. In this project we will guide you through connecting your EV3 Brick, creating your first program, controlling a Large Motor, a Touch Sensor and a Color Sensor. These steps can take up to 45 minutes.
|
||||
|
||||
## Turn on your EV3 Brick
|
||||
|
||||
|
@ -37,7 +37,7 @@ Place a ``||motors:tank large B+C||`` block from ``||motors:Motors||`` under ``|
|
||||
Change the speed to `-60%` (for motor B) and `+60%` (for motor C).
|
||||
Change the rotations to `9`.
|
||||
|
||||
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 brick. The motors are set for the reverse direction because they are mounted upside down in this model.
|
||||
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 Brick. The motors are set for the reverse direction because they are mounted upside down in this model.
|
||||
|
||||
```blocks
|
||||
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
|
||||
@ -47,7 +47,7 @@ motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
|
||||
|
||||
Place a ``||motors:stop all motors||`` block under ``||motors:tank large B+C||``.
|
||||
|
||||
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 brick then stop.
|
||||
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 Brick then stop.
|
||||
|
||||
```blocks
|
||||
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
|
||||
@ -59,7 +59,7 @@ motors.stopAll()
|
||||
Place a ``||brick:show string||`` block under ``||motors:stop all motors||``.
|
||||
Change the `"Hello World"` text to `"30 cm"`.
|
||||
|
||||
The ``||motors:tank large B+C||`` will run for `9` rotations when the **center** button is pressed on the EV3 brick then stop and display "30 cm" on the EV3 Brick’s screen.
|
||||
The ``||motors:tank large B+C||`` will run for `9` rotations when the **center** button is pressed on the EV3 Brick then stop and display "30 cm" on the EV3 Brick’s screen.
|
||||
|
||||
```blocks
|
||||
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
|
||||
|
@ -38,7 +38,7 @@ Place a ``||motors:tank large B+C||`` block from ``||motors:Motors||`` under ``|
|
||||
Change the speed to `-60%` (for motor B) and `+60%` (for motor C).
|
||||
Change the rotations to `9`.
|
||||
|
||||
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 brick. The motors are set for the reverse direction because they are mounted upside down in this model.
|
||||
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 Brick. The motors are set for the reverse direction because they are mounted upside down in this model.
|
||||
|
||||
```blocks
|
||||
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
|
||||
@ -48,7 +48,7 @@ motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
|
||||
|
||||
Place a ``||motors:stop all motors||`` block under ``||motors:tank large B+C||``.
|
||||
|
||||
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 brick then stop.
|
||||
The ``||motors:tank large B+C||`` block will run for `9` rotations when the **center** button is pressed on the EV3 Brick then stop.
|
||||
|
||||
```blocks
|
||||
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
|
||||
@ -60,7 +60,7 @@ motors.largeBC.stop()
|
||||
Place a ``||brick:show string||`` block under ``||motors:stop all motors||``.
|
||||
Change the `"Hello World"` text to `"30 cm"`.
|
||||
|
||||
The ``||motors:tank large B+C||`` will run for `9` rotations when the **center** button is pressed on the EV3 brick then stop and display "30 cm" on the EV3 Brick’s screen.
|
||||
The ``||motors:tank large B+C||`` will run for `9` rotations when the **center** button is pressed on the EV3 Brick then stop and display "30 cm" on the EV3 Brick’s screen.
|
||||
|
||||
```blocks
|
||||
motors.largeBC.tank(-60, 60, 9, MoveUnit.Rotations)
|
||||
|
@ -4,7 +4,7 @@ If your're having trouble getting your code onto the EV3 Brick, try these steps
|
||||
|
||||
## Check your **@drivename@** firmware
|
||||
|
||||
MakeCode requires the firmware version **1.10E** or up.
|
||||
MakeCode needs a firmware version of **1.10E** or higher installed on your brick.
|
||||
|
||||
### ~hint
|
||||
|
||||
@ -12,22 +12,28 @@ Firmware is the software that runs all the basic operations on your brick. Your
|
||||
|
||||
### ~
|
||||
|
||||
To check the version on your brick,
|
||||
To check the the firmware version on your brick:
|
||||
|
||||
* go to the **Settings** menu (wrench symbol)
|
||||
* select to **Brick Info**
|
||||
1. Go to the **Settings** menu (it's under the wrench tool symbol)
|
||||
2. Select **Brick Info** and press ENTER
|
||||
|
||||

|
||||
|
||||
* check the version under **Brick FW:**
|
||||
3. Check the version number under **Brick FW:**
|
||||
|
||||

|
||||
|
||||
If you cannot find the **brick info** or the version is less than **1.10E**, **you need to upgrade your firmware**.
|
||||
If you can't find the **Brick Info** or you see that the version is less than **1.10E**, **you need to upgrade your firmware**.
|
||||
|
||||
**To update your firmware, use the [EV3 manager](https://ev3manager.education.lego.com/)** or follow these instructions: [Updating and Resetting Firmware](https://www.lego.com/en-us/service/help/products/themes-sets/mindstorms/updating-and-resetting-lego-mindstorms-ev3-firmware-408100000007884).
|
||||
## Upgrade your **@drivename@**
|
||||
|
||||
If your EV3 Brick isn't connected to the internet through a computer, or with some other mobile device, you'll need to do a manual update of the firmware. Read the instructions in the **Manual Firmware Update** section of the [Firmware Update](https://education.lego.com/en-us/support/mindstorms-ev3/firmware-update) support page.
|
||||
If your a firmware version level is less than **1.10E**, you need to install an upgraded version. You can upgrade the firmware with the **EV3 Lab** or **EV3 Programming** software. Also, you can do a manual upgrade by downloading the firmware install file. See the [Firmware Update](https://education.lego.com/en-us/support/mindstorms-ev3/firmware-update) support page to learn about the upgrade process.
|
||||
|
||||
### ~ hint
|
||||
|
||||
**Recommended:** Upgrade with the **[EV3 Manager](https://ev3manager.education.lego.com/)**
|
||||
|
||||
### ~
|
||||
|
||||
## Can I see the **@drivename@** drive on my computer?
|
||||
|
||||
|
@ -6,7 +6,7 @@ Show different moods on your @boardname@.
|
||||
|
||||

|
||||
|
||||
## Step 1
|
||||
## Step 1 @fullscreen
|
||||
|
||||
Open the ``||brick:Brick||`` Toolbox drawer. Drag out a ``||brick:show mood||`` block onto the Workspace, and place it into the ``||loops:on start||`` block. You should hear and see the block click into place.
|
||||
|
||||
|
@ -49,7 +49,7 @@ pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): P
|
||||
<span class="ui yellow circular label">1</span>
|
||||
<strong>${lf("Connect the EV3 to your computer with a USB cable")}</strong>
|
||||
<br />
|
||||
<span style="font-size:small">${lf("Use the miniUSB port on the top of the EV3 brick")}</span>
|
||||
<span style="font-size:small">${lf("Use the miniUSB port on the top of the EV3 Brick")}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -62,7 +62,7 @@ pxt.editor.initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): P
|
||||
<div class="content">
|
||||
<div class="description">
|
||||
<span class="ui yellow circular label">2</span>
|
||||
<strong>${lf("Move the .uf2 file to the EV3 brick")}</strong>
|
||||
<strong>${lf("Move the .uf2 file to the EV3 Brick")}</strong>
|
||||
<br />
|
||||
<span style="font-size:small">${lf("Locate the downloaded .uf2 file and drag it to the EV3 USB drive")}</span>
|
||||
</div>
|
||||
|
@ -240,7 +240,7 @@ export class FieldMusic extends pxtblockly.FieldImages implements Blockly.FieldC
|
||||
this.stopSounds();
|
||||
}
|
||||
|
||||
private createTextNode_(content: string) {
|
||||
protected createTextNode_(content: string) {
|
||||
const category = this.parseCategory(content);
|
||||
let text = content.substr(content.indexOf(' ') + 1);
|
||||
text = text.length > 15 ? text.substr(0, 12) + "..." : text;
|
||||
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"additionalFilePath": "../../node_modules/pxt-common-packages/libs/automation",
|
||||
"dependencies": {
|
||||
"ev3": "file:../ev3"
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
# Chassis
|
||||
|
||||
A library to control a chassis.
|
@ -1,97 +0,0 @@
|
||||
/**
|
||||
* A differential drive robot
|
||||
*/
|
||||
//% weight=50 color=#cf00cf
|
||||
namespace chassis {
|
||||
/**
|
||||
* A differential drive robot
|
||||
*/
|
||||
//% fixedInstances
|
||||
export class Chassis {
|
||||
// the motor pair
|
||||
public motors: motors.SynchedMotorPair;
|
||||
// the radius of the wheel (cm)
|
||||
public wheelRadius: number;
|
||||
// the distance between the wheels (cm)
|
||||
public baseLength: number;
|
||||
|
||||
constructor() {
|
||||
this.motors = motors.largeBC;
|
||||
this.wheelRadius = 3;
|
||||
this.baseLength = 12;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a differential drive robot move with a given speed (cm/s) and rotation rate (deg/s)
|
||||
* using a unicycle model.
|
||||
* @param speed speed of the center point between motors, eg: 10
|
||||
* @param rotationSpeed rotation of the robot around the center point, eg: 30
|
||||
* @param distance
|
||||
**/
|
||||
//% blockId=motorDrive block="drive %chassis|at %speed|cm/s|turning %rotationSpeed|deg/s"
|
||||
//% inlineInputMode=inline
|
||||
//% weight=95 blockGap=8
|
||||
drive(speed: number, rotationSpeed: number, distance: number = 0) {
|
||||
if (!speed) {
|
||||
this.motors.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
// speed is expressed in %
|
||||
const R = this.wheelRadius; // cm
|
||||
const L = this.baseLength; // cm
|
||||
const PI = 3.14;
|
||||
const maxw = 170 / 60 * 2 * PI; // rad / s
|
||||
const maxv = maxw * R; // cm / s
|
||||
// speed is cm / s
|
||||
const v = speed; // cm / s
|
||||
const w = rotationSpeed / 360 * 2 * PI; // rad / s
|
||||
|
||||
const vr = (2 * v + w * L) / (2 * R); // rad / s
|
||||
const vl = (2 * v - w * L) / (2 * R); // rad / s
|
||||
|
||||
const sr = vr / maxw * 100; // %
|
||||
const sl = vl / maxw * 100; // %
|
||||
|
||||
// cm / (cm/s) = s
|
||||
const seconds = distance / speed;
|
||||
|
||||
this.motors.tank(sr, sl, seconds, MoveUnit.Seconds)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the wheel radius in centimeters
|
||||
* @param cm
|
||||
*/
|
||||
//% blockId=chassisSetWheelRadius block="set %chassis|wheel radius to %cm|(cm)"
|
||||
setWheelRadius(cm: number) {
|
||||
this.wheelRadius = cm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base length in centimeters
|
||||
* @param cm
|
||||
*/
|
||||
//% blockId=chassisSetBaseLength block="set %chassis|base length to %cm|(cm)"
|
||||
setBaseLength(cm: number) {
|
||||
this.baseLength = cm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the motors used by the chassis, default is B+C
|
||||
* @param motors
|
||||
*/
|
||||
//% blockId=chassisSetMotors block="set %chassis|motors to %motors"
|
||||
//% weight=10
|
||||
setMotors(motors: motors.SynchedMotorPair) {
|
||||
this.motors = motors;
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `chassis base ${this.baseLength}, wheel ${this.wheelRadius}`;
|
||||
}
|
||||
}
|
||||
|
||||
//% fixedInstance whenUsed
|
||||
export const chassis = new Chassis();
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "chassis",
|
||||
"description": "Chassis robot support",
|
||||
"files": [
|
||||
"README.md",
|
||||
"chassis.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
],
|
||||
"public": true,
|
||||
"dependencies": {
|
||||
"core": "file:../core"
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
|
@ -132,6 +132,7 @@ namespace motors {
|
||||
protected _port: Output;
|
||||
protected _portName: string;
|
||||
protected _brake: boolean;
|
||||
private _pauseOnRun: boolean;
|
||||
private _initialized: boolean;
|
||||
private _init: () => void;
|
||||
private _run: (speed: number) => void;
|
||||
@ -142,6 +143,7 @@ namespace motors {
|
||||
this._port = port;
|
||||
this._portName = outputToName(this._port);
|
||||
this._brake = false;
|
||||
this._pauseOnRun = true;
|
||||
this._initialized = false;
|
||||
this._init = init;
|
||||
this._run = run;
|
||||
@ -172,6 +174,19 @@ namespace motors {
|
||||
this._brake = brake;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates to pause while a motor moves for a given distance or duration.
|
||||
* @param value true to pause; false to continue the program execution
|
||||
*/
|
||||
//% blockId=outputMotorSetPauseMode block="set %motor|pause on run %brake=toggleOnOff"
|
||||
//% motor.fieldEditor="motors"
|
||||
//% weight=60 blockGap=8
|
||||
//% group="Properties"
|
||||
setPauseOnRun(value: boolean) {
|
||||
this.init();
|
||||
this._pauseOnRun = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverts the motor polarity
|
||||
*/
|
||||
@ -201,13 +216,22 @@ namespace motors {
|
||||
this.settle();
|
||||
}
|
||||
|
||||
private settle() {
|
||||
protected settle() {
|
||||
// if we've recently completed a motor command with brake
|
||||
// allow 500ms for robot to settle
|
||||
if(this._brake)
|
||||
if (this._brake)
|
||||
pause(500);
|
||||
}
|
||||
|
||||
protected pauseOnRun(stepsOrTime: number) {
|
||||
if (stepsOrTime && this._pauseOnRun) {
|
||||
// wait till motor is done with this work
|
||||
this.pauseUntilReady();
|
||||
// allow robot to settle
|
||||
this.settle();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the motor(s).
|
||||
*/
|
||||
@ -269,10 +293,7 @@ namespace motors {
|
||||
}
|
||||
|
||||
this._move(useSteps, stepsOrTime, speed);
|
||||
// wait till motor is done with this work
|
||||
this.pauseUntilReady();
|
||||
// allow robot to settle
|
||||
this.settle();
|
||||
this.pauseOnRun(stepsOrTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -306,12 +327,12 @@ namespace motors {
|
||||
(Data8) NO – Port number [0 - 3]
|
||||
(Data8) TYPE – Output device type, (0x07: Large motor, Medium motor = 0x08) Dispatch status Unchanged
|
||||
Description This function enables specifying the output device type
|
||||
*/
|
||||
*/
|
||||
for (let i = 0; i < DAL.NUM_OUTPUTS; ++i) {
|
||||
if (this._port & (1 << i)) {
|
||||
const b = mkCmd(i, DAL.opOutputSetType, 1)
|
||||
b.setNumber(NumberFormat.Int8LE, 2, large ? 0x07 : 0x08)
|
||||
writePWM(b)
|
||||
writePWM(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -333,7 +354,7 @@ namespace motors {
|
||||
motors.__motorUsed(this._port, this._large);
|
||||
}
|
||||
|
||||
private __init() {
|
||||
private __init() {
|
||||
this.setOutputType(this._large);
|
||||
}
|
||||
|
||||
@ -572,6 +593,8 @@ namespace motors {
|
||||
stepsOrTime: stepsOrTime,
|
||||
useBrake: this._brake
|
||||
});
|
||||
|
||||
this.pauseOnRun(stepsOrTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "0.2.1",
|
||||
"version": "0.1.62",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "0.2.1",
|
||||
"version": "0.1.62",
|
||||
"description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode",
|
||||
"private": true,
|
||||
"keywords": [
|
||||
@ -39,8 +39,8 @@
|
||||
"webfonts-generator": "^0.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-common-packages": "0.22.7",
|
||||
"pxt-core": "3.13.30"
|
||||
"pxt-common-packages": "0.23.15",
|
||||
"pxt-core": "3.18.17"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
||||
|
@ -112,7 +112,7 @@
|
||||
},
|
||||
{
|
||||
"name": "Troubleshoot",
|
||||
"path": "/troubleshoot"
|
||||
"path": "https://makecode.mindstorms.com/troubleshoot"
|
||||
},
|
||||
{
|
||||
"name": "Blocks",
|
||||
|
@ -15,6 +15,6 @@
|
||||
"Maker": "maker"
|
||||
},
|
||||
"electronManifest": {
|
||||
"latest": "v0.1.56"
|
||||
"latest": "v0.1.60"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user