University of Southern CaliforniaUSC
USC ICT TwitterUSC ICT FacebookUSC ICT YouTube

Embedded Python Library cannot use steer function | 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
Embedded Python Library cannot use steer function
October 16, 2015
10:10 am
Avatar
Member
Members
Forum Posts: 9
Member Since:
May 18, 2015
sp_UserOfflineSmall Offline

Hi Ari,

I tried to use SmartBody as an Embedded Python Library. The problem is that when I use 

 

scene.getBmlProcessor().execBML('mychar', '<sbm:reach sbm:action="pick-up" sbm:reach-duration="0.2" target="touchPawn2" sbm:use-locomotion="true"/>')

 

The character would only behave the motion at where they are, without locomotion.

 

I have used

BehaviorSetMaleMocapLocomotion

BehaviorSetGestures

BehaviorSetReaching

to init my character and I also have done:

 

steerManager = scene.getSteerManager()
steerManager.setEnable(True)

 

So I am wondering whether what else do I need to do to make this work.

 

Hope you can help me with this problem!

 

Sincerely

cszqwe

October 16, 2015
4:36 pm
Avatar
Admin
Forum Posts: 980
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

If you are using SmartBody as an embedded Python library, how are you transferring the state of the character to your rendering system (and what renderer are you using?)

There is a joint called world_offset which you should map to a parent matrix (in addition to mapping the joint rotations of the character) which will be modified as the locomotion is applied.

 

Ari

October 19, 2015
2:24 am
Avatar
Member
Members
Forum Posts: 9
Member Since:
May 18, 2015
sp_UserOfflineSmall Offline

I am using Blender. I just synchronize all joints.

arr = ['world_offset', 'JtRoot', 'breathX', 'breathY', 'JtSpineA', 'JtHipLf', 'JtHipRt', 'JtSpineB', 'JtKneeLf', 'JtKneeRt', 'JtSpineC', 'JtAnkleLf', 'JtAnkleRt', 'JtNeckA', 'JtClavicleLf', 'JtClavicleRt', 'JtBallLf', 'JtBallRt', 'JtSkullA', 'JtShoulderLf', 'JtShoulderRt', 'JtToeLf', 'JtToeRt', 'JtEyeRt', 'JtEyeLf', 'JtElbowLf', 'JtElbowRt', 'JtWristLf', 'JtWristRt', 'JtThumbALf', 'JtLittleALf', 'JtRingALf', 'JtMiddleALf', 'JtIndexALf', 'Lhand_att', 'Rhand_att', 'JtThumbARt', 'JtIndexARt', 'JtMiddleARt', 'JtRingARt', 'JtLittleARt', 'JtThumbBLf', 'JtLittleBLf', 'JtRingBLf', 'JtMiddleBLf', 'JtIndexBLf', 'JtThumbBRt', 'JtIndexBRt', 'JtMiddleBRt', 'JtRingBRt', 'JtLittleBRt', 'JtThumbCLf', 'JtLittleCLf', 'JtRingCLf', 'JtMiddleCLf', 'JtIndexCLf', 'JtThumbCRt', 'JtIndexCRt', 'JtMiddleCRt', 'JtRingCRt', 'JtLittleCRt', 'JtThumbDLf', 'JtLittleDLf', 'JtRingDLf', 'JtMiddleDLf', 'JtIndexDLf', 'JtThumbDRt', 'JtIndexDRt', 'JtMiddleDRt', 'JtRingDRt', 'JtLittleDRt']

 

In fact, the locomotion behavior can behave correctly. My character can move forward ( which would return back to her original position after animation), turn around and so on. 

 

The problem is that when I use 

scene.getBmlProcessor().execBML('mychar', '<sbm:reach sbm:action="pick-up" sbm:reach-duration="0.2" target="touchPawn2" sbm:use-locomotion="true"/>')

Once my touchPawn is not just at the same location of my character, there would be an exception which states

"Traceback (most recent call last):

     File "<string>", line 1, in <module>

NameError: name 'scene' is not defined".

October 19, 2015
4:07 am
Avatar
Admin
Forum Posts: 980
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

There are several implicit variable names that get set in the setupPython() function which I don't believe is getting called when SmartBody is being used as an embedded library:

 

scene = getScene()
bml = scene.getBmlProcessor()
sim = scene.getSimulationManager()
assets = scene.getAssetManager()

 

so perhaps 'scene' doesn't exist yet, and you can substitue 'scene' for 'getScene()' like this:

getScene().getBmlProcessor().execBML('mychar', '<sbm:reach sbm:action="pick-up" sbm:reach-duration="0.2" target="touchPawn2" sbm:use-locomotion="true"/>')

 

or you can call:

scene = getScene()

scene.getBmlProcessor().execBML('mychar', '<sbm:reach sbm:action="pick-up" sbm:reach-duration="0.2" target="touchPawn2" sbm:use-locomotion="true"/>')

 

Let me know if either of those work for you.

 

Curiously, are you using this in the blender game engine or in Blender itself?

 

Ari

October 19, 2015
5:02 am
Avatar
Member
Members
Forum Posts: 9
Member Since:
May 18, 2015
sp_UserOfflineSmall Offline

Thanks for your reply.

 

In blender game engine. I use SmartBody in script and once BGE starts, my SmartBody began to work.

 

Actually, I have set the name well. And all other functions perform quite well. The only problem is that my character cannot do reach function. She just stands there without moving. If the touch pawn is just around her, she would try to touch it. If the pawn is far away, she just does nothing and the above error message shows. 

 

I am wondering whether the steerlib is not included in SmartBody.dll?

October 19, 2015
5:37 pm
Avatar
Admin
Forum Posts: 980
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Try the following two things:

 

1) After you have set up your character for locomotion, try to make them move using the blends (the steering normally controls these blends, but you can activate them manually):

scene.getBmlProcessor().execBML('mychar', '<blend name="mocapLocomotion" x="200"/>')

This should instruct the character to move forward as fast as possible.

2) Make the following change as one of your initial commands to SmartBody

scene.getSteerManager().setStringAttribute("engineOptions.moduleSearchPath", "/path/to/pprAI.dll")

where the second parameter is a file path to the file pprAI.dll (on windows) since SmartBody expects to find the steering library in a particular location; perhaps when using SmartBody embedded in Python, it cannot find it properly.

 

Ari

October 20, 2015
7:15 am
Avatar
Member
Members
Forum Posts: 9
Member Since:
May 18, 2015
sp_UserOfflineSmall Offline

Thanks for you reply, however I am sorry it still does not work...

 

1. scene.getBmlProcessor().execBML('mychar', '')

 

This bml command performs well. My character behaves the move motion and really move. 

 

However, after scene.getSteerManager().setStringAttribute("engineOptions.moduleSearchPath", "pprAI.dll"), it still reminds me that

Traceback (most recent call last):

    File "", line 1, in

NameError: name 'scene' is not defined

 

I guess maybe this error occurs as I do not define in C++ that scene is SmartBody.getScene(), and when the steer function calls scene, it refers to an undefined object? Is this possible?

November 8, 2015
5:57 pm
Avatar
Admin
Forum Posts: 980
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

All I can think of is that somehow the 'scene' variable got removed, or is somehow running in a different Python context. Not sure why this happens.

Ari

Forum Timezone: America/Los_Angeles

Most Users Ever Online: 733

Currently Online: mondayneedle1, andersen19eaton, kristensen00leblanc, worriedutopia9579, eric506784, t9rrzpi307
105 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