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

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 and this one the motor driver shield mounted on arduino mega 2560, in order to drive them and get odometry info. The files I'm using for motors are: "base_controller" (get odometry data) "motor_controller6" (this uses all parameters and suscribes to cmd_vel topic which also teleop_twist_keyboard is suscribed) "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 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.


Photos of wire connections


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

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


Thanks for your fast reply. Here is what I got after execute rostopic echo rpm 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

@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



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

Seen: 875 times

Last updated: Aug 14 '17