Skip to content

Commit

Permalink
update release v4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dmconover committed Sep 8, 2021
1 parent 2b4aca4 commit 9f617e1
Show file tree
Hide file tree
Showing 48 changed files with 1,841 additions and 666 deletions.
668 changes: 486 additions & 182 deletions MachineMotion.py

Large diffs are not rendered by default.

1,068 changes: 1,059 additions & 9 deletions README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .MachineMotion import *
4 changes: 2 additions & 2 deletions examples/MachineMotionV1/configAxisDirection.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
direction = DIRECTION.REVERSE
mm.configAxisDirection(axis, direction)
print("Axis " + str(axis) + " is set to " + direction + " mode. It will now home towards " + homesTowards[direction] + "." )
mm.emitHome(axis)
mm.moveToHome(axis)

direction = DIRECTION.NORMAL
mm.configAxisDirection(axis, direction)
print("Axis " + str(axis) + " is set to " + direction + " mode. It will now home towards " + homesTowards[direction] + "." )
mm.emitHome(axis)
mm.moveToHome(axis)
4 changes: 2 additions & 2 deletions examples/MachineMotionV1/configHomingSpeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
axis = 1 # The axis to move

print("Moving axis " + str(axis) + " by 100mm.")
mm.emitRelativeMove(axis, DIRECTION.POSITIVE, 100)
mm.moveRelative(axis, 100)
mm.waitForMotionCompletion()

#Homes the axis at the newly configured homing speed.
print("Homing axis " + str(axis))
mm.emitHome(axis)
mm.moveToHome(axis)
5 changes: 2 additions & 3 deletions examples/MachineMotionV1/getPositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# Home Axis Before Moving
print("--> Axis " + str(axis) + " moving home")
mm.emitHome(axis)
mm.moveToHome(axis)
print("--> Axis " + str(axis) + " homed")


Expand Down Expand Up @@ -50,10 +50,9 @@

# Define Motion Parameters
distance = 500
move_direction = DIRECTION.POSITIVE

# Move 500mm and check position again
mm.emitRelativeMove(axis, move_direction, distance)
mm.moveRelative(axis, distance)
desiredPosition_axis = mm.getDesiredPositions(axis)
print("--> Move ongoing")
print("Desired position of axis " + str(axis) + " is : " + str(desiredPosition_axis) + " mm.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@

print("Start Conveyor Move...")
print("Continuous move: speed 100mm/s & acceleration 50mm/s^2")
mm.setContinuousMove(conveyor_axis, 100, 50)
mm.moveContinuous(conveyor_axis, 100, 50)
time.sleep(5)

# Change speed while moving
print("Continuous move: speed 500mm/s & acceleration 250mm/s^2")
mm.setContinuousMove(conveyor_axis, 500, 250)
mm.moveContinuous(conveyor_axis, 500, 250)
time.sleep(5)

# Stop the continuous move
mm.stopContinuousMove(conveyor_axis, conveyor_stop_acc)
mm.stopMoveContinuous(conveyor_axis, conveyor_stop_acc)
time.sleep(2)

# Reverse direction of conveyor by changing the sign of the speed
print("Reverse continuous move: speed -1000mm/s & acceleration 500mm/s^2")
mm.setContinuousMove(conveyor_axis, -1000, 500)
mm.moveContinuous(conveyor_axis, -1000, 500)
time.sleep(5)

# Stop the continuous move
print("Stop Conveyor Move...")
mm.stopContinuousMove(conveyor_axis, conveyor_stop_acc)
mm.stopMoveContinuous(conveyor_axis, conveyor_stop_acc)
time.sleep(3)
print("--> Example completed")
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@

# Begin Relative Move
distance = 100 # in mm
direction = DIRECTION.POSITIVE
mm.emitRelativeMove(axis, direction, distance)
mm.moveRelative(axis, distance)
mm.waitForMotionCompletion()
print("Axis " + str(axis) + " moved " + str(distance) + "mm in the " + direction + " direction.")
print("--> Axis " + str(axis) + " moved " + str(distance) + "mm")

# Pass a negative distance value to move in the opposite direction
distance = -100 # in mm
mm.moveRelative(axis, distance)
mm.waitForMotionCompletion()
print("--> Axis " + str(axis) + " moved " + str(distance) + "mm")

print("--> Example Complete")
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
# Move axis 2 in the negative direction by 100 mm
# Move axis 3 in the positive direction by 50 mm
distances = [50, 100, 50]
directions = [DIRECTION.POSITIVE, DIRECTION.POSITIVE, DIRECTION.POSITIVE]
mm.emitCombinedAxesRelativeMove(axesToMove, directions, distances)
mm.moveRelativeCombined(axesToMove, distances)
mm.waitForMotionCompletion()
for index, axis in enumerate(axesToMove):
print("Axis " + str(axis) + " moved " + str(distances[index]) + "mm in the " + directions[index] + " direction.")
print("Axis " + str(axis) + " moved " + str(distances[index]) + "mm")
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@

# Home the actuator
print ("Axis "+ str(axis) +" is going home")
mm.emitHome(axis)
mm.moveToHome(axis)
print("Axis "+ str(axis) +" is at home")
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

### Home all axes sequentially
print ("All Axes Moving Home sequentially")
mm.emitHomeAll()
mm.moveToHomeAll()
print("All Axes Homed")
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
sys.path.append("../..")
from MachineMotion import *

### This Python example showcases absolute moves with MachineMotion v1. ###
### This Python example showcases moveToPosition with MachineMotion v1. ###

mm = MachineMotion()

#When starting a program, one must remove the software stop before moving
# When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
mm.releaseEstop()
print("--> Resetting system")
Expand All @@ -17,15 +17,15 @@
mm.configAxis(axis, MICRO_STEPS.ustep_8, MECH_GAIN.timing_belt_150mm_turn)

# Movement configuration
position = 100 #The absolute position you'd like to move to
position = 100 #The position to which you'd like to move

# Home Axis before absolute move
print("Axis " + str(axis) + " is going home.")
mm.emitHome(axis)
# Home Axis before moving to position
print("Axis " + str(axis) + " is going to home.")
mm.moveToHome(axis)
print("Axis " + str(axis) + " homed.")

# Move
mm.emitAbsoluteMove(axis, position)
mm.moveToPosition(axis, position)
print("Axis " + str(axis) + " is moving towards position " + str(position) + "mm.")
mm.waitForMotionCompletion()
print("Axis " + str(axis) + " is at position " + str(position) + "mm.")
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# Home actuators before performing absolute moves
print("All Axes Moving Home Sequentially")
mm.emitHomeAll()
mm.moveToHomeAll()
print("All Axes homed.")

### SIMULTANEOUS ABSOLUTE MOVES OF THREE AXES ###
Expand All @@ -30,7 +30,7 @@
# Moves axis 2 to absolute position 100mm
# Moves axis 3 to absolute position 50mm
positions = [50, 100, 50]
mm.emitCombinedAxesAbsoluteMove(axesToMove, positions)
mm.moveToPositionCombined(axesToMove, positions)
mm.waitForMotionCompletion()
for index, axis in enumerate(axesToMove):
print("Axis " + str(axis) + " moved to position " + str(positions[index]) + "mm")
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
mm = MachineMotion()

acceleration = 500 # The max acceleration [mm/s^2] that all subsequent moves will move at
mm.emitAcceleration(acceleration)
mm.setAcceleration(acceleration)
print("Global acceleration set to " + str(acceleration) + "mm/s^2.")
6 changes: 3 additions & 3 deletions examples/MachineMotionV1/setPosition.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

# Home the actuator
print("Axis " + str(axis) + " will home")
mm.emitHome(axis)
mm.moveToHome(axis)
print("Axis " + str(axis) + " homed")

### Perform asolute moves with different reference points ###

print("Absolute Moves are referenced from home")
position = 100
mm.emitAbsoluteMove(axis, position)
mm.moveToPosition(axis, position)
mm.waitForMotionCompletion()
print("Axis " + str(axis) + " is " + str(position) + "mm away from home.")

Expand All @@ -37,6 +37,6 @@
# Move again
position2 = 30
print("Now moving to absolute position " + str(position2) + " mm, referenced from location 'setPosition' was called")
mm.emitAbsoluteMove(axis, position2)
mm.moveToPosition(axis, position2)
mm.waitForMotionCompletion()
print("Axis " + str(axis) + " is now " + str(position2) + "mm from reference position and " + str(position + position2) + "mm from home")
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
mm = MachineMotion()

speed = 500 # The max speed [mm/s] that all subsequent moves will move at
mm.emitSpeed(speed)
mm.setSpeed(speed)
print("Global speed set to " + str(speed) + "mm/s.")
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@

# Configure Move Parameters
speed = 200
mm.emitSpeed(speed)
mm.setSpeed(speed)

# Begin Relative Move
distance = 1000
direction = DIRECTION.POSITIVE
mm.emitRelativeMove(axis, direction, distance)
print("Axis " + str(axis) + " is moving " + str(distance) + "mm in the " + direction + " direction.")
mm.moveRelative(axis, distance)
print("Axis " + str(axis) + " is moving " + str(distance) + "mm")
# This move should take 5 seconds to complete (distance/speed). Instead, we wait 2 seconds and then stop the machine.
time.sleep(2)
mm.emitStop()
mm.stopAllMotion()
print("Axis " + str(axis) + " stopped.")
3 changes: 1 addition & 2 deletions examples/MachineMotionV1/waitForMotionCompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

# Move the axis by 100mm
distance = 100
direction = DIRECTION.POSITIVE

print("Moving %d mm!" % distance)
mm.emitRelativeMove(axis, direction, distance)
mm.moveRelative(axis, distance)
print("This message gets printed immediately")
mm.waitForMotionCompletion()
print("This message gets printed once machine has finished moving")
8 changes: 5 additions & 3 deletions examples/MachineMotionV2/configHomingSpeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### This Python example configures homing speed for MachineMotion v2. ###

mm = MachineMotion(machineMotionHwVersion=MACHINEMOTION_HW_VERSIONS.MMv2)
mm = MachineMotionV2()

# When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
Expand All @@ -26,9 +26,11 @@
axis = 1 # The axis to move

print("Moving axis " + str(axis) + " by 100mm.")
mm.emitRelativeMove(axis, DIRECTION.POSITIVE, 100)
mm.moveRelative(axis, 100)
mm.waitForMotionCompletion()

#Homes the axis at the newly configured homing speed.
print("Homing axis " + str(axis))
mm.emitHome(axis)

mm.moveToHome(axis)
mm.waitForMotionCompletion()
36 changes: 36 additions & 0 deletions examples/MachineMotionV2/configMultiDriveServo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import sys
sys.path.append("../..")
from MachineMotion import *

### This Python example configures and moves a multi-drive axis. ###

### Multiple motors that are mechanically linked can now be treated
### as though they are a single axis. Once propely configured,
### multi-drive axes can be moved just as with single-drive axes.

### Machine Motion declaration
mm = MachineMotionV2()

### If not on a conveyor, the parent drive must have home and end sensors.
### The child drive's sensors will be ignored.
parent = 1
parentDirection = DIRECTION.NORMAL
child = 2
childDirection = DIRECTION.NORMAL

mechGain = MECH_GAIN.timing_belt_150mm_turn
motorCurrent = 5.0 # Current (A)

print("--> Configuring parent drive " + str(parent) + " with child " + str(child))

### Configure your multi-drive axis by passing the list of drives, directions and parent drive.
mm.configServo([parent, child], mechGain, [parentDirection, childDirection], motorCurrent, parentDrive = parent)

### The parent and child drives are now linked.
### Control the multi-drive axis via the parent drive:

print("--> Multi-drive axis is moving relative by 200mm!")
mm.moveRelative(parent, 200)
mm.waitForMotionCompletion()

print("--> Example Complete!")
2 changes: 1 addition & 1 deletion examples/MachineMotionV2/configStepperServo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### This Python example configures actuators for a MachineMotion v2. ###

mm = MachineMotion(machineMotionHwVersion=MACHINEMOTION_HW_VERSIONS.MMv2)
mm = MachineMotionV2()

# When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
Expand Down
2 changes: 1 addition & 1 deletion examples/MachineMotionV2/controlBrakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### This Python example control brakes on MachineMotion v2. ###

mm = MachineMotion(machineMotionHwVersion=MACHINEMOTION_HW_VERSIONS.MMv2)
mm = MachineMotionV2()

# When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
Expand Down
2 changes: 1 addition & 1 deletion examples/MachineMotionV2/digitalRead.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### This Python example reads digital inputs for MachineMotion v2. ###

mm = MachineMotion(machineMotionHwVersion=MACHINEMOTION_HW_VERSIONS.MMv2)
mm = MachineMotionV2()

# Detect all connected digital IO Modules
detectedIOModules = mm.detectIOModules()
Expand Down
2 changes: 1 addition & 1 deletion examples/MachineMotionV2/digitalWrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### This Python example writes digital outputs for MachineMotion v2. ###

mm = MachineMotion(machineMotionHwVersion=MACHINEMOTION_HW_VERSIONS.MMv2)
mm = MachineMotionV2()

# Detect all connected digital IO Modules
detectedIOModules = mm.detectIOModules()
Expand Down
2 changes: 1 addition & 1 deletion examples/MachineMotionV2/eStop.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
### MachineMotion CONFIGURATION ###

# Create MachineMotion instance
mm = MachineMotion(machineMotionHwVersion=MACHINEMOTION_HW_VERSIONS.MMv2)
mm = MachineMotionV2()
time.sleep(0.1) # Wait to initialize internal eStop topics.

# Define a callback to process estop status
Expand Down
2 changes: 1 addition & 1 deletion examples/MachineMotionV2/getEndStopState.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### This Python example showcases how to read enstop sensor states with MachineMotion v2. ###

mm = MachineMotion(machineMotionHwVersion=MACHINEMOTION_HW_VERSIONS.MMv2)
mm = MachineMotionV2()

# When starting a program, one must remove the software stop
print("--> Removing software stop")
Expand Down
8 changes: 4 additions & 4 deletions examples/MachineMotionV2/getPositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

###### CONFIGURING MACHINEMOTION ######

mm = MachineMotion(machineMotionHwVersion=MACHINEMOTION_HW_VERSIONS.MMv2)
mm = MachineMotionV2()

# When starting a program, one must remove the software stop before moving
print("--> Removing software stop")
Expand All @@ -21,7 +21,8 @@

# Home Axis Before Moving
print("--> Axis " + str(axis) + " moving home")
mm.emitHome(axis)
mm.moveToHome(axis)
mm.waitForMotionCompletion()
print("--> Axis " + str(axis) + " homed")


Expand All @@ -44,10 +45,9 @@

# Define Motion Parameters
distance = 100
move_direction = DIRECTION.POSITIVE

# Move 100mm and check position again
mm.emitRelativeMove(axis, move_direction, distance)
mm.moveRelative(axis, distance)
print("--> Move ongoing")
while not mm.isMotionCompleted():
actualPosition_axis = mm.getActualPositions(axis)
Expand Down
Loading

0 comments on commit 9f617e1

Please sign in to comment.