

Partial Public Class frmArm

    Public Shared boolLocationFocused As Boolean = False

    '================== Arm   ========================
    ' Arm dimensions in mm
    Const constMaxJointAngle = 115
    Const constShoulderToElbow = 175   ' 
    Const constElbowToWristR = 67       ' 
    Const constWristROffset = 30
    Const constWristRToWrist = 0
    Const constWristToGripper = 140
    Const constBaseAngleYZ = 0  ' 
    Const constCameraOffsetY = 50
    Const constCameraOffsetZ = 25
    Const constShoulderBaseY = 40
    Const constShoulderBaseZ = 355
    Const constArmLength_mm = constShoulderToElbow + constElbowToWristR + constWristRToWrist + constWristToGripper  ' 382 mm


    Public Shared boolEnableArm As Boolean = True
    Public Shared intArmComPort As Integer = 999

    Public Structure typePointCoordinate ' coordinates in mm relative to Bot
        Dim X As Integer
        Dim Y As Integer
        Dim Z As Integer
    End Structure


    Public Structure typeJointCoordinate  'Coordinates in mm
        Dim tpcShoulderBase As typePointCoordinate
        Dim tpcShoulder As typePointCoordinate
        Dim tpcElbow As typePointCoordinate
        Dim tpcWrist As typePointCoordinate
        Dim tpcWristRotateB4Offset As typePointCoordinate
        Dim tpcWristRotate As typePointCoordinate
        Dim tpcGripperEnd As typePointCoordinate
        Dim tpcCamera As typePointCoordinate
    End Structure

    ' angles in degrees
    Public Structure typeArmAngles
        Dim sngBaseYX As Single
        Dim sngBaseXZ As Single
        Dim sngShoulder As Single  ' Relative to ground NOT the joint angle
        Dim sngElbow As Single  ' Relative to ground NOT the joint angle
        Dim sngWrist As Single
        Dim sngWristRotate As Single
        Dim sngGripperOpening As Single  '
    End Structure

    Public Shared taaArmAngles As typeArmAngles
    Public Shared tjcJointCoordinates As typeJointCoordinate



    Public Shared timeJointMove(9) As DateTime

    '==============  Arm Auto Control  ==================
    Public Structure typeArmObject
        Dim strName As String
        Dim tmcLocation As typeMapCoordinate ' Object location
        Dim intObjectHeight As Integer ' Height of object above ground
        Dim intOrientation As Integer  ' Bot orientation required to pick up object
        Dim intRotation As Integer     ' Gripper Rotation angle required to pick up object 
        Dim intGripOffset_mm As Integer ' Gripper offset from Visually located position required to pick up object 
    End Structure
    Public Shared taoObjectArray(32) As typeArmObject




    Public Const constGripperOpenPosition = 519
    Public Const constGripperClosedPosition = 718

    Const constDefaultBaudNum As Byte = 1  '1Mbps


    '==============   API  ==================
    Public Shared boolCloseGripperAPI As Boolean = False
    Public Shared boolOpenGripperAPI As Boolean = False
    Public Shared boolHomeArmAPI As Boolean = False
    Public Shared boolLookUpAPI As Boolean = False
    Public Shared boolLookDownAPI As Boolean = False
    Public Shared boolMoveToNewAnglesAPI As Boolean = False
    Public Shared boolPickUpAPI As Boolean = False
    Public Shared intXAPI As Integer = 999
    Public Shared taaNewArmAngles As typeArmAngles

    '==============   Misc  ==================
    Public Shared boolArmConnected As Boolean = False
    Public Shared intArmSegmentSelect As Integer = 2


    ' ==============   Dynamixel Register Addresses (see http://support.robotis.com/en/product/dynamixel/ax_series/dxl_ax_actuator.htm)
    Const constPresentPosition As Integer = 36
    Const constGoalPosition As Integer = 30   '30
    Const constCWComplianceMargin As Integer = 26  '
    Const constCCWComplianceMargin As Integer = 27  '
    Const constCWComplianceSlope As Integer = 28  '
    Const constCCWComplianceSlope As Integer = 29  '
    Const constMovingSpeed As Integer = 32
    Const constAlarmShutDown As Integer = 18
    Public Const constTorqueLimit As Integer = 34   ' 34
    Const constTorqueMax As Integer = 14     '14
    Const constAlarm As Integer = 17
    Const constLoad As Integer = 40
    Const constTemperature As Integer = 43
    Const constHiTemperature As Integer = 11
    Const constMoving As Integer = 46
    Const constReturnDelayTime As Integer = 5
    Public Const constTorqueEnable As Integer = 24

    Const constShoulderSegment As Byte = 2
    Const constElbowSegment As Byte = 3
    Const constWristRotateSegment As Byte = 4
    Const constWristSegment As Byte = 5
    Const constGripperSegment As Byte = 6

    Const constBaseServo As Byte = 1
    Const constShoulderRServo As Byte = 2
    Const constShoulderServo As Byte = 3
    Const constElbowServo As Byte = 4
    Const constElbowRServo As Byte = 5
    Const constWristRotateServo As Byte = 6
    Const constGripperServo As Byte = 7



End Class
