Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

How control robot wheels natural. wheel speed slow up/down. tail problem

I have fixed model of robot & two wheels. wheel speed range : -1000 ~ 1000 forward, backward.

When I stop or change direction, robot tilt forward.

So, I control wheel speed slowly up & down.

// simple Car wheel control.
class Car {
    public :
        int lspd = 0;
        int rspd = 0;
        int goal_lspd = 0;
        int goal_rspd = 0;
        const int DELTASPD = 10;
        const int MAXSPD = 1000;

        void followGoalSpeed() {
            if( lspd < goal_lspd ) lspd += DELTASPD;
            if( lspd > goal_lspd ) lspd -= DELTASPD;
            if( rspd < goal_lspd ) rspd += DELTASPD;
            if( rspd > goal_lspd ) rspd -= DELTASPD;
        }

        // pseudo code.
        void joystick_control(int angle) {
            switch( angle ) {
                case FORWARD :
                    goal_lspd = goal_rspd = MAXSPD;
                    break;
                case BACKWARD :
                    goal_lspd = goal_rspd = -MAXSPD;
                    break;

                case LEFT :
                    goal_lspd = MAXSPD;
                    goal_rspd = MAXSPD/2; // or 0
                    break;

                case RIGHT :
                    goal_lspd = MAXSPD/2; // or 0
                    goal_rspd = MAXSPD;
                    break;
            } // end of switch loop

            followGoalSpeed();
        }
};

int main() {
    Car car;

    // pseudo code.
    while( true ) {
        car.joystick_control( getJoystick() );
    }
}

With this code, it doesn't tilt more.

But I have another issue.

If I change JOYSTICK [LEFT -> FORWARD], robot not go direct, draw large circle, some seconds...

Situation Example...
| LSPD | RSPD |
| 0000 | 1000 | // turning left... ing...
| 0000 | 1000 | // [JOYSTICK CHANGE TO FORWARD]
| 0010 | 1000 | // turning left... still..
| 0020 | 1000 | // turning left... still..
| 0030 | 1000 | // turning left... still..
-------------- continue ------------
| 0900 | 1000 | // almost done.... but turning left still..........
-------------- continue ------------
| 1000 | 1000 | // FINALLY...!!!! robot move FORWARD.

in this code, angle have only 4 states, but not real.

How I trace goal Velocity without tilt problem..?

Thank you if suggest another wheel speed strategy.

or link any research paper, suffer same problems issue, too.

PS. I use translater. Thank you if you just retouch my languages.

Comments