APIs, concepts, guides, and more

◆ SetupController()

static void SetupController ( MotionController * controller,
int numAxes = 0 )
static
static void SetupController(MotionController *controller, int numAxes = 0)
{
// Start or shutdown the network depending on the configuration
{
StartTheNetwork(controller);
}
else if (controller->NetworkStateGet() != RSINetworkState::RSINetworkStateUNINITIALIZED &&
controller->NetworkStateGet() != RSINetworkState::RSINetworkStateSHUTDOWN)
{
std::ostringstream message;
message << "The Sample Apps are configured to use Phantom Axes, but the network is not in the UNINITIALIZED or SHUTDOWN state.\n"
<< "If you intended to run with hardware, then follow the steps in README.md and /include/SampleAppsHelper.h\n"
<< "Otherwise, shutdown the network before running the sample apps with phantom axes.";
throw std::runtime_error(message.str().c_str());
}
// Check if we are using hardware or phantom axes
{
// Let the user defined function configure the axes
// Check that there are enough axes configured
int axisCount = controller->AxisCountGet();
if (axisCount < numAxes)
{
std::ostringstream message;
message << "Error! Not enough axes configured. Expected " << numAxes << " axes but only found " << axisCount << " axes."
<< "Please configure the axes in the SampleAppsConfig::ConfigureHardwareAxes function.";
throw std::runtime_error(message.str().c_str());
}
}
else
{
// Record the initial object counts to restore later
initialAxisCount = controller->AxisCountGet();
// Add phantom axes for the sample app if needed
if (numAxes > initialAxisCount)
{
controller->AxisCountSet(numAxes);
}
for (int i = 0; i < numAxes; i++)
{
ConfigurePhantomAxis(controller, i);
}
}
}
Examples
AxisConfiguration.cpp, CalculateAccelerationFromVelocity.cpp, DifferenceOfPositionUserLimit.cpp, PhantomAxis.cpp, PointToPoint.cpp, and SampleAppsHelper.h.

Definition at line 334 of file SampleAppsHelper.h.