Skip to content

Commit e1696d2

Browse files
committed
Improve Arc accuracy
1 parent fd08ccc commit e1696d2

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

bitbot.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,16 @@ namespace bitbot
13181318
if(isPRO() && !pidActive)
13191319
{
13201320
radius = Math.max(radius, 7)
1321+
// if(getFirmwareCode() == 11) // v11 firmware incorrectly limits max speed, so do it here for all versions
1322+
{
1323+
let spdMin = (30 * radius)/(radius - 5.38) // 30 is minimum speed before clamping, 5.38 is half width between wheels
1324+
let spdMax = (100 * radius)/(radius + 5.38)
1325+
speed = clamp(speed, spdMin, spdMax)
1326+
}
1327+
1328+
// fudge the angle to correct for speed and radius variances
1329+
angle = angle * (1.0 + (speed-20)/(Math.max(radius/35.0, 1.0) * 1000.0))
1330+
13211331
let aSpeed = ((direction == BBArcDirection.ReverseLeft) || (direction == BBArcDirection.ReverseRight)) ? -speed : speed
13221332
let aAngle = ((direction == BBArcDirection.ForwardRight) || (direction == BBArcDirection.ReverseRight)) ? -angle : angle
13231333
sendCommand6(ARCANGLE, aSpeed, radius & 0xff, radius >> 8, aAngle & 0xff, aAngle >>8)

pxt.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "BitBot",
3-
"version": "2.1.11",
3+
"version": "2.1.12",
44
"description": "MakeCode package for 4tronix BitBot PRO, BitBot XL & BitBot robots",
55
"license": "MIT",
66
"dependencies": {

0 commit comments

Comments
 (0)