University of Southern CaliforniaUSC
USC ICT TwitterUSC ICT FacebookUSC ICT YouTube

Reaching | General SmartBody Discussion | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Reaching
December 11, 2015
11:12 am
Avatar
Germany
Member
Members
Forum Posts: 24
Member Since:
June 22, 2015
sp_UserOfflineSmall Offline

Hello,

 

I cannot quite get the raching going implemeting it in C++. So far I want my character just to grab witht eh right hand a certain object to which I manually attached a SBPawn. The reaching is triggered and some movement is started. However, I did something wrong so the whole body gets deformed in a strange way althought the hand reaches to the approximately correct position.

The position can be seen in this picture at:

https://www.dropbox.com/s/5v3bnm896vwwhm6/failedReach.png?dl=0

 

I am not sure what goes wrong maybe something related to a wrong skeleton or a wrongly scaled motion. The Reach is initialized with:

SmartBody::SBScene* scene = SmartBody::SBScene::getScene();
    SmartBody::SBReach* pReach = m_pReachManager->createReach(charname);
    pReach->setInterpolatorType("KNN");
    scene->loadAssetsFromPath("behaviorsets/reaching/motions/");
    SmartBody::SBSkeleton* pSkeleton = scene->getSkeleton("common.sk");
    //scene->addAssetPath("motion", "behaviorsets/reaching/motions/");
    //scene->loadAssets();
    std::vector<std::string> vecMotionNames;
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachRtHigh"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachRtMidHigh"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachRtMidLow"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachLfLow"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachLfHigh"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachLfMidHigh"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachRtMidLow"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachRtLow"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachMiddleHigh"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachMiddleMidHigh"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachMiddleMidLow"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachMiddleLow"));

    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachClose_Lf"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachClose_Rt"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachClose_MiddleLow"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachClose_MiddleMidHigh"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachClose_MiddleMidLow"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachClose_MiddleHigh"));

    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachBehind_High1"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachBehind_High2"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachBehind_Low1"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachBehind_Low2"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachBehind_MidHigh1"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachBehind_MidHigh2"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachBehind_MidLow1"));
    vecMotionNames.push_back(("ChrHarmony_Relax001_ArmReachBehind_MidLow2"));

    std::string skelName = scene->getCharacter(charname)->getSkeleton()->getName();

    for(int i=0; i<vecMotionNames.size(); i++){
        SmartBody::SBMotion* pMotion = scene->getMotion(vecMotionNames[i]);
        if(pMotion==NULL)
            vstr::errp()<<"Motion: "<<vecMotionNames[i]<<" not loaded correctly!"<<std::endl;
        pMotion->setMotionSkeletonName("common.sk");
        pReach->addMotion("right", pMotion);
    }
    
    pReach->setGrabHandMotion("right",scene->getMotion("ChrHarmony_Relax001_HandGraspSmSphere_Grasp"));
    pReach->setReachHandMotion("right",scene->getMotion("ChrHarmony_Relax001_HandGraspSmSphere_Reach"));
    pReach->setReleaseHandMotion("right",scene->getMotion("ChrHarmony_Relax001_HandGraspSmSphere_Release"));
    pReach->setPointHandMotion("right",scene->getMotion("HandsAtSide_RArm_GestureYou"));

    pReach->build(scene->getCharacter(charname)); 

and the motion is triggered with this bml command:

"<sbm:reach sbm:action=\"grab\" target=\""+pTarget->getName()+"\" sbm:reach-finish=\"false\" sbm:reach-duration=\"2\"/>";

Do you have any ideas what I did wrong or where I should try to find the error?

 

Additionally, while consulting the manual I found a little error on page 133 it has to be

mypawn.setVec3Attribute("collisionShapeScale", size1, size2, size3)

instead of

mypawn.setVec3Attribute("collisionShape", size1, size2, size3)

December 12, 2015
12:23 am
Avatar
Admin
Forum Posts: 980
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

I've made the fix in the documentation, thanks.

I suspect that the problem is related to retargeting; SmartBody has an online retargeting system where motion data gets transferred in real time to your character. This gives it a lot of flexibility (essentially, any character properly configured can take advantage of any data set) but requires a bit of extra scrutiny. Frankly, it can create some confusion and frustration (even for me...) and I probably should create better tools to visualize this issue.

The reaching data set that you are using is associated with the common.sk skeleton. There's an instruction:

pMotion->setMotionSkeletonName("common.sk");

 

which associates a motion with it's original skeleton.

So the first thing I would try is to create your character using that skeleton:

c = scene.createCharacter("mycharacter", "")

sk = scene.createSkeleton("common.sk")

c.setSkeleton(sk)

and see if that character is able to use your reaching data set, instead of Brad. Brad himself uses a different skeleton configuration ChrBrad.sk (internall, we call this thezebra2 configuration) where joints are named differently. If the character created using the common.sk works, but Brad doesn't, then you need to make sure of two things:

(1) that Brad's skeleton has a joint map to the standard skeleton naming. There is a script called zebra2-map.py that has those instructions (easily converted to C++)

(2) that there is a mapping between common.sk and Brad's skeleton that allows the online retargeting to work, like this in BehaviorSetCommon.py:

 

def createRetargetInstance(srcSkelName, tgtSkelName):
endJoints = StringVec();
endJoints.append('l_ankle')
endJoints.append('l_forefoot')
endJoints.append('l_toe')
endJoints.append('l_wrist')
endJoints.append('r_ankle')
endJoints.append('r_forefoot')
endJoints.append('r_toe')
endJoints.append('r_wrist')

relativeJoints = StringVec();
relativeJoints.append('spine1')
relativeJoints.append('spine2')
relativeJoints.append('spine3')
relativeJoints.append('spine4')
relativeJoints.append('spine5')
relativeJoints.append('r_sternoclavicular')
relativeJoints.append('l_sternoclavicular')
relativeJoints.append('r_acromioclavicular')
relativeJoints.append('l_acromioclavicular')
# replace retarget each animation with just a simple retarget instance
retargetManager = scene.getRetargetManager()
   retarget = retargetManager.getRetarget(srcSkelName,tgtSkelName)
if retarget == None:
retarget = retargetManager.createRetarget(srcSkelName,tgtSkelName)
   retarget.initRetarget(endJoints,relativeJoints)

where srcSkelName is "common.sk" an tgtSkelName is ChrBrad.sk

 

Ari

December 14, 2015
11:27 am
Avatar
Germany
Member
Members
Forum Posts: 24
Member Since:
June 22, 2015
sp_UserOfflineSmall Offline

Thank you four your detailed answer.

These adjustments helped although the main problem originated from the problem that the common.sk was not loaded due to a missing line

scene->addAssetPath("motion", "sbm-common/common-sk");

Maybe it would be a helpful thing if there is an error message if one of the skeletons for retargeting is not loaded.

Now it is going in the right direction, still some small problems that I can hopefully solve myself.

Thank you.

Forum Timezone: America/Los_Angeles

Most Users Ever Online: 733

Currently Online: mondayneedle1, juhlvalenzuela2, lanp4anase, worriedutopia9579, DixieDelgado, lyinglegacy8966, eric506784
89 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

jwwalker: 80

jyambao: 51

rbaral: 47

adiaz: 30

WargnierP: 29

lucky7456969: 28

mbarros: 28

avida.matt: 26

JonathanW: 24

laguerre: 23

Member Stats:

Guest Posters: 65

Members: 52460

Moderators: 3

Admins: 4

Forum Stats:

Groups: 1

Forums: 5

Topics: 427

Posts: 2343