Ask Your Question
0

How to send ticks from encoders correctly?

asked 2019-01-06 12:03:14 -0600

stevemartin gravatar image

I have a question regarding the package that I have found here:

LINK

From the documentation, it is required to publish the ticks from the encoders in Int16 message type. Do I need to send each and every tick that is being produced from the start and end of the motor? So like: Motor starts: send 1 send 2 send 3 etc...

If yes, Int16 has a maximum decimal number of 32677, what shall I do when it reaches that number?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-01-06 15:26:06 -0600

billy gravatar image

From your link:

lwheel (std_msgs/Int16)

rwheel (std_msgs/Int16)

Output from the left and right wheel encoders. The hardware is expected to count pulses from the wheel encoders, and provide the total number of pulses since the start of tracking.

You don't send ticks, The hardware in the robot is responsible for counting the encoder lines and providing that number to ROS. You will send the count periodically, but you decide how often to send the numbers.

You ask a very good question about the values being limited to Int16. It's possible the code has a way to detect rollover. You can check the source code and see if there is handling for that.

edit flag offensive delete link more

Comments

But from this page: LINK

It says:

This launch file assumes your robot:

Takes commands for the wheel power on /lmotor_cmd and /rmotor_cmd

Publishes the wheel encoder on /lwheel and /rwheel
stevemartin gravatar image stevemartin  ( 2019-01-07 01:48:40 -0600 )edit

Yes. That aligns with the first link you provided. You need to count the encoder lines in HW and provide that data to ROS. You would do this by publishing the encoder values to the topics noted. It's possible there is a convenient driver for the HW you are using. What is the HW?

billy gravatar image billy  ( 2019-01-07 12:43:32 -0600 )edit

@billy I am using ASUS Tinkerboard and ASUS.GPIO library in Python to read the high pulses from the encoder. It misses 3-5 ticks.

stevemartin gravatar image stevemartin  ( 2019-01-08 03:07:55 -0600 )edit

It's not surprising it's missing counts. Raspberry pi (Zero) processing a simple callback in python can take > 10 ms, often longer. ASUS likely similar. The counts would have to come in very slowly for that to work. Check with ASUS forum on setting up an input counter timer or use purpose built HW.

billy gravatar image billy  ( 2019-01-08 11:35:56 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-01-06 12:03:14 -0600

Seen: 343 times

Last updated: Jan 06 '19