Compare commits
2 Commits
v1.2.22
...
drivingbas
Author | SHA1 | Date | |
---|---|---|---|
|
540a097198 | ||
|
93cfb76f68 |
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"appref": "v1.2.21"
|
||||
"appref": "v1.2.18"
|
||||
}
|
||||
|
@@ -36,10 +36,6 @@
|
||||
"name": "Line following with 1 color sensor",
|
||||
"description": "Simple line following using the color sensor.",
|
||||
"youTubeId": "_LeduyKQVjg"
|
||||
}, {
|
||||
"name": "Proportional line following with 1 color sensor",
|
||||
"description": "Proportional line following using the color sensor.",
|
||||
"youTubeId": "-AirqwC9DL4"
|
||||
}]
|
||||
```
|
||||
|
||||
|
@@ -524,7 +524,6 @@ void stopProgram() {
|
||||
}
|
||||
|
||||
extern "C" void target_reset() {
|
||||
pthread_mutex_trylock(&execMutex);
|
||||
stopMotors();
|
||||
stopProgram();
|
||||
if (lmsPid)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "1.2.22",
|
||||
"version": "1.2.21",
|
||||
"description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode",
|
||||
"private": false,
|
||||
"keywords": [
|
||||
|
BIN
sim/public/cityshapermap.jpg
Normal file
BIN
sim/public/cityshapermap.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 115 KiB |
55
sim/visuals/robotgametable.ts
Normal file
55
sim/visuals/robotgametable.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
namespace pxsim {
|
||||
export class RobotGameTable {
|
||||
readonly ctx: CanvasRenderingContext2D;
|
||||
readonly data: ImageData;
|
||||
|
||||
cx: number; // cm
|
||||
cy: number; // cm
|
||||
angle: number; // radians
|
||||
cwidth: number; // cm
|
||||
|
||||
constructor(public canvas: HTMLCanvasElement, public scale: number) {
|
||||
this.ctx = this.canvas.getContext("2d");
|
||||
this.data = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height);
|
||||
this.cx = this.width / 2;
|
||||
this.cy = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the width in cm
|
||||
*/
|
||||
get width() {
|
||||
return this.canvas.width * this.scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the height in cm
|
||||
*/
|
||||
get height() {
|
||||
return this.canvas.height * this.scale;
|
||||
}
|
||||
|
||||
color(): number {
|
||||
// compute color sensor position from center;
|
||||
// todo
|
||||
const px = Math.max(0, Math.min(this.data.width, (this.cx ) / this.scale));
|
||||
const py = Math.max(0, Math.min(this.data.height, (this.cy ) / this.scale));
|
||||
// get color
|
||||
const i = px * this.data.width + py;
|
||||
let c =
|
||||
(this.data.data[i] << 16) | (this.data.data[i + 1] << 8) | (this.data.data[i + 2]);
|
||||
// map color to known color
|
||||
return c;
|
||||
}
|
||||
|
||||
intensity(): number {
|
||||
const c = this.color();
|
||||
return ((c >> 16 & 0xff) + (c >> 8 & 0xff) + (c & 0xff)) / 3;
|
||||
}
|
||||
|
||||
ultrasonicDistance() {
|
||||
// obstacles?
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user