Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
2. Need support? Ask a question to our Community Support category.
3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

# How to model buoyancy for underwater robot?

Member, Developers Posts: 428 EDU
Does anyone have any tips for accurately modeling buoyant systems as far as mass properties? The underwater robotics team I'm on is designing an ROV using Onshape. However, getting useful mass properties is a bit challenging.

Ideally, we could override the volume of parts & assemblies to their measured values from dropping them in a beaker or something (e.g. air on the inside of the pressure hold adds extra volume, vendor models aren't exact, etc., etc.), but that functionality doesn't seem to be available today.

Also, having some way of finding the center of volume (geometric centroid) would be super useful so we can balance it with the center of mass.

It might be possible to whack this with the configuration hammer, i.e.:
• Two configs of every part: (A). the density of 1 (since the center of mass = center of volume for density = 1) and (B) the actual density for accurate mass/center of mass
• Two configs of every pressure vessel: (A) empty of parts inside, but has a block of air (for accurate volume) and (B) the actual parts inside (for center of mass)
Then, you'd toggle between configurations a few times, record mass property values, and go from there.

Alternatively, maybe writing some sort of script in Blender could accomplish the buoyancy calculations based on the mesh without too much trouble. I've already done a bit of scripting in Blender with our ROV model to generate a transformation matrix from control inputs to motor power outputs & visualize propulsion, and it wasn't that bad. However, there's the time investment of writing a bunch of scripts, and there will be accuracy limitations from using a mesh representation...

Unfortunately, the assembly mass properties endpoint doesn't seem to have a way to exclude certain instances or override the density to get the geometric centroid, so the Onshape API probably won't work, at least in a simple way.
Student at University of Washington | Get in touch: [email protected] | My personal site: https://alnis.dev
Tagged:

• Member Posts: 1,426 PRO
For the geometric centroid, could you use a new part studio in context to convert your whole top level assembly, then write a feature that calls evApproximate centroid (set all density to 1 as you suggest)? I've not played with it but you might also be able to do something similar and make a custom feature to assign density or total mass to a part. For example if you know the total mass, you might use that as an input in your feature to set the part density to whatever gives you that mass.

I'm kinda shooting from the hip here. Not sure if that's workable, and even if it is, it's certainly still cumbersome. Also not sure if it's any better than configs.
Evan Reese / Principal and Industrial Designer with Ovyl
Website: ovyl.io
• Member Posts: 343 PRO
For the CB, I think you should be able to create a part studio in context, draw a big block around the whole thing and do an "intersect" boolean with the context.
The only issue would be that you would need to fill any "sealed" cavities (either before or after the boolean). If you don't have too many of these a config where they are filled might not be that hard to setup.
• Member Posts: 1,221 ✭✭✭✭✭
edited February 9
you will need probably to copy your assembly to part studio from in-context references and make sure all routes to internal cavities that are watertight are sealed properly with interfering parts and make some manual preprocessing with direct edit tools. Then boolean union all the outer envelope into a single part and use qFaceOrEgeBoundedFaces() query passing a single query seed face of the envelope part and and probably one another arbitrary face or edge just because it expects something as bounding entities. This query will resolve to all the adjacent faces of the seed face on the envelope part, and because all the internal cavities are sealed and their faces are not achievable with adjacency, it will only contain outer faces. Then you can enclose solid body of those outer faces and evaluate its centroid.
• Member, OS Professional, Mentor, Developers, User Group Leader Posts: 1,799 PRO
edited February 9
I think you can do this using the user interface.

With select bounded faces, pick the seed 1st, then pick all the bounding faces.

1st pick is the seed:

then, pick all the boundaries:

with the selected faces, create a manifold:

I found it odd that the OS's materials library doesn't include air or water. Maybe I couldn't find them or maybe they should add them.

It'd be interesting if we could write a feature script that would read the center of mass of water displacement & block weight and compute buoyancy. We can read computed numbers now with feature script, right?

The more I think about it..... You could compute an upright vector that'd compute the stability of the hull design. What's cool is that it'd be parametric and could display a 3d vector on your geometry. You could easily make changes to the hull and see the effects and maximize stability.

• Member, OS Professional, Mentor, Developers, User Group Leader Posts: 1,799 PRO
edited February 9
Ok, I've totally convinced myself you could write a featurescript that could figure out the waterline on a hull.

-max waterline (red surface)
-face of hull (use a boundary method up to the max waterline)
-boat loads (pick those things that matter)

It returns:
-a surface showing waterline.

shifting weight on boat position 1:

shifting weight on boat position 2:

I'm not going to write it but I see how this could be a useful tool. As the weight moves around or you add weight, the buoyancy victors change depending on the shape of the hull. It's an iterative process which I think feature script could easily perform.

If you write this script make sure you put a counter in your while statement to prevent run away scripts. I think I had 10 or 15 OS sessions going when I wrote fitspline do to conditions that wouldn't solve. I think I stopped after 1000 iterations which meant things weren't converging.

@alnis if you write it, I'd definitely play with it.

• Member, Developers Posts: 428 EDU
@Evan_Reese That sounds like a relatively clean and simple way to do it! There's still the need to override some volumes due to vendor parts not matching actual volume (some are surface models, others are simplified, etc.), but maybe this could be merged with a spreadsheet of known volumes of some sort.

@eric_pesty That seems like the easiest approach. It might get a bit cranky with surface models, non-manifold geometry (e.g. circles tangent to rectangles), etc., but it can probably give a decent result pretty quickly

@konstantin_shiriazdanov Thank you for the detailed information about how to approach writing a script for this!

@billy2 That looks like a really neat idea for a tool for ship/boat design! It would definitely make for a fun project. Unfortunately, our ROV has by no means a nice and friendly surface to work with, so maybe not super applicable here, but I'm sure someone would find something like it useful.

Thanks for all of the ideas everyone! I'll make sure to post an update later once we've put our ROV in the water and balanced it a few times to see which method gives the closest results for the least amount of work.
Student at University of Washington | Get in touch: [email protected] | My personal site: https://alnis.dev