This repository was archived by the owner on Aug 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpearArm.cpp
More file actions
48 lines (36 loc) · 1.35 KB
/
SpearArm.cpp
File metadata and controls
48 lines (36 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "StepperC.h"
#include "SpearArm.h"
#include "common.h"
#include "main.h"
Arm::Arm(){
//baseMotor = Stepper(15652, 10, 11, 2, 8000, 0, UINT32_MAX-1);
shoulderMotor = DCPotMotor(8, 9, A0, 50, 400, 950);
//elbowMotor = Stepper(15652, 4, 5, 3, 8000, 0, UINT32_MAX/3);
//wristPitchMotor = Stepper(15652, 6, 7, 18, 2000, 0, UINT32_MAX-1);
shoulderMotor.setPIDParams(0.8, 0, 0, 1000/(THREAD_DURATION));
Serial.println("motors init");
}
/* void Arm::home(){
// Moves all Stepper and DCMotor towards zero until they hit limit switch
// Moves DCPotMotor (shoulder) to a comfortable position
// DCPotMotor does not need a limit switch
this->baseMotor.step_number = this->baseMotor.steps_per_rotation;
this->elbowMotor.step_number = this->elbowMotor.steps_per_rotation;
this->wristPitchMotor.step_number = this->wristPitchMotor.steps_per_rotation;
in_home_mode = true;
while (this->baseMotor.step_number != 0) {
this->baseMotor.home();
}
while (this->elbowMotor.step_number != 0) {
this->elbowMotor.home();
}
in_home_mode = false;
} */
void Arm::adjust(uint32_t *targets){
/*
* Moves each motor towards it's target radian for a short duration of time
*/
//this->baseMotor.rotateTowardsRadian(targets[BASE]);
this->shoulderMotor.rotateTowardsRadian(targets[SHOULDER]);
//this->elbowMotor.rotateTowardsRadian(targets[ELBOW]);
}