# Motion magic and variable cruise speed

We have a motion magic arm that is using the arbitrary feed forward. We would like to feed the command a variable speed.

Using you all as a sounding board and to hopefully grab the attention of CTRE @ozrien should i periodically change the configMotionCruiseVelocity or something else?

Are you trying to control the speed continuously (as in a joystick maps to how quickly the arm moves) or just have a slow and fast mode for automatic movement?

For the first, I’d recommend changing the position setpoint continuously by some amount proportional to (loop dt * joystick input) to achieve a sort of moving position setpoint.

For the second, configuring cruise velocity is a good approach. Your position setpoints are already determined and you aren’t changing the cruise velocity mid motion.

Motion magic is a control mode that moves your manipulator to a specific position, so that’s what you want to be changing.

This is how I would do it, there are very likely other ways.

Yes for the first. A bit of testing did come to that conclusion to copy the CTRE example and adjust the position setpoint. What we want to accomplish in the end is to JOG the arm to its two extreme setpoints. Trouble with the suggested solution is Jogging in both directions. If the arm is currently near max and you push up on the stick the target position at the start of the could be in the negative direction until the value passes the current position.

There is just a bit more work to be done with two directions I believe that we will have to use the analog value of the stick to scale a predefined Max-step value and either add/subtract that to the current position depending on the direction of the joystick until the min/max travel is achieved.

``````setpoint = (axisCurrentPosition + (joyStickValue * maxStep));

if(setpoint > maxPos){
setpoint = maxPos;
}else if(setpoint < minPos){
setpoint = minPos;
}else{
setpoint = setpoint;
}

_talon.set(controlMode.MotionMagic, setpoint, DemandType.ArbitraryFeedForward, Arb_FeedForward);
``````

Thanks for the thinking out-loud sounding board. Sometimes asking out loud reviles the answers.

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