APIs, concepts, guides, and more
Axis: Basic Motion

Basics for getting up and running with Axis motion in RapidCode for Python.

Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.

The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.


In this page:


📜 Axis Basic Motion

Learn how to command basic Axis motion in Python.

""" Sample application that demonstrates basic Axis motion.
"""
from _imports import RapidCode, helpers, time
print("⬤ Axis Basic Motion")
# get/create the motion controller
creation_params: RapidCode.CreationParameters = helpers.get_creation_parameters()
controller: RapidCode.MotionController = RapidCode.MotionController.Create(creation_params)
helpers.check_errors(controller)
# type hints enable IDE autocomplete for RapidCode objects
print(f"This object is a {type(controller)}")
# create an axis if it doesn't exist
controller.AxisCountSet(1)
# get axis
axis: RapidCode.Axis = controller.AxisGet(0)
helpers.check_errors(axis)
print(f"Axis {axis.NumberGet()} creation error count: {axis.ErrorLogCountGet()}")
# execute a relative move (distance, velocity, accel, decel, jerk%)
axis.MoveRelative(2, 10, 1, 1, 50)
# monitor motion
while not axis.MotionDoneGet():
print(f"Position: {axis.CommandPositionGet()}, Velocity: {axis.CommandVelocityGet()}")
time.sleep(1)
# clean up
controller.Delete()