Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get flexible body position and velocity #1674

Closed
Pablo-M-V-99 opened this issue May 17, 2024 · 1 comment
Closed

how to get flexible body position and velocity #1674

Pablo-M-V-99 opened this issue May 17, 2024 · 1 comment
Assignees
Labels
question Request for help or information

Comments

@Pablo-M-V-99
Copy link

Hi,
I'm a student and I'm trying to use MuJoCo for simulating a moving flag.
Here is the model I'm using for the flag:

	<body name="pin" pos="0 0 1.5">
  		<flexcomp name="flag" type="grid" count="9 19 1" spacing="0.05 0.05 0.05" mass="10" radius="0.001">
	    	<edge equality="true" damping="0.001"/>
			<plugin plugin="mujoco.elasticity.shell">
			  	<config key="thickness" value="1e-2"/>
			 	<!--Units are in Pa (SI)-->					
			  	<config key="poisson" value="0"/>
			  	<config key="young" value="3e6"/>
	    	        </plugin>
	  	</flexcomp>
	</body>

At the moment two hems of the flag are locked in place, while the other two are connected to a mocap body that I use to simulate a desired movement for the flag. For the movement I wrote a 5th degree polynomial trajectory, which, in theory, guarantees the movement ends with zero speed and zero acceleration.
However, I would like to implement a test on the velocity of all the elements that make up the flag to be sure the flag is completely still before starting a new movement.
Something like:

for all the elements that make up the flag
if element_speed > threshold_speed
wait until element_speed <= threshold_speed

I have started using Mujoco only recently, so I don't know how I can access this information. Can you help me?

@Pablo-M-V-99 Pablo-M-V-99 added the question Request for help or information label May 17, 2024
@quagla
Copy link
Collaborator

quagla commented May 28, 2024

Hi @Pablo-M-V-99

These are the arrays you want to look at https://github.com/google-deepmind/mujoco/blob/main/include/mujoco/mjmodel.h#L840

For an usage example, please have a look at e.g.

int b1 = m->flex_vertbodyid[m->flex_vertadr[f] + m->flex_edge[2*i]];

Let me know if it doesn't help!

@quagla quagla closed this as completed May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Request for help or information
Projects
None yet
Development

No branches or pull requests

2 participants