View unanswered posts | View active topics It is currently Sun Sep 21, 2014 2:07 am






Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Segway Robot 
Author Message
Rookie

Joined: Wed Oct 09, 2013 3:55 pm
Posts: 19
Post Segway Robot
Lolz, this is going to be a fun project, not to mention I need to have it done to graduate. :lol: My robotics teacher has been making jokes about a segway for two years now.
I am using a two motor robot with the vex built in accelerometors. This is the code I have so far.
Code:
task main()
{
   while(1)
   {
      bmotorflippedmode[port1] = true
      bmotorflippedmode[port10] = true
               
      //Both my motors are upsidedown :D
      motor[port1] = vexRT[AccelY] + vexRT[AccelX];
      motor[port10] = vexRT[AccelY] - vexRT[AccelX];
   }
}

Much simpler than I was thinking. Thank You RobotC!


Wed Oct 09, 2013 4:12 pm
Profile
Rookie

Joined: Wed Oct 09, 2013 3:55 pm
Posts: 19
Post Re: Segway Robot
Sorry, my html skillz aren't very good, so you are just going to have to deal with not knowing the indents. (Hint: I put a bracket whenever I indent.[{}])


Wed Oct 09, 2013 4:14 pm
Profile
Expert

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: Segway Robot
BTW, these forums don't use HTML for formatting. They use BBCode.

Try using the code tags:
Code:
[code][/code]

_________________
Matt


Wed Oct 09, 2013 5:35 pm
Profile WWW
Rookie

Joined: Wed Oct 09, 2013 3:55 pm
Posts: 19
Post Re: Segway Robot
Oh, thanks for the tip. :)


Sun Oct 27, 2013 5:03 pm
Profile
Rookie

Joined: Wed Oct 09, 2013 3:55 pm
Posts: 19
Post Re: Segway Robot
Working on building a more sturdy robot that can actually hold a person on it. It's going to have 3 wagon wheels, (my mentor felt it would be easier/cheaper to use 3 and have it be sturdy rather than 2 and have people falling over) 2 bigger motors from the first robotics team at my school, and just a vex cortex with the controller for the accelerometers. I am open to any ideas that some person might have. I'll record how it works and post it on youtube.


Tue Oct 29, 2013 4:01 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Segway Robot
123girr wrote:
Lolz, this is going to be a fun project, not to mention I need to have it done to graduate. :lol: My robotics teacher has been making jokes about a segway for two years now.
I am using a two motor robot with the vex built in accelerometors. This is the code I have so far.
Code:
task main()
{
   while(1)
   {
      bmotorflippedmode[port1] = true
      bmotorflippedmode[port10] = true
               
      //Both my motors are upsidedown :D
      motor[port1] = vexRT[AccelY] + vexRT[AccelX];
      motor[port10] = vexRT[AccelY] - vexRT[AccelX];
   }
}

Much simpler than I was thinking. Thank You RobotC!

I would be really surprised if this code works. Would you tell us how you mounted the accelerometer? Which axis is up/down, which one is forward/backward, which one is sideway? I can't interpret your code without that info.


Tue Oct 29, 2013 8:44 pm
Profile
Rookie

Joined: Wed Oct 09, 2013 3:55 pm
Posts: 19
Post Re: Segway Robot
here is a better bit of code, sorry
Code:
#pragma config(Motor,  port1,           Right,         tmotorVex393, openLoop)
#pragma config(Motor,  port10,          Left,          tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
     while(1)
     {
           motor[Right] = vexRT[AccelY] + vexRT[AccelX];
           motor[Left] = vexRT[AccelY] - vexRT[AccelX];
     }
}

And yes it does work. I used a basic joystick control program and just replaced the Ch# with the AccelX&Y
I am going to have it mounted to a pole off of a base. I don't think they need it to be life sized or even 2 wheeled and I don't want to spend however much for an extra gyro to keep it up straight. Currently though, I am just holding it and having fun with a clawbot. :)


Mon Dec 02, 2013 5:33 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Segway Robot
123girr wrote:
here is a better bit of code, sorry
Code:
#pragma config(Motor,  port1,           Right,         tmotorVex393, openLoop)
#pragma config(Motor,  port10,          Left,          tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
     while(1)
     {
           motor[Right] = vexRT[AccelY] + vexRT[AccelX];
           motor[Left] = vexRT[AccelY] - vexRT[AccelX];
     }
}

And yes it does work. I used a basic joystick control program and just replaced the Ch# with the AccelX&Y
I am going to have it mounted to a pole off of a base. I don't think they need it to be life sized or even 2 wheeled and I don't want to spend however much for an extra gyro to keep it up straight. Currently though, I am just holding it and having fun with a clawbot. :)

Your code does not show what AccelX and AccelY are. Are they the channels where you connected the X and Y axes of the accelerometer to? If so, the code seems way too simple. I would expect at least some sort of scaling of the raw accelerometer values before you can apply to the motor powers. I am not familiar with VEX, so I can't imagine how this code could work. Would you mind explaining your code and the configuration?
Also, what do you mean by not keeping it up straight? If the robot has more than 2 wheels or cannot balance by itself, it is not a Segway.


Tue Dec 03, 2013 12:03 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: Segway Robot
AccelX and AccelY sound like accelerometer data (pls CMIIW).
I honestly doubt that it would be possible ever to program a Segway-like self-balancing robot using just accelerometers. It simply doesn't exist a mathematical model for balancing an inverse pendulum (like a segway) by acceleration data neither by a formula nor by control and regulation loops.
OTOH there are lot of models which work with different sensors, e.g., distance sensors, but the best approach certainly is using a gyroscope.

edit:
the issue about accererometers is, e.g., that tilt/inclination and linear acceleration and centrifugal forces cannot be distinguished.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Last edited by Ford Prefect on Wed Dec 04, 2013 7:51 am, edited 1 time in total.



Tue Dec 03, 2013 4:46 am
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: Segway Robot
Well, couldn't you technically figure out the orientation of the pendulum by combining the x- and y- axis acceleration values, since gravity? Assuming the thing is oriented correctly, of course. It's waaaay more difficult than just using a gyro though :)

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Tue Dec 03, 2013 10:14 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Segway Robot
There is a sample project on the new EV3 called Gyro Boy. It is a Segway bot that uses just the gyro. So it is possible.


Wed Dec 04, 2013 2:28 am
Profile
Rookie

Joined: Wed Oct 09, 2013 3:55 pm
Posts: 19
Post Re: Segway Robot
Yes, AccelX and AccelY are referring to the built in accelerometors in the vex joystick. Also, if you read my earlier comments, It is going to have four wheels. I don't need to worry about balancing it. A gyro is a bit out of my budget ($0).


Wed Dec 04, 2013 4:11 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Segway Robot
123girr wrote:
It is going to have four wheels. I don't need to worry about balancing it.

Then it is not a Segway robot. It sounds like you are just using the accelerometer as a controller (i.e. tilt it forward and the robot goes forward ... etc).


Wed Dec 04, 2013 4:16 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: Segway Robot
correct.
a segway is a balancing bot. No balancing - no segway.
by 4 wheels it's just a car.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Wed Dec 04, 2013 6:33 pm
Profile
Professor
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 272
Location: Olympia, WA
Post Re: Segway Robot
But it needs Ackermann steering to count as a car ;)

_________________
FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!


Wed Dec 04, 2013 9:13 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 23 posts ]  Go to page 1, 2  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.