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?
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++?
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: