for further information but I still cannot seem to get manual mocap data to move a finger on the hand or any part of the hand so I can see how to use mocap data.
Here is my current code that is not working. Any help or working example would be greatly appreciated!
import ptvsd
ptvsd.enable_attach(address=("localhost", 5678), redirect_output=True)
ptvsd.wait_for_attach()
import RLPy
hips = ["hips", "", "Hips"]
right_up_leg = ["rightupleg", "hips", "RightUpLeg"]
right_leg = ["rightleg", "rightupleg", "RightLeg"]
right_foot = ["rightfoot", "rightleg", "RightFoot"]
left_up_leg = ["leftupleg", "hips", "LeftUpLeg"]
left_leg = ["leftleg", "leftupleg", "LeftLeg"]
left_foot = ["leftfoot", "leftleg", "LeftFoot"]
spine = ["spine", "hips", "Spine"]
spine_1 = ["spine1", "spine", "Spine3"]
spine_2 = ["spine2", "spine1", "Spine6"]
spine_3 = ["spine3", "spine2", "Spine9"]
neck = ["neck", "spine3", "Neck"]
head = ["head", "neck", "Head"]
right_shoulder = ["rightshoulder", "spine3", "RightShoulder"]
right_arm = ["rightarm", "rightshoulder", "RightArm"]
right_forearm = ["rightforearm", "rightarm", "RightForeArm"]
right_hand = ["righthand", "rightforearm", "RightHand"]
right_hand_thumb_1 = ["righthandthumb1", "righthand", "RightHandThumb1"]
right_hand_thumb_2 = ["righthandthumb2", "righthandthumb1", "RightHandThumb2"]
right_hand_thumb_3 = ["righthandthumb3", "righthandthumb2", "RightHandThumb3"]
right_in_hand_index = ["rightinhandindex", "righthand", "RightInHandIndex"]
right_hand_index_1 = ["righthandindex1", "rightinhandindex", "RightHandIndex1"]
right_hand_index_2 = ["righthandindex2", "righthandindex1", "RightHandIndex2"]
right_hand_index_3 = ["righthandindex3", "righthandindex2", "RightHandIndex3"]
right_in_hand_middle = ["rightinhandmiddle", "righthand", "RightInHandMiddle"]
right_hand_middle_1 = ["righthandmiddle1", "rightinhandmiddle", "RightHandMiddle1"]
right_hand_middle_2 = ["righthandmiddle2", "righthandmiddle1", "RightHandMiddle2"]
right_hand_middle_3 = ["righthandmiddle3", "righthandmiddle2", "RightHandMiddle3"]
right_in_hand_ring = ["rightinhandring", "righthand", "RightInHandRing"]
right_hand_ring_1 = ["righthandring1", "rightinhandring", "RightHandRing1"]
right_hand_ring_2 = ["righthandring2", "righthandring1", "RightHandRing2"]
right_hand_ring_3 = ["righthandring3", "righthandring2", "RightHandRing3"]
right_in_hand_pinky = ["rightinhandpinky", "righthand", "RightInHandPinky"]
right_hand_pinky_1 = ["righthandpinky1", "rightinhandpinky", "RightHandPinky1"]
right_hand_pinky_2 = ["righthandpinky2", "righthandpinky1", "RightHandPinky2"]
right_hand_pinky_3 = ["righthandpinky3", "righthandpinky2", "RightHandPinky3"]
left_shoulder = ["leftshoulder", "spine3", "LeftShoulder"]
left_arm = ["leftarm", "leftshoulder", "LeftArm"]
left_forearm = ["leftforearm", "leftarm", "LeftForeArm"]
left_hand = ["lefthand", "leftforearm", "LeftHand"]
left_hand_thumb_1 = ["lefthandthumb1", "lefthand", "LeftHandThumb1"]
left_hand_thumb_2 = ["lefthandthumb2", "lefthandthumb1", "LeftHandThumb2"]
left_hand_thumb_3 = ["lefthandthumb3", "lefthandthumb2", "LeftHandThumb3"]
left_in_hand_index = ["leftinhandindex", "lefthand", "LeftInHandIndex"]
left_hand_index_1 = ["lefthandindex1", "leftinhandindex", "LeftHandIndex1"]
left_hand_index_2 = ["lefthandindex2", "lefthandindex1", "LeftHandIndex2"]
left_hand_index_3 = ["lefthandindex3", "lefthandindex2", "LeftHandIndex3"]
left_in_hand_middle = ["leftinhandmiddle", "lefthand", "LeftInHandMiddle"]
left_hand_middle_1 = ["lefthandmiddle1", "leftinhandmiddle", "LeftHandMiddle1"]
left_hand_middle_2 = ["lefthandmiddle2", "lefthandmiddle1", "LeftHandMiddle2"]
left_hand_middle_3 = ["lefthandmiddle3", "lefthandmiddle2", "LeftHandMiddle3"]
left_in_hand_ring = ["leftinhandring", "lefthand", "LeftInHandRing"]
left_hand_ring_1 = ["lefthandring1", "leftinhandring", "LeftHandRing1"]
left_hand_ring_2 = ["lefthandring2", "lefthandring1", "LeftHandRing2"]
left_hand_ring_3 = ["lefthandring3", "lefthandring2", "LeftHandRing3"]
left_hand_pinky = ["leftinhandpinky", "lefthand", "LeftInHandPinky"]
left_hand_pinky_1 = ["lefthandpinky1", "leftinhandpinky", "LeftHandPinky1"]
left_hand_pinky_2 = ["lefthandpinky2", "lefthandpinky1", "LeftHandPinky2"]
left_hand_pinky_3 = ["lefthandpinky3", "lefthandpinky2", "LeftHandPinky3"]
hik_bone_list = [hips, right_up_leg, right_leg, right_foot, left_up_leg, left_leg, left_foot,
spine, spine_1, spine_2, spine_3, neck, head,
right_shoulder, right_arm, right_forearm, right_hand,
right_hand_thumb_1, right_hand_thumb_2, right_hand_thumb_3,
right_in_hand_index, right_hand_index_1, right_hand_index_2, right_hand_index_3,
right_in_hand_middle, right_hand_middle_1, right_hand_middle_2, right_hand_middle_3,
right_in_hand_ring, right_hand_ring_1, right_hand_ring_2, right_hand_ring_3,
right_in_hand_pinky, right_hand_pinky_1, right_hand_pinky_2, right_hand_pinky_3,
left_shoulder, left_arm, left_forearm, left_hand,
left_hand_thumb_1, left_hand_thumb_2, left_hand_thumb_3,
left_in_hand_index, left_hand_index_1, left_hand_index_2, left_hand_index_3,
left_in_hand_middle, left_hand_middle_1, left_hand_middle_2, left_hand_middle_3,
left_in_hand_ring, left_hand_ring_1, left_hand_ring_2, left_hand_ring_3,
left_hand_pinky, left_hand_pinky_1, left_hand_pinky_2, left_hand_pinky_3]
tpose = [
0, 105, 0, 0, 0, 0, #hips [0]
-11, 105, 0, 0, 0, 0,
-11, 56, 0, 0, 0, 0,
-11, 8, 0, 0, 0, 0,
11, 105, 0, 0, 0, 0,
11, 56, 0, 0, 0, 0,
11, 8, 0, 0, 0, 0.0,
0, 118, 0, 0, 0, 0, #spine [7]
0, 129, 0, 0, 0, 0,
0, 141, 0, 0, 0, 0,
0, 152, 0, 0, 0, 0,
0, 164, 0, 0, 0, 0,
0, 173, 0, 0, 0, 0,
-3, 160, 0, 0, 0, 0, #right_shoulder [13]
-17, 160, 0, 0, 0, 0,
-46, 160, 0, 0, 0, 0,
-74, 160, 0, 0, 0, 0, #right_hand [16]
-77, 161, 3, 0, 30, 0, #right_hand_thumb_1 [17]
-81, 161, 3, 0, 0, 0,
-83, 161, 3, 0, 0, 0,
-78, 161, 2, 0, 0, 0, #right_in_hand_index [20]
-83, 161, 3, 0, 0, 0,
-87, 161, 3, 0, 0, 0,
-89, 161, 3, 0, 0, 0,
-78, 161, 0, 0, 0, 0, #right_in_hand_middle [24]
-83, 161, 1, 0, 0, 0,
-88, 161, 1, 0, 0, 0,
-90, 161, 1, 0, 0, 0,
-78, 161, -0, 0, 0, 0, #right_in_hand_ring [28]
-83, 161, -0, 0, 0, 0,
-86, 161, -0, 0, 0, 0,
-89, 161, -0, 0, 0, 0,
-77, 161, -1, 0, 0, 0, #right_in_hand_pinky [32]
-82, 161, -2, 0, 0, 0,
-85, 161, -2, 0, 0, 0,
-87, 161, -2, 0, 0, 0,
3, 160, 0, 0, 0, 0, #left_shoulder [36]
17, 160, 0, 0, 0, 0,
46, 160, 0, 0, 0, 0,
74, 160, 0, 0, 0, 0, #left_hand [39]
77, 161, 3, 0, -30, 0, #left_hand_thumb_1 [40]
81, 161, 3, 0, 0, 0,
83, 161, 3, 0, 0, 0,
78, 161, 2, 0, 0, 0,
83, 161, 3, 0, 0, 0,
87, 161, 3, 0, 0, 0,
89, 161, 3, 0, 0, 0,
78, 161, 0, 0, 0, 0,
83, 161, 1, 0, 0, 0,
88, 161, 1, 0, 0, 0,
90, 161, 1, 0, 0, 0,
78, 161, 0, 0, 0, 0,
83, 161, 0, 0, 0, 0,
86, 161, 0, 0, 0, 0,
89, 161, 0, 0, 0, 0,
77, 161, -1, 0, 0, 0,
82, 161, -2, 0, 0, 0,
85, 161, -2, 0, 0, 0,
87, 161, -2, 0, 0, 0] # [58]
fram1_data=[-0.05, 106.89, -3.65, -6.91, 173.25, -1.78, -11.44, -1.88, -0.06, -6.14, 12.7, -9.17, 0.19, -48.07, 0.02, 27.03, -11.94, 0.71, 0.52, -48.92, -0.88, -7.01, -2.03, 16.63, 11.54, -1.81, -0.15, 6.95, 20.59, 4.21, 0.11, -48.01, 0.07, 6.32, -4.32, 0.42, 0.84, -47.31, -0.06, -7.0, 21.87, -1.47, -0.1, 16.66, -0.05, 3.42, 0.62, -2.97, -0.04, 11.32, -0.06, 0.86, 0.14, -0.75, -0.02, 11.78, 0.01, 1.43, 0.21, -1.24, -0.05, 11.31, -0.03, 0.33, -1.32, 0.27, -0.15, 12.08, -0.0, 0.34, -1.33, 0.27, -0.14, 9.01, 0.01, 8.37, -24.14, 3.38, -3.52, 8.02, -0.02, -2.34, 1.02, 10.14, -14.04, -0.15, -0.07, -27.48, 30.59, 18.74, -28.99, -0.1, -0.12, 7.78, 36.33, 6.57, -27.99, -0.02, -0.02, 18.56, -1.48, -48.22, -2.7, 0.21, 3.39, -0.0, 56.65, 24.69, -4.0, 0.0, 0.0, -0.0, 13.01, 7.06, -2.78, 0.0, 0.0, -0.0, -3.83, 0.0, -3.5, 0.55, 2.15, -0.0, 0.0, 0.0, -5.66, -0.1, 1.08, -0.0, 15.0, 12.78, -3.93, 0.0, 0.0, -0.0, 0.0, 12.78, -2.23, 0.0, 0.0, -0.0, 0.0, 12.78, -3.67, 0.56, 0.82, -0.0, 0.0, 0.0, -5.62, -0.09, 0.34, -0.0, 0.0, 14.26, -4.29, 0.0, 0.0, -0.0, 0.0, 14.26, -2.69, 0.0, 0.0, -0.0, 0.0, 14.26, -3.65, 0.58, -0.14, -0.0, 0.0, 0.0, -5.03, -0.02, -0.52, -0.0, -15.0, 13.89, -3.74, 0.0, 0.0, -0.0, 0.0, 13.89, -2.59, 0.0, 0.0, -0.0, 0.0, 13.89, -3.43, 0.51, -1.3, -0.0, 0.0, 0.0, -4.5, -0.02, -1.18, -0.0, -25.0, 10.03, -2.99, 0.0, 0.0, -0.0, 0.0, 10.03, -1.89, 0.0, 0.0, -0.0, 0.0, 10.03, 3.48, 8.09, 0.04, 5.92, 19.77, -1.93, 14.08, 0.06, 0.03, 1.13, -12.31, -70.29, 28.98, 0.11, 0.07, 3.24, -2.94, 1.22, 28.0, -0.02, 0.26, 4.08, 10.77, 6.19, 2.7, 0.21, 3.39, -0.0, -52.26, -28.52, 4.0, 0.0, 0.0, -0.0, -2.75, -5.08, 2.78, 0.0, 0.0, -0.0, -5.53, 0.0, 3.5, 0.55, 2.15, -0.0, 0.0, 0.0, 5.66, -0.1, 1.08, -0.0, -15.0, -16.84, 3.93, 0.0, 0.0, -0.0, 0.0, -16.84, 2.23, 0.0, 0.0, -0.0, 0.0, -16.84, 3.67, 0.56, 0.82, -0.0, 0.0, 0.0, 5.62, -0.09, 0.34, -0.0, 0.0, -18.32, 4.29, 0.0, 0.0, -0.0, 0.0, -18.32, 2.69, 0.0, 0.0, -0.0, 0.0, -18.32, 3.65, 0.58, -0.14, -0.0, 0.0, 0.0, 5.03, -0.02, -0.52, -0.0, 15.0, -21.5, 3.74, 0.0, 0.0, -0.0, 0.0, -21.5, 2.59, 0.0, 0.0, -0.0, 0.0, -21.5, 3.43, 0.51, -1.3, -0.0, 0.0, 0.0, 4.5, -0.02, -1.18, -0.0, 25.0, -24.8, 2.99, 0.0, 0.0, -0.0, 0.0, -24.8, 1.89, 0.0, 0.0, -0.0, 0.0, -24.8]
fram2_data=[6.44, 106.86, 2.11, -6.0, 144.52, -2.36, -11.52, -1.83, -0.05, 7.03, 9.66, 1.24, -0.07, -48.0, -0.04, 3.28, -11.53, -0.02, 0.81, -47.99, -0.85, -4.79, 2.47, 2.48, 11.55, -1.86, 0.02, 5.86, 10.68, 8.65, 0.17, -47.99, 0.05, 6.93, -0.61, 4.33, -0.25, -47.97, 0.22, -3.08, 22.35, -10.46, 0.04, 16.65, 0.0, 3.11, -0.77, 2.42, 0.01, 11.31, -0.03, 0.78, -0.18, 0.61, -0.02, 11.78, -0.0, 1.31, -0.28, 1.01, -0.02, 11.31, -0.01, 0.04, -0.33, 0.2, 0.02, 12.09, -0.04, 0.04, -0.33, 0.2, -0.03, 9.0, -0.08, 1.2, -5.81, 3.62, -3.51, 8.06, 0.02, -3.8, -0.27, 7.17, -14.01, -0.01, -0.01, -0.67, 7.81, 71.31, -29.0, 0.01, -0.15, -4.46, 0.72, 6.46, -28.0, 0.05, -0.07, 13.32, -6.34, -14.73, -2.7, 0.21, 3.39, -0.0, 51.61, 20.16, -4.0, 0.0, 0.0, -0.0, 2.94, 2.53, -2.78, 0.0, 0.0, -0.0, 5.46, 0.0, -3.5, 0.55, 2.15, -0.0, 0.0, 0.0, -5.66, -0.1, 1.08, -0.0, 15.0, 19.35, -3.93, 0.0, 0.0, -0.0, 0.0, 19.35, -2.23, 0.0, 0.0, -0.0, 0.0, 19.35, -3.67, 0.56, 0.82, -0.0, 0.0, 0.0, -5.62, -0.09, 0.34, -0.0, 0.0, 23.71, -4.29, 0.0, 0.0, -0.0, 0.0, 23.71, -2.69, 0.0, 0.0, -0.0, 0.0, 23.71, -3.65, 0.58, -0.14, -0.0, 0.0, 0.0, -5.03, -0.02, -0.52, -0.0, -15.0, 22.43, -3.74, 0.0, 0.0, -0.0, 0.0, 22.43, -2.59, 0.0, 0.0, -0.0, 0.0, 22.43, -3.43, 0.51, -1.3, -0.0, 0.0, 0.0, -4.5, -0.02, -1.18, -0.0, -25.0, 18.58, -2.99, 0.0, 0.0, -0.0, 0.0, 18.58, -1.89, 0.0, 0.0, -0.0, 0.0, 18.58, 3.49, 8.08, 0.03, 2.26, 10.43, -4.93, 14.02, 0.02, 0.07, 4.27, -8.99, -74.93, 29.0, 0.1, 0.04, -2.67, -3.66, 4.19, 28.01, 0.05, 0.03, 4.62, 3.08, 7.23, 2.7, 0.21, 3.39, -0.0, -52.71, -22.76, 4.0, 0.0, 0.0, -0.0, -3.65, 0.68, 2.78, 0.0, 0.0, -0.0, -2.84, 0.0, 3.5, 0.55, 2.15, -0.0, 0.0, 0.0, 5.66, -0.1, 1.08, -0.0, -15.0, -14.1, 3.93, 0.0, 0.0, -0.0, 0.0, -14.1, 2.23, 0.0, 0.0, -0.0, 0.0, -14.1, 3.67, 0.56, 0.82, -0.0, 0.0, 0.0, 5.62, -0.09, 0.34, -0.0, 0.0, -17.7, 4.29, 0.0, 0.0, -0.0, 0.0, -17.7, 2.69, 0.0, 0.0, -0.0, 0.0, -17.7, 3.65, 0.58, -0.14, -0.0, 0.0, 0.0, 5.03, -0.02, -0.52, -0.0, 15.0, -18.98, 3.74, 0.0, 0.0, -0.0, 0.0, -18.98, 2.59, 0.0, 0.0, -0.0, 0.0, -18.98, 3.43, 0.51, -1.3, -0.0, 0.0, 0.0, 4.5, -0.02, -1.18, -0.0, 25.0, -24.32, 2.99, 0.0, 0.0, -0.0, 0.0, -24.32, 1.89, 0.0, 0.0, -0.0, 0.0, -24.32]
mocap_manager = RLPy.RGlobal.GetMocapManager()
hand_device_ID = "HandDevice"
hand_device = mocap_manager.AddHandDevice(hand_device_ID)
# avatar_list = RLPy.RScene.GetAvatars()
# avatar = avatar_list[0]
selection_list = RLPy.RScene.GetSelectedObjects()
if len(selection_list) > 0:
for object in selection_list: # find first avatar
object_type = object.GetType()
if object_type == RLPy.EObjectType_Avatar:
avatar = object
if hand_device is not None:
hand_device.AddAvatar(avatar)
hand_device.SetProcessDataIndex(avatar, 0)
# hand_device.AddAvatar(avatar)
hand_device.SetEnable(avatar, True)
hand_setting = hand_device.GetHandSetting(avatar)
hand_setting.SetRightHandJoin(RLPy.EHandJoin_Wrist)
hand_setting.SetLeftHandJoin(RLPy.EHandJoin_Wrist)
hand_setting.SetHandJoinType(RLPy.EHandJoinType_UseParentBone)
hand_setting.SetRightHandDataSource(RLPy.EHandDataSource_RightHand)
hand_setting.SetLeftHandDataSource(RLPy.EHandDataSource_RightHand)
hand_setting.SetActivePart(RLPy.EBodyActivePart_Hand_R | RLPy.EBodyActivePart_Finger_R |
RLPy.EBodyActivePart_Hand_L | RLPy.EBodyActivePart_Finger_L)
device_setting = hand_device.GetDeviceSetting()
device_setting.SetMocapCoordinate(RLPy.ECoordinateAxis_Y, RLPy.ECoordinateAxes_Z, RLPy.ECoordinateSystem_RightHand)
device_setting.SetCoordinateOffset(0, [0, 0, 0])
position_setting = device_setting.GetPositionSetting()
rotation_setting = device_setting.GetRotationSetting()
rotation_setting.SetType(RLPy.ERotationType_Euler)
rotation_setting.SetUnit(RLPy.ERotationUnit_Degrees)
rotation_setting.SetEulerOrder(RLPy.EEulerOrder_ZXY)
rotation_setting.SetCoordinateSpace(RLPy.ECoordinateSpace_Local)
position_setting.SetUnit(RLPy.EPositionUnit_Centimeters)
position_setting.SetCoordinateSpace(RLPy.ECoordinateSpace_Local)
hand_device.SetTPoseData(avatar, tpose)
hand_device.Initialize(hik_bone_list)
if hand_device.IsTPoseReady(avatar) == True:
mocap_manager.Start(RLPy.EMocapState_Record)
fram1_time = 1000
fram2_time = 5000
hand_device.ProcessData(0, fram1_data, fram1_time)
hand_device.ProcessData(0, fram2_data, fram2_time)
mocap_manager.Stop()