mirror of
https://github.com/modelec/servo_moteurs.git
synced 2026-01-18 16:47:23 +01:00
Test Baptiste
This commit is contained in:
@@ -68,7 +68,16 @@ void MyTCPClient::pwm_setServoPosition(int servo, int position) {
|
||||
}
|
||||
|
||||
void MyTCPClient::baisser_bras() {
|
||||
int angle = 100;
|
||||
int angle;
|
||||
switch(this->poisitionBras){
|
||||
case BRAS_HAUT:
|
||||
angle = 100;
|
||||
break;
|
||||
case BRAS_TRANSPORT:
|
||||
angle = 17;
|
||||
break;
|
||||
}
|
||||
this->positionBras = BRAS_BAS;
|
||||
for (int i = 1; i <= angle;i++){
|
||||
usleep(5'000);
|
||||
this->pwm_setServoPosition(4, i);
|
||||
@@ -76,13 +85,46 @@ void MyTCPClient::baisser_bras() {
|
||||
}
|
||||
}
|
||||
|
||||
void MyTCPClient::lever_bras() {
|
||||
int angle = 107;
|
||||
for (int i = 1; i <= angle;i++){
|
||||
usleep(5'000);
|
||||
this->pwm_setServoPosition(4, angle-i);
|
||||
this->pwm_setServoPosition(5, i);
|
||||
void MyTCPClient::transport_bras(){
|
||||
int angle;
|
||||
switch(this->poisitionBras){
|
||||
case BRAS_BAS:
|
||||
angle = 17;
|
||||
for (int i = 1; i <= angle; i++){
|
||||
usleep(5'000);
|
||||
this->pwm_setServoPosition(4, angle-i);
|
||||
this->pwm_setServoPosition(5, i);
|
||||
}
|
||||
break;
|
||||
case BRAS_HAUT:
|
||||
angle = 90;
|
||||
for (int i = 1; i <= angle; i++){
|
||||
usleep(5'000);
|
||||
this->pwm_setServoPosition(4, i);
|
||||
this->pwm_setServoPosition(5, angle-i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
this->positionBras = BRAS_TRANSPORT;
|
||||
}
|
||||
|
||||
void MyTCPClient::lever_bras() {
|
||||
int angle;
|
||||
switch(this->poisitionBras){
|
||||
case BRAS_BAS:
|
||||
angle = 107;
|
||||
break;
|
||||
case BRAS_TRANSPORT:
|
||||
angle = 90
|
||||
break;
|
||||
}
|
||||
this->positionBras = BRAS_HAUT;
|
||||
for (int i = 1; i <= angle;i++){
|
||||
usleep(5'000);
|
||||
this->pwm_setServoPosition(4, angle-i);
|
||||
this->pwm_setServoPosition(5, i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MyTCPClient::fermer_pince(int pince) {
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#define SERVO_MIN 82 // 0.02*4096
|
||||
#define SERVO_MAX 492 // 0.12*4096
|
||||
|
||||
#define BRAS_BAS 0
|
||||
#define BRAS_HAUT 1
|
||||
#define BRAS_TRANSPORT 2
|
||||
class MyTCPClient : public TCPClient {
|
||||
public:
|
||||
explicit MyTCPClient(const char* serverIP = "127.0.0.1", int port = 8080);
|
||||
@@ -24,6 +26,8 @@ public:
|
||||
|
||||
void baisser_bras();
|
||||
|
||||
void transport_bras();
|
||||
|
||||
void lever_bras();
|
||||
|
||||
void fermer_pince(int pince);
|
||||
@@ -38,4 +42,5 @@ public:
|
||||
|
||||
private:
|
||||
PiPCA9685::PCA9685 pca;
|
||||
int positionBras;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user