translation driver and testing

This commit is contained in:
2024-10-01 16:36:04 +02:00
parent 7f4376c2e5
commit 2e0a27c732
2 changed files with 11 additions and 13 deletions

View File

@@ -589,21 +589,21 @@ long CKobuki::loop(void *user_data, TKobukiData &Kobuki_data) {
// povie kobukimu ze ma ist niekolko metrov dopredu alebo dozadu, rozhoduje znamienko
// funkcia kompenzuje chodenie rovno pomocou regulatora, interne vyuziva setArcSpeed a
// ako spatnu vazbu pouziva data z enkoderov
// tells the kobuki to go a few meters forward or backward, the sign decides
// the function compensates for walking straight with the controller, internally it uses setArcSpeed and
// uses encoder data as feedback
void CKobuki::goStraight(long double distance){
long double u_translation = 0; // riadena velicina, rychlost robota pri pohybe
long double w_translation = distance; // pozadovana hodnota
long double u_translation = 0; // controlled magnitude, speed of the robot in motion
long double w_translation = distance; // requested value
// parametre regulatora
// controller parameters
long double Kp_translation = 4500;
long double e_translation = 0;
int upper_thresh_translation = 600;
int lower_thresh_translation = 40;
int translation_start_gain = 20;
long double u_rotation = 0; // riadena velicina
long double u_rotation = 0; // controlled magnitude
long double w_rotation = 0;
long double Kp_rotation = 57;
long double e_rotation = 0;
@@ -613,7 +613,7 @@ void CKobuki::goStraight(long double distance){
theta = 0;
long i = 5;
//send command and hold until robot reaches point
while (fabs(x - w_translation) > 0.005 && x<w_translation) {
e_translation = w_translation - x;
u_translation = Kp_translation * e_translation;
@@ -640,10 +640,9 @@ void CKobuki::goStraight(long double distance){
if (u_rotation == 0) {
u_rotation = -32767;
}
//send command to robot
this->setArcSpeed(u_translation, u_rotation);
usleep(25*1000);
// increment starting speed
i = i + translation_start_gain;
}
@@ -705,8 +704,7 @@ void CKobuki::doRotation(long double th) {
}
}
std::cout << "stop the fuck!" << std::endl;
// usleep(25*1000);
std::cout << "Rotation done" << std::endl;
this->setRotationSpeed(0);
usleep(25*1000);
}

View File

@@ -36,7 +36,7 @@ int movement()
if (text == 1)
{
robot.goStraight(10);
robot.goStraight(1);
}
else if (text == 2)
{