segway help

View previous topic View next topic Go down

segway help

Post by Sting Auer on Fri Oct 29, 2010 10:37 pm

i am having trouble with it stopping, and with turning

Code:


// [RCD]
Val
{
   BRAKES(default=0, max=50)
   LEAN(default=0, min=-60, max=90, step=5)
   LWHEEL(default=0, min=-50000, max=50000)
   RWHEEL(default=0, min=-50000, max=50000)
   TURNING(default=0, min=-100, max=100, step=100)
}
Key
{
   0:LEAN(step=5)
   1:LEAN(step=-5)
   2:TURNING(step=-100)
   3:TURNING(step=100)
}
Body
{
   Core() {
      S:Frame(angle=-120) {
         S:Frame(angle=-150) {
            S:Chip(color=#0000FF) {
               S:Chip(color=#0000FF) {
                  N:Trim(angle=90, color=#8080FF) {
                     S:Chip(color=#8080FF) {
                        S:Frame(angle=120) {
                           S:RLW(angle=-120, power=-LWHEEL, brake=BRAKES) { }
                        }
                        S:Frame(angle=-120) {
                           S:RLW(angle=120, power=-RWHEEL, brake=BRAKES) { }
                        }
                     }
                  }
                  N:RLW(angle=180, power=500) { }
               }
               E:Trim(angle=90) {
                  E:Frame(option=1) { }
               }
               W:TrimF(angle=90, option=1) {
                  S:Arm(angle=180) { }
               }
               E:Frame(angle=LEAN, option=1) {
                  E:Frame(option=1) { }
               }
               W:Frame(angle=LEAN, option=1) {
                  W:Frame(option=1) { }
               }
            }
         }
      }
   }
}
Script
{LWHEEL=_AX(core)*10000-TURNING
RWHEEL=_AX(core)*10000+TURNING

BRAKES=_WX(core)*2}


any tips?
avatar
Sting Auer
Hover
Hover

Posts : 170
Join date : 2010-09-19
Location : Aw crap i think I'm lost.

View user profile

Back to top Go down

Re: segway help

Post by DanielLC on Sat Oct 30, 2010 12:15 am

Stopping and starting is probably a balance issue. Make it go forward if it's leaning too far forward, and back when it's leaning too far back. Then it should stand still and do nothing, but at least not fall over. After that, just make it so pressing forward just makes it lean forward more, and it will automatically accelerate to keep from falling over. Ironically, this means that the first thing it will do when you press forward is go backwards.

I'm not sure what to do about turning. There's only so fast you can do a friction-based turn. If you don't mind cheating a bit, you can just put jets on the wheels, and make them cancel the left/right component.

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

View user profile

Back to top Go down

Re: segway help

Post by JHaskly on Sat Oct 30, 2010 5:50 am

Or you can use some awesome leaning stuff so that the centre of gravity counteracts the inertia of the model as you turn!

_________________
Previously (and currently) known as Juz.

Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 21
Location : Brisbane

View user profile

Back to top Go down

Re: segway help

Post by RA2lover on Sat Oct 30, 2010 7:48 am

IMO a better way to balance would be trying to get _GX() and _GY() as close as possible to the wheels _X() and _Y().
avatar
RA2lover
Walker
Walker

Posts : 382
Join date : 2010-10-11
Age : 22
Location : Brazil

View user profile

Back to top Go down

Re: segway help

Post by Sting Auer on Sat Oct 30, 2010 12:50 pm

here is a newer version. it is moving better but now it doesnt work AT ALL on uneven ground. it just falls over on the slightest uphill or downhill slope.

Code:


// [RCD]
Val
{
   BRAKES(default=0, max=50)
   GETUP(default=0, min=-180, max=180, step=10)
   LEAN(default=0, min=-60, max=90, step=5)
   LWHEEL(default=0, min=-3000, max=3000)
   RWHEEL(default=0, min=-3000, max=3000)
   TURNING(default=0, min=-500, max=500, step=100)
}
Key
{
   0:LEAN(step=5)
   1:LEAN(step=-5)
   2:TURNING(step=-100)
   3:TURNING(step=100)
   14:GETUP(step=5)
   16:GETUP(step=-5)
}
Body
{
   Core() {
      S:Frame(angle=-120) {
         S:Frame(angle=-150) {
            S:Chip(color=#0000FF) {
               S:Chip(color=#0000FF) {
                  N:Trim(angle=90, color=#8080FF) {
                     S:Chip(color=#8080FF) {
                        S:Frame(angle=120) {
                           S:Frame(angle=-30) {
                              S:RLW(angle=-90, power=-LWHEEL, brake=BRAKES) { }
                           }
                        }
                        S:Frame(angle=-120) {
                           S:Frame(angle=30) {
                              S:RLW(angle=90, power=-RWHEEL, brake=BRAKES) { }
                           }
                        }
                     }
                  }
                  N:Frame(angle=GETUP) {
                     N:Frame() { }
                  }
                  S:Frame(angle=100) {
                     S:Frame() { }
                  }
                  S:Frame(angle=-100) {
                     S:Frame() { }
                  }
               }
               E:Trim(angle=90) {
                  E:Frame(option=1) { }
               }
               W:TrimF(angle=90, option=1) {
                  S:Arm(angle=180) { }
               }
               S:Frame(angle=LEAN, option=1) {
                  S:Frame(option=1) {
                     S:Frame(option=1) { }
                  }
               }
            }
         }
      }
   }
}
Script
{LWHEEL=_AX(core)*10000-TURNING
RWHEEL=_AX(core)*10000+TURNING

BRAKES=_WX(core)*5}


it turns better now, and it can stop itself better now.
avatar
Sting Auer
Hover
Hover

Posts : 170
Join date : 2010-09-19
Location : Aw crap i think I'm lost.

View user profile

Back to top Go down

Re: segway help

Post by DanielLC on Sat Oct 30, 2010 3:02 pm

Is there a way to tell the slope of the ground? If so, make it so it automatically pushes itself uphill to counter out that it would otherwise tend to go down. If not, you might be able to add a variable to figure it out based on how far it is from where it should be leaning.

To keep it from falling down, you could either add a zero onto _AX(core)*10000, or you could add a multiple of _AX(core)^3 so that it starts pushing a lot harder when it starts falling down.

It would be more elegant to use (_AX(core)-LEANING). This way it will just use the wheels to adjust to the angle it should be at.

You can stop that rocking back and forth by adding an artificial friction. Make it slow down the rotation. Basically, find how much _AX(core) is changing, and add a multiple of that. Is that what _WX() does?

If you want it to stop on its own, make it adjust LEANING based on its speed. Or just have it add a multiple of its speed into the power of its wheels.

You should probably take out the breaks. The way it balances shouldn't depend on how fast it goes.

DanielLC
Tank
Tank

Posts : 78
Join date : 2010-10-23

View user profile

Back to top Go down

Re: segway help

Post by JHaskly on Sat Oct 30, 2010 5:01 pm

Yes, that's what _W*() do.

Or you could do math.sgn(_AX(0))*_AX(0)^2 Wink
sidenote: Since the core is always chip 0, you can write 0 instead of core.

RA2Lover = the closer the centre of gravity, the slower it goes.

_________________
Previously (and currently) known as Juz.

Please do not write "LUA", beause it's "Lua". It's Moon in Portuguese, not a Limited User Account, Last Universal Ancestor, or the Lukla Airport in Nepal.

JHaskly
Admin

Posts : 235
Join date : 2010-07-16
Age : 21
Location : Brisbane

View user profile

Back to top Go down

Re: segway help

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum