Maestro 24 GetPosition C++

Hello, for my school project i am writing a program in C++ to control camera movements which are controlled by the servos. I downloaded MaestroEasyExampleCpp project and i want to build on the top of that my own user interface. I understand how to set the target position, but i would like to also to have a button to click to display the current position of the servo. what command can i use to get current position of the channel?

Thank you in advance for your help.


Someone else on our forum had a similar question; you can find our response to it here.

- Amanda

Thanks. I will try to incorporate getVariables into my code this weekend.

Hello, i have a problem using getVariables function. From the AdvancedExample i saw this function:

[code]private void DisplayPosition()
ServoStatus[] servos;
usc.getVariables(out servos);

        PositionTextBox.Text = servos[0].position.ToString();

and i tried to implement it in c++ as follows:

Void TryDisplayPosition() { Usc^ device; try { device = connectToDevice(); // Find a device and connect. ServoStatus[] servos; device->getVariables(servos); textBox1->Text = System::Convert::ToString(servos[0].position); } catch (Exception^ exception) // Handle exceptions by displaying them to the user. { displayException(exception); } finally // Do this no matter what. { delete device; // Close the connection so other processes can use the device. } }

and i get errors that ‘servos’ variable is undefined and that ‘void Pololu::Usc::Usc::getVariables(Pololu::Usc::MaestroVariables %)’ : cannot convert parameter 1 to ‘Pololu::Usc::MaestroVariables %’

how do i define ‘servos’ variable and use getVariables function using c++?

Thank you in advance for your help

I tested your code using the MaestroEasyExampleCpp example in the USB SDK. From the errors, it looks like a conversion issue between C# and C++. I modified the line where you declared servos and it compiled successfully. Here is the code I used:

cli::array<ServoStatus>^ servos;

- Amanda

Thank you so much for your help! it works now!