Home Community Blog Buy Now

Misty Community Forum

Data acquisition from the IMU

Hello, Misty’s community!
Why isn’t the data acquisition from the IMU sensor through the misty.AddPropertyTest method?

Is it because IMU sensor does not share properties like, for example, capacitive and bumpers sensors do?

misty.AddPropertyTest method is used when we want to filter specific data from Misty’s sensor, right?

What is the main difference between misty.AddPropertyTest and misty.AddReturnProperty methods? The question is because two methods are used to get data from Misty’s sensors.

Hello, @RafaelRo!

Yep, you nailed it. Each message from the IMU event type includes values for all properties of the same IMU sensor. This is different from TimeOfFlight, BumpSensor, and TouchSensor event messages, wherein each event message could be from a different sensor in the group.

You can still use the misty.AddPropertyTest() method to apply a filter on IMU event messages (for example, if you only wanted to invoke your IMU event callback when the yaw value is within a certain range). You just don’t need to use it to filter out messages from other sensors within the IMU sensor group – because there is only one sensor that streams messages through the IMU event type.

See this thread for more conversation on this topic.

One way to think about it is:

  • The misty.AddPropertyTest() method filters out irrelevant messages, so your callback function only triggers when a message has values that meet certain conditions.
  • The misty.AddReturnProperty() method makes it easier to access the value of a nested property without parsing the JSON response data by including the value of that property in the data.AdditionalResults array of your callback data object.

From the docs:

Use the misty.AddReturnProperty() method to add the values of specific properties from an event message to the data object passed to the callback function for the event. When the event callback handles the data object for an event, that data includes the values of any properties added with misty.AddReturnProperty() in an AdditionalResults array.

You can add multiple return properties to the same event. The order of values in the AdditionalResults array matches the order in which you added those properties to the event in your skill code.

So, AddPropertyTest is useful when you only want to trigger your callback function under certain event conditions, and AddReturnProperty is useful when you want an easy way to get to the value of a few particular properties. Of course, you can still get to the value of each individual property in an event message by using data.PropertyTestResults[0].PropertyParent.<propertyName>, so it’s really up to you which practice you want to follow :slight_smile:


Got it! It Is clearer for me. Thank you!

1 Like