Serial Port Communication added!
This commit is contained in:
parent
0940317345
commit
a072beb928
@ -1,23 +0,0 @@
|
|||||||
#include <Braccio.h>
|
|
||||||
#include <Servo.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include "math.hpp"
|
|
||||||
|
|
||||||
Servo base;
|
|
||||||
Servo shoulder;
|
|
||||||
Servo elbow;
|
|
||||||
Servo wrist_rot;
|
|
||||||
Servo wrist_ver;
|
|
||||||
Servo gripper;
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
Serial.begin(9600);
|
|
||||||
Braccio.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
Vec4 targ = Vec4(0, 0, 0, 0);
|
|
||||||
Vec4 rot = targ.to_rotation();
|
|
||||||
// speed inverse knematics wrist rot grip
|
|
||||||
Braccio.ServoMovement(30, rot.x, rot.y, rot.z, rot.w, 90, 70);
|
|
||||||
}
|
|
@ -1,10 +1,17 @@
|
|||||||
#ifndef ROBOT_MATH_HPP
|
#include <Braccio.h>
|
||||||
#define ROBOT_MATH_HPP
|
#include <Servo.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
Servo base;
|
||||||
|
Servo shoulder;
|
||||||
|
Servo elbow;
|
||||||
|
Servo wrist_rot;
|
||||||
|
Servo wrist_ver;
|
||||||
|
Servo gripper;
|
||||||
|
|
||||||
#define PI 3.14159265359
|
#define PI 3.14159265359
|
||||||
#define PIdiv2 PI/2
|
#define PIdiv2 PI/2
|
||||||
|
|
||||||
|
|
||||||
const float shoulder_and_elbow_length = 12.5;
|
const float shoulder_and_elbow_length = 12.5;
|
||||||
const float shoulder_plus_elbow_length = shoulder_and_elbow_length * 2;
|
const float shoulder_plus_elbow_length = shoulder_and_elbow_length * 2;
|
||||||
const float wrist_length = 19;
|
const float wrist_length = 19;
|
||||||
@ -63,4 +70,25 @@ public:
|
|||||||
float x,y,z,w;
|
float x,y,z,w;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
// communication
|
||||||
|
Vec4 read() {
|
||||||
|
float x = parseFloat();
|
||||||
|
float y = parseFloat();
|
||||||
|
float z = parseFloat();
|
||||||
|
float w = parseFloat();
|
||||||
|
return Vec4(x,y,z,w);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(9600);
|
||||||
|
Braccio.begin();
|
||||||
|
pinPeripheral(PIN_SERIAL1_TX, PIO_SERCOM);
|
||||||
|
pinPeripheral(PIN_SERIAL1_RX, PIO_SERCOM);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
Vec4 targ = read();
|
||||||
|
Vec4 rot = targ.to_rotation();
|
||||||
|
// speed inverse knematics wrist rot grip
|
||||||
|
Braccio.ServoMovement(30, rot.x, rot.y, rot.z, rot.w, 90, 70);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user