I do not understand how I can create bodies with contract geometry.
It seems to work completely different then Gazebo that I am used to.
I created, using python, a model consisting of 2 bricks. The idea is that one is a ground floor (the rowing course) and the other a box (the boat) that should fall onto the ground floor. Eventually, there should be friction between the 2 bricks, so the boat can be pulled over the ground with a friction similar to a boat in the water.
This is the picture in opensim when I load the model. If simulation is started, after the first step the boat is vanished and nothing happens afterwards. I would have hoped that the boat would fall on the floor due to gravity.
I tried so make the program below (that creates the osim file) as simple as possible. Only 2 bodies and 2 joints.
Both a Geometry and a ContactGeometry is added to each body.
I would have hoped that this would make it so that the bodies will collide in simulation, but alas, no.
How can I create the intended behavior in opensim?
Thanks in advance, Sietse
Code: Select all
import opensim as osim
import sys
arm = osim.Model()
arm.setName("BootBaan")
arm.setGravity(osim.Vec3(0, -9.90665, 0))
theCourse = osim.Body("The_rowing_course",
1.0,
osim.Vec3(0, 0, 0),
osim.Inertia(0, 0, 0))
theCourseGeometry = osim.Brick(osim.Vec3(10, 0.05, 2))
theCourse.attachGeometry(theCourseGeometry)
theCourseGeometry.setColor(osim.Vec3(0,0,1))
theCourseContactSpace = osim.ContactHalfSpace(osim.Vec3(0, 0.2, 0),
osim.Vec3(0, 0, -1.57),
theCourse)
theCourseContactSpace.setName("baantje")
arm.addContactGeometry(theCourseContactSpace)
theBoat = osim.Body("The_boat",
1.0,
osim.Vec3(0, 0, 0),
osim.Inertia(0, 0, 0))
theBoatGeometry = osim.Brick(osim.Vec3(3, 0.05, 0.5))
theBoat.attachGeometry(theBoatGeometry)
theBoatGeometry.setColor(osim.Vec3(0,1,1))
theBoatContactSpace = osim.ContactHalfSpace(osim.Vec3(0, 0.2, 0),
osim.Vec3(0, 0, -1.57),
theBoat)
theBoatContactSpace.setName("bootje")
arm.addContactGeometry(theBoatContactSpace)
courseJoint = osim.WeldJoint("courseJoint",
arm.getGround(),
osim.Vec3(0, 0.025, 0),
osim.Vec3(0, 0, 0),
theCourse,
osim.Vec3(0, 0, 0),
osim.Vec3(0, 0, 0))
boatJoint = osim.PinJoint("boatJoint",
theCourse,
osim.Vec3(0, 2, 0),
osim.Vec3(0, 0, 0),
theBoat,
osim.Vec3(0, 0, 0),
osim.Vec3(0, 0, 0))
arm.addBody(theCourse)
arm.addBody(theBoat)
arm.addJoint(courseJoint)
arm.addJoint(boatJoint)
arm.initSystem()
arm.printToXML("BootBaan.osim")
Also tried a FreeJoint, but then there is a Simbody exception: Matrix is singular, so can't be inverted.