Gcode
This module provides utilities for G-code based devices.
ATTRIBUTE | DESCRIPTION |
---|---|
MOVEMENT_BUFFER |
buffer time after movement
TYPE:
|
MOVEMENT_TIMEOUT |
timeout for movement
TYPE:
|
CLASS | DESCRIPTION |
---|---|
GCodeDevice |
Protocol for G-code devices |
GCode |
Interface to control a G-code based device. |
Documentation last updated: 2025-02-22
GCode
GCode(
port: str,
*,
device_type_name: str = "GRBL",
baudrate: int = 115200,
movement_buffer: int | None = None,
movement_timeout: int | None = None,
verbose: bool = False,
**kwargs,
)
Bases: Mover
GCode provides an interface to control a G-code based device. Refer to https://reprap.org/wiki/G-code for more information on G-code commands.
ATTRIBUTE | DESCRIPTION |
---|---|
movement_buffer |
buffer time after movement
TYPE:
|
movement_timeout |
timeout for movement
TYPE:
|
connection_details |
connection details for the device
TYPE:
|
device |
device object that communicates with physical tool
TYPE:
|
flags |
flags for the class
TYPE:
|
is_busy |
whether the device is busy
TYPE:
|
is_connected |
whether the device is connected
TYPE:
|
verbose |
verbosity of class
TYPE:
|
deck |
Deck object for workspace
TYPE:
|
workspace |
workspace bounding box
TYPE:
|
safe_height |
safe height in terms of robot coordinate system
TYPE:
|
saved_positions |
dictionary of saved positions
TYPE:
|
speed |
travel speed of robot
TYPE:
|
speed_factor |
fraction of maximum travel speed of robot
TYPE:
|
speed_max |
maximum speed of robot in mm/min
TYPE:
|
robot_position |
current position of the robot
TYPE:
|
home_position |
home position of the robot in terms of robot coordinate system
TYPE:
|
tool_offset |
tool offset from robot to end effector
TYPE:
|
calibrated_offset |
calibrated offset from robot to work position
TYPE:
|
scale |
factor to scale the basis vectors by
TYPE:
|
tool_position |
robot position of the tool end effector
TYPE:
|
work_position |
work position of the robot
TYPE:
|
worktool_position |
work position of the tool end effector
TYPE:
|
position |
work position of the tool end effector; alias for worktool_position
TYPE:
|
max_accels |
maximum accelerations of the robot
TYPE:
|
max_speeds |
maximum speeds of the robot
TYPE:
|
METHOD | DESCRIPTION |
---|---|
query |
query the device |
toggleCoolantValve |
toggle the coolant valve |
connect |
connect to the device |
disconnect |
disconnect from the device |
resetFlags |
reset all flags to class attribute _default_flags |
shutdown |
shutdown procedure for tool |
enterZone |
enter a zone on the deck |
exitZone |
exit the current zone on the deck |
halt |
halt robot movement |
home |
make the robot go home |
isFeasible |
checks and returns whether the target coordinates is feasible |
loadDeck |
load Deck layout object to mover |
loadDeckFromDict |
load Deck layout object from dictionary |
loadDeckFromFile |
load Deck layout object from file |
move |
move the robot in a specific axis by a specific value |
moveBy |
move the robot by target direction |
moveTo |
move the robot to target position |
moveToSafeHeight |
move the robot to safe height |
moveRobotTo |
move the robot to target position |
moveToolTo |
move the tool end effector to target position |
reset |
reset the robot |
rotate |
rotate the robot in a specific axis by a specific value |
rotateBy |
rotate the robot by target direction |
rotateTo |
rotate the robot to target orientation |
rotateRobotTo |
rotate the robot to target orientation |
rotateToolTo |
rotate the tool end effector to target orientation |
safeMoveTo |
safe version of moveTo by moving to safe height first |
setSafeHeight |
set safe height for robot |
setSpeedFactor |
set the speed factor of the robot |
setToolOffset |
set the tool offset of the robot |
showWorkspace |
show the workspace of the robot |
updateRobotPosition |
update the robot position |
transformRobotToTool |
transform robot coordinates to tool coordinates |
transformRobotToWork |
transform robot coordinates to work coordinates |
transformToolToRobot |
transform tool coordinates to robot coordinates |
transformWorkToRobot |
transform work coordinates to robot coordinates |
calibrate |
calibrate the internal and external coordinate systems |
Initialize GCode class
PARAMETER | DESCRIPTION |
---|---|
port
|
serial port address
TYPE:
|
device_type_name
|
name of the device type. Defaults to 'GRBL'.
TYPE:
|
baudrate
|
baudrate of the device. Defaults to 115200.
TYPE:
|
movement_buffer
|
buffer time after movement. Defaults to None.
TYPE:
|
movement_timeout
|
timeout for movement. Defaults to None.
TYPE:
|
verbose
|
verbosity of class. Defaults to False.
TYPE:
|
home
Make the robot go home
PARAMETER | DESCRIPTION |
---|---|
axis
|
axis to home. Defaults to None.
TYPE:
|
timeout
|
timeout for movement. Defaults to None.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
bool
|
whether the robot successfully homed
TYPE:
|
moveBy
moveBy(
by: Sequence[float] | Position | ndarray,
speed_factor: float | None = None,
*,
jog: bool = False,
rapid: bool = False,
robot: bool = False,
) -> Position
Move the robot by target direction
PARAMETER | DESCRIPTION |
---|---|
by
|
target direction
TYPE:
|
speed_factor
|
speed factor. Defaults to None.
TYPE:
|
jog
|
jog movement. Defaults to False.
TYPE:
|
rapid
|
rapid movement. Defaults to False.
TYPE:
|
robot
|
robot coordinates. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Position
|
new tool/robot position
TYPE:
|
moveTo
moveTo(
to: Sequence[float] | Position | ndarray,
speed_factor: float | None = None,
*,
jog: bool = False,
rapid: bool = False,
robot: bool = False,
) -> Position
Move the robot to target position
PARAMETER | DESCRIPTION |
---|---|
to
|
target position
TYPE:
|
speed_factor
|
speed factor. Defaults to None.
TYPE:
|
jog
|
jog movement. Defaults to False.
TYPE:
|
rapid
|
rapid movement. Defaults to False.
TYPE:
|
robot
|
robot coordinates. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Position
|
new tool/robot position
TYPE:
|
query
query(
data: Any,
multi_out: bool = True,
*,
timeout: int | float = 1,
jog: bool = False,
wait: bool = False,
) -> Any
Query the device
PARAMETER | DESCRIPTION |
---|---|
data
|
data to query
TYPE:
|
multi_out
|
lines of data. Defaults to True.
TYPE:
|
timeout
|
timeout for movement. Defaults to None.
TYPE:
|
jog
|
jog movement. Defaults to False.
TYPE:
|
wait
|
wait for movement. Defaults to False.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Any
|
response from device
TYPE:
|
setSpeedFactor
Set the speed factor of the robot
PARAMETER | DESCRIPTION |
---|---|
speed_factor
|
speed factor. Defaults to None.
TYPE:
|
persist
|
persist speed factor. Defaults to True.
TYPE:
|
GCodeDevice
Bases: Protocol
Protocol for G-code devices
setSpeedFactor
Set the speed factor of the device