Imu.getAccel() returns gyro values ???
-
Hi,
there was a similar question 4 years ago realting to uiflow1 under the following URL:
https://community.m5stack.com/topic/1672/imu-get-acc-reports-gyroThere are 2 blocks in IMU for accel and gyro! IMU get accel and IMU get gyro.
It seems that the returned values in both of both functions are gyro values. UIFlow generates the following code, and in the variables beschlx and beschly are identical values, namely gyro values. Furthermore it seems that the function does not return sperate values for x,y,z. Or is the return value a triple and I have to split the values somehow?
def loop():
global label0, label1, label2, label3, label4, label5, beschlx, beschly, beschlz
M5.update()
beschlx = Imu.getAccel()
beschly = Imu.getGyro()
beschlz = Imu.getAccel()
label3.setText(str(beschlx))
label4.setText(str(beschly))
label5.setText(str(beschlz))Best regards,
Nestor -
I have to correct myself.
I work with an atom S3 right now.Imu.getAccel() returns values between -1 and 1 depending on the inclination of the atom S3.
Imu.getGyro() returns values at least up to 30 depending on the velocity of movement of the atom S3.It looks like the functions each return the value for the other function. Are the functions implemented incorrectly or is the sensor wired incorrectly?
Furthermore how can i access the x,y,z values? The blocks do not seem to have a parameter (There were blocks in uiflow 1 for x,y,z each) Are the values returned as a triple which needs to get sperated somehow?
Best regards,
Nestor -
Hi I figured out that Imu.getGyro() returns a tuple of 3 values and that a tuple can be considered as a list. The following code works to seperate the tuple:
def loop():
global label0, label1, label2, label3, label4, label5, highscorebeschl, beschly, beschlx, beschltuple, beschlz
M5.update()
beschltuple = Imu.getGyro()
beschlx = beschltuple[0]
beschly = beschltuple[1]
beschlz = beschltuple[2]
label3.setText(str(beschlx))
label4.setText(str(beschly))
label5.setText(str(beschlz))in blockly the block in list ... get # ... can be used
However blockly counts from 1 to 3 while the generated phython code counts from 0 to 2.So in the end the question remains why Imu.getGyro() and Imu.getAccel() return the values of the other function.
Best regards,
Nestor -
@Nestor89 It has been fixed.