University of Southern CaliforniaUSC
USC ICT TwitterUSC ICT FacebookUSC ICT YouTube

SmartBody and locomotion via BML | 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
SmartBody and locomotion via BML
March 31, 2015
8:35 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

I am trying to get SmartBody to work for a little while now. The idea in my case is to get it to work with OpenSceneGraph. So I wrote a little wrapper for the vertex arrays used in SmartBody to get it to render with OSG. That part seems to work nicely as Brad gets rendered and I can send BML commands to make him do the air guitar etc. However, I cannot get him to walk or run to a specific location properly. The body itself moves but there is no articulation at all; Brad just moves as a single block.

I just updated to the latest version of SmartBody and added the code segments from the updated manual to specify walkCycle etc. I also looked around the forum and tried a few more things with no luck so far. I feel like I am pretty close and that there is just a minor setting I am overlooking. My code is somewhat convoluted by now but I can try and post some of it if that helps. I would appreciate any pointer as I am just banging my head against the wall so far.

 

Thanks,
Thomas

March 31, 2015
8:43 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Is the character deforming properly (in other words, is the 'skinning' working?) 

Are you using OSG as a complete replacement of the rendering (like sbgui?)

The best way to make sure that the locomotion system gets working on your character is to use the behavior sets like this:

scene.run('BehaviorSetMaleMocapLocomotion.py')
setupBehaviorSet()
retargetBehaviorSet('ChrBrad')

Assuming that was done, you should be able to send a locomotion command via BML:

bml.execBML('ChrBrad', '<locomotion target="100 50"/>')

If the character is moving rigidly, it might mean that the retargeting isn't working properly, and that only the base joint is getting moved, but not the other joints.

Can you post a video of your problem?

Ari

April 1, 2015
6:14 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

Thanks for the quick response. I did find that fragment of code some time ago and added it. Since I am using C++ it looks like this in my code:

  scene->runScript ("BehaviorSetMaleLocomotion.py"); scene->run ("setupBehaviorSet"); scene->run ("retargetBehaviorSet (\"ChrBrad\")");

 

The OSG part of the code replaces the rendering entirely, I do not use sbgui. That part seems to be working as Brad does move, just the locomotion part does not articulate him. I created a video that shows what is happening:

http://avida.cs.wright.edu/vid.....tbody.mpeg

You can see Brad move initially based on the idle movement but than he moves rigidly once the locomotion BML command hits.

Reading the documentation and looking around on the forum it seems like it should be just as simple as you described. But something is missing apparently. Any light you could shed would be greatly appreciated.

Thanks,

Thomas

April 1, 2015
6:34 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Can you send me the log file? It looks like the character is using the basic locomotion, which is the fallback when no locomotion system is added. Perhaps the behavior sets aren't being loaded properly?

If you don't have output, you can create a log to a file like this in C++:

 

vhcl::Log::FileListener* fileog = new vhcl::Log::FileListener("mysmartbody.log");

vhcl::Log::g_log.AddListener(stdoutLog);

 

Ari

April 1, 2015
9:09 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

When I add code along those lines all that shows up in there is "Loading Python..." for some reason.

I do have a stdout logger so I just dumped that output in a file. You can access it via this link:

http://avida.cs.wright.edu/vid.....rtbody.log

There are some additional messages from OSG, specifically the ones about the textures but I hope it has what you are looking for. I do not see much about behavior sets. Is there a way to increase the log level to make it output more information?

 

Thanks again,

Thomas

April 2, 2015
2:55 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

Ari Shapiro said
Can you send me the log file? It looks like the character is using the basic locomotion, which is the fallback when no locomotion system is added. Perhaps the behavior sets aren't being loaded properly?

That is certainly possible. I plaid with it some more. When I set the steer type to the new locomotion model via agent->setSteerType ("new"); the character is simply ignoring the locomotion BML commands.

April 2, 2015
3:32 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

I think I may be getting more of what you were looking for initially. When I create the character it uses the name "mycharacter", not "ChrBrad". So I assume I need to pass "mycharacter" when calling retargetBehaviorSet, which then generates error messages that may hint at what is going on:

** State: allLocomotion

Traceback (most recent call last):

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

  File "/usr/local/src/smartbody/data/behaviorsets/BehaviorSetMaleLocomotion.py", line 82, in retargetBehaviorSet

    

locomotionSetup('test_utah.sk', 'test_utah.sk', "base", '', 'all')

  File "/usr/local/src/smartbody/data/behaviorsets/MaleLocomotion/scripts/stateMaleLocomotion.py", line 60, in locomotionSetup

    

joint = skeleton.getJointByName(baseJoint)

AttributeError

:

'NoneType' object has no attribute 'getJointByName'

April 2, 2015
5:45 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

For the behaviorsets to work at all, you would need to make sure that you have set the media path to the 'data' directory:

scene->setMediaPath("/usr/local/src/smartbody/data/")

and that SmartBody knows where to find the behavior set scripts:

scene.addAssetPath('script', 'behaviorsets')

 

and that you run the main behavior set script which will load all of them:

scene.run('default-behavior-sets.py')

 

That error that you posted looks like it comes from the 'MaleLocomotion' behavior set, and not the 'MaleMocapLocomotion' behavior set. The difference is that the 'MaleLocomotion' set was a keyframed by a 3D animator , and the 'MaleMocapLocomotion' was obtained from motion capture and then cleaned up, and has a more realistic feel. You can use either one, but let's stick to one until we figure out the problem.

So make sure you are using the commands:

scene.run('BehaviorSetMaleMocapLocomotion.py')
setupBehaviorSet()
retargetBehaviorSet('mycharacter')

From the error log, it appears that SmartBody cannot find the assets that it needs, so everything fails. So double check the media path first, and let me know if that changes anything.

 

Ari

April 2, 2015
6:53 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

I think we are getting somewhere. I added the call to the default-behavior-set python script, which I did not have in there before and changed to the Mocap locomotion as you described. I had to add a couple asset paths but it now is able to find everything (I think). However, I am getting these error messages now:

locomotion smooth cycle

Motion skeleton doesn't exist. Cannot compute effector trajectory

The last one repeats a lot, followed by it crashing. I assume this happens when it tries to build the joint trajectory. Is there a special motion skeleton I need to add to the scene?

April 2, 2015
6:58 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Can you post/send the new log file? Something still isn't loading properly. 

 

Ari

April 2, 2015
7:02 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

Sure, this is the output I am getting:

Loading Python...
Loading Assets...

Loading [/usr/local/src/smartbody/data/ChrBrad]

Loading [/usr/local/src/smartbody/data/behaviorsets/Gestures2/motions]

Loading [/usr/local/src/smartbody/data/behaviorsets/MaleMocapLocomotion/motions]

Loading [/usr/local/src/smartbody/data/behaviorsets/MaleMocapLocomotion/skeletons]

Loaded 166 motions...

Creating the character...

Character mycharacter's skeleton added to the scene.

Character mycharacter's deformable mesh reset.

Build Skinned Buffer

dynamic mesh size = 0, skin weight size = 0

meshIndexList size = 0

nTotalVtxs = 0, nTotalTris = 0

handle deformableMesh = ChrBrad.dae

cannot find mesh 'ChrBrad.dae', load from the file...

try to load mesh at '/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad.dae'

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_Hair_Dif.png    2048    2048    4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_Teeth_Dif.png   1024    1024    4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_Hands_Dif.png   2048    2048    4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_Hands_Nrm.png   2048    2048    4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_UpperBody_Dif.png       2048    2048    4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_UpperBody_Nrm.png       2048    2048    4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_LowerBody_Dif.png       2048    2048    4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_LowerBody_Nrm.png       2048    2048    4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_Head_Dif.png    2048    2048    4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_Head_Nrm.png    2048    2048    4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_Eyelash_Dif.png 512     512     4

Loading image       :/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad_Eye_Dif.png     1024    1024    3

try to load mesh at '/usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad/ChrBrad.dae'

File /usr/local/src/smartbody/data//usr/local/src/smartbody/data/mesh/ChrBrad/ChrBrad/ChrBrad.dae cannot be read, asset will not be loaded.

Build Skinned Buffer

dynamic mesh size = 73, skin weight size = 73

meshIndexList size = 73

nTotalVtxs = 43810, nTotalTris = 83927

has mesh ChrBrad.dae, num. of vertices = 46681

handle deformableMesh = ChrBrad.dae

has mesh ChrBrad.dae, num. of vertices = 46681

Character mycharacter's deformable mesh ChrBrad.dae added to the scene.

Character mycharacter's deformable mesh ChrBrad.dae added to the scene.

locomotion smooth cycle

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Motion skeleton doesn't exist. Cannot compute effector trajectory

Segmentation fault

April 2, 2015
7:36 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

It still seems like a loading error. Can you make sure that the file:

 

ChrBackovic.sk

 

exists in behaviorsets/MaleMocapLocomotion/skeletons.

If you like, I can spend a few minutes with you over Skype.  You can can send me an email directly at shapiro@ict.usc.edu.

 

Ari

April 2, 2015
7:54 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

Yes, that file is in exactly that directory. I had to add that path to the asset paths since it was complaining about not finding that file. So it seems that it is trying to load it. I am not sure which motion skeleton it is missing though.

Unfortunately, the university here is blocking Skype, so that is not an option. Google hangouts work though.

From what I can see in the debugger it crashes when executing locomotion-ChrMarine-state-Locomotion.py

April 2, 2015
10:04 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

Dug around some more. It appears that these errors are generated when processing the file locomotion-ChrMarine-init.py, i.e. when it is trying to mirror the motions. Not sure why it is complaining because the motions it needs are loaded according to the strace output I created from running it. But somehow it does not find them when it tries to access these motions?

April 3, 2015
4:51 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Just looking over these past messages. Your code should look like this:

 

scene->runScript ("BehaviorSetMaleLocomotion.py");

scene->run ("setupBehaviorSet()");  // need parenthesis after setupBehaviorSet()

scene->run ("retargetBehaviorSet (\"ChrBrad\")");

You previously posted 'setupBehaviorSet' without the parenthesis, which would fail.

 

Ari

April 3, 2015
8:35 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

Yes, I knew it was something simple. That does fix the errors and it is no longer crashing. However, Brad simply ignores the location BML command now. I can still have him make the air guitar, though. I do not see any error messages at the output that would point me to anything, unfortunately.

April 3, 2015
8:37 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Maybe your scene is in meters? try:

 

bml.execBML('mycharacter', '<locomotion target="1 5"/>')

 

Ari

April 3, 2015
8:47 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

Yes, that is what i thought too. I moved the character around a little to get a feel for the size and it does seem more like it is in meters. However, Brad is still not moving with the smaller numbers.

April 20, 2015
8:01 pm
Avatar
Member
Members
Forum Posts: 12
Member Since:
March 31, 2015
sp_UserOfflineSmall Offline

Still not really getting anywhere. I only get an error for the target numbers if it gets as big as 150. With 150 it warns me that it is outside of the valid area. I do not get that error with anything smaller. However, Brad refuses to move anywhere and is stuck in the idle position.

April 24, 2015
10:33 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

We'll have to do a face-to-face debug session whenever we can coordinate. Not sure what's going on here. You can try to manipulate the steering parameters a bit (to make the steering space larger or smaller).

 

Ari

September 16, 2015
6:29 pm
Avatar
Member
Members
Forum Posts: 26
Member Since:
September 16, 2015
sp_UserOfflineSmall Offline

I'm working with thomas_w and some issues are still being experienced. I've been investigating and still have some issues which perhaps we can resolve with assistance.

  • We are using the C++ API of SmartBody
  • We are not using sbgui

At the moment animations playback correctly via scene->execBML("") but locomotion does not function as expected. If scene->run("retargetBehaviorSet('characterName') is called, any subsequent BML locomotion commands fail to have any effect - the character remains in the idle posture. Standalone animations function properly.However, if we do not run the retargeting Python function, locomotion functions in the simple mode ('meat hook' mode referenced in the manual). The character moves in the world but no walking motion, arms swinging, etc. are performed. Again, executing standalone BML animation commands function properly. One thought I had is perhaps retargeting should be performed using the C++ API instead (e.g. SBRetargetManager, etc.)?

When performing character->setBoolAttribute('steering.pathFollowingMode', false) the API logs a message stating such an attribute does not exist.

I also noticed that the locomotion Python example is using ChrBrad for the visible model but uses ChrMaarten for the deformableMesh and that this usage appears in other examples. Is there a reason we should prefer or use ChrMaarten instead of ChrBrad?

Thanks for the assistance!

September 16, 2015
7:16 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Are you using the Python API, or just the C-API? Most of the C++ functions have a corresponding Python function of the same name, so using Python or C++ wouldn't matter. The C API is a bit more restrictive, although you can also call a C-function with a Python command as a parameter to run Python through the C API.

To get the locomotion system working properly, you need to have a set of data-driven blends that are named properly (locomotion, stepping, etc.). You can do this easily by retargeting the locomotion behaviorsets (there are two of them: one which uses keyframed animation, and one which uses mocap data). You can also create your own locomotion data for your character, although that will probably be a lot of work.  SmartBody does an online retarget of the data so that your character moves appropriately (the locomotion data was set up for a different character). If you are not using the Python interface and loading the behaviorset scripts, it is going to be a bit more difficult since you'll need to load all this information procedurally. Here's how you can load a behaviorset in Python:

 

# setup locomotion
scene.run('BehaviorSetMaleMocapLocomotion.py')
setupBehaviorSet()
retargetBehaviorSet('ChrBrad')

ChrMaarten is the older version of the character, ChrBrad is the newer version. The body is the same, the facial data is a little different, but there's no reason you need to pick one over the other; I think ChrBrad's face is a little more detailed than ChrMaarten's.

 

Ari

September 25, 2015
4:19 pm
Avatar
Member
Members
Forum Posts: 26
Member Since:
September 16, 2015
sp_UserOfflineSmall Offline

We are using the C-API and make calls using scene->execBML(), scene->run(), and scene->runScript() to call some Python functions for setup. Other tasks such as creating steering agents and navigation meshes are done using the C-API. Is interacting with the engine in such a manner problematic?

We are using the motion capture behaviorsets. That is how I understood it and we execute such code.

scene-&gt;runScript("default-behavior-sets.py"); scene-&gt;runScript("BehaviorSetMaleMocapLocomotion.py"); scene-&gt;run("setupBehaviorSet()"); scene-&gt;run("retargetBehaviorSet ('mycharacter1')");

As mentioned, If the last line, retargeting, is run any subsequent locomotion BML commands do nothing - is this expected? It seems unexpected. If the retargeting line is commented out locomotion commands function but without any natural movements - as expected.

September 25, 2015
5:42 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

The way that you are interfacing using the C++ api is proper.

No, that sounds like something is wrong. Are you using a log file or seeing any error messages? You can set a file to be written to as a log by doing:

scene->startFileLogging("smartbody.log")

and see what errors there are.

Make sure that before you run the default-behavior-sets.py file you have told SmartBody where it can find that script:

scene->addAssetPath("script", "behaviorsets")

September 28, 2015
5:58 pm
Avatar
Member
Members
Forum Posts: 26
Member Since:
September 16, 2015
sp_UserOfflineSmall Offline

Both checking in the console and after using a log file there are not error messages.

The behaviorsets directory is included as you described.

A small example, based on the material found in the user manual and exploration of the source code, demonstrating the issue is included. Perhaps this will make it easier. If the example is run, you will see that the joint does not show any changes in position. If the idle animation is used instead of a locomotion command the joint position changes.

 

#include <vhcl_log.h>
#include <vhcl_string.h>
#include <sb/SBScene.h>
#include <sb/SBCharacter.h>
#include <sb/SBSkeleton.h>
#include <sb/SBPython.h>
#include <sb/SBSteerManager.h>
#include <sb/SBSteerAgent.h>
#include <sb/SBSimulationManager.h>
#include <sb/SBBmlProcessor.h>
#include <sb/SBSceneListener.h>
#include <sb/SBJointMap.h>
#include <sb/SBJointMapManager.h>

class SimpleListener : public SmartBody::SBSceneListener
{
	public:
	 	SimpleListener() {}
	 	~SimpleListener() {}

	 	virtual void OnLogMessage( const std::string & message )
	 	{
			std::cout << message << std::endl;
		}
};

int main( int argc, char ** argv )
{
	std::string mediaPath = "../smartbody/src/data";

	// add a message logger to stdout
	vhcl::Log::StdoutListener* stdoutLog = new vhcl::Log::StdoutListener();
	vhcl::Log::g_log.AddListener(stdoutLog);
	LOG("Loading Python...");

	// initialize the Python libraries
	initPython("../../../../../usr/lib64/python2.7");

	// get the scene object
	SmartBody::SBScene* scene = SmartBody::SBScene::getScene();
	SimpleListener listener;
	scene->addSceneListener(&listener);

	// set the mediapath which dictates the top-level asset directory
	scene->setMediaPath(mediaPath);

	// indicate where different assets will be located
	// "motion" = animations and skeletons
	// "script" = Python scripts to be executed
	// "mesh" = models and textures
	scene->addAssetPath("motion", "ChrBrad");
	scene->addAssetPath("mesh", "mesh");
	scene->addAssetPath("script", "behaviorsets");
	scene->addAssetPath("script", "scripts");
	// necessary for idle animation
	scene->addAssetPath("motion", "behaviorsets/Gestures2/motions");

	// load the assets from the indicated locations
	LOG("Loading Assets...");
	scene->loadAssets();
	int numMotions = scene->getNumMotions();
	LOG("Loaded %d motions...", numMotions);

	// create a character
	LOG("Creating the character...");
	SmartBody::SBCharacter* character = scene->createCharacter("mycharacter", "");
	// load the skeleton from one of the available skeleton types
	SmartBody::SBSkeleton* skeleton = scene->createSkeleton("ChrBrad.sk");
	// attach the skeleton to the character
	character->setSkeleton(skeleton);
	// create the standard set of controllers (idling, gesture, nodding, etc.)
	character->createStandardControllers();
	// get the simulation object
	SmartBody::SBSimulationManager* sim = scene->getSimulationManager();

	// Setup joint mappings
	scene->runScript("zebra2-map.py");
	SmartBody::SBJointMap* jointMap = scene->getJointMapManager()->getJointMap("zebra2");
	SmartBody::SBSkeleton* bradSkeleton = scene->getSkeleton("ChrBrad.sk");
	jointMap->applySkeleton(bradSkeleton);
	jointMap->applyMotionRecurse("ChrBrad");

  scene->runScript ("default-behavior-sets.py");
	scene->runScript("BehaviorSetMaleMocapLocomotion.py");
	scene->run("setupBehaviorSet()");
	scene->run("retargetBehaviorSet('mycharacter')");

	// Steering setup
	SmartBody::SBSteerManager* steer = scene->getSteerManager();
	SmartBody::SBSteerAgent *agent = steer->getSteerAgent("mycharacter");
	if (agent == NULL)
		agent = steer->createSteerAgent("mycharacter");

	agent->setSteerStateNamePrefix("mocap");
	agent->setSteerType("basic");

	steer->setEnable(false);
	character->setBoolAttribute("steering.pathFollowingMode", false);
	steer->setDoubleAttribute("gridDatabaseOptions.gridSizeX", 200);
	steer->setDoubleAttribute("gridDatabaseOptions.gridSizeZ", 200);
	steer->setBoolAttribute("addBoundaryWalls", true);
	steer->setEnable(true);

	// if you want to use a real-time clock do the following:
	bool useRealTimeClock = false;
	if (useRealTimeClock) {
		sim->setupTimer();
	} else {
		// otherwise, the time will run according
		sim->setTime(0.0);
	}

	// make the character do something
	//scene->getBmlProcessor()->execBML("mycharacter", "<body posture=\"ChrBrad@Idle01\"/>");
	//scene->getBmlProcessor()->execBML("mycharacter", "<locomotion manner=\"run\" target=\"10 10 4 -10\"/>");
	scene->getBmlProcessor()->execBML("mycharacter", "<locomotion speed=\"1.5\" target=\"10 10 4 -10\"/>");

	double lastPrint = 0;

	LOG("Starting the simulation...");
	sim->start();

	while (sim->getTime() < 25.0) // run for 25 simulation seconds
	{
		scene->update();
		if (!useRealTimeClock)
	  	// update at 1/60 of a second when running in simulated time
	  	sim->setTime(sim->getTime() + 0.16); 
		else
	  	sim->updateTimer();

		if (sim->getTime() > lastPrint) {
	  	LOG("Simulation is at time: %5.2f
", sim->getTime());
	  	lastPrint = sim->getTime() + 10;
		}

		const std::vector<std::string>& characterNames = scene->getCharacterNames();
		for (size_t c = 0; c < characterNames.size(); c++) {
	  	SmartBody::SBCharacter* character = scene->getCharacter(characterNames[c]);
	  	std::string jointName = "JtRoot"; SmartBody::SBJoint* joint = character->getSkeleton()->getJointByName(jointName);
	  	if (joint) {
	    	SrVec position = joint->getPosition();
				LOG("%f : Character %s joint %s is at position (%f, %f, %f)", sim->getTime(), character->getName().c_str(), jointName.c_str(), position.x, position.y, position.z);
	  	}
		}
	}

	sim->stop();

	return 0;
}
September 29, 2015
4:35 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Ok, thanks for the code. I can reproduce your problem; not sure what it is, I'll try to figure this out.

 

Ari

September 29, 2015
7:33 pm
Avatar
Admin
Forum Posts: 983
Member Since:
December 1, 2011
sp_UserOfflineSmall Offline

Ok, two things:

 

1) Change the block of code that performs to joint map to run before you create the character:

// Setup joint mappings
	scene->runScript("zebra2-map.py");
	SmartBody::SBJointMap* jointMap = scene->getJointMapManager()->getJointMap("zebra2");
	SmartBody::SBSkeleton* bradSkeleton = scene->getSkeleton("ChrBrad.sk");
	jointMap->applySkeleton(bradSkeleton);
	jointMap->applyMotionRecurse("ChrBrad");

before

LOG("Creating the character...");
	SmartBody::SBCharacter* character = scene->createCharacter("mycharacter", "");
	// load the skeleton from one of the available skeleton types
	SmartBody::SBSkeleton* skeleton = scene->createSkeleton("ChrBrad.sk");

Also, this will change the name of the joint from JtRoot to base, so use 'base' instead.

 

2) The joint->getPosition() yields a local position, not a global one. To get the global position of a joint use:

SrVec position = joint->getGlobalTransform().gmat().get_translation();

Also, your test simulation only runs for 25 seconds, which isn't enough time for the character to go to both locations that you indicate, try increasing it to 50.

 

Let me know if making those changes works for you.

 

Ari

October 5, 2015
4:15 pm
Avatar
Member
Members
Forum Posts: 26
Member Since:
September 16, 2015
sp_UserOfflineSmall Offline

Relocating the joint mapping code appears to have fixed the issue. The adjustments to retrieving joint position worked as well. Thanks again for your assistance.

Forum Timezone: America/Los_Angeles

Most Users Ever Online: 733

Currently Online: Jamesnuh, gotselyuk1987mon, koenig62ramos, krygerhagen69, coxgeorge3, doyle68bekker, ludvigsen62abbott, shortstext78, cormierhopper5
66 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

jwwalker: 80

jyambao: 52

rbaral: 47

adiaz: 30

WargnierP: 29

lucky7456969: 28

mbarros: 28

avida.matt: 26

JonathanW: 24

laguerre: 23

Member Stats:

Guest Posters: 67

Members: 100502

Moderators: 3

Admins: 4

Forum Stats:

Groups: 1

Forums: 5

Topics: 460

Posts: 2403