Can't I just add up all of the accelerations of the accelerometer and then use this physics equation to get distance?
d = v(i) x t + (1/2) x a x t ^2
In this:
v(i) would be 0
t = 1 second
a = all accelerometer speeds added together for.1 second
t = 1 second
Can't I just use this equation to get vertical velocity? A lot of people have said it is impossible but It has been done with variometer apps. I can’t figure out the code. Can anyone guide me in the right direction?
v(f) = v(i) + a x t
v(i) = 0
a = y-axis acceleration for 1 second
t = 1 second
Please let me know if this is possible.
Thank you so much for your help.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi everyone. I have the following code that I am trying to execute in Xcode. I then install it on my iPhone. It doesn't run at all and I don't know why. Any thoughts?
Thank you.
import CoreMotion
class MyViewController: UIViewController {
let motionManager = CMMotionManager()
func startAccelerometer() {
if motionManager.isAccelerometerAvailable {
motionManager.accelerometerUpdateInterval = 0.1 // 10 updates per second
motionManager.startAccelerometerUpdates(to: .main) { (data, error) in
guard let accelerometerData = data else { return }
let x = accelerometerData.acceleration.x
let y = accelerometerData.acceleration.y
let z = accelerometerData.acceleration.z
// Process the x, y, and z acceleration values here
print("X: \(x), Y: \(y), Z: \(z)")
}
}
}
}
Topic:
Developer Tools & Services
SubTopic:
Xcode
Hi everyone. I am trying to place accelerometer data on my iPhone App. However, when printing the data, the data is on top of each other and sometimes at the top of the screen. Labels are also abbreviated. I am clueless. I would appreciate any help. Below are photos.
Thank you!!
Topic:
Developer Tools & Services
SubTopic:
Xcode
Hi. I have the following code with results in an error message
//
// ViewController.swift
// Accelerometer
//
//
import UIKit
import CoreMotion
let motion = CMMotionManager()
class ViewController: UIViewController {
@IBOutlet var xaxis: UILabel!
@IBOutlet var yaxis: UILabel!
@IBOutlet var zaxis: UILabel!
let movementManager = CMMotionManager()
override func viewDidLoad() {
super.viewDidLoad()
movementManager.startAccelerometerUpdates()
movementManager.accelerometerUpdateInterval = 0.1
Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { _ in
if let data = self.movementManager.accelerometerData {
// self.xaxis.text = String(data.acceleration.x)
//self.yaxis.text = String(data.acceleration.y)
//self.zaxis.text = String(data.acceleration.z)
var xoutput: () = self.xaxis.text = String(data.acceleration.x)
var xoutput = xoutput * 9.81
print(xoutput)
}
}
}
}
I realize that it is not working since the whole value of "xoutput" has a string in it. Any advice on making it so it will be a Double?
THANK YOU!
Topic:
Developer Tools & Services
SubTopic:
Xcode