Twist msg to pwm conversion help

asked 2022-09-06 15:32:04 -0500

praveen_khm gravatar image

updated 2022-09-07 21:25:58 -0500

ravijoshi gravatar image

Hi,

I am working on a ROS based Robot and this is my first attempt on ROS. Here is what I have done till now:

  1. Installed ROS on PC and connected to an Arduino based robot through ROSSerial
  2. Getting Data in the form on linear and angular velocities (x,y and theta)

On the Arduino side, here is what is completed:

  1. Motor controller program : Sending motors (m1, m2, m3, m4) controls four motors
  2. Encoder : Connected four encoders and reading the ticks. Also outputs current RPM
  3. Kinematics : When I feed the linear and angular velocities, it outputs required RPM
  4. PID Algorithm : PID is calculated based on the required and current RPM.

Now, I am not sure how do I connect these all together to make sure it works. The current RPM and Required RPM is shown correctly. However, it does not drive the robot properly. I am using the teleop_twist keyboard to drive the robot. The values range from -0.5 to 0.5 (m/s) for linear velocity and -1 to 1 for angular velocity.

Does it mean that when I press the, say 'i' key, it should drive 0.5 meters / second and stop? I am struggling to get this all together from a month. Checked a lot of GitHub pages, but nothing that can make me understand. Any help is greatly appreciated please.

edit retag flag offensive close merge delete

Comments

The teleop twist keyboard only publishes the cmd_vel topic. The buttons, when pressed, sets the cmd_vel to a specific value. the "i" button for example, sets the linear x value to 0.5. It will repeatedly publish this value at the rate you set it at until you give it a different command.

So if you press "i" and set the rate at 1 hz, it would publish "x:0.5" every second

bc524 gravatar image bc524  ( 2022-09-06 21:01:39 -0500 )edit

Thank you for the answer. Where do I set the publish rate in teleop keyboard?

praveen_khm gravatar image praveen_khm  ( 2022-09-07 02:34:07 -0500 )edit

Sorry, I somewhat conflated teleop twist with the function that I use it to control. It doesn't "repeatedly" send the data, it just keeps it at that value. apologies for the mixup.

https://github.com/ros-teleop/teleop_...

repeat rate lets you set for the teleop to re-send the command over and over again if your system requires constant entry to respond.

key timeout is to force the teleop to revert back to zeroes after you are no longer pressing a button.

bc524 gravatar image bc524  ( 2022-09-07 05:29:57 -0500 )edit

I found another question with a similar title. So I am posting it here. It may be helpful. #q315702

ravijoshi gravatar image ravijoshi  ( 2022-09-07 21:27:48 -0500 )edit