translation the shaft encoder data - Robotics Stack Exchange most recent 30 from robotics.stackexchange.com 2022-01-25T23:56:55Z https://robotics.stackexchange.com/feeds/question/4384 https://creativecommons.org/licenses/by-sa/4.0/rdf https://robotics.stackexchange.com/q/4384 0 translation the shaft encoder data Maria https://robotics.stackexchange.com/users/6791 2014-08-09T10:20:01Z 2015-01-03T17:32:32Z <p>I am designing a robot in real world and i want to plot everything in X,Y (Cartesian) coordinates </p> <p>I just want to use the encoders of wheels to determine the current position of mobile robot and its orientation depending on a specific calculation formula (like this <a href="http://rossum.sourceforge.net/papers/DiffSteer/" rel="nofollow noreferrer">http://rossum.sourceforge.net/papers/DiffSteer/</a> ) even if that will lead to inaccurate calculations .</p> <p>Actually , I found out this formula below to compute x, y coordinates from encoder data but I still confused in some sides of this formula </p> <p><img src="https://i.stack.imgur.com/QbN00.jpg" alt="enter image description here"> <img src="https://i.stack.imgur.com/Pl42O.jpg" alt="enter image description here"></p> <p>I had a Rover 5 chassis form Dagu with two normal DC motors and two encoders (incremental rotary encoder) per each wheel, how could I translate the pulses of encoders or how to work out the x.y position of the robot based on the shaft encoder data.</p> <p>I deduced some of values from Rover 5 chassis :</p> <p>cm = conversion factor that translates encoder pulses into linear wheel displacement</p> <p>Dn = nominal wheel diameter (in mm) : <strong><em>about 20 Cm</em></strong></p> <p>Ce = encoder resolution (in pulses per revolution) : <strong><em>Encoder resolution: 1000 state changes per 3 wheel rotations</em></strong></p> <p>n = gear ratio of the reduction gear between the motor (where the encoder is attached) and the drive wheel. : <strong><em>Gearbox ratio: 86.8:1</em></strong></p> <p>In Rover 5 chassis there are 4 small wires with female headers. RED is +5V for the encoder , BLACK is 0V (ground) , WHITE is signal A , YELLOW is signal B . The important wires in each encoder are signal A and signal B ,so </p> <p>How to get values of NL , NR in the formula above from signal A &amp; signal B ?</p> <p>Is the value of NL is the direct value from wire signal A or signal B ? the same question for NR . </p> <p>Thanks a lot</p> https://robotics.stackexchange.com/questions/4384/-/4386#4386 2 Answer by cube for translation the shaft encoder data cube https://robotics.stackexchange.com/users/482 2014-08-09T22:35:52Z 2014-08-09T22:35:52Z <p><strong>Encoders</strong></p> <p>These are quadrature encoders.</p> <p>Quadrature encoders have two sensors that look at a rotating wheel with black and white bins alternating in regular intervals (or magnetic sensors looking at alternating magnets). These two sensors are shifted relative to each other, so that when one looks at a center of one bin, the other is precisely at the edge between two bins.</p> <p>Now, when the wheel spins, you will get a change on the sensors' outputs for every time one of them crosses the bin boundary. If you have $n$ bins, the value will change $2n$ times per rotation. At any time at most one of the A or B values will change, and you can calculate direction of rotation from the pattern. Also, if your microcontroller is not fast enough and misses a tick, you can detect this as both A and B changing value at once.</p> <p>So, to get $N_L$ you will have to monitor the A and B signals from the left encoder and keep count of the changes. +1 for change in one direction, -1 for change in the other direction. The same goes for $N_R$, only this time you do it with the right side encoder.</p> <p>concerning the $c_m$ factor, you have specified that there are 1000 state changes per three wheel rotations. That means that your $c_m$ is wheel perimeter times $\frac{3}{1000}$.</p> <p>Some more information about quadrature encoders is here: <a href="http://letsmakerobots.com/node/24031" rel="nofollow">http://letsmakerobots.com/node/24031</a></p> <p><strong>Calculating $x$ and $y$</strong></p> <p>I believe it is more precise to replace equations (1.7a) and (1.7b) with</p> <p>$$x_i = x_{i - 1} + \Delta{U_i} \cos (\theta_{i - 1} + \frac{\Delta\theta_i}{2})$$ $$y_i = y_{i - 1} + \Delta{U_i} \sin (\theta_{i - 1} + \frac{\Delta\theta_i}{2})$$</p> https://robotics.stackexchange.com/questions/4384/-/5285#5285 0 Answer by user3150208 for translation the shaft encoder data user3150208 https://robotics.stackexchange.com/users/2609 2015-01-03T17:32:32Z 2015-01-03T17:32:32Z <p>You seem to have gotten the correct formula. But continue to study them until you understand how they are derived, don't just copy. </p> <p>One thing I can add this that odometer only works for a short distance. A few meters and not even that if outdoors running over rocks and grass. You need some other kind of sensor and then combine the data. One of those 9DOF compass/accelerometer/gyros work well can now you can get them for $5 or$6 on a breakout board. Use this and the wheel data and you are better off. </p>