APIs, concepts, guides, and more
axis-motion.py
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
23print(f"Axis {axis.NumberGet()} creation error count: {axis.ErrorLogCountGet()}")
24
25# execute a relative move (distance, velocity, accel, decel, jerk%)
26axis.MoveRelative(2, 10, 1, 1, 50)
27
28# monitor motion
29while not axis.MotionDoneGet():
30 print(f"Position: {axis.CommandPositionGet()}, Velocity: {axis.CommandVelocityGet()}")
31 time.sleep(1)
32
33# clean up
34controller.Delete()