open-airlab / UNav-Sim

Visually Realistic Underwater Robotics Simulator UNav-Sim
Other
103 stars 11 forks source link

Motor Control #6

Closed freezeLUO closed 4 months ago

freezeLUO commented 4 months ago

Question

What's your question?

When controlling the motion of the ROV using API(moveByMotorPWMsAsync) to manipulate the PWM of the motors, how should I reverse the motors to control the descent of the ROV?

abdelhakim96 commented 4 months ago

Here is an example:

const float duration = 0.01;
vector<float> control_input{ -0.1f, -0.1f, -0.1f, -0.1f, 0.0, 0.0, 0.0, 0.0 };
        while (true) {
            client.moveByMotorPWMsAsync( control_input, duration);
        }

The first four entries in the control_input vector controls the four vertical thrusters in the bluerov2 model. You just need to reverse the sign.

freezeLUO commented 4 months ago

control_input{ 0.1f, 0.1f, 0.1f, 0.1f, 0.0, 0.0, 0.0, 0.0 } can raise ROV ,but control_input{ -0.1f, -0.1f, -0.1f, -0.1f, 0.0, 0.0, 0.0, 0.0 } will not bring ROV down in my test.

abdelhakim96 commented 4 months ago

do you have the most recent version? There has been slight modification sometime ago that fixed this issue. Try to pull the latest version and rebuild.

Check that the file here: AirLib/include/vehicles/rov/RotorActuator.hpp have this line of code correct: control_signal_filter_.setInput(Utils::clip(control_signal, -1.0f, 1.0f));

freezeLUO commented 4 months ago

this line of code is correct in my RotorActuator.hpp

abdelhakim96 commented 4 months ago

Hmmm, maybe you are using an old build? can you try clean and rebuilding? If it doesn't work, maybe it's reading the file from the multirotor files of airsim, so try to change the same line of code in this file: AirLib\include\vehicles\multirotor\RotorActuator.hpp

freezeLUO commented 4 months ago

OK,I will have a try...

freezeLUO commented 4 months ago

Hello, I have rebuild this project. When I run HelloROV with x64, I meet a problem (LNK1104 cannot open file “xxxxx\UNav-Sim\AirLib\lib\Win32\Debug\AirLib.lib”),I find that this file(AirLib.lib) is not generated in this directory, insteadly, there is a AirLib.lib in generated x64\Debug.

abdelhakim96 commented 4 months ago

I hope the first issue is resolved.

Yes the example was not finished yet and the build system was not implemented. Please pull the latest version of UNavSim.

I have updated it. Its a simple P-Controller for the Bluerov. Feel free to try it out.

freezeLUO commented 4 months ago

Thank you,the first issue has been resolved!

abdelhakim96 commented 4 months ago

Thanks for letting us know! Glad it's sorted.