# Help with motion of the car - Displacement

by NeoXx
Tags: displacement, motion
 P: 5 Hi all, I am writing a code for the Ultra Sonic Sensor for the car which will show if there is enough parking space for the car to park parallel. Basically, the UltraSonicSensor starts recording values when the distance from the side of the car to some object is greater than the car width. It stops recording values when its the opposite, that is when the distance from the side of the car to some object is smaller than the car width. However, I am unsure how to find out the length of the car space, which is the same as the displacement of the car from the moment the sensor has started recording, and to the moment it has stopped. I thought of using the equation v^2 = u^2 + 2as As the car velocity and acceleration change all the time, would it be okay to use this equation? Thus, the moment the sensor starts recording, it should save the initial velocity at that exact time, right? And then it should record acceleration and velocity of the car many times until the sensor stops recording, and then calculate the average of both right? And those two averages should enter the equation alongside with initial velocity. I would be grateful if someone could point out if I'm thinking the right way or I'm completely wrong :) Thanks!
 Sci Advisor P: 2,422 You are trying to solve a localization and mapping problem without really understanding motion. I can walk you through this simple case, but if you are doing this as an exercise, you really ought to learn a few things first. First of all, what do you have access to? Do you have continuous readings of velocity? Because $\bar{v} = d/t$. So if you have an estimate on average velocity over some time span t, you have estimate on distance traveled. If you have access to accelerometer data, you can improve the quality of the estimate, but it's not trivial. In either case, you need to be able to gauge the error as well. I mean, say, you need a minimum of 4 meters to park in. You read 3 meters 80cm. Can you park there? Well, that depends. Did you read 3m 80cm ± 10cm? Or 3m 80cm ± 50cm? You can park if it's the former with 97% accuracy. It's a 50/50 shot with the second one. Your system should either reject the second result, or at least, provide some sort of a warning. That's why every good localization technique has error estimates. Fortunately, you have about as simple the case as you can imagine for localization, and I can probably explain it all to you, or at least, give you formulas to use. But I need to know which sensors/readings you have access to.
 P: 5 Thank you for your answer first of all! I am using this sonar sensor: http://www.maxbotix.com/documents/MB1020_Datasheet.pdf I believe the readings are continuous data. If you could guide me I would be grateful! :)
P: 2,422

## Help with motion of the car - Displacement

I mean, what sort of readings/sensors do you have that relate to velocity or acceleration of the car.
 P: 5 There is a mbed processor from ARM(it's basically a small CPU) that will be connected to the car (Don't know how exactly) in order to show at which speed the car is going. I can't tell you more because I don't know as I was told to write a C++ programming code for the mbed processor based on equations I need to use in order to implement it to the sensor, and then the sensor could calculate whether there is enough parking space. I don't have problems with writing a computer code, but with using necessary equations in order to find out the space of the parking slot.
 HW Helper Sci Advisor Thanks P: 7,914 As K^2 says, to answer the question of accuracy we need to know what data you get regarding the car's movements: - speed and acceleration, or just speed? - any directional info, or just scalars? - how accurate is each data item? - how frequently can you sample? - how accurate is the sampling frequency? I assume you get distance info from the sonar, but it will be hard to know to interpret this. If the proximity to the obstacles is different at the end of the parking space from what it was at the beginning, is it because the car is at an angle to the space or because the obstacles are different distances from the kerb? Anyway, let's assume for now you just get speed, and we travel in a straight line parallel to the kerb, and we have a set of speeds v0, v1... vn at times t0, t1,.. tn. A first cut would be to compute the average speed over each time interval and sum: Ʃ(vi+vi+1)(ti+1-ti)/2 If that's not accurate enough, because the speed varies too much, could consider fitting a smooth curve to the datapoints. There are standard methods for this, but you could perhaps do even better by putting in realistic constraints, such as an upper limit on (positive) acceleration. But I would start with something fairly simple and model it to see how well it works. Either use real car data or make up a randomised simulation.
 Sci Advisor P: 2,422 The algorithm above accounts for all of this continuously and gives you an estimate for the error. But yes, it assumes straight-line driving, which isn't a bad assumption when looking for a spot. The noise in velocity data will be attenuated significantly by integration. If it's still too strong, you can just use a Kalman Filter for the whole thing. It will take care of everything. But these things require some finesse to tune.
 P: 5 Thank you very much for your help! I will most probably use the algorithm, but I will take a look at the Kalman Filter as well. Thanks again.
 P: 139 Why are you using the *width* of the car not the length? Unrelated: I tried to get autoparking computers fitted to my car, but no such luck. No-one makes them. However they mostly use cameras not ultrasound. However I am talking about systems that steer the vehicle for the driver, not a system that measures the parking space.
 P: 5 I use both the width and the length. I need to use the width in order for the sensor to know whether its a parking space by comparing that space and the width of the car.
P: 2,422
 Quote by d3mm Unrelated: I tried to get autoparking computers fitted to my car, but no such luck. No-one makes them. However they mostly use cameras not ultrasound. However I am talking about systems that steer the vehicle for the driver, not a system that measures the parking space.
It's very vehicle-specific. While it might be possible to write generic software, all of the hardware would have to be customized for your car either way. You can get that sort of stuff custom built. I'd happily take something like this on as a project. But it would be ridiculously expensive this way. Well north of \$10k. Might actually cost more than your car is worth. So there is not a lot of interest in that sort of aftermarket upgrade.
 P: 139 K^2, that plus liability and regulatory issues is pretty much what the aftermarket specialists I spoke to told me. Turns out it's easier to get a new car with a factory fit system but that doesn't help if you need to use a particular non-supported vehicle for performance or sentimental reasons.
PF Patron
P: 10,076
 Quote by d3mm Why are you using the *width* of the car not the length? Unrelated: I tried to get autoparking computers fitted to my car, but no such luck. No-one makes them. However they mostly use cameras not ultrasound. However I am talking about systems that steer the vehicle for the driver, not a system that measures the parking space.
I wonder what your Insurance Company would have to say if you made a claim as a result of 'damage resulting'.
 P: 139 Fear, uncertainly and doubt are the biggest threats to creativity and happiness.
PF Patron