ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Trying to fit teleop_twist_keyboard velocity

asked 2017-08-13 12:32:00 -0600

gerson_n gravatar image

updated 2017-08-14 11:43:56 -0600

Hi to all!

I haven't had troubles using teleop_twist_keyboard node, it works perfectly. But I can't find a way to decrease velocity of the motors I have. These are the motors https://www.pololu.com/product/2827 and this one the motor driver shield https://www.pololu.com/product/2507 mounted on arduino mega 2560, in order to drive them and get odometry info. The files I'm using for motors are:

https://www.dropbox.com/s/wvl4fkcdo0i... "base_controller" (get odometry data) https://www.dropbox.com/s/jzkx5rxckoz... "motor_controller6" (this uses all parameters and suscribes to cmd_vel topic which also teleop_twist_keyboard is suscribed) https://www.dropbox.com/s/iuhv9oni4zl... "robot_specs" (parameters typical from motors)

Inside motor_controller6.ino I tried change everything that could have fit velocity:

float Kp = 15 (this is the main parameter because the 9 keyboard's keys for directions, detects faster it while I press it)
md.setM1Speed(PWM_val1) and md.setM2Speed(PWM_val2) (dividing it)
MAX_RPM (reducing it value)

Also inside teleop_twist_keyboard.py I decrease speed and turn, but seems doesn't work. Is it important clarify that "z, x and c" doesn't affect velocity nor turn speed. I'm working with this node, but is too fast and my robot is one meter high. So, abrupt speeds and turns make it tagger and it could fall. I just want to decrease velocity and turn, what should I change inside motor_controller6.ino? I understand most of code actions and relations but I can't figure out that part.

-Update-

Photos of wire connections https://www.dropbox.com/s/nq2ripdkrni... https://www.dropbox.com/s/cd9tm4ud6u8... https://www.dropbox.com/s/rrqqeaph1jx...

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-08-13 13:11:17 -0600

ahendrix gravatar image

It looks like you have a PID controller to control the speed of each motor, but from what you describe it seems like it is always commanding maximum speed from your motor, regardless of the requested speed.

It may be that your PID controller is not working, or it could be that encoders aren't giving good feedback signals.

Since you are using a pre-built PID controller, I would check the encoders first. You should be able to see the RPM from both encoders by echoing the rpm topic, with

rostopic echo rpm

You should be able to turn your motors by hand and see the RPM values change. If you don't, I would double check that your encoder wires are hooked up, and that your arduino sketch has the correct pin settings for both encoders.

edit flag offensive delete link more

Comments

Thanks for your fast reply. Here is what I got after execute rostopic echo rpm https://www.dropbox.com/s/82k60up2v9x...https://www.dropbox.com/s/7s047t2zqsf... and so on.

gerson_n gravatar image gerson_n  ( 2017-08-14 11:24:52 -0600 )edit

I'm currently modifying all values that could have any influence on these lines PWM_val1 = updatePid(1, PWM_val1, rpm_req1, rpm_act1); PWM_val2 = updatePid(2, PWM_val2, rpm_req2, rpm_act2); I understand that velocity is related to PID controller. On the post I added photos with wire connections.

gerson_n gravatar image gerson_n  ( 2017-08-14 11:33:30 -0600 )edit

I managed to decrease velocity just dividing by a big number these lines: md.setM1Speed(PWM_val1/18 and more) md.setM2Speed(PWM_val1/same) Under a 18 factor, velocity didn't change, but as soon as I increased that factor, velocity started decrease. So, I'm currently dividing it by 35 and works great

gerson_n gravatar image gerson_n  ( 2017-08-18 08:15:45 -0600 )edit
1

@gerson_n: if this answer solved your problem you should mark it as correct.

jayess gravatar image jayess  ( 2017-08-28 13:56:51 -0600 )edit

Yes, I'm on it

gerson_n gravatar image gerson_n  ( 2017-08-29 11:08:10 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2017-08-13 12:32:00 -0600

Seen: 1,095 times

Last updated: Aug 14 '17