What are possible ways I can track the orientation of an object? - Page 1
Forum section: electronics / beginners

author: engineheat
author_rank: Frequent Contributor
timestamp: November 12, 2017, 10:19:22 pm
content: Here's a photo that shows what I'm talking about:I want to track the orientation of the device shown relative to a reference plane. The orientation is the angle "alpha" shown above. I don't think I can use a rotary encoder since there is no central shaft/axis that the device can revolve around. In fact, the movement of the device might not even be a perfect circle.Can someone please advise what kind of component I would need? Can accelerometer , tilt sensor, or gyroscope work? What is the easiest way to implement this?Thanks

author: ataradov
author_rank: Super Contributor
timestamp: November 13, 2017, 12:48:21 am
content: Need more information. If there is no fixed central point, then there are infinitely many solutions, unless device actually has a reasonably big plane.

author: danadak
author_rank: Super Contributor
timestamp: November 13, 2017, 12:52:21 am
content: 1) Laser and linear CCD array and algorithm to convert geometry into real position.2) Magnetic field sensing.2) Optical encoder.Google "angular position sensing", lots of hits.Regards, Dana.

author: ataradov
author_rank: Super Contributor
timestamp: November 13, 2017, 12:53:13 am
content: It would be helpful to know the scale of things as well.

author: engineheat
author_rank: Frequent Contributor
timestamp: November 13, 2017, 06:56:04 pm
content: Thanks for the help so far.Do you guys think this might work?https://www.adafruit.com/product/1120It's a accelerometer + magnetometer(compass). If I have a compass, then I would have a global direction. I can input the direction at the reference plane and take the difference to get a direction relative to the reference plane can't I?The accelerometer would also be helpful because if I understand correctly, it know what position is "down" toward the ground, so I can even keep track of any tilt relative to the ground plane too.Is the above true?thanks

author: ataradov
author_rank: Super Contributor
timestamp: November 13, 2017, 06:58:44 pm
content: You have not provided enough information. Are we talking about mm scale, or meters? What accuracy do you need? Accelerometers and magnetometers accumulate errors, so you would need to calibrate the system from time to time.

author: Richard Crowley
author_rank: Super Contributor
timestamp: November 13, 2017, 07:06:05 pm
content: What is the requirement for accuracy?What is the requirement for detection/reporting speed?What is the nature of your "reference"?Is it fixed (at some azimuth relative to magnetic N/S?)Is is unpredictable? (Stationary but of unknown reference?)Is it moving?Is there provision for "calibration"?What are detector conditions?Size? Mass? Power? Interface?Does it have access to the planetary magnetic field? (Or is it inside a magnetically shielded enclosure?)As @ataradov said, there are dozens of details missing that are necessary to suggest something practical.

author: Brumby
author_rank: Unknown
timestamp: November 13, 2017, 11:55:30 pm
content: To the OP:At the moment, your question is similar to "I need a ground transport solution." For us to say whether one idea is better suited than another, we need more information. Without it we could suggest a wheelbarrow, a bicycle, a car or a B-double. If you wanted to transport another person, then all of these could achieve that - but some are less optimal as compared to others.Since there are often more ways than one of doing something - and you are asking for guidance - we will need a better understanding of what you want to achieve ... with some detail.As stated above, more information is required for a helpful answer.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: November 14, 2017, 12:34:27 am
content: In the absence of detail about the problem here are some other ideas which have been used in the past to solve similar problems.1. Light point on ends of device, tracked by camera2. Ultrasound or IR distance measuring unit on device, measuring distance to reference3. IMU on device4. Laser reflected from mirror on device to linear array detector5. Capacitance sensors on ends of device.Things which will affect technology selection and detail design include range of motion, accuracy required, size and cost allocation.For example a really good IMU solution might be the large suitcase, cost hundreds of thousand dollars and provide minutes of arc resolution over many hours. A cheaper IMU solution might be the size of a computer mouse, cost under a $1000, and provide degree type accuracy over a few minutes. Any IMU solution will allow lots of geometry variation. Other solutions may not allow geometry variation but will be cheaper and more accurate.

author: engineheat
author_rank: Frequent Contributor
timestamp: November 14, 2017, 08:59:46 am
content: Thanks for trying to help. Sorry I didn't give enough info, I guess I didn't realize it's this complex. Maybe this scenario will help:Imagine the device as a smartphone, with similar size/shape.All it does is tell the angle (orientation) of its screen to a person's chest (reference plane). Initially, the player will align the screen of this "smartphone" with his/her chest by pressing the screen against the chest, and clicking a button. Now the "smartphone" will know the what the reference plane is. To play the game, the player moves the "smartphone" around with his/her arm as if he/she is trying to take a selfie. (note, the screen is always facing the player, but can be at different orientation). The device should display the orientation (angle) at all times. The accuracy requirement is low, give or take 3-5 degrees is fine. A lag of 0.5 to 1 sec is okay too, so speed requirement is low too.Of course, the device is not a smartphone, but i just used smartphone as an example to better illustrate the example as far as size, range requirement goes. Any method that can enable the above game would satisfy my need.Thanks

author: ataradov
author_rank: Super Contributor
timestamp: November 14, 2017, 05:19:43 pm
content: If the duration of measurement before the next calibration is reasonably small (minutes) and movement is not too sudden, then you can use accel/magnetometer. But you will need to track both sides and to the math if person is moving.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: November 15, 2017, 04:32:01 am
content: Small SSOP size rate sensors and/or magnetometer should do this job pretty well. They are cheap as well as compact. Bias drifts need to be re-zeroed periodically (as in the period held against the chest to establish reference). Many times accuracy can be improved by modelling the arm and joints and using this information to constrain the results from the rate sensors.It is very challenging to estimate angles by integrating accelerations. The requirements on scale and offset errors are extreme.

author: bson
author_rank: Unknown
timestamp: November 15, 2017, 05:45:30 am
content: A 3D accelerometer would give you the attitude at any time in X, Y, Z.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: November 15, 2017, 07:03:48 pm
content: Quote from: bson on November 15, 2017, 05:45:30 amYeah, sorry, my comment was really about rates.A 3D accelerometer cannot resolve attitudes with rotational symmetry about the local vertical. Most of the time a magnetometer can deal with that.

author: janoc
author_rank: Super Contributor
timestamp: November 15, 2017, 09:18:55 pm
content: Quote from: CatalinaWOW on November 15, 2017, 07:03:48 pmMagnetometer with only an accelerometer is usable only if the device moves very very slowly, otherwise the noise will make the data quickly useless. Also the magnetometers are slow devices - a typical accelerometer or gyroscope updates 1000x per second or more, a magnetometer typically only about 10-15x second.If you want to go in this direction, then a better solution is a complete MARG - an accelerometer, gyroscope and magnetometer. The way it works is that you mostly rely on the gyro data which are nice low latency and with low noise and then "occasionally" (relatively speaking - still could be 100x a second!) correct for the gyro drift. Accelerometer gives the gravity vector, magnetometer corrected using the accelerometer for tilt gives you the magnetic north direction.Now the math can be complex and building this out of three separate sensors is a pain - they need to have their axes perfectly aligned or you will have all sorts of weird and wonderful problems.However, these days thanks to the smartphones one can buy something like the Invensense MPU-9250 integrated solution giving directly the orientation as a quaternion (or Euler angles, but those suck for all sorts of reasons). Another popular integrated device is the Bosch BNO 055 unit which also can do all the work for you.The way the OP would use this would be to either build two of the sensors and have one fixed to the reference point. Then calculate the "difference" between the two orientations (there is some quaternion math for it). One sensor wouldn't be enough because the IMU is "absolute" and measures relative to the Earth (magnetic North & gravity directions). And this may change over time, e.g. by introducing metal near the apparatus. So it would have to be either calibrated quite often or just use two sensors.I have built this kind of device using the MPU-9250 and an STM32F103 micro, it works like a charm. However, it is not a beginner project - the MPU-9250 can be fiddly and freeze if you send it bad data and soldering it is impossible without reflow oven or hot air - 0.4mm pin pitch QFN with 24 pins and some 3x3mm size ... if you don't mind larger size, there are some breakout boards for them though.Also, if you don't have the knowledge/time to spend on this, you can actually buy a ready-to-go sensor - e.g. the InterSense InertiaCube:http://www.intersense.com/pages/18/234However, be prepared for the sticker shock. Moreover, the device doesn't do anything more than the MARG solution above.

author: Richard Crowley
author_rank: Super Contributor
timestamp: November 15, 2017, 09:51:29 pm
content: Rotating laser beam and sensor (like Larson Scanner).But the user would have to wear a neck-tie made of retro-reflectors.An accuracy of 3~5 degrees almost puts this into the stratospheric budget of government/military/industrial projects.You would be better off using a camera with "face-sense" technology.

author: janoc
author_rank: Super Contributor
timestamp: November 16, 2017, 09:27:47 am
content: Quote from: CatalinaWOW on November 14, 2017, 12:34:27 amA very good MEMS IMU can be had for ~$20 in parts today, using one-off prices. Maybe not good enough to guide an ICBM on target but certainly good enough for e.g. human motion capture/animation or stabilizing a flying drone.Those $1k prices were current maybe a decade ago, before the cheap MEMS sensors became widely available.

author: engineheat
author_rank: Frequent Contributor
timestamp: November 16, 2017, 09:57:07 pm
content: Quote from: janoc on November 15, 2017, 09:18:55 pmThanks for the help, and to all others who have contributed.I'm going to digest this a little and do some more research in the next couple of days. But the gist I'm getting is that this is no beginning project.I wonder if using the following assumption would make the project easier (ie, only a magnetometer is needed):1. The user doesn't move, so the reference plane (chest) is fixed.2. Every time the user "play" the game, he/she always orient himself such that he is facing North. This way, a global reference can be used.I wonder if the accuracy requirement is relaxed to +- 10 degrees and speed is not critical (a few seconds for calculation), a magnetometer by itself is sufficient?

author: janoc
author_rank: Super Contributor
timestamp: November 17, 2017, 03:02:00 pm
content: Quote from: engineheat on November 16, 2017, 09:57:07 pmIt would help a lot if you could describe what are you exactly attempting to accomplish. Depending on that there could be other solutions too.Quote from: engineheat on November 16, 2017, 09:57:07 pmHum and how is the player going to know which way is "North"? Are you going to give them a compass? Also, keep in mind that magnetometer quite sucks for whenever it is tilted even few degrees (roll/pitch). What you will get out of it is an x,y,z vector (not bearing in degrees - you need to calculate that) specifying the direction to the local magnetic North, affected by whatever magnetic noise you may have - metal nearby, magnets, loudspeakers, motors, etc. It is not the best sensor alone.If you only need a relative measurement, gyro is actually better. You only need to make sure you have some way to "reset" it every once in a while (every few seconds) because after a few turns it will accumulate drift. Depending on what exactly you are doing it could be achieved e.g. by a light sensor getting triggered when the user turns into a known orientation.BTW, this is something you can easily implement e.g. using a Wiimote. The Motion+ accessory (the newer Wiimotes have it built-in) is a gyro and you can use the "sensor bar" and the infrared camera on the Wiimote to reset the drift. Of course, this works best when the user is facing in the "forward" direction most of the time.

author: engineheat
author_rank: Frequent Contributor
timestamp: November 18, 2017, 08:39:01 pm
content: Thanks for the help guys. Upon digesting everything I've read, I feel using gyro/accelerometers is a bit complicated for now. It is probably not suitable for a beginner. I thought about ways to simplify the problem. Rather than tracking the device orientation in free space, I decided to add a constraint. There can be a path that the device has to move along, and if I know the shape of the path and its location along the path, I can derive the rough orientation.Let me rephrase the problem:Let's say I'm trying to design a toy involving some small toy cars on a path. The path starts at a starting point A, and I want to know the distance the car is from point A. If the path is straight, I can use something like a proximity sensor, but the path can be S shaped and there might be obstacles that block lasers or other optical methods.The path is shaped such that as the car increase the path distance from starting point A, the 3D Euclidean distance from A increases also. If I can track either, I'm okay.I don't want to use a string with an rotary encoder because the user might want to pick up the car. Having a string attached to the car is awkward. I also don't want to have the car count some kind of "steps" as it traverse the path because the user might pick up the car and place it some where else on the path. Even when this happens, I want to be able to track its new location along the path (or the Euclidean distance to the starting point).Having the car recognizing some pattern on the track is too technically demanding for me now. I'm thinking about an approach that uses magnets. Please tell me if this might work: If I place magnets of different strength along the path at fixed intervals (say, every 2cm), then if the car can track the magnet strength (and/or directions) using a magnetometer, it should know its rough location. This also do away with strings/wires and is much cleaner.I'm don't have high requirements for positional accuracy (the car only needs to know which interval it is in) nor speed of response. (ie, I don't need to track the location as the car is moving at a high speed, only when it is stopped).Thanks

author: sokoloff
author_rank: Super Contributor
timestamp: November 18, 2017, 08:58:18 pm
content: Depending on your final application, using an actual inexpensive smartphone might be the easiest route for a beginner. No hardware, only software, readily available dev tools and sample code, etc.

author: ataradov
author_rank: Super Contributor
timestamp: November 18, 2017, 09:02:25 pm
content: Does the car need to know its position, or you need to know position of the car?In any case, I'd look at RFID technology. Almost like your magnet proposal, but you can actually transfer data, so the whole thing will be more robust.And if you need to know position of the car, but the car itself does not care, then a lot of coils in the track, and a magnet on the car will do the trick.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: November 19, 2017, 03:49:43 am
content: A very simple solution for this application is to turn the track into a long linear potentiometer. Depending on your accuracy requirements you might choose to segment the track with discrete resistors, or use resistance wire. Accuracy will also determine how many counts the ohmeter needs and whether you have to worry about things like contact resistance and temperature.

author: janoc
author_rank: Super Contributor
timestamp: November 19, 2017, 01:23:37 pm
content: Quote from: engineheat on November 18, 2017, 08:39:01 pmDon't use magnetometers - they are way too sensitive and you will have all sorts of problems with noise and what not. If you want to put magnets on the track, then a simple coil on the car to pick up the magnetic field will do you a much better job.Another good alternative could be the RFID mentioned by someone above. Either put the tag on the car and pick up coils along the track or you can have the coil on the car - each has advantages and disadvantages.Heck, you could even print and stick barcodes to the track and read them as the vehicle is passing over it.Or, if you only need a very simple position tracking, put a reed relay in the strategic places of the track that will be triggered by a magnet on the passing car. Or a simple photo interrupter setup (LED + phototransistor). It doesn't get much simpler than that.It is a pity that you didn't describe this part about a car on a track right away - it could have saved you the entire discussion about IMUs and lasers and what not. Tracking orientation is a very different problem from tracking a position of a moving object along a track, the latter being simpler.

author: engineheat
author_rank: Frequent Contributor
timestamp: November 19, 2017, 08:33:52 pm
content: Quote from: CatalinaWOW on November 19, 2017, 03:49:43 amThanks everyone, but I believe this is probably the simplest solution for my need. I believe for this solution, the car is essentially an ohmmeter, it can get the resistance of the track at different points and translate it into location directly.Does anyone see any flaws with this?

author: ataradov
author_rank: Super Contributor
timestamp: November 19, 2017, 08:35:56 pm
content: Quote from: engineheat on November 19, 2017, 08:33:52 pmIf your car is not very heavy and stable, you will get a whole lot resistance variation just due to poor contact and dirt on the track/wipers.Inductive solution will be way more reliable, and not all that hard to implement.

author: engineheat
author_rank: Frequent Contributor
timestamp: November 19, 2017, 09:37:21 pm
content: Quote from: ataradov on November 19, 2017, 08:35:56 pmCan you elaborate a little bit on "inductive solution" so I can dig more into it?thanks

author: ataradov
author_rank: Super Contributor
timestamp: November 19, 2017, 09:41:08 pm
content: Quote from: engineheat on November 19, 2017, 09:37:21 pmRough idea - place coils along the track and a magnet in the car. As car passes by the magnets, it will induce current in the coils, which you can detect.This is a brute-force approach with many independent coils, it can be simplified a lot for specific use cases, but again, you have not provided enough information to go into any details.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: November 20, 2017, 04:38:39 am
content: If you are measuring the resistance of brass HO train rails it will be very challenging, with concern about wipers and many other things.If you put a 1k resistor between each segment of HO track it is easy to identify the track segment, but distance resolution is poor.Between lies a whole range of options with different performance and difficulty. You could for example take a 10K wire wound resistor and unwind it. If the length met your needs you would have an easy to read, noise resistant solution.Note that the ohmmeter does not have to be in the car. The car can be a shorting bar, with the ohmmeter at one or the other end.Also note that this simple approach assumes that you are not also using the rails for power.Similar arguments apply to inductive, capacitive and optical sensing methods. For example you could divide the region between the wheels on your track into white and black zones with the percentage of one color equal to the percentage of your total distance. For a straight track this would result in a white and black right triangles with apexes at the opposite ends of the track. Then your car could sense the percentage with a row of phototransistors (lots of details in that last phrase). The number of phototransistors along with the sophistication of your signal processing would determine the distance resolution and accuracy.There will always be trades between precision and cost/complexity. Always modified by the tools, materials and knowledge available to you.

author: engineheat
author_rank: Frequent Contributor
timestamp: November 23, 2017, 12:03:05 am
content: Quote from: CatalinaWOW on November 20, 2017, 04:38:39 amThanks, I get your optical sensing idea, with the black and white pattern along the track. I am really curious about the inductive method you mentioned. For the inductive approach, do I just replace inductors in series along the track and try to measure the inductance? And same for the capacitive method (a series of capacitors)?

author: ataradov
author_rank: Super Contributor
timestamp: November 23, 2017, 03:07:19 am
content: Since you don't seem to need a great deal of precision, it would be easier to just place a number of individual coils along the track. If number of sensors ends up being too big for individual processing, then you can double up coils after a certain period. So your track would look like ABCDABCDABCDABCD. You won't be able to differentiate individual ABCD pattern, so you need to keep track of the position, and when D wraps around to A, increment the segment number. This will not work if car can be placed anywhere on the track.And since you can track when magnet leaves one coil and enters the other, you can get really good accuracy with a handful of coils. That's basically how industrial systems like this work.

author: engineheat
author_rank: Frequent Contributor
timestamp: December 04, 2017, 03:02:44 am
content: Quote from: ataradov on November 23, 2017, 03:07:19 amLet me make sure I understand you correctly, is this what you mean by "coils along the track"?There are two coils shown above but the idea might be what you are saying. Right?And by ABCD, you mean there are 4 different types of coils wrapping along each other?thanks

author: ataradov
author_rank: Super Contributor
timestamp: December 04, 2017, 03:05:13 am
content: No, horizontal coils under the track surface. Like the ones you see on the real roads in the US -https://en.wikipedia.org/wiki/Induction_loop#Vehicle_detectionAnd as far as series connection goes - look at how linear motors are designed. I can't find a good diagram, but here is a picture of onehttps://sharepoint.umich.edu/lsa/physics/demolab/Main%20Photo%20Library/_w/Linear%20Motor%20Close%20up%20on%20Sled_5K40.68-2_JPG.jpgThere are only 3 actual coils, they are just distributed over the length of the track. By sequentially passing current though them, you make the "rotor" move in a linear fashion. You need the opposite of that - detect induced current.

author: engineheat
author_rank: Frequent Contributor
timestamp: December 04, 2017, 03:11:02 am
content: Thanks for all the help so far. I've learned a lot.I'm going to learn a bit more about IMU and accelerometers and gyroscopes, but does everyone at least agree that tracking the distance along a track (using the various approaches given so far) is a lot easier and cheaper than tracking the orientation relative to a plane (like what my original post mentioned)?It seems using IMU, things can quickly get complicated if the original reference plane moves or shift. And even if the reference plane is fixed, there is a lot of complicated math involved and it's prone to noise of all kinds.

author: ataradov
author_rank: Super Contributor
timestamp: December 04, 2017, 03:15:12 am
content: Quote from: engineheat on December 04, 2017, 03:11:02 amIn general - yes. Details depend on your specific details - sizes of everything, speed of the moving objects, etc.But generally IMUs is the last resort method for something like this.You may even get away with simple light sensors along the track - just detect when they go dark when an object goes over them. But that depends on lighting in the room.You can use infra-red light barriers. This is less dependent on external light, but will probably have problems in a direct sun light.

author: engineheat
author_rank: Frequent Contributor
timestamp: December 04, 2017, 05:12:07 am
content: Quote from: ataradov on December 04, 2017, 03:05:13 amThanks, I never knew about the induction loop vehicle detection. It seems to be based on Faraday's Law, but how can it detect vehicle if real vehicles are not magnetic?In your "coil along the track" method, where you have coils ABCDABCD..., all the As are the same coil right?(electrically connected, but the windings are at different locations). You mentioned I would need to "keep track of the position, and when D wraps around to A, increment the segment number". So I can track when D wraps around A when a change in current in D follows a change in current in A? I think I understand your approach now. But I want to make sure. Thanks

author: ataradov
author_rank: Super Contributor
timestamp: December 04, 2017, 05:17:21 am
content: Quote from: engineheat on December 04, 2017, 05:12:07 amWhat do you mean by not magnetic? Real vehicles are made of a lot of steel. You don't need an actual magnet. The loop is an open-core inductor, when metal object (a car) gets into the field, the field induces eddy currents in the metal, which create their own magnetic field, that counteracts the one from the coil. And that can be detected on the receiving end.Quote from: engineheat on December 04, 2017, 05:12:07 amExactly.Quote from: engineheat on December 04, 2017, 05:12:07 amCorrect.

author: engineheat
author_rank: Frequent Contributor
timestamp: December 04, 2017, 09:47:52 pm
content: So far, we discussed two methods:1. Track the orientation of the car along the track, because there is a 1 to 1 relationship between orientation and distance from the origin.2. Track the distance along the track, using the methods we discussed recently.Another method is to track the Euclidean distance between the car to the origin. Are there any easy way to do this? For example, if we place a magnet at the origin, and if there is a way to detect magnetic field (which decreases as distance from the source increases), we can obtain the Euclidean distance. This might not be practical, but it's a theoretically example.I don't think I can use devices like Infrared proximity sensor since optical solutions usually require a direct line of sight, and there might be obstacles in my application.Are there any practical ways to detect Euclidean distance between 2 objects even if there are obstacles in between? The distance is on the order of no more than 50cm or so.Thanks

author: janoc
author_rank: Super Contributor
timestamp: December 04, 2017, 10:14:55 pm
content: Quote from: engineheat on December 04, 2017, 09:47:52 pmThe practicality depends on many things, among them the distance to be measured itself. It would help a lot if you could actually tell people here what exactly are you attempting to do, including the dimensions, required accuracy/resolution and any design constraints (e.g. can't use anything radio because ...) you may have. Without that nobody can give you a sensible answer.Tracking distance by measuring an intensity of a field (electric or magnetic) is not very accurate and doesn't work beyond a short (> 10-15cm) distance unless you want to go into rather complicated equipment. Also anything metal will affect it, orientation of the object will affect it, the measurement is not linear, etc.Magnetic tracking is doable but then you would need to build something like a Razer Hydra (tracks two controllers through 3D space, both position & orientation using a magnetic field) or Flock of Birds/Fastrack type of tracking device (same, just on a larger scale). That is a highly nontrivial effort even for a lot more experienced person than you are and a gigantic overkill for the very constrained problem (determining a position of a moving object along a track) that you have.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: December 04, 2017, 11:11:47 pm
content: One way to measure Euclidean distance would be to have an RF pulser on your object, and a rotating radio direction finder antenna at the reference position. Direction from the RDF antenna, distance from a time of flight measurement. You might be able to do the same thing with ultrasound.Both concepts doable. Both complex and tricky to set up.As with the other general approaches explored on this thread there are many other ways to measure Euclidean distance, with different advantages and disadvantages. Things like stereoscopic imaging. None come to mind that are simple and direct.Given your general approach to this problem I would recommend looking up the TRIZ invention methodology. A fascinating approach to generating solutions to problems developed by a Russian patent examiner. I have found the approach very useful, but others find it worthless so your mileage may vary.

author: engineheat
author_rank: Frequent Contributor
timestamp: December 08, 2017, 03:27:51 am
content: Thanks for the help so far.Is it true that IMUs, specifically the accelerometer and gyro suffers from drift, so it requires periodic calibration even if a Kalman filter is used?

author: ataradov
author_rank: Super Contributor
timestamp: December 08, 2017, 03:32:23 am
content: Quote from: engineheat on December 08, 2017, 03:27:51 amYes. That's why google maps asks you to rotate your phone around from time to time. That's the calibration procedure.Kalman filter will not help with systematic errors.

author: Awesome14
author_rank: Regular Contributor
timestamp: December 08, 2017, 05:00:12 am
content: I didn't read the entire thread, so forgive me if this has already been stated. To get orientation you add a third dimension to an accelerometer using a gyroscope.

author: engineheat
author_rank: Frequent Contributor
timestamp: December 08, 2017, 05:02:13 pm
content: Quote from: ataradov on December 08, 2017, 03:32:23 amWhat about when the measuring scale is on the order of 20 to 30 cm rather than the Earth. Do they still get wildly inaccurate after awhile if you don't calibrate? By "accurate" I mean angular accuracy.I just ordered an Adafruit IMU to experiment and play around. I guess those are pretty low end so the drift might be high.Thanks

author: ataradov
author_rank: Super Contributor
timestamp: December 08, 2017, 05:09:14 pm
content: Quote from: engineheat on December 08, 2017, 05:02:13 pmEven worse. Accelerometers are very bad for determining coordinates. Accelerometers return acceleration, and position is a second integral of acceleration. You have double integration errors. That's where the significant part of the error comes from, not the accelerometer itself.Quote from: engineheat on December 08, 2017, 05:02:13 pmYes, they are. Even if you have absolutely accurate accelerometer that never drifts, your position will drift because of numerical errors due to double integration.Accelerometers are the worst method for this task.

author: janoc
author_rank: Super Contributor
timestamp: December 08, 2017, 07:34:35 pm
content: Quote from: ataradov on December 08, 2017, 03:32:23 amThat is a bit more complicated than that.An accelerometer does not drift. It is noisy, yes, but does not perceptibly drift in the sense that the mean of the returned value for the same orientation changes over time (long term shifts due to temperature or gravity changes notwithstanding). A gyro is much less noisy but it does drift due to various factors, such as precession. That is why in order to have a stable orientation solution a gyro+accelerometer are insufficient and a magnetometer is commonly added. Then the tracking is done from the gyroscope and the drift is compensated out using the accelerometer and magnetometer which are slow and noisy but fixed against the absolute references - namely gravity and the magnetic north.The spinning calibration procedure does not deal with the drift but serves to determine the maxima and minima for the accelerometer and magnetometer data so that they can be correctly normalized before being used in the orientation estimation. A more advanced system will actually fit an ellipsoid to the magnetometer data - that permits to compensate for errors due to the presence of metal or other magnetic fields. Ideal sensor in an empty space would return data points on the surface of a perfect sphere but the presence of metal deforms the magnetic field. In such case the data won't lie on a sphere anymore and each axis will have different normalization factors. This needs to be done both because of the manufacturing tolerances of the sensors but also to deal with local conditions - the magnetic field and gravitational fields vary a lot over the surface of the Earth.And yes, Kalman filter (or any other mathematical solution) cannot fix the fundamental physics problem behind this. Stuff like Kalman is only used to get rid of the noise and to find a "good" ratio of the "fast but drifty" (gyro) and "slow but correct" (magnetometer + accelerometer) data for the given application. Kalman filter is nothing else but a linear interpolation between two sets of values with the interpolation coefficient being (gain) being determined in a special way.

author: janoc
author_rank: Super Contributor
timestamp: December 08, 2017, 07:56:41 pm
content: Quote from: ataradov on December 08, 2017, 05:09:14 pmThat is not how an accelerometer is used for this. Attempting to determine a position from an accelerometer data is a futile effort unless working on millisecond time scales and having an external reference against which you can correct the rapidly accumulating error. **An accelerometer is going to be used to determine the pitch and roll angles relative to gravity (the "down" vector). It won't drift and such solution is perfectly usable if you filter out the noise and the object is not accelerating or turning rapidly (the forces due to that will cause errors). On the other hand, an accelerometer won't give you the yaw (the rotation around the vertical axis). To get the yaw you need a magnetometer and use it as a magnetic compass (after compensating for pitch and roll which you get from the accelerometer).Now if the object is moving, then you need a sensor that is immune to the forces due to turning and accelerations - and that is a gyro. Which will give you orientation no problem but it drifts. So the strategy is to use the data from the gyro most of the time but detect when the object is not accelerating/turning based on the sensor data and then take a fix from the accelerometer/magnetometer to zero out the gyro drift. And that's basically what an IMU does.Or you mix the data proportionally based on how reliable they are - if accelerating fast, the accelerometer data quality is poor, so you use mostly gyro and only a little of the accelerometer/magnetometer. If not accelerating/turning, you give it higher confidence. This is, in essence, how a sensor fusion using something like a Kalman filter works.(** That is very much how the HTC Vive/Valve Lighthouse laser-based virtual reality tracking system works - they use an accelerometer to estimate the distance traveled on very short timescales before the error gets out of hand - essentially dead-reckoning. Then whenever the laser beam from the base station hits the sensors on the tracked object they get an absolute position/orientation fix and use that to correct the estimated position. They use this strategy because it permits a very high update rate which is important for their application case. A typical accelerometer can do 1000+ readings/second whereas the laser is unable to scan that fast - it is mechanically swept about 100 times/second. But this is a rather atypical application.)

author: engineheat
author_rank: Frequent Contributor
timestamp: December 15, 2017, 07:56:38 pm
content: Quote from: CatalinaWOW on December 04, 2017, 11:11:47 pmI'm intrigued by the RF approach. As I understand, radio signals can go through opaque objects but optical signals like IR cannot, right? The RF approach also seems simpler than the measuring the strength of a field, without the flaws that Janov has mentioned.I'm thinking about just building something like that for fun. The max distance is 30 cm or so. Latency requirement is low, I only need a measurement once every 1 or 2 seconds. Accuracy requirement is lax as well, can be off by 1 or 2cm and it's no big deal.So I guess I need to purchase a RF pulsar and an antenna. Any other information that can be helpful (like potential pitfalls or things to be aware of when using the RF approach)?thanks

author: janoc
author_rank: Super Contributor
timestamp: December 15, 2017, 08:52:32 pm
content: Anything radio on such small scale will require a very high frequency to get a meaningful resolution. Which also means that you will have almost no obstacle penetration capability.However, building anything like this is a very advanced project requiring pretty deep knowledge in RF engineering and signal processing. If you are struggling with basic concepts like putting light barriers or inductive sensors along your track, I am not quite sure how you are envisioning building a complicated microwave system.Keep it simple.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: December 16, 2017, 05:21:52 am
content: As I said earlier these RF concepts are difficult and complex to implement.Math is your friend in evaluating concepts. If you don't have the math get it. It will be faster and cheaper than experiment.Just some simple math to show both difficulty and the importance of defining your problem carefully in terms of precision required, environment etc.You say you only need 1-2 cm accuracy. Radio and light travels at 3E10 cm/sec. So to do time of flight measurement you need to measure pulse arrival with something better than 0.1 nanosecond accuracy. This can be done, but not with a counter on an Arduino.Going to ultrasound which has a speed of roughly 3E4 cm/sec changes this to somewhat smaller than 0.1 millisecond, much easier to do with simple equipment.You have been presented with a variety of approaches to this problem by several people on this thread. There are several paths forward.1. You can provide a complete specification of what you are trying to do and hope that someone on this forum will do the work to provide a cookbook solution for you.2. You can buy a bunch of hardware to implement parts or all of one or more of the ideas presented and work out something by trial and error.3. You can spend the time and effort to understand and analyze one or more of the ideas and work out the details of how it would be implemented.4. A combination of 2 and 3. If three is done first this is actually the best approach, and represents what usually happens in most professional situations. 2 is necessary to uncover errors and omissions from the analysis phase.

author: janoc
author_rank: Super Contributor
timestamp: December 16, 2017, 01:00:38 pm
content: Quote from: CatalinaWOW on December 16, 2017, 05:21:52 amUltrasound is certainly doable, either by simple time of flight measurement and a triangulation (one needs at least 3 measurements to obtain a position fix) or going the whole hog and doing multilateration by measuring phase differences. Either is doable - I have implemented an ultrasonic 3D "mouse" back in 1998 using an AT89C2051 micro and a PC for doing the data processing. The mouse had an ultrasonic transmitter and there were 4 fixed receivers.However even an ultrasonic system can get complicated fast - e.g. in my case I wasn't able to take the time measurements simultaneously because that micro has only 2 timers and one was generating the 40kHz ultrasonic ping already. That leads to large errors unless the object moves very slowly. Modern micro with 4 or more input capture channels wouldn't have that issue.Then there is the problem with ultrasound transducers - most are very directional so if you want to cover a larger volume, you will need many of them (you need to have at least 3 signals at any given time in order to be able to track). Which will likely require an FPGA to do the time measurements. Or you will have to find some special transducers with wide angle sensitivity but those aren't common (nor cheap).Another issue is with detecting when the "ping" has actually arrived. If you use only a simple threshold, like I did, you will get errors due to external noise and due to the characteristics of the transducers (they don't transmit/receive with equal power in all directions). This is solvable in the way sonar does it - by sending a modulated "chirp" instead and then using auto-correlation to find the center of the "chirp" in the incoming signal, regardless of any sensor-related attenuation or false signals. But that requires some decent processing power on the micro/FPGA because you are doing that for every channel.

author: bson
author_rank: Unknown
timestamp: December 16, 2017, 02:21:54 pm
content: Another idea (I don't know enough to tell how viable it is) - might be to run a current along a guide wire, then have four current sensors; two front, two rear. The relative strength of the two front sensors will tell you where the guide wire is between them, ditto rear. From this you can deduce orientation. Steering to stay on course could be a pretty simple feedback loop, not requiring any processing at all. You can also include automatic speed limiting as the guide gets too close to any one sensor (which should dampen or at least cap any feedback/system oscillation I think). Of course a PID controller would be a step up.Just a thought.