boncey / Flickr4Java

Java API For Flickr. Fork of FlickrJ
BSD 2-Clause "Simplified" License
174 stars 155 forks source link

How do you code gears to move legs forward and backwards with motors? (I've never coded with C++) #716

Closed MurkySoda closed 5 months ago

MurkySoda commented 7 months ago

I'm using a Vex v5 kit to make a machine that will move without wheels for an engineering project in school. I was wondering how you make motors move to a limit, and move back. For ex, the motor will move 60 degrees left then 60 degrees to the right, causing the back legs to move forwards and back. (I am using 2 motors, 1 for back legs and 1 for front legs.)

Right now our legs just move around in a circle getting caught on each other and flipping the whole thing over. (The person I'm working with also has no idea how to code any of this and as of right now we are just trying to keep the legs from collapsing cuz they body is too fat lmao.) So I'm just trying to actually find a good starting place for us because we don't even know how to start writing the code for this. We just need something simple, we are using one of those vex controllers that kinda look like xbox controllers to move this thing, and making legs sync with controller movements (meant for cars) just makes it a whole lot harder. Also the fact that we have to code this raw because it the tech we have doesn't sync with the Vex v5 website.

PS: We also have no idea how to code 2 motors into this, we realize that after seeing that both motors move and errors immediately when we tried to code using samples on the W3 website for learning C++, but the project is due in 2 weeks so I guess we have some time.

All help is appreciated, thanks!

Here is what we have so far: (for motor1)

def when_started1():
    drivetrain.turn_for(LEFT, 60, DEGREES)
    drivetrain.turn_for(RIGHT, 60, DEGREES)

vr_thread(when_started1)

edit: ^ Yeah it's barely anything, also we don't know how to make variables for motors 1 and 2 because that code just moves both motors. (WE ARE USING GEARS TO TURN THE SHAFT CONNECTED TO THE LEGS. (The legs use tank tread rubber for traction lmao.))