Yes, I'm looking at various methods of altering limb positions, but I
can't get my head around the openscad syntax and methodology. I could
probably knock something out quickly in freebasic/c#/whatever, but the
lack of global variables, and examples that I can understand and
replicate in openscad, is my stumbling block. Even a simple hinge,
operating in one plane I find incapable of using the results where I
want, in the way i want them. (i.e., not difficult calculating the new
positions, but putting the results where I want them, seems impossible.
I'll have to think of it in some other way). I'm not worried at this
stage with freedom of joint movements, just wanting to be able to pass
vectors too and fro, between modules/whatever - very basic stuff, that
has me stumped...
On 07/03/2021 21:01, Jordan Brown wrote:
The way that I would think of a body and joints is to start with some
part - probably the torso, but technically you could start anywhere -
and attach limbs, heads, et cetera as children. A joint rotates its
children. So you have a torso with a shoulder joint, which rotates
its child the upper arm, with an elbow joint which rotates its child
the lower arm, and so on. (But remember, the joints aren't simple
hinge-like connections; they can twist too - and twist sometimes
happens along a part. Lower-arm twists happen along the entire arm,
not exclusively at either joint.)
The essence is that the hand doesn't have to care what the shoulder is
doing. The hand just does its thing, relative to wherever the
shoulder, upper arm, elbow, lower arm, and wrist put it.
You could start with any part, but starting with the torso probably
results in the most natural behavior. If you started with the big
toe, wiggling the toe would have the toe stay motionless while the
rest of the body moved. That's sort of technically correct, but is
probably unexpected.
BOSL2 has an attachment feature that lets you position objects relative to
parent objects. I find it very useful for this kind of thing. It was
inspired by the Relativity library. There is also a library called obiscad
with a similar functionality.
mondo wrote
Yes, I'm looking at various methods of altering limb positions, but I
can't get my head around the openscad syntax and methodology. I could
probably knock something out quickly in freebasic/c#/whatever, but the
lack of global variables, and examples that I can understand and
replicate in openscad, is my stumbling block. Even a simple hinge,
operating in one plane I find incapable of using the results where I
want, in the way i want them. (i.e., not difficult calculating the new
positions, but putting the results where I want them, seems impossible.
I'll have to think of it in some other way). I'm not worried at this
stage with freedom of joint movements, just wanting to be able to pass
vectors too and fro, between modules/whatever - very basic stuff, that
has me stumped...
On 07/03/2021 21:01, Jordan Brown wrote:
The way that I would think of a body and joints is to start with some
part - probably the torso, but technically you could start anywhere -
and attach limbs, heads, et cetera as children. A joint rotates its
children. So you have a torso with a shoulder joint, which rotates
its child the upper arm, with an elbow joint which rotates its child
the lower arm, and so on. (But remember, the joints aren't simple
hinge-like connections; they can twist too - and twist sometimes
happens along a part. Lower-arm twists happen along the entire arm,
not exclusively at either joint.)
The essence is that the hand doesn't have to care what the shoulder is
doing. The hand just does its thing, relative to wherever the
shoulder, upper arm, elbow, lower arm, and wrist put it.
You could start with any part, but starting with the torso probably
results in the most natural behavior. If you started with the big
toe, wiggling the toe would have the toe stay motionless while the
rest of the body moved. That's sort of technically correct, but is
probably unexpected.
OpenSCAD mailing list
Discuss@.openscad
--
Sent from: http://forum.openscad.org/
On 3/7/2021 2:12 PM, Ray West wrote:
Yes, I'm looking at various methods of altering limb positions, but I
can't get my head around the openscad syntax and methodology. I could
probably knock something out quickly in freebasic/c#/whatever, but the
lack of global variables, and examples that I can understand and
replicate in openscad, is my stumbling block. Even a simple hinge,
operating in one plane I find incapable of using the results where I
want, in the way i want them. (i.e., not difficult calculating the new
positions, but putting the results where I want them, seems
impossible. I'll have to think of it in some other way). I'm not
worried at this stage with freedom of joint movements, just wanting to
be able to pass vectors too and fro, between modules/whatever - very
basic stuff, that has me stumped...
You have to think in a very top-down way. You can only pass things
down, never up. (You can sort of simulate passing things up by having
functions that parallel the modules and tell you things about what the
modules would do.)
But I don't immediately see why you would ever need to pass anything up.
Here's a quick and dirty stick figure. Load it up, enable the
customizer (Window / Hide Customizer), and play. Most of the
interesting things are in the Joint Positions section. (Note: I
haven't implemented all of the degrees of freedom, and I haven't
implemented the real-world limits on motion at the various joints.)
// Cheap and dirty stick figure.
// Note that measurements are global values and picked up directly
// by the modules, while joint positions are parameters
// (which in turn come from global values).
// This is mostly because you can generally assume that the left and
// right arms are the same length, but the shoulders and elbows may
// be in different positions.
/* [ Measurements ] /
torso_h = 24;
torso_w = 18;
torso_d = 8;
shoulder_h = torso_h - 4;
shoulder_d = 4;
neck_h = 4;
neck_d = 4;
head_w = 6;
head_h = 9;
head_d = 8;
uarm_l = 12;
uarm_d = 4;
elbow_d = 3;
larm_d = 3;
larm_l = 10;
uleg_l = 18;
uleg_d = 6;
lleg_l = 18;
lleg_d = 4;
/ [ Joint positions ] */
lshoulder_theta = 30;
lshoulder_phi = 45;
rshoulder_theta = 30;
rshoulder_phi = 45;
lelbow_theta = 45;
relbow_theta = 45;
lhip_theta = 0;
lhip_phi = 20;
rhip_theta = 0;
rhip_phi = 20;
lknee_theta = 20;
rknee_theta = 0;
// Children:
// 0 - neck
// 1 - left shoulder
// 2 - right shoulder
// 3 - left leg
// 4 - right leg
module torso() {
scale([1, torso_d/torso_w, 1]) cylinder(h=torso_h,d=torso_w);
translate([0,0,torso_h]) children(0);
translate([torso_w/2, 0, shoulder_h]) children(1);
translate([-torso_w/2, 0, shoulder_h]) children(2);
translate([torso_w0.5, 0, 0]) children(3);
translate([-torso_w0.5, 0, 0]) children(4);
}
// Children:
// 0 - head
module neck() {
cylinder(h=neck_h, d=neck_d);
translate([0,0,neck_h]) children(0);
}
module head() {
translate([0,0,head_h/2]) scale([head_w/head_h, head_d/head_h, 1]) sphere(d=head_h);
}
// Children
// 0 - upper arm
module shoulder(theta, phi) {
sphere(d=shoulder_d);
rotate([theta, 0, -phi]) children();
}
// Children
// 0 - elbow
module upper_arm() {
rotate([0,90,0]) {
cylinder(h=uarm_l, d=uarm_d);
translate([0,0,uarm_l]) children();
}
}
// Children
// 0 - lower arm
module elbow(theta) {
sphere(d=elbow_d);
rotate([theta,0,0]) children();
}
module lower_arm() {
cylinder(d=larm_d, h=larm_l);
}
module hip(theta, phi) {
rotate([-theta, -phi]) children();
}
module upper_leg() {
rotate([180,0,0]) cylinder(h=uleg_l, d=uleg_d);
translate([0,0,-uleg_l]) children();
}
module knee(theta) {
rotate([theta,0,0]) children();
}
module lower_leg() {
rotate([180,0,0]) cylinder(h=lleg_l, d=lleg_d);
}
torso() {
neck() {
head();
}
shoulder(lshoulder_theta,lshoulder_phi)
upper_arm()
elbow(lelbow_theta)
lower_arm();
mirror([1,0,0]) shoulder(rshoulder_theta,rshoulder_phi)
upper_arm()
elbow(relbow_theta)
lower_arm();
hip(lhip_theta, lhip_phi)
upper_leg()
knee(lknee_theta)
lower_leg();
mirror([1,0,0]) hip(rhip_theta, rhip_phi)
upper_leg()
knee(rknee_theta)
lower_leg();
}
That seems nice but you also need to provide a movement flow bottom-up too.
That happens when you want to find the joint angles in order to get for
instance the hand reaching some point relative to the head or torso center.
You defined something that may be called a forward kinematic by the
animation people. But you also need an inverse kinematic. Just my two cents.
Em seg., 8 de mar. de 2021 às 02:19, Jordan Brown <
openscad@jordan.maileater.net> escreveu:
You have to think in a very top-down way. You can only pass things down,
never up. (You can sort of simulate passing things up by having functions
that parallel the modules and tell you things about what the modules would
do.)
But I don't immediately see why you would ever need to pass anything up.
Here's a quick and dirty stick figure. Load it up, enable the customizer
(Window / Hide Customizer), and play. Most of the interesting things are
in the Joint Positions section. (Note: I haven't implemented all of the
degrees of freedom, and I haven't implemented the real-world limits on
motion at the various joints.)
On 3/8/2021 1:48 AM, Ronaldo Persiano wrote:
That seems nice but you also need to provide a movement flow bottom-up
too. That happens when you want to find the joint angles in order to
get for instance the hand reaching some point relative to the head or
torso center. You defined something that may be called a
forward kinematic by the animation people. But you also need an
inverse kinematic. Just my two cents.
Yes. I have absolutely no idea how to do reverse kinematics,
determining joint position based on an intended goal.
On 08.03.21 18:30, Jordan Brown wrote:
Yes. I have absolutely no idea how to do reverse kinematics,
determining joint position based on an intended goal.
Examples -> Advanced -> Animation shows 2D reverse kinematics.
There's a link in the source code to RepRap wiki where I got
the math from.
Doing that in 3D is slightly more interesting though :-).
ciao,
Torsten.
I found this to be useful and interesting:
https://www.youtube.com/watch?v=IN8tjTk8ExI
Jon
On 3/8/2021 12:55 PM, Torsten Paul wrote:
On 08.03.21 18:30, Jordan Brown wrote:
Yes. I have absolutely no idea how to do reverse kinematics,
determining joint position based on an intended goal.
Examples -> Advanced -> Animation shows 2D reverse kinematics.
There's a link in the source code to RepRap wiki where I got
the math from.
Doing that in 3D is slightly more interesting though :-).
ciao,
Torsten.