APIs, concepts, guides, and more

◆ SetupController()

void SetupController ( MotionController * controller,
int numAxes = 0 )
void SetupController(MotionController *controller, int numAxes = 0)
{
// Start or shutdown the network depending on the configuration
{
Helpers::NetworkStart(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 /src/config.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
ConfigureHardwareAxes(controller);
// 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 Config::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);
}
}
}

[SetupController]

Examples
axis-configuration.cpp, calculate-acceleration-from-velocity.cpp, config.h, difference-of-position-user-limit.cpp, hello-rttasks.cpp, phantom-axis.cpp, point-to-point.cpp, random-walk.cpp, and starter-template.cpp.

Definition at line 134 of file config.h.