nasa-jpl / fastcat

C++ EtherCAT Device Command & Control Library
Other
42 stars 11 forks source link

FTS: Potential bug in signal extraction logic #93

Closed alex-brinkman closed 1 year ago

alex-brinkman commented 1 year ago

For N!=M in the NxM calibration matrix, there appears to be a bug in the code for the signal extraction.

The number of signals(M) can exceed N=(FC_FTS_N_DIMS=6). In the following logic the UpdateSignal() call is only looped over N times so this would be an issue for non-square calibration matricies.

https://github.com/nasa-jpl/fastcat/blob/d3b9b1ddaee24e38510acaafb4a2fc1dd88c8f27/src/fastcat_devices/fts.cc#L103

  for (int ii = 0; ii < FC_FTS_N_DIMS; ii++) {
    if (!UpdateSignal(signals_[ii])) {
      ERROR("Could not extract signal");
      return false;
    }
    wrench_[ii] = 0;

    for (size_t jj = 0; jj < signals_.size(); jj++) {
      wrench_[ii] += calibration_[ii][jj] * signals_[jj].value;
    }
  }

To implement a fix, write a new test case that shows non-square calibration matrix in a new YAML file and prove this is not working as expected. Implement the fix, then show the test case is passing.

alex-brinkman commented 1 year ago

fixed with #94