GeorgeGJ
Posts: 2
Joined: Fri Apr 08, 2016 8:24 pm

Python Script for servo motors

Fri Apr 08, 2016 8:57 pm

Hi! I'm a new raspberry pi user, and right now I'm struggling with code for my project. I was hoping to get some answers/inspiration from everyone here.

(Imagine a bike that could drive and steer it self while keeping balance).
The project is to build a monorail robot that can self balance on two wheels, and make 90 degrees turns without deviating from its path which is 5cm. The robot is 1 meter long. The plan is to make it take a 90 degrees turn with servo steering both wheels. And within the path. So basically if the wheels go outside this given path, I failed. Its body is allowed to go outside the path, that isn't as important.

*My question is, is it possible to code the servos to behave as I want? Turning both wheels at the turn, simultaneously OR even with different angles.

-i.e. if its a right turn, wheel_front 60 degrees , wheel_back 90 degrees.
wheel_front 50 degrees , wheel_back 95 degrees.
wheel_front 40 degrees , wheel_back 100 degrees. And so on.

I know these angles do not correspond to the angles of a servo, I'm just using the basic unit circle. ( I do know how to use servos to a certain degree ).

I'm planning to make the turn in sequences and at low velocity, but unfortunately I've hit a big experience barrier I can't overcome , and that is coding, I'm a beginner-ish.

I humbly ask for your opinions & help. If I left out important stuff , you could ask or assume ideal situations.

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: Python Script for servo motors

Sat Apr 09, 2016 4:31 pm

GeorgeGJ wrote:unfortunately I've hit a big experience barrier I can't overcome , and that is coding
I think a self balancing bicycle may be a slightly larger barrier. And I'm not getting the monorail part. Why does it need to steer if it's on a rail?
Everything you ask can be achieved but it's erm... tricky.

Dave.
Apple say... Monkey do !!

GeorgeGJ
Posts: 2
Joined: Fri Apr 08, 2016 8:24 pm

Re: Python Script for servo motors

Sun Apr 10, 2016 12:30 pm

I have to agree with you that the name is very strange, it will look like one but we as in I and several more people need to make it drive on tape instead of on rails, which would have been much easier (imo).

But you think it's doable but tricky? Could you give me hints about the code? I wonder if it could be done in the same script or does this need two synced scripts that run parallel..

User avatar
joan
Posts: 14960
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Python Script for servo motors

Sun Apr 10, 2016 12:45 pm

GeorgeGJ wrote:I have to agree with you that the name is very strange, it will look like one but we as in I and several more people need to make it drive on tape instead of on rails, which would have been much easier (imo).

But you think it's doable but tricky? Could you give me hints about the code? I wonder if it could be done in the same script or does this need two synced scripts that run parallel..
I believe you are concentrating on the wrong problem. Driving the servos will be trivial. You just say servo 1 go to angle 1, servo 2 go to angle 2.

The tricky part will be knowing what angle 1 and angle 2 should be. Have you solved that problem?

Return to “Python”