انکودر چرخ و ادومتری در ربات های متحرک: چشم شمارنده چرخ ها
ربات مت

حرک برای آنکه بداند کجاست و با چه سرعتی می رود، به حسگری نیاز دارد که چرخش چرخ هایش را بشمارد؛ این وظیفه بر عهده انکودر چرخ است. انکودر چرخش مکانیکی محور را به سیگنال دیجیتال تبدیل می کند: در نوع نوری، دیسکی شیاردار از برابر حسگر نوری می گذرد و هر لبه یک پالس می سازد؛ در نوع مغناطیسی، حسگر اثر هال میدان آهنربای چرخان را می خواند. شمارش پالس ها مسافت را می دهد و نرخ پالس ها سرعت را نشان می دهد.
پرکاربردترین نوع، انکودر افزایشی کوادراتور است که دو کانال A و B با اختلاف فاز ۹۰ درجه می دهد. ترتیب لبه های این دو کانال جهت چرخش را نشان می دهد و در رمزگشایی X4، با شمردن هر چهار لبه، دقت چهار برابر می شود؛ یک انکودر ۱۰۲۴ خطی به ۴۰۹۶ شمارش در هر دور می رسد. انکودر مطلق برای هر زاویه یک کد یکتا می دهد و پس از قطع برق هم موقعیت را می داند، اما گران تر است.
در عمل، انکودر معمولا روی محور موتور، پیش از گیربکس، نصب می شود؛ جایی که سرعت چرخش بالاست. برای نمونه، انکودر موتور N20 حدود ۲۰ تا ۴۰ پالس در هر دور محور می دهد و با گیربکس ۳۰:۱ به ۶۰۰ تا ۱۲۰۰ پالس در هر دور چرخ می رسد؛ با چرخ ۳٫۳ سانتی متری، هر شمارش حدود ۰٫۱۷ میلی متر جابه جایی است. زاویه خروجی هم برابر شمارش ها تقسیم بر شمارش در هر دور، ضرب در ۲π و تقسیم بر نسبت گیربکس است.
ادومتری یعنی تخمین موقعیت ربات با انتگرال گیری از حرکت چرخ ها. در ربات دیفرانسیلی، جابه جایی رو به جلو میانگین مسافت دو چرخ و تغییر جهت اختلاف آن ها تقسیم بر فاصله چرخ هاست. در ROS، این داده ها در موضوع /odom منتشر می شود و کنترلر diff_drive_controller در ros2_control برای کنترل سرعت و موقعیت به همین بازخورد تکیه می کند.
اما ادومتری به تنهایی کامل نیست: لغزش چرخ، ناهمواری سطح و خطای قطر چرخ باعث انباشت خطا با گذشت زمان می شود؛ به ویژه خطای زاویه که خطاهای بعدی را تقویت می کند. به همین دلیل در سامانه های واقعی، ادومتری با IMU، LiDAR یا دوربین ترکیب می شود تا دریفت اصلاح شود. با این همه، انکودر همچنان ارزان ترین حسگر موقعیت در رباتیک متحرک است.
For a mobile robot to know where it is and how fast it moves, it needs a sensor that counts wheel rotation: the wheel encoder, which converts shaft rotation into a digital signal. In the optical type, a slotted disc passes an LED and phototransistor pair and each signal edge produces a pulse; in the magnetic type, a Hall-effect sensor reads a spinning magnet's field. Counting pulses gives distance, and the pulse rate gives speed.
The most widely used type is the incremental quadrature encoder, which produces two channels, A and B, 90 degrees out of phase. The order of their edges reveals the direction of rotation, and X4 decoding counts all four edges, quadrupling resolution; a 1024-line encoder then reaches 4096 counts per revolution. Absolute encoders give a unique code for each angle and remember position after power loss, but they cost more.
In practice, the encoder is usually mounted on the motor shaft, before the gearbox, where rotation is fastest. For example, a low-cost encoder on an N20 motor gives about 20 to 40 pulses per motor-shaft revolution, and with a 30:1 gearbox that becomes 600 to 1200 pulses per wheel revolution; with a 3.3 cm wheel radius, each count is about 0.17 mm of travel. The output angle is the count divided by the counts per revolution, multiplied by 2π and divided by the gear ratio.
Odometry means estimating the robot's position and heading by integrating wheel motion. In a differential-drive robot, forward displacement is the average of the two wheels' travel, and the heading change is their difference divided by the track width. In ROS, this data is published on the /odom topic, and the diff_drive_controller in ros2_control relies on it for speed and position control.
But odometry alone is incomplete: wheel slip, uneven ground, and wheel-diameter errors make the error accumulate over time — above all the heading error, which amplifies every later error. Real systems therefore fuse odometry with an IMU, LiDAR, or camera to correct drift. Even so, the encoder remains the cheapest position sensor in mobile robotics.
کلیدواژه ها: انکودر، ادومتری، کوادراتور، شمارش در هر دور، ربات دیفرانسیلی، ROS؛ Encoder, odometry, quadrature, counts per revolution, differential drive, ROS
منابع:
- Modular Machines, "Enhance DC Motors using Motor Encoders", http://www.modularmachines.ai/security_robot/2025/04/08/SecurityRobot-MotorEncoder.html
- MIT, "A Primer on Odometry and Motor Control", http://web.mit.edu/6.186/2006/doc/odomtutorial/odomtutorial.pdf
- Donkey Car, "Odometry / Encoders", https://docs.donkeycar.com/parts/odometry/
- Cursa, "Encoders for Robot Motion: Position, Velocity, and Odometry Reliability", https://cursa.app/en/page/encoders-for-robot-motion-position-velocity-and-odometry-reliability