Skip to content

Commit

Permalink
🔀 Merge branch 'hugo/bugfix/Fix-RobotKit-inversed-motions-func'
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed Nov 15, 2023
2 parents b688c90 + f34b29e commit aa4bbbb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Modules/RobotKit/Sources/Robot+Motion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ extension Robot {

case .free(let left, let right):
let payload = [
setMotor(.left, speed: left, rotation: left > 0 ? .clockwise : .counterclockwise),
setMotor(.right, speed: right, rotation: right > 0 ? .clockwise : .counterclockwise),
setMotor(.left, speed: left, rotation: left < 0 ? .clockwise : .counterclockwise),
setMotor(.right, speed: right, rotation: right < 0 ? .clockwise : .counterclockwise),
]
output.append(contentsOf: payload)

Expand All @@ -66,16 +66,16 @@ extension Robot {
case .forwardLeft(let speed):
guard speed.isInRange0to1 else { break }
let payload = [
setMotor(.left, speed: speed * 0.8, rotation: .clockwise),
setMotor(.right, speed: speed, rotation: .clockwise),
setMotor(.left, speed: speed * 0.8, rotation: .counterclockwise),
setMotor(.right, speed: speed, rotation: .counterclockwise),
]
output.append(contentsOf: payload)

case .forwardRight(let speed):
guard speed.isInRange0to1 else { break }
let payload = [
setMotor(.left, speed: speed, rotation: .clockwise),
setMotor(.right, speed: speed * 0.8, rotation: .clockwise),
setMotor(.left, speed: speed, rotation: .counterclockwise),
setMotor(.right, speed: speed * 0.8, rotation: .counterclockwise),
]
output.append(contentsOf: payload)

Expand All @@ -90,16 +90,16 @@ extension Robot {
case .backwardLeft(let speed):
guard speed.isInRange0to1 else { break }
let payload = [
setMotor(.left, speed: speed * 0.8, rotation: .counterclockwise),
setMotor(.right, speed: speed, rotation: .counterclockwise),
setMotor(.left, speed: speed * 0.8, rotation: .clockwise),
setMotor(.right, speed: speed, rotation: .clockwise),
]
output.append(contentsOf: payload)

case .backwardRight(let speed):
guard speed.isInRange0to1 else { break }
let payload = [
setMotor(.left, speed: speed, rotation: .counterclockwise),
setMotor(.right, speed: speed * 0.8, rotation: .counterclockwise),
setMotor(.left, speed: speed, rotation: .clockwise),
setMotor(.right, speed: speed * 0.8, rotation: .clockwise),
]
output.append(contentsOf: payload)

Expand Down

0 comments on commit aa4bbbb

Please sign in to comment.