# How to use TransformState.makePos in making a vehicle

I am a beginner of Bullet Panda3D, studying how to make a vehicle.

The example is “Bullet Vehicles”
panda3d.org/manual/index.php/Bullet_Vehicles
The source code is in
panda3d.org/manual/index.php/Bullet_Samples

In the code, I can not understand how to use TransformState.makePos(),

`````` # Chassis
shape = BulletBoxShape(Vec3(0.6, 1.4, 0.5))
ts = TransformState.makePos(Point3(0, 0, z1))
<snip>
# Right rear wheel
np.reparentTo(self.worldNP)
self.addWheel(Point3( 0.70, -1.05, z2), False, np)``````

I changed z1 value above code to see the function of TransformState.makPos(0,0,z1).

I found followings;

1. As z1 increases, the distance between the origin of vehicle body and the axis of wheels spreads.
2. As z2 (wheel z position)increases, the axis of wheel goes up.

However, I can not understand the meaning of z1 and where are the origin of z1 and z2 ?

I guess this problem would be basic transformation, but I have no idea.

I did not understand what the actual problem is, but I try to give a few hints:

1. A general transform is described via a TransformState. A transform can have a translation (pos), an orientation (hpr), a scale and a shear.
2. In order to create a transform state you can use the static makeXZY function, e. g. to create a transform state which has only a translation use TransformState.makePos(Point3(…)).
3. A vehicle has a chassis.
4. The chassis is a rigid body, which can be composed from several shapes.
5. A shape has a (local) transform relative to it’s body.
6. A vehicle has several wheels.
7. Each wheel has a transform relative to the vehicle.

z1:
The first section is about defining the chassis. In the manual I add the shape with a local transform, wich is just location the shape at Point3(0, 0, 0.5). A little bit above the “origin” of the chassis rigid body.

z2:
The first section is about defining the wheels. If you look at the Method self.addWheel you will see that the transform state is used here to define the wheel hardpoint, that is the point where the wheel is attached to the chassis. Usually cars have one wheel somewhere front/left, front/right, rear/left and rear/right.

Dear enn0x

Thank you so much for your support. I really appreciate for your kindness.
However, I have not understand the function and meanings yet.
So, I would like to ask you again.

The following figure(see the URL below) shows the result of “16_Vehicle.py”

homepage3.nifty.com/captain-hash … mState.png

in
panda3d.org/manual/index.php/Bullet_Samples
but no texture, just show only collision box shape(Chassis) and wheels.

This result is obtained from the following modified codes.

``````# Chassis
shape = BulletBoxShape(Vec3(0.6, 1.4, 0.5))
ts = TransformState.makePos(Point3(0, 0, z1))
<snip>
# Right rear wheel
self.addWheel(Point3( 0.70, -1.05, 0.3), False, np)
# Left rear wheel
self.addWheel(Point3( 0.70, -1.05, z2), False, np)``````

where z1 = 0.6, z2 = 0.4

In the figure, the symbols C and C’ represent the local origin of Chassis and the position of ts (ts is variable in the code).
R_R and R_L be the center position of Right rear and Left rear wheels, respectively.

I think that the coorinate system of Panda3d is right-hand system ( z-axis is vertival axis, and x-axis -> Red, y-axis -> Green, z-axis -> Bure )

My questions are following;

1. Why the C’ go down from C as z1 increases. I think that C’ may rise up if z1 depends on the right-hand system.

2. I confirmed that the center position R_L of wheels rise up when z2 increases.
However, I do’t know where is the reference point of z2 ?

So, to summarize,
A) Does z1 depend on right-hand system ?
B) Where is the reference point of z2 ? and is it related to C’ (ts) ?

Sincerely

You look at the transforms from the wrong side.

–> C’ in your screenshot is the origin of the vehicle coordinate system, which is identical with the origin of the chassis rigid body. In other words: “C is where the vehicle is”

–> C is the position of the chassis collision shape. The shape has a local offset of (0, 0, z1) relative to the chassis rigid body. Hence z1=0.5 means the shape is 0.5 ABOVE the vehicle position (C’), because the positive Z-axis points upwards.

Same for tires.

By the way: you can add more than one shape to the chassis rigid body (each with it’s own local transform), in order to have a better approximation of the true vehicle chassis shape. For example two boxes to roughly model a limo.

Dear enn0x

Thank you for helping me several times !!!

I just understand the relationship between C and C’ !

But, z2 for the wheel has still unresolved.
I confirmed the following behavior through simulation,
as z2 increases, the distance between C’ (the origin of the vehicle coordinate system,) and the center position R_L of wheel deceases.

I think that
a) z2 is along the positive Z-axis points upwards.
b) z2 is on the origin of the wheel coordinate system
c) z2 represents a hardpoint (joint) of the wheel
d) z2 is given based on the vehicle coordinate system

From these, I do not understand the behavior described above.

Is it wrong ??

Sincerely

a.) Right
b.) Nope. It is the hardpoint (see c.). The wheel might travel up and down from the hardpoint depending on the spring state (relaxed, full load, …)
c.) Right
d.) Right

I can not confirm this. Starting with the original tutorial I modified the position of the front/right wheel. This is what I get:

• Point3( 0.70, 1.05, 0.3): original position
• Point3( 2.70, 1.05, 0.3): F/R wheel is now to the left of the car, which is +x axis
• Point3( 0.70, 2.05, 0.3): F/R wheel is now in front of the car, which is +y axis
• Point3( 0.70, 1.05, 2.3): F/R wheel is now above the car, which is the +z axis
So everything seems right to me. Increasing your z2 should move the wheel upwards, and thus increase the distance to C’ and not decrease.