How to measure and control an Avoidance car's turn angle? - Page 1
Forum section: electronics / projects

author: laoadam
author_rank: Newbie
timestamp: February 18, 2022, 10:25:29 pm
content: Hi,I am doing a Arduino Robot car ref. to:https://youtu.be/4CFO0MiSlM8my question is how to measure and control the Avoidance car's turn angle when the Ultrasonic sensor detected an Obstacle?I don't think the HMC5883L kind of compass or even GPS module can work if in-room.ThanksAdam

author: Marco
author_rank: Super Contributor
timestamp: February 20, 2022, 03:43:12 pm
content: You assume the rolling surface is consistent and just send a pre-programmed amount of power to the wheel motors.

author: janoc
author_rank: Super Contributor
timestamp: February 20, 2022, 04:37:55 pm
content: Quote from: laoadam on February 18, 2022, 10:25:29 pmWhy do you think a compass (that uses magnetic field of the Earth) wouldn't work indoors? Of course it would.However, getting a magnetometer calibrated and compensating for all kinds of errors that could occur (e.g. from pieces of metal nearby) is a highly non-trivial task. Moreover, magnetometer alone is not suitable for measuring the orientation/turning rate of a vehicle. For that you need a gyroscope or, ideally, a full IMU system including a gyro that actually does the measurement your control system uses, magnetometer for compensating the gyro's drift in the yaw axis and an accelerometer for compensating drift in roll/pitch axes. Magnetometer and accelerometers are rarely used for this kind of job directly because they are noisy sensors, prone to picking up a lot of error caused e.g. by movement of the vehicle (accelerometer) or surrounding environment (magnetometer).Now whether or not you need such closed loop control where you actually measure the turning rate like this instead of just going with the assumption Marco mentioned depends on your needs. For your toy robot a full IMU would be a massive overkill because you don't really care about theexactamount the robot has turned (but it likely would be a very good learning experience).Concerning a GPS module - that wouldn't work indoors, indeed. However, even if it did (or you used it outdoors), GPS is not suitable for tracking small and rapid position changes. Even the best GPS modules have accuracy in meters (+-3m being typical) and slow update rate (1Hz being typical). That's OK for navigating a car or flying a drone into the general vicinity of some waypoint but not for what you want to do.

author: RoGeorge
author_rank: Super Contributor
timestamp: February 20, 2022, 04:54:58 pm
content: Nice robot!Another way to measure how much the robot turned on a slippery floor would be to put a mouse sensor underneath. Old PS/2 mice are very easy to read with a microcontroller. If a PS/2 mouse is hard to source, another way could be to use a cheap USB mouse, but with a known optical sensor (by known I mean a sensor with available datasheet and online docs about how to read it), and to read only the sensor data.A mouse sensor is nothing but a low resolution video camera (something like 16x16, 64x64 or so video pixels), so if the robot has a camera, you may try to use the pixels from the incoming video instead of attaching an optical mouse to the robot. The algorithm used by an optical mouse is sometimes called "optical flow" detection, if you want to search more about it.

author: Someone
author_rank: Super Contributor
timestamp: February 20, 2022, 08:34:37 pm
content: Quote from: janoc on February 20, 2022, 04:37:55 pmDGPS + RTK ends up with 10Hz (or faster) cm accuracy, good enough to drive vehicles/robots around with. The GPS heading is a derivative and rather noisy, but with appropriate filtering that matches the dynamics of the platform it all works out ok.

author: janoc
author_rank: Super Contributor
timestamp: February 21, 2022, 09:00:36 pm
content: Quote from: Someone on February 20, 2022, 08:34:37 pmAnd you think someone is going to set up a DGPS base station and get a DGPS-capable module for an Arduino toy robot, right?That thing would cost more than the entire robot - and then some.Also, centimeter resolution is not really enough if you want to measure rotation change/rate on a small robot like this. That would be extremely inaccurate, even if you feed it into some sort of filter.

author: mikerj
author_rank: Super Contributor
timestamp: February 21, 2022, 09:48:06 pm
content: How about a gyro?

author: Someone
author_rank: Super Contributor
timestamp: February 21, 2022, 11:06:28 pm
content: Quote from: janoc on February 21, 2022, 09:00:36 pmWorks fine on small platforms like that, since the OP is asking about short term positioning and not long term accuracy/drift they don't need to have valid corrections from a stationary receiver. As I said:Quote from: Someone on February 20, 2022, 08:34:37 pmSensor fusion is a wonderful thing.