LogoLogo
REVLib Docs
  • REV ION Brushless
  • Quick Links
  • Frequently Asked Questions
  • NEO Brushless Motors
    • Brushless DC Motor Basics
    • NEO Vortex
      • Docking a SPARK Flex
      • Vortex Shafts
      • Installing a Shaft
      • NEO Vortex Solo Adapter
    • NEO V1.1
      • NEO V1
      • Pinion Pressing Guides
    • NEO 550
      • Pinion Pressing Guide
    • Dynamometer Testing
    • Motor Comparison
  • SPARK Flex Motor Controller
    • SPARK Flex Overview
      • SPARK Flex Dock
    • SPARK Flex Specifications
    • SPARK Flex Feature Description
      • Power and Motor Connections
      • Control Connections
      • Data Port
      • Mounting Holes
      • Control Interfaces
      • Mode Button
      • Operating Modes
    • SPARK Flex Getting Started
      • Wiring the SPARK Flex
      • Make it Spin!
      • Basic Configurations
    • SPARK Flex Status LED Patterns
    • SPARK Flex Troubleshooting
    • SPARK Flex Operating Modes
  • SPARK MAX Motor Controller
    • SPARK MAX Overview
    • SPARK MAX Specifications
      • Power and Motor Connections
      • Control Connections
      • Encoder Port
      • Data Port
    • SPARK MAX Getting Started
      • Wiring the SPARK MAX
      • Make it Spin!
      • Basic Configurations
    • SPARK MAX Status LED Patterns
    • SPARK MAX Troubleshooting
    • SPARK MAX Operating Modes
    • SPARK MAX Control Interfaces
    • SPARK MAX Configuration Parameters
    • Using Encoders with the SPARK MAX
      • Absolute Encoders
      • Alternate Encoder Mode
      • Securing the Encoder Adapters
      • Calibration for MAXSwerve
  • REVLib
    • REVLib Overview
      • REVLib Changelog
      • Migrating to REVLib 2025
    • Closed-Loop Control Overview
      • Closed Loop Control Getting Started
      • Getting Started with PID Tuning
      • Position Control Mode
      • Velocity Control Mode
      • Current Control Mode
      • Smart Motion Control
      • Smart Velocity Control
    • Code Examples
    • Migrating to REVLib
    • Device Firmware Changelogs
  • Tips and Tricks
    • Anderson Powerpole Connectors
    • REV Hardware Client Documentation
  • Legacy Documentation
    • SPARK Motor Controller
    • SPARK MAX Client
      • Navigating the SPARK MAX Client
      • Updating Device Firmware
      • Recovery Mode with the SPARK MAX Client
      • SPARK MAX Client Troubleshooting
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. REVLib
  2. Closed-Loop Control Overview

Smart Motion Control

PreviousCurrent Control ModeNextSmart Velocity Control

Last updated 4 months ago

Was this helpful?

January 4, 2025 Update -

Documentation for REVLib 2025 can now be found at:

Please bookmark our new page as we transition over and add more information there!

Smart Motion Control is a complex control mode that allows for smoother and more controlled movements from one position to another. By configuring the maximum velocity and acceleration, as shown in , this control mode will create a motion that accelerates, holds a constant "cruise" velocity, and then decelerates to a stop at the setpoint.

Tuning the PID Controller for Smart Motion may be difficult on mechanisms with a very limited range of motion.

This control mode takes a setpoint in units of rotations, but the underlying implementation executes a Velocity PID controller, so the PID tuning process will be more like a Velocity controller.

The is a good tool for tuning this control loop, as it allows you to toggle between Smart Motion and Velocity control to fine-tune the constants and parameters.

Smart Motion's function is the same as that of , which uses an underlying position-based PID controller which may be easier to tune and can sometimes provide better results.

Running Smart Motion Control is as easy as any other control mode: configure the constants, pick your setpoints, and set it as the mode when you apply the position target, as seen below:

m_pidController.setReference(setPoint, CANSparkBase.ControlType.kSmartMotion);

API Docs:

m_pidController.SetReference(SetPoint, rev::CANSparkBase::ControlType::kSmartMotion);

API Reference:

Using the Velocity Control mode will rotate your mechanism continuously. Please exercise caution while tuning. Utilize hard and soft limits to protect your robot.

https://docs.revrobotics.com/revlib
Smart Motion Example Program
WPILib's TrapezoidalProfile
setReference
SetReference
This graph was generated with a very slow acceleration and max velocity to show the curve. Once your constants are dialed in, these can be increased to make your motion quick and precise. This graph was made using a Spark Flex driving a 1:1 rubber flywheel.
Smart Motion Parameters