Test Baptiste

This commit is contained in:
bap
2024-04-11 17:52:59 +02:00
parent cc2f8c8a70
commit 950f29d6be
2 changed files with 55 additions and 8 deletions

View File

@@ -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) {

View File

@@ -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;
};