Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add mode for motors without encoders #6

Open
LaneaLucy opened this issue Dec 2, 2023 · 5 comments
Open

Please add mode for motors without encoders #6

LaneaLucy opened this issue Dec 2, 2023 · 5 comments

Comments

@LaneaLucy
Copy link

i have some robot here with gear motors without encoders, and i cant change the motors in near future, nor can i add somewhere encoders to it. when i use "O" on serial console, i can control speed but sadly when using "M", which is used by diffdrive_arduino by default, because the lack of encoders, it just ramps up until full speed.
and because i know still nothing about Ros or robots, im not able to do it myself, because at the moment, i don't understand what its computing to send ass "M" parameters and i don't know where i could get a -255 to 255 value for speed to send with the "O" command.

Thx for your time,
Lanea Lucy S.

@amoljamble1
Copy link

PID controller is implemented inside Arduino program.

@LaneaLucy
Copy link
Author

Yes, but the ros control part is the problem. The Arduino part can control the motors in non pid mode if you use other commands. But the ros control part only uses the pid commands. If there would be a option for the ros part to tell to use the non pid command, it would be great

@amoljamble1
Copy link

void ArduinoComms::setMotorValues(int val_1, int val_2) { std::stringstream ss; ss << "m " << val_1 << " " << val_2 << "\r"; sendMsg(ss.str(), false); } this is the part of code you need to look into. here it sends "m val_1 val_2". this function sends rpm values to the arduino if you want to send pwm value you can modify the function accordingly.

@Vinothhk
Copy link

Can you pls share the arduino code

@joshnewans
Copy link
Owner

Yeah sorry I should have included it in the readme. The Arduino code is available here.

To respond to the original post, adding an open loop mode to this ros2_control interface is not a bad idea. I don't have time to do it myself but if someone submits a PR (on the humble branch, which I need to swap to main at some point) then I will try to find the time to review and merge it.

I forget if it's mentioned in one of the videos, but you'll have to figure out for yourself roughly which speeds correspond to which values in open loop mode. To do this you'll need to test a bunch of values (e.g. o -255 -255, o -192 -192 through -255, -192, -128, -64, 64, 128, 192, 255) and then fit a line to that and add the scale factor as a parameter (or perhaps a more complex function if in testing you find it to be very nonlinear). Measuring the speed will be tricky, you'll probably need it to run for some amount of time (e.g. 10 seconds) and then count the number of full and partial revolutions in that time.

Then whenever ros2_control requests a speed in rad/sec you can convert it to a [-255,255] value to send to o.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants