Beispiel #1
0
    def queue_extended_point(self,
                             position,
                             dda_speed,
                             e_distance,
                             feedrate_mm_sec,
                             relative_axes=[]):
        """
        Move the toolhead to a new position at the given rate
        @param list position: 5D position to move to. All dimension should be in steps.
        @param double rate: Movement speed, in steps/??
        """
        if len(position) != self.extendedPointLength:
            raise makerbot_driver.PointLengthError(len(position))
        if self.send_accelerated_point:
            dda_rate = 1000000.0 / float(dda_speed)
            self.queue_extended_point_accelerated(position, dda_rate,
                                                  relative_axes, e_distance,
                                                  feedrate_mm_sec)
        else:
            payload = struct.pack(
                '<BiiiiiI', makerbot_driver.
                host_action_command_dict['QUEUE_EXTENDED_POINT'], position[0],
                position[1], position[2], position[3], position[4], dda_speed)

            self.writer.send_action_payload(payload)
Beispiel #2
0
def calculate_vector_difference(minuend, subtrahend):
    """ Given two 5d vectors represented as lists, calculates their
    difference (minued - subtrahend)

    @param list minuend: 5D vector to be subracted from
    @param list subtrahend: 5D vector to subtract from the minuend
    @return list difference
    """
    if len(minuend) != 5:
        raise makerbot_driver.PointLengthError(
            "Expected list of length 5, got length %i" % (len(minuend)))
    if len(subtrahend) != 5:
        raise makerbot_driver.PointLengthError(
            "Expected list of length 5, got length %i" % (len(subtrahend)))

    difference = []
    for m, s in zip(minuend, subtrahend):
        difference.append(m - s)

    return difference
Beispiel #3
0
def calculate_euclidean_distance(minuend, subtrahend):
    """
    Given two points of the same dimension, calculates their
    euclidean distance

    @param list minuend: 5D vector to be subracted from
    @param list subtrahend: 5D vector to subtract from the minuend
    @param int distance: Distance between the two points
    """
    if not len(minuend) == len(subtrahend):
        raise makerbot_driver.PointLengthError("Expected identical lengths, instead got %i %i" % (len(minuend), len(subtrahend)))
    distance = 0.0
    for m, s in zip(minuend, subtrahend):
        distance += pow(m - s, 2)
    distance = math.sqrt(distance)
    return distance
Beispiel #4
0
    def set_extended_position(self, position):
        """
        Inform the machine that it should consider this point its current point
        @param list position: 5D position to set the machine to, in steps.
        """
        if len(position) != self.extendedPointLength:
            raise makerbot_driver.PointLengthError(len(position))

        payload = struct.pack(
            '<Biiiii',
            makerbot_driver.host_action_command_dict['SET_EXTENDED_POSITION'],
            position[0],
            position[1],
            position[2],
            position[3],
            position[4],
        )

        self.writer.send_action_payload(payload)
Beispiel #5
0
    def queue_extended_point_new(self, position, duration, relative_axes):
        """
        Queue a position with the new style!  Moves to a certain position over a given duration
        with either relative or absolute positioning.  Relative vs. Absolute positioning
        is done on an axis to axis basis.

        @param list position: A 5 dimentional position in steps specifying where each axis should move to
        @param int duration: The total duration of the move in miliseconds
        @param list relative_axes: Array of axes whose coordinates should be considered relative
        """
        if len(position) != self.extendedPointLength:
            raise makerbot_driver.PointLengthError(len(position))

        payload = struct.pack(
            '<BiiiiiIB', makerbot_driver.
            host_action_command_dict['QUEUE_EXTENDED_POINT_NEW'], position[0],
            position[1], position[2], position[3], position[4], duration,
            makerbot_driver.Encoder.encode_axes(relative_axes))

        self.writer.send_action_payload(payload)
Beispiel #6
0
    def queue_extended_point_accelerated(self, position, dda_rate,
                                         relative_axes, distance, feedrate):
        """
        Queue a position with the new style!  Moves to a certain position over a given duration
        with either relative or absolute positioning.  Relative vs. Absolute positioning
        is done on an axis to axis basis.
        @param list position: A 5 dimentional position in steps specifying where each axis should move to
        @param int dda_rate: Steps per second along the master axis
        @param list relative_axes: Array of axes whose coordinates should be considered relative
        @param float distance: distance in millimeters moved in (x,y,z) space OR if distance(x,y,z) == 0, then max(distance(A),distance(B))
        @param float feedrate: the actual feedrate in units of millimeters/second
        """
        if len(position) != self.extendedPointLength:
            raise makerbot_driver.PointLengthError(len(position))

        payload = struct.pack(
            '<BiiiiiIBfh', makerbot_driver.makerbot_driver.
            host_action_command_dict['QUEUE_EXTENDED_POINT_ACCELERATED'],
            position[0], position[1], position[2], position[3], position[4],
            dda_rate, makerbot_driver.Encoder.encode_axes(relative_axes),
            float(distance), int(feedrate * 64.0))
        self.writer.send_action_payload(payload)