Differential Drive 4 wheel to 2 wheel

The husarion rosbot currently uses 4 wheel drive.

Is there any method to change it to 2 wheel drive? i didnt find any documentation for this in husarion or i might have miss out somewhere. I only know that this is under differential drive but have no idea where to start.

Hi urahara94,

You can change it to 2 wheel drive robot. There is two different solution for that.

First one:

You can connect just two motor:
-Right one to hMotA or hMorB
-Left one to hMotC or hMotD

It will work fine.

Second one:

All drive control functions and methods are in [here].(hFramework/ROSbot.cpp at master · husarion/hFramework · GitHub) You will find 4 wheels in this file: FL, FR, RL, RR. You just have to simplify all of them to Left and Right wheels. For example:

void ROSbot::initWheelController()
    wheelFL = new Wheel(hMotD, 1);
    wheelRL = new Wheel(hMotC, 1);
    wheelFR = new Wheel(hMotA, 0);
    wheelRR = new Wheel(hMotB, 0);

    sys.taskCreate(std::bind(&ROSbot::wheelUpdater, this));

Will be looking like this after changes:

void ROSbot::initWheelController()
    wheelL = new Wheel(hMotD, 1);
    wheelR = new Wheel(hMotA, 0);

    sys.taskCreate(std::bind(&ROSbot::wheelUpdater, this));

Of course, you don’t have to create your own version of hFramework, you can include this function in your main.cpp with different names.



the first method works.
i did not notice that the wheel control works the same for 2 wheels and 4 wheels.

The 2nd method is a blur for me.
Just for future references how should i add the syntax to my main.cpp?
Inserting the code directly will result in error of not delcaring wheelL… and error in context for sys.taskcreate

and Thank you very much!