Script to change motor torque

About advanced scenes, and the Thyme scripting language used in Algodoo.

Script to change motor torque

Postby PhunWars » Tue Mar 01, 2011 9:58 pm

As title says is there a script useable to change the torque of a motor ? I'm working on a car and if I put high gears the motor loses power and to regain that power I need to increase the motor torque (increasing it from the start will make the car too much unstable)
Image
User avatar
PhunWars
 
Posts: 78
Joined: Wed Dec 30, 2009 11:01 pm

Re: Script to change motor torque

Postby TC42 » Tue Mar 01, 2011 10:20 pm

Oncollide
Code: Select all
(e)=>{scene.my.motorpower=scene.my.motorpower +1}
(incremental)
or
Code: Select all
(e)=>{scene.my.motorpower=500}
(changes variable to set value)
or
Code: Select all
(e)=>{{scene.my.motorpower>=500} ? {scene.my.motorpower=500} : {scene.my.motorpower + 1}}
(increments up to a value 500)
should work if you put the value scene.my.motorpower into the motorTorque attribute of a hinge
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Script to change motor torque

Postby Someone Else » Wed Mar 02, 2011 3:33 pm

Actually, put
Code: Select all
{scene.my.motorpower}

into the motor torque thing in the SCRIPT MENU. Or, if you want to make it phunlet-friendly (that is, it does not use any scene.my variables), use materialVelocity of a box that touches a circle that already has your scripted hinge on it. materialVelocity is speed, friction is torque.

Also, you must first declare scene.my.motorpower = 100 in the console. Press F11 or ~.
And, whatever you choose to use in the above post should go in a box off to the side.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Script to change motor torque

Postby PhunWars » Wed Mar 02, 2011 10:22 pm

TC42 wrote:Oncollide
Code: Select all
(e)=>{scene.my.motorpower=scene.my.motorpower +1}
(incremental)
or
Code: Select all
(e)=>{scene.my.motorpower=500}
(changes variable to set value)
or
Code: Select all
(e)=>{{scene.my.motorpower>=500} ? {scene.my.motorpower=500} : {scene.my.motorpower + 1}}
(increments up to a value 500)
should work if you put the value scene.my.motorpower into the motorTorque attribute of a hinge

Ok, but the motor already collides with 2 transmission spheres that collides with the rear and the front wheel...can I use a laser or something ? For example: pressing U motor torque becomes like 10000 and pressing D motor torque becomes 5000 or something like that
Image
User avatar
PhunWars
 
Posts: 78
Joined: Wed Dec 30, 2009 11:01 pm

Re: Script to change motor torque

Postby TC42 » Wed Mar 02, 2011 10:29 pm

Yup, just use onlaserhit or onhitbylaser instead of oncollide. But then it won't be phun-friendly.

Someone Else wrote:into the motor torque thing in the SCRIPT MENU


That's what I meant, I just didn't explain it well :D
Image
Spambot wrote:Nowadays, memes usually are studied less in the field of biology, but more with the arena of psychology along with sociology. But, the major area of a meme, getting embraced and imitated all the time is what’s at any core connected with any meme.
User avatar
TC42
 
Posts: 984
Joined: Sun Jan 09, 2011 1:53 pm
Location: $ sudo apt get-install sandwich_

Re: Script to change motor torque

Postby Someone Else » Thu Mar 03, 2011 4:21 pm

onLaserHit or onHitByLaser can still be phunlet-friendly. Just shoot scripted lasers at a box fixated to the car's frame that collides with the motorized circle. Also, laser scripts are slightly different. Use
Code: Select all
e.geom.friction = e.geom.friction + 1
or whatever. Notice how I use e.GEOM.friction. To indicate the laser, use e.laser.color. I use color because lasers have no friction.
onCollide is e.other.friction or e.this.friction. Instead of the latter, I always use just friction. The e.this is implied.

Also, Algodoo recognizes +inf as infinity. -inf is, of course, negative infinity.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Script to change motor torque

Postby PhunWars » Thu Mar 03, 2011 8:53 pm

Someone Else wrote:onLaserHit or onHitByLaser can still be phunlet-friendly. Just shoot scripted lasers at a box fixated to the car's frame that collides with the motorized circle. Also, laser scripts are slightly different. Use
Code: Select all
e.geom.friction = e.geom.friction + 1
or whatever. Notice how I use e.GEOM.friction. To indicate the laser, use e.laser.color. I use color because lasers have no friction.
onCollide is e.other.friction or e.this.friction. Instead of the latter, I always use just friction. The e.this is implied.

Also, Algodoo recognizes +inf as infinity. -inf is, of course, negative infinity.

I know but I need to change motor torque, not friction (gear system is already based on the friction of the wheels)
Image
User avatar
PhunWars
 
Posts: 78
Joined: Wed Dec 30, 2009 11:01 pm

Re: Script to change motor torque

Postby PhunWars » Thu Mar 03, 2011 9:05 pm

As you can see at the increase of speed (and at the increase of the friction due to the gears) the motor loses power very quickly...
Attachments
Nuovo motore_plot_0000.png
Nuovo motore_plot_0000.png (2.76 KiB) Viewed 1634 times
Nuovo motore_plot_0001.png
Nuovo motore_plot_0001.png (3.37 KiB) Viewed 1634 times
Image
User avatar
PhunWars
 
Posts: 78
Joined: Wed Dec 30, 2009 11:01 pm

Re: Script to change motor torque

Postby Someone Else » Fri Mar 04, 2011 7:36 pm

Use this as a template thing.

:arrow: Make a circle that is center-hinged to the background.
:arrow: Make a box that touches the circle.
:arrow: Aim two lasers at the box.
:arrow: In one laser, put this script:
Code: Select all
e.geom.materialVelocity = 100;
e.geom.friction = +inf

:arrow: In the other laser, put this script:
Code: Select all
e.geom.materialVelocity = 1000;
e.geom.friction = 500

:arrow: Make the activation buttons of the lasers 1 and 2 respectively.

A simple Thymed phunlet-friendly Algodoo-only engine and transmission combo.
materialVelocity is speed, friction is torque.
Note that it does not change any attributes of the circle. Only the box.
You can add as many gears as you like.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy

Re: Script to change motor torque

Postby PhunWars » Tue Mar 08, 2011 1:55 am

Someone Else wrote:Use this as a template thing.

:arrow: Make a circle that is center-hinged to the background.
:arrow: Make a box that touches the circle.
:arrow: Aim two lasers at the box.
:arrow: In one laser, put this script:
Code: Select all
e.geom.materialVelocity = 100;
e.geom.friction = +inf

:arrow: In the other laser, put this script:
Code: Select all
e.geom.materialVelocity = 1000;
e.geom.friction = 500

:arrow: Make the activation buttons of the lasers 1 and 2 respectively.

A simple Thymed phunlet-friendly Algodoo-only engine and transmission combo.
materialVelocity is speed, friction is torque.
Note that it does not change any attributes of the circle. Only the box.
You can add as many gears as you like.

It works but the friction with the box makes the car jump and everything becomes unstable, I also tried to increase the density to the motor circle but things just get worse and if I decrease the friction of the box then angular velocity will decrease too, so we are at the start point
Image
User avatar
PhunWars
 
Posts: 78
Joined: Wed Dec 30, 2009 11:01 pm

Re: Script to change motor torque

Postby Someone Else » Tue Mar 08, 2011 7:42 pm

umm... All I can say is...

1. Experiment with different values. I do not know how malerialVelocity/friction compares with motorSpeed/motorTorque.

2. Put another box with its own scripted lasers on the other side of the circle. Just clone the box and lasers. This should balance the force on one side of the circle with an equal and opposite force on the other side of the circle, which should only produce a torque and not stretch the hinge.
Matthias Wandel is epic, in my humble opinion.
I love my brain...
TC42 wrote:Also, your sig is too big, please change it.

ARE YA HAPPY NOW?????

Thymechanic/Phundamentalist

Recently, I discovered something a lot of you probably already knew: Minecraft is awesome.
Due to this, I may not be as active as usual for a while.
User avatar
Someone Else
 
Posts: 1147
Joined: Sun Nov 21, 2010 10:53 pm
Location: The Milky Way Galaxy


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 5 guests