[Help]: Need help with creating a live app using Appdesigner, assigning parameters to Linear Gauge from script, and extracting values from slider into the main script

4 views (last 30 days)
Hello, I am new to it and wanted to create a live app i.e. I want to obtain some data from my script, display it in the Linear Gauge, and then I want to manipulate some other variables in the slider to perform other operations.
For example, in the following code, I am getting position data in the recvMsg.Position(#numbers) and I want to display them in the LinearGauge. While observing the position in the gauge, I want to manually set the torque in the slider, assign that value to Pub_msg.Data(#numbers), send the data to ROS, and then repeat over in the while loop.

Answers (1)

Cris LaPierre
Cris LaPierre on 1 Aug 2020
All components have properties. You can manipulate these properties in different callbacks. Callbacks are typically triggered when you interact with a component (e.g. click on a button, select an item from a list, etc.). You access these properites through the app structure.
You can see the names of the various components in the app structure in the component browser (top right). You can see the available properties of the selected component in the Inspector tab (bottom right). For example, you have selected the wrist rotate slider. If you scroll up in the inspector, you will see the property 'Value'.
You can get or set the slider value by changing its Value property. To get the value after you have interacted with the slider, right click on it and select Callbacks > Add ValueChangedFcn. In the callback, you will be provided the code for getting the new value of the slider and assigning it to the local variable value:
value = app.WristRotateSlider.Value;
You can also set the value of the slider from any other callback. To do that, use the following code where newVal is a variable containing the desired new value:
app.WristRotateSlider.Value = newVal;
A similar approach will allow you to modify your components programmatically.
If you haven't done so already, I recommend completing the app designer tutorial.

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!