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

elastoplastic extension #560

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/mujoco/mjrender.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ struct mjrContext_ { // custom OpenGL context
int nskin; // number of skins
unsigned int* skinvertVBO; // skin vertex position VBOs (nskin)
unsigned int* skinnormalVBO; // skin vertex normal VBOs (nskin)
unsigned int* skincolorVBO; // skin vertex color VBOs (nskin)
unsigned int* skintexcoordVBO; // skin vertex texture coordinate VBOs (nskin)
unsigned int* skinfaceVBO; // skin face index VBOs (nskin)

Expand Down
1 change: 1 addition & 0 deletions include/mujoco/mjvisualize.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ struct mjvScene_ { // abstract scene passed to OpenGL renderer
int* skinvertnum; // number of vertices in skin (nskin)
float* skinvert; // skin vertex data (nskin)
float* skinnormal; // skin normal data (nskin)
float* skinuserdata; // skin vertex scalar userdata (nskin) eg. for colorcoded visualisaton. normalized [0.0,..,1.0]

// OpenGL lights
int nlight; // number of lights currently in buffer
Expand Down
20 changes: 12 additions & 8 deletions model/plugin/belt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,24 @@
1.0 0. 0. ">
<plugin plugin="mujoco.elasticity.cable">
<!--Units are in Pa (SI)-->
<config key="twist" value="1e8"/>
<config key="bend" value="1e7"/>
<config key="twist" value="1e10"/>
<config key="bend" value="2.5e10"/>
<config key="yieldstress" value="10e7"/>
<config key="ultimatestress" value="2e8"/>
<config key="ultimatestrain" value="0.12"/>
</plugin>
<joint kind="main" damping="0.1"/>
<geom type="box" size="0.03535533906 0.02 0.0015" rgba=".8 .2 .1 1" group="3"/>
<skin subgrid="3"/>
<joint kind="main" damping="10"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I load this model, it immediately explodes.

<geom type="box" size="0.03535533906 0.02 0.0055" rgba=".8 .2 .1 1" group="3" density="1000"/>
<skin subgrid="2"/>
</composite>
</worldbody>

<!--
<equality>
<connect name="right_boundary" body1="B_last" anchor="0.07 0 0"/>
<connect name="right_boundary" body1="B_last" anchor="0.07 0 0"/>
</equality>

-->
<actuator>
<motor site="S_last" gear="0 0 0 1 0 0" ctrlrange="-.2 .2"/>
<motor site="S_last" gear="0 0 0 1 0 0" ctrlrange="-2 2"/>
</actuator>
</mujoco>
2 changes: 1 addition & 1 deletion model/plugin/cable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<config key="twist" value="1e7"/>
<config key="bend" value="4e6"/>
</plugin>
<joint kind="main" damping=".015"/>
<joint kind="main" damping="0.15"/>
<geom type="capsule" size=".005" rgba=".8 .2 .1 1" condim="1"/>
</composite>
<body name="slider" pos=".7 0 .6">
Expand Down
20 changes: 13 additions & 7 deletions model/plugin/coil.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,26 @@
0.1 -0. 0.25132741">
<plugin plugin="mujoco.elasticity.cable">
<!--Units are in Pa (SI)-->
<config key="twist" value="5e8"/>
<config key="bend" value="15e8"/>
<config key="twist" value="1e10"/>
<config key="bend" value="2.5e10"/>
<config key="yieldstress" value="10e7"/>
<config key="ultimatestress" value="2e8"/>
<config key="ultimatestrain" value="0.12"/>
</plugin>
<joint kind="main" damping="0.12" armature="0.01"/>
<joint kind="main" damping="1" armature="0.01"/>
<geom type="capsule" size=".005" rgba=".8 .2 .1 1"/>
</composite>
<composite prefix="actuated" type="cable" curve="cos(s) sin(s) s" count="41 1 1"
size="0.251327412 .1 4" offset="0.25 0 .05" initial="fixed">
<plugin plugin="mujoco.elasticity.cable">
<!--Units are in Pa (SI)-->
<config key="twist" value="5e8"/>
<config key="bend" value="15e8"/>
<config key="twist" value="1e10"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I pull the second spring, at some point it looks like the simulation blows up.

<config key="bend" value="2.5e10"/>
<config key="yieldstress" value="10e7"/>
<config key="ultimatestress" value="2e8"/>
<config key="ultimatestrain" value="0.12"/>
</plugin>
<joint kind="main" damping="0.1" armature="0.01"/>
<joint kind="main" damping="1" armature="0.01"/>
<geom type="capsule" size=".005" rgba=".8 .2 .1 1"/>
</composite>
<body name="slider" pos="0.35 0 0.301327412">
Expand All @@ -99,6 +105,6 @@
</contact>

<actuator>
<position joint="slide" name="extend" gear="1 0 0 0 0 0" ctrlrange="-.25 1" kp="100"/>
<position joint="slide" name="extend" gear="1 0 0 0 0 0" ctrlrange="-1 4" kp="100"/>
</actuator>
</mujoco>
38 changes: 38 additions & 0 deletions model/plugin/elastoplastic_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<mujoco>
<option gravity="0 0 0"/>
<option timestep="0.001" o_solref="-1e8 -1e4" o_solimp="0.8 0.99 0.02 0.1 6">
<flag
gravity="disable"
override="enable"
/>
</option>
<extension>
<required plugin="mujoco.elasticity.cable"/>
</extension>
<worldbody>

<geom type="plane" size="0 0 1" quat="1 0 0 0"/>
<site name="reference" pos="0 0 0"/>
<composite type="cable" curve="s" count="81 1 1" size="1" offset="0 0 1" initial="none">
<plugin plugin="mujoco.elasticity.cable">
<config key="twist" value="1e10"/>
<config key="bend" value="2.5e10"/>
<config key="yieldstress" value="5e7"/>
<config key="ultimatestress" value="2e8"/>
<config key="ultimatestrain" value="0.12"/>

</plugin>
<joint kind="main" damping="2"/>
<geom type="capsule" size=".004" density="1000"/>
</composite>
</worldbody>
<contact>
<exclude body1="B_first" body2="B_last"/>
</contact>
<sensor>
<framepos objtype="site" objname="S_last"/>
</sensor>
<actuator>
<motor site="S_last" gear="0 0 0 0 1 0" ctrllimited="true" ctrlrange="-10 10"/>
</actuator>
</mujoco>
21 changes: 21 additions & 0 deletions plugin/elasticity/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#include (GenerateExportHeader)

set(MUJOCO_ELASTICITY_INCLUDE
${CMAKE_CURRENT_SOURCE_DIR}/../..
${CMAKE_CURRENT_SOURCE_DIR}/../../src
Expand All @@ -25,20 +27,39 @@ set(MUJOCO_ELASTICITY_SRCS
solid.h
)

if (WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/plugin/ ) #change output directory of plugin to be found by simulate.exe
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib/ ) #change output directory of static plugin to be at the right place at debug time
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) #export also .lib along the .dll for static linking
set(BUILD_SHARED_LIBS TRUE)

#add_library(elasticity SHARED ${MUJOCO_ELASTICITY_SRCS})

#target_sources(mujoco PRIVATE ${MUJOCO_ELASTICITY_SRCS})

#add_link_options("LINKER:-v")

endif()

add_library(elasticity SHARED)
target_sources(elasticity PRIVATE ${MUJOCO_ELASTICITY_SRCS})
target_include_directories(elasticity PRIVATE ${MUJOCO_ELASTICITY_INCLUDE})
target_link_libraries(elasticity PRIVATE mujoco)


target_compile_options(
elasticity
PRIVATE ${AVX_COMPILE_OPTIONS}
${MUJOCO_MACOS_COMPILE_OPTIONS}
${EXTRA_COMPILE_OPTIONS}
${MUJOCO_CXX_FLAGS}
)

target_link_options(
elasticity
PRIVATE
${MUJOCO_MACOS_LINK_OPTIONS}
${EXTRA_LINK_OPTIONS}
)


Loading