简体   繁体   English

如何以步长和距离计算速度TYPE_STEP_COUNTER

[英]How to calculate speed with steps and distance TYPE_STEP_COUNTER

I need to calculate speed with the information of steps and distance cover ! 我需要根据步数和距离覆盖范围的信息来计算速度! Can anyone please guide me how can i do that one way i think of as using formula S = VT but in this case i need time per step in order to calculate the velocity per step ..I have already looked at stackoverflow but did not solve the issue. 谁能指导我如何使用公式S = VT来实现这一目标,但是在这种情况下,我需要每一步的时间才能计算出每一步的velocity ..我已经研究过stackoverflow但没有解决问题。 Thanks. 谢谢。

In this block of code i am calculating step count by TYPE_COUNTER_STEP and distance by taking person height and multiply it by 0.45 and then multiply it with steps 在此代码块中,我要通过TYPE_COUNTER_STEP和距离来计算步数,方法是将人的身高乘以0.45,然后将其乘以步数

public void registerForSensorEvents() { SensorManager sManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); 公共无效registerForSensorEvents(){SensorManager sManager =(SensorManager)getSystemService(Context.SENSOR_SERVICE);

// Step Counter
sManager.registerListener(new SensorEventListener() {

                              @Override
                              public void onSensorChanged(SensorEvent event) {
                                  float steps = event.values[0];

                                  arrayList.add((int)steps);
                                  getCurrentStepValue = (int) steps ;
                                  stepValue.setText(getCurrentStepValue - arrayList.get(0) + "");

                                  double distaneCovered = step_length * (getCurrentStepValue - arrayList.get(0));

                                  distanceValue.setText("" + distaneCovered);


                              }

                              @Override
                              public void onAccuracyChanged(Sensor sensor, int accuracy) {

                              }
                          }, sManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER),
        SensorManager.SENSOR_DELAY_NORMAL);

} }

You should take an initial stamp with first step, in second step take the difference between "now" and initial stamp, then you'll have time/step, reset initial stamp to "now" and do the same in following steps. 您应该首先进行初始标记,第二步进行“现在”和初始标记之间的区别,然后您将有时间/步骤,将初始标记重置为“现在”,然后在后续步骤中进行相同的操作。

As well you can simply have a timer and calculate number of steps (so distance) in X seconds instead of having time/step, it would depend on what you really need to do. 同样,您可以简单地使用一个计时器并以X秒为单位计算步数(即距离),而不用时间/步数,这取决于您真正需要做的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 NEXUS5X 29API 中找不到 TYPE_STEP_COUNTER 传感器 - TYPE_STEP_COUNTER sensor not found in NEXUS5X 29API 计算速度TYPE_COUNTER_STEP SENSOR - Calculate Velocity TYPE_COUNTER_STEP SENSOR 如何为步骤计数器设置步骤之间的最短时间? - How to set a minimum amount of time between steps for a Step Counter? 如何总结 step1 和 step2 以达到给定距离,计算这些步骤的各种总和并将其返回为 integer? - How to sum up step1 and step2 to reach the given distance, count the various sums of these steps and return it as an integer? 即使在卸载后,我的计步器也不会重置步数 - My step counter does not reset the steps, even after uninstall 如何根据步骤计算速度 - How to count speed based on steps 如何使用javascript根据距离和速度计算时间并在HM中以12小时制显示 - How to calculate time and show in H-M with 12 hour clock, based on distance and speed using javascript 如何使用GPS精确计算速度和距离? 跟踪用户位置。 运行应用 - How to precisely calculate speed and distance using GPS? Tracking user location. App for running 如何从速度和时间(不是从位置点)计算行驶距离:Android(Java) - How to calculate distance travelled from speed and time (not from location points) :Android(Java) 计算到相同类型其他节点的距离 - Calculate distance to other node of same type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM