Sliding Pistons

14 views
Skip to first unread message

indy2005

unread,
Aug 19, 2010, 6:10:50 AM8/19/10
to Mekanimo
Hi,

I want to have two cylinders slide inside one another but remain
constrained with an upper and lower limit so they never separate. I
would normally do this with a prismatic joint, bu am unclear on how to
do this in Mekanimo.

I am trying to avoid anything non-native to Box2D (i.e. torsional
springs).

Regards

i

Fahri

unread,
Aug 19, 2010, 6:20:08 AM8/19/10
to Mekanimo
Create two overlapping rectangles and then place a vertical or
horizontal rail. Then from the object tree set the rail's upperLimit
and lowerLimit properties to desired values. Then set the
limitsEnabled property to True. Now you have a piston-cylinder with
end stops.

To set the sliding line to something other than a vertical or
horizontal orientation, you can change the rail's axis property from
the code as shown below.

vRail1.axis = [-3, 3]

To visualize the direction draw a line from [0, 0] to [-3, 3].

indy2005

unread,
Aug 19, 2010, 6:34:58 AM8/19/10
to Mekanimo
Hi thanks.

It would be good if when you connected a rail, you could get it to
calculate the axis from the rotation of body1 for example, or if there
was a python function you could could use, where you enter an angle,
and it returns the axis for that angle.

Regards

i

Fahri

unread,
Aug 19, 2010, 7:03:07 AM8/19/10
to Mekanimo

To obtain the axis value from two points you can write a Python
function

import math
def axisFromPoints(pnt1, pnt2):
x = pnt2[0] - pnt1[0]
y = pnt2[1] - pnt1[1]
mag = math.hypot(x, y)
if mag == 0:
return 0, 0
else:
alpha = x / mag
beta = y / mag
return alpha, beta

To get two points from your rectangle to determine the axis:

First show the vertex numbers of your rectangle

>>> r1.showNumbers = True

Then let's say you would like to use vertex 0 and 3

>>> axis = axisFromPoints(r1.points[0], r1.points[3])

Then use this axis for your rail

>>> vRail1.axis = axis

indy2005

unread,
Aug 19, 2010, 7:04:33 AM8/19/10
to Mekanimo
Hi,

When you change via Python, the object tree doesnt update the Axis
property which is a little confusing.

Also, as this is the front suspension of a motorbike, I need the lower
cylinder never to move outside the upper cylinder, but this isnt
happening. I have used the Tan of the angle to work out the slope to
plug into the axis property.

Regards

i

Fahri

unread,
Aug 19, 2010, 7:10:26 AM8/19/10
to Mekanimo
Did you do

vRail1.limitsEnabled = True

after setting the limits?

indy2005

unread,
Aug 19, 2010, 7:46:45 AM8/19/10
to Mekanimo
Hi,

Yes, although I think it is the fact that there is a joint on the body
with no rotation allowed which pins it to the body of the bike. Could
this force being used to maintain the zero rotation to the body be
distorting the rail?

Also, I found this easier to create the pistons as horizontal, with a
straight horizontal rail, and then create an assembly which I could
rotate into position. Mekanimo then starts to behave very strangely.
I currently cant reset the model (this has happened several times).
And when I save and reopen, I have lost my changes.

Regards

i

Fahreddın Basegmez

unread,
Aug 19, 2010, 8:02:37 AM8/19/10
to meka...@googlegroups.com
There are some problems with assemblies.  For now, disassemble all assemblies prior to running your model.  

I think I will create a tutorial about modeling a bike probably this weekend.  

--
You received this message because you are subscribed to the Google Groups "Mekanimo" group.
To post to this group, send email to meka...@googlegroups.com.
To unsubscribe from this group, send email to mekanimo+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mekanimo?hl=en.


indy2005

unread,
Aug 19, 2010, 7:48:01 AM8/19/10
to Mekanimo
Traceback (most recent call last):
File "mainframe.pyo", line 4690, in onReset
File "system.pyo", line 7792, in reinit
File "assembly.pyo", line 77, in __getattr__
AttributeError: sprite
Traceback (most recent call last):
File "mainframe.pyo", line 4690, in onReset
File "system.pyo", line 7792, in reinit
File "assembly.pyo", line 77, in __getattr__
AttributeError: sprite
Traceback (most recent call last):
File "mainframe.pyo", line 4690, in onReset
File "system.pyo", line 7792, in reinit
File "assembly.pyo", line 77, in __getattr__
AttributeError: sprite


When pressing reset model...seems to be linked to when I created an
assembly

On Aug 19, 12:10 pm, Fahri <mangab...@gmail.com> wrote:

indy2005

unread,
Aug 19, 2010, 8:14:13 AM8/19/10
to Mekanimo
Hi,

That would be great. I am trying to make a "motor cross" version of
the demo here. See the pistons (although I dont see from the code
where the 2 shapes per axel come from, only one).

http://www.emanueleferonato.com/2009/04/06/two-ways-to-make-box2d-cars/

Thanks for letting me know abuot assemblies...it was behaving very
strangely.

Regards

i

indy2005

unread,
Aug 19, 2010, 8:15:00 AM8/19/10
to Mekanimo
can I ask did you see the animated gif OK I uploaded to SkyDrive?



On Aug 19, 12:48 pm, indy2005 <s_m...@ntlworld.com> wrote:

Fahri

unread,
Aug 19, 2010, 8:19:58 AM8/19/10
to Mekanimo
Yes I did see the GIF. I will create a tutorial named "How to model a
bike"

That should address many of your questions.

indy2005

unread,
Aug 19, 2010, 9:44:29 AM8/19/10
to Mekanimo
Hi,

It would be great to get an angled rail, perhaps one which picks up
the orientation of body1. I have found it quite counter intuitive to
work out the axis I need. Just user feedback.

p.s. got the basic bike working now....thanks!

i

indy2005

unread,
Aug 19, 2010, 10:01:17 AM8/19/10
to Mekanimo

Fahri

unread,
Sep 22, 2010, 8:18:05 PM9/22/10
to Mekanimo
I created a tutorial about how to create a bike with Mekanimo. The
rail rotation handles and XML generation will be available in the next
version.

http://www.youtube.com/watch?v=BK5247_Ej6A

On Aug 19, 10:01 am, indy2005 <s_m...@ntlworld.com> wrote:
> http://cid-6e40632dd37ec1bb.office.live.com/self.aspx/.Public/Tech/Mo...
Reply all
Reply to author
Forward
0 new messages