Detecting if Phoenix 6 motion magic has finished its profile

Quick Question
In phoenix 5 we used to the call .GetActiveTrajectoryPosition() on a Falcon and compare it to the motion magic setpoint (we would save the setpoint into a member variable when we stared the motion magic move) so that we could determine if the motion magic profile setpoint had finished moving (ie the profile had finished)

We used code like this in the isFinished method of a command

               return (m_turretMotor.GetActiveTrajectoryPosition() ==
                       m_TurretSetPointPosition);

What is the equivalent of this for phoenix 6?

We can see a .getMotionMagicIsRunning() method, but not sure if this could be used as the control mode is still motion magic even after the profile finished.

Also we couldn’t work out what to compare this to. We tried
ctre::phoenix6::signals::MotionMagicIsRunningValue::Enabled
but that doesn’t work.

Any help greatly appreciated.

The API migration guide refers to
ClosedLooopReference being the equivalent of activeTrajectory but if you search the phoenix C++ API for ClosedLoppReference nothing comes up.

So still looking for the solution.

It is so frustrating trying to migrate from Phoenix 5 to Phoenix 6. I really wish there was a one to one guide for migrating between the two that had every command that was used in Phoenix 5.

One step closer.
You need to search for GetClosedLoopReference not CloseLoopReference

This returns a
ClosedLoopReference Status Signal object

Now just need to work out how to make a
ClosedLoopReference Status Signal object' that has a setpoint of m_TurretSetPointPosition` so that we can compare the two.

OK here is the solution (I think)

bool ShooterSubsystem::HasElevatorAngleMotionMagicFinished(){
  if (m_elevatorMotor.GetClosedLoopReference().GetValueAsDouble()==m_elevatorPostiion){
    fmt::print("Motion magic finished");
    return true;
  }
  else return false;
}

Hope this helps someone out.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.