Is there a correct way to enumerate a multi axis (i.e. list the axes mapped to it)? Both flavors of RapidSetup are able to do it, but when I try from C++, it doesn’t seem to work.
- The MultiAxis indices are in the range [
MotionController::AxisCountGet()
,MotionController::MotionCountGet()
) - The number of axes mapped to that multi axis come from
MultiAxis::AxisCountGet()
. - Each mapped axis is obtained using an index that goes from 0 to the result of #2 via
MultiAxis::AxisGet(...)
.
Am I correct so far?
When I do this, the axis count is always 0.
Here’s some C++ code that behaves this way for me.
char* rsi_path = getenv("RSI");
if (rsi_path == NULL)
throw std::exception("RSI not defined in the environment.");
std::cout << "Using RSI directory: " << rsi_path << "\n";
auto mc = r::MotionController::CreateFromSoftware(rsi_path);
if (mc == NULL)
throw std::exception("Error creating motion controller object!");
if (mc->ErrorLogCountGet() > 0)
throw *(mc->ErrorLogGet());
auto network_state = mc->NetworkStateGet();
if (network_state != r::RSINetworkState::RSINetworkStateOPERATIONAL) {
std::cout << " Starting network...\n";
std::cout.flush();
mc->NetworkStart();
}
network_state = mc->NetworkStateGet();
if (network_state != r::RSINetworkState::RSINetworkStateOPERATIONAL) {
std::stringstream buf;
buf << " Network start failed! state(" << (int)network_state << ")\n";
auto msg_count = mc->NetworkLogMessageCountGet();
for (auto msg_idx=0; msg_idx<msg_count; msg_idx++)
buf << " " << mc->NetworkLogMessageGet(msg_idx) << "\n";
throw std::exception(buf.str().c_str());
}
mc->Refresh();
auto axis_count = mc->AxisCountGet();
auto motion_count = mc->MotionCountGet();
std::cout << "Axis Count: " << axis_count << "\n"
"Motion Count: " << motion_count << "\n"
;
for (auto ma_idx=axis_count; ma_idx<motion_count; ma_idx++) {
auto ma = mc->MultiAxisGet(ma_idx);
std::string label = ma->UserLabelGet();
std::cout << "\nMultiAxis #" << ma->NumberGet() << " (" << label << ")\n";
auto ma_axis_count = ma->AxisCountGet();
std::cout << " Axis Count: " << ma_axis_count << "\n";
}
FWIW, I get the same behavior from Python, which is what I use most of the time for quick inspection/verification tools. I have to assume I’m doing something incorrectly.