问题
I am working on a project for detecting the user's current motion, and I use the CMMotionActivityManager with these motions includes 'Stationary', 'Walking', 'Automotive', 'Running'. Now there is a requirements for I need to know the location when people parked the car. But the thing is, I only need the location when people parked at last. How to eliminate the influence of the stop signs. Because people always stop when they are driving.
If the car is stopped, then the status will be 'stationary,1,walking,0,running,0,automotive,1,cycling,0'
If the car is in the automotive motion, the status: 'stationary,0,walking,0,running,0,automotive,1,cycling,0'
If the car is in the stationary motion: 'stationary,1,walking,0,running,0,automotive,0,cycling,0'
This is part of the code :
if (activity.automotive && activity.stationary) {
//stop signs status
}
if (activity.automotive && !activity.stationary) {
//automotive
}
if (!activity.automotive && activity.stationary && activity.confidence == CMMotionActivityConfidenceHigh) {
//stationary with a high confidence
}
But the system just cannot be that sensitive, it cannot determine if the user is stopped for a stop sign or finally parked. Since it is not sensitive enough, I do not know how to elevate the accuracy of detecting if people finally stopped the car.
回答1:
A method of signalling when a car is parked could be based off the users next action. Having automotive true and stationary true will tell you that the vehicle has stopped. The subsequent action will tell you what they do next. In the case of a stop sign the next action is to drive off so automotive would be true and stationary false. In the case of parking the user may leave the car and move on foot, so it would be automotive false and walking true.
来源:https://stackoverflow.com/questions/35790497/ios-cmmotionactivity-manager-how-to-detect-stop-signs-when-the-car-is-stop