Skip to content

Commit

Permalink
Clean up front arm
Browse files Browse the repository at this point in the history
  • Loading branch information
Workshop2 committed May 9, 2020
1 parent 96ec0c9 commit 86139b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 39 deletions.
6 changes: 3 additions & 3 deletions experiments/servos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ var config = require('../config/config');
const run = async () => {
var psybot = await Psybot.Create(config.settings.usbConnection);
await psybot.frontArm.centerAsync();
await psybot.frontArm.faceUpAsync();
//await psybot.frontArm.faceUpAsync();
await psybot.frontArm.centerAsync();
await psybot.frontArm.faceDownAsync();
//await psybot.frontArm.faceDownAsync();
await psybot.frontArm.centerAsync();
await psybot.frontArm.faceLeftAsync();
await psybot.frontArm.centerAsync();
await psybot.frontArm.faceRightAsync();
await psybot.frontArm.centerAsync();
await psybot.frontArm.sweepLeftAsync();
await psybot.frontArm.sweepUpDownAsync();
//await psybot.frontArm.sweepUpDownAsync();
}

run();
37 changes: 3 additions & 34 deletions psybot-lib/components/frontarm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,31 @@ import delay from "../delay"

export class FrontArm {
private bottomServo: Servo;
//private topServo: Servo;
private operationTimeout: number = 400;
private operationTimeout: number = 600;

constructor(bottomServoPin: number, topServoPin: number) {
constructor(bottomServoPin: number) {
this.bottomServo = new Servo({
pin: bottomServoPin,
range: [40, 180],
center: true
});

// this.topServo = new Servo({
// pin: topServoPin,
// range: [40, 140],
// center: true
// });

this.centerAsync();
}

public async stopAsync(): Promise<void> {
//this.topServo.stop();
this.bottomServo.stop();

await delay(this.operationTimeout);
}

public async stopBottomAsync(): Promise<void> {
private async stopBottomAsync(): Promise<void> {
this.bottomServo.stop();
await delay(this.operationTimeout);
}

public async stopTopAsync(): Promise<void> {
//this.topServo.stop();
await delay(this.operationTimeout);
}

public async centerAsync(): Promise<void> {
this.bottomServo.center();
//this.topServo.center();

await delay(this.operationTimeout);
}

public async faceUpAsync(): Promise<void> {
//this.topServo.min();

await delay(this.operationTimeout);
}

public async faceDownAsync(): Promise<void> {
//this.topServo.max();

await delay(this.operationTimeout);
}
Expand All @@ -68,11 +42,6 @@ export class FrontArm {
await delay(this.operationTimeout);
}

public async sweepUpDownAsync(sweepOptions?: ServoSweepOpts): Promise<void> {
await this.stopTopAsync();
//this.topServo.sweep(sweepOptions);
}

public async sweepLeftAsync(sweepOptions?: ServoSweepOpts): Promise<void> {
await this.stopBottomAsync();
this.bottomServo.sweep(sweepOptions);
Expand Down
3 changes: 1 addition & 2 deletions psybot-lib/psybot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export class Psybot {
get frontArm(): FrontArm {
if (!this._frontArm) {
this._frontArm = new FrontArm(
this.armPins.bottomServoPin,
this.armPins.topServoPin);
this.armPins.bottomServoPin);
}

return this._frontArm;
Expand Down

0 comments on commit 86139b9

Please sign in to comment.