Script to change motor torque
11 posts • Page 1 of 1
Script to change motor torque
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)

-

PhunWars - Posts: 78
- Joined: Wed Dec 30, 2009 11:01 pm
Re: Script to change motor torque
Oncollide
or
or
should work if you put the value scene.my.motorpower into the motorTorque attribute of a hinge
- Code: Select all
(e)=>{scene.my.motorpower=scene.my.motorpower +1}
or
- Code: Select all
(e)=>{scene.my.motorpower=500}
or
- Code: Select all
(e)=>{{scene.my.motorpower>=500} ? {scene.my.motorpower=500} : {scene.my.motorpower + 1}}
should work if you put the value scene.my.motorpower into the motorTorque attribute of a hinge
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Script to change motor torque
Actually, put
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.
- 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...
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.
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.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Script to change motor torque
TC42 wrote:Oncollide(incremental)
- Code: Select all
(e)=>{scene.my.motorpower=scene.my.motorpower +1}
or(changes variable to set value)
- Code: Select all
(e)=>{scene.my.motorpower=500}
or(increments up to a value 500)
- Code: Select all
(e)=>{{scene.my.motorpower>=500} ? {scene.my.motorpower=500} : {scene.my.motorpower + 1}}
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

-

PhunWars - Posts: 78
- Joined: Wed Dec 30, 2009 11:01 pm
Re: Script to change motor torque
Yup, just use onlaserhit or onhitbylaser instead of oncollide. But then it won't be phun-friendly.
That's what I meant, I just didn't explain it well
Someone Else wrote:into the motor torque thing in the SCRIPT MENU
That's what I meant, I just didn't explain it well
-

TC42 - Posts: 984
- Joined: Sun Jan 09, 2011 1:53 pm
- Location: $ sudo apt get-install sandwich_
Re: Script to change motor torque
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
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.
- Code: Select all
e.geom.friction = e.geom.friction + 1
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...
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.
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.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Script to change motor torque
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. Useor whatever. Notice how I use e.GEOM.friction. To indicate the laser, use e.laser.color. I use color because lasers have no friction.
- Code: Select all
e.geom.friction = e.geom.friction + 1
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)

-

PhunWars - Posts: 78
- Joined: Wed Dec 30, 2009 11:01 pm
Re: Script to change motor torque
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 (2.76 KiB) Viewed 1634 times
-
- Nuovo motore_plot_0001.png (3.37 KiB) Viewed 1634 times

-

PhunWars - Posts: 78
- Joined: Wed Dec 30, 2009 11:01 pm
Re: Script to change motor torque
Use this as a template thing.
Make a circle that is center-hinged to the background.
Make a box that touches the circle.
Aim two lasers at the box.
In one laser, put this script:
In the other laser, put this script:
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.
- Code: Select all
e.geom.materialVelocity = 100;
e.geom.friction = +inf
- Code: Select all
e.geom.materialVelocity = 1000;
e.geom.friction = 500
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...
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.
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.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
Re: Script to change motor torque
Someone Else wrote:Use this as a template thing.
Make a circle that is center-hinged to the background.
Make a box that touches the circle.
Aim two lasers at the box.
In one laser, put this script:
- Code: Select all
e.geom.materialVelocity = 100;
e.geom.friction = +inf
In the other laser, put this script:
- Code: Select all
e.geom.materialVelocity = 1000;
e.geom.friction = 500
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

-

PhunWars - Posts: 78
- Joined: Wed Dec 30, 2009 11:01 pm
Re: Script to change motor torque
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.
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...
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.
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.
-

Someone Else - Posts: 1147
- Joined: Sun Nov 21, 2010 10:53 pm
- Location: The Milky Way Galaxy
11 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests




