APIs, concepts, guides, and more
axis-motion.py
Note
See Axis: Basic Motion 📜 for a detailed explanation of this sample code.
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.
1""" Sample application that demonstrates basic Axis motion.
2"""
3
4from _imports import RapidCode, helpers, time
5
6print("⬤ Axis Basic Motion")
7
8# get/create the motion controller
9creation_params: RapidCode.CreationParameters = helpers.get_creation_parameters()
10controller: RapidCode.MotionController = RapidCode.MotionController.Create(creation_params)
11helpers.check_errors(controller)
12
13# type hints enable IDE autocomplete for RapidCode objects
14print(f"This object is a {type(controller)}")
15
16# create an axis if it doesn't exist
17controller.AxisCountSet(1)
18
19# get axis
20axis: RapidCode.Axis = controller.AxisGet(0)
21helpers.check_errors(axis)
22
23# ready axis for motion
24axis.EStopAbort()
25axis.MotionDoneWait()
26axis.ClearFaults()
27axis.AmpEnableSet(True)
28
29# execute a relative move (distance, velocity, accel, decel, jerk%)
30axis.MoveRelative(2, 10, 1, 1, 50)
31
32# monitor motion
33while not axis.MotionDoneGet():
34 print(f"Position: {axis.CommandPositionGet()}, Velocity: {axis.CommandVelocityGet()}")
35 time.sleep(1)
36
37# clean up
38helpers.abort_motion_object(axis)
39controller.Delete()