示例#1
0
文件: mobot.py 项目: davidko/PyBarobo
    def moveToNB(self, angle1, angle2, angle3, angle4):
        """
        Move all joints on the Linkbot. Linkbot-I modules will ignore the 
        'angle2' parameter and Linkbot-L modules will ignore the 'angle3' 
        parameter.

        This function is the non-blocking version of moveTo(), meaning this
        function will return immediately after the robot has begun moving and
        will not wait until the motion is finished.

        @type angle1: number
        @param angle1: Position to move the joint, in degrees
        @type angle2: number
        @param angle2: Position to move the joint, in degrees
        @type angle3: number
        @param angle3: Position to move the joint, in degrees
        """
        angle1 = _util.deg2rad(angle1)
        angle2 = _util.deg2rad(angle2)
        angle3 = _util.deg2rad(angle3)
        angle4 = _util.deg2rad(angle4)
        buf = bytearray([barobo.BaroboCtx.CMD_SETMOTORANGLESABS, 0x13])
        buf += bytearray(struct.pack('<4f', angle1, angle2, angle3, 0.0))
        buf += bytearray([0x00])
        self._transactMessage(buf)
  def smoothMoveTo(self, joint, accel0, accelf, vmax, angle):
    """
    Move a joint to a desired position with a specified amount of starting and
    stopping acceleration.

    @type joint: number
    @param joint: The joint to move
    @type accel0: number
    @param accel0: The starting acceleration, in deg/sec/sec
    @type accelf: number
    @param accelf: The stopping deceleration, in deg/sec/sec
    @type vmax: number
    @param vmax: The maximum velocity for the joint during the motion, in deg/sec
    @type angle: number
    @param angle: The absolute angle to move the joint to, in degrees
    """
    _accel0 = _util.deg2rad(accel0)
    _accelf = _util.deg2rad(accelf)
    _vmax = _util.deg2rad(vmax)
    _angle = _util.deg2rad(angle)
    buf = bytearray([barobo.BaroboCtx.CMD_SMOOTHMOVE, 20, joint-1])
    buf += bytearray(struct.pack('<4f', _accel0, _accelf, _vmax, _angle))
    buf += bytearray([0x00])
    buf[1] = len(buf)
    self._transactMessage(buf)
示例#3
0
文件: mobot.py 项目: davidko/PyBarobo
 def moveNB(self, angle1, angle2, angle3, angle4):
     """
     Non-blocking version of move(). See move() for more details
     """
     angle1 = _util.deg2rad(angle1)
     angle2 = _util.deg2rad(angle2)
     angle3 = _util.deg2rad(angle3)
     angle4 = _util.deg2rad(angle4)
     buf = bytearray([barobo.BaroboCtx.CMD_MOVE_MOTORS, 0x13])
     buf += bytearray(struct.pack('<4f', angle1, angle2, angle3, angle4))
     buf += bytearray([0x00])
     self._transactMessage(buf)
示例#4
0
文件: mobot.py 项目: davidko/PyBarobo
 def driveToNB(self, angle1, angle2, angle3, angle4):
     """
     Non-blocking version of driveTo(). See driveTo() for more details
     """
     angle1 = _util.deg2rad(angle1)
     angle2 = _util.deg2rad(angle2)
     angle3 = _util.deg2rad(angle3)
     angle4 = _util.deg2rad(angle4)
     buf = bytearray([barobo.BaroboCtx.CMD_SETMOTORANGLESPID, 0x13])
     buf += bytearray(struct.pack('<4f', angle1, angle2, angle3, angle4))
     buf += bytearray([0x00])
     self._transactMessage(buf)
示例#5
0
文件: mobot.py 项目: davidko/PyBarobo
 def moveJointToNB(self, joint, angle):
     """
     Non-blocking version of moveJointTo. See moveJointTo for more details.
     """
     angle = _util.deg2rad(angle)
     buf = bytearray([barobo.BaroboCtx.CMD_SETMOTORANGLEABS, 0x08, joint-1])
     buf += bytearray(struct.pack('<f', angle))
     buf += bytearray([0x00])
     self._transactMessage(buf)
示例#6
0
 def moveJointToNB(self, joint, angle):
     """
 Non-blocking version of moveJointTo. See moveJointTo for more details.
 """
     angle = _util.deg2rad(angle)
     buf = bytearray(
         [barobo.BaroboCtx.CMD_SETMOTORANGLEABS, 0x08, joint - 1])
     buf += bytearray(struct.pack('<f', angle))
     buf += bytearray([0x00])
     self._transactMessage(buf)
示例#7
0
 def setAcceleration(self, accel):
     """
 Set the acceleration of all joints. Each joint motion will begin with this
 acceleration after calling this function. Set the acceleration to 0 to
 disable this feature. 
 """
     buf = bytearray([barobo.BaroboCtx.CMD_SETGLOBALACCEL, 0])
     buf += struct.pack('<f', _util.deg2rad(accel))
     buf += bytearray([0x00])
     buf[1] = len(buf)
     self._transactMessage(buf)
 def setAcceleration(self, accel):
   """
   Set the acceleration of all joints. Each joint motion will begin with this
   acceleration after calling this function. Set the acceleration to 0 to
   disable this feature. 
   """
   buf = bytearray([barobo.BaroboCtx.CMD_SETGLOBALACCEL, 0])
   buf += struct.pack('<f', _util.deg2rad(accel))
   buf += bytearray([0x00])
   buf[1] = len(buf)
   self._transactMessage(buf)
示例#9
0
    def setJointSpeed(self, joint, speed):
        """
        Set the speed of a joint.

        @type joint: number
        @param joint: The joint to change the speed. Can be 1, 2, or 3
        @type speed: number
        @param speed: The speed to set the joint to, in degrees/second.
        """
        _speed = _util.deg2rad(speed)
        buf = bytearray([barobo.BaroboCtx.CMD_SETMOTORSPEED, 0x08, joint - 1])
        buf += bytearray(struct.pack('<f', _speed))
        buf += bytearray([0x00])
        self._transactMessage(buf)
示例#10
0
文件: mobot.py 项目: davidko/PyBarobo
    def setJointSpeed(self, joint, speed):
        """
        Set the speed of a joint.

        @type joint: number
        @param joint: The joint to change the speed. Can be 1, 2, or 3
        @type speed: number
        @param speed: The speed to set the joint to, in degrees/second.
        """
        _speed = _util.deg2rad(speed)
        buf = bytearray([barobo.BaroboCtx.CMD_SETMOTORSPEED, 0x08, joint-1])
        buf += bytearray(struct.pack('<f', _speed))
        buf += bytearray([0x00])
        self._transactMessage(buf)
示例#11
0
    def moveToNB(self, angle1, angle2, angle3, angle4):
        """
    Move all joints on the Linkbot. Linkbot-I modules will ignore the 'angle2'
    parameter and Linkbot-L modules will ignore the 'angle3' parmeter.

    This function is the non-blocking version of moveTo(), meaning this
    function will return immediately after the robot has begun moving and will
    not wait until the motion is finished.

    @type angle1: number
    @param angle1: Position to move the joint, in degrees
    @type angle2: number
    @param angle2: Position to move the joint, in degrees
    @type angle3: number
    @param angle3: Position to move the joint, in degrees
    """
        angle1 = _util.deg2rad(angle1)
        angle2 = _util.deg2rad(angle2)
        angle3 = _util.deg2rad(angle3)
        angle4 = _util.deg2rad(angle4)
        buf = bytearray([barobo.BaroboCtx.CMD_SETMOTORANGLESABS, 0x13])
        buf += bytearray(struct.pack('<4f', angle1, angle2, angle3, 0.0))
        buf += bytearray([0x00])
        self._transactMessage(buf)
示例#12
0
 def startJointAcceleration(self, joint, accel, timeout=0):
     """
     Make a robot's joint start accelerating forwards (positive accel value)
     or backwards.
     
     @type joint: number
     @type accel: float, degrees/s/s
     @type timeout: float, number of seconds. After this number of seconds,
         accel for the joint will be set to 0.
     """
     buf = bytearray([barobo.BaroboCtx.CMD_SET_ACCEL, 0, joint - 1])
     buf += struct.pack('<f', _util.deg2rad(accel))
     buf += bytearray(struct.pack('<i', timeout))
     buf += bytearray([0x00])
     buf[1] = len(buf)
     self._transactMessage(buf)