Go to Post We do not pursue awards, we pursue greatness and the awards follow. - Sunshine [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-02-2013, 15:04
bumblebee3339's Avatar
bumblebee3339 bumblebee3339 is offline
Team's main account
FRC #3339 (BumbleBee)
 
Join Date: Feb 2013
Rookie Year: 2009
Location: Israel
Posts: 34
bumblebee3339 is an unknown quantity at this point
Autonomous code issue :(

I've written a state machine with 6 states,
It uses two encoders to know if to stay or proceed.
Image:

It includes a 'wheel distance' sub vi:

The sub vi takes the output of the encoder and makes it a distance in cm (it isnt the problem)

The issue is that the robot doesnt move at all.
I used Highlight and it look like the motors DO get the value and should move and then it enters the parallel loops and stays there forever because the robot doesnt move.

Code explained: (If you didnt get it)
It takes the current value of the encoder and adds it 50 (cm)
Then it gives the motors a value until both of the encoders encrease by 50,
then it moves to the next state and so on...

So, I can't figure out why the motors don't move
BTW they move in the teleop so it's not about the jaguars or PWMs.

Thx for the helpers
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2013, 16:45
bvisness's Avatar
bvisness bvisness is offline
Programming Mentor, Former Driver
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Woodbury, MN
Posts: 181
bvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of light
Re: Autonomous code issue :(

It could be a motor safety problem, since you're only commanding the tank drive output once, and then entering your two loops. You should probably put the tank drive at 0.5 block inside the loop to avoid that problem.

Besides that, your code looks quite good! I'm not sure what your problem would be.
Reply With Quote
  #3   Spotlight this post!  
Unread 10-02-2013, 02:51
propionate's Avatar
propionate propionate is offline
Team co-lead and LabVIEW programmer
AKA: Stephen
FRC #1732 (Hilltopper Robotics)
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Milwaukee
Posts: 93
propionate is on a distinguished road
Re: Autonomous code issue :(

A few potential problems I see with the overall structure:

1. Your "Wheel Distance" VI's are both inside of a while loop. They will be constantly updating, so the drive motors will never actually reach their goal of 50cm.

2. There is no wait timer in the while loop. You may want to add one to avoid any potential cRIO lag issues.

3. You are writing to the drive motors in 3 separate places that I can see. This is generally not a good idea, as LabVIEW gets confused pretty quick if multiple VI's are giving commands to the same motor.

Number 3 is what is most likely causing the problem. Here is some code that should do what you want:

http://i.imgur.com/R1Ukf8Y.png

Instead of your custom VI, I just created a case structure as a placeholder. It works on the same principle as yours, except there is no need to add the 50cm and then subtract off. Simply reset the encoders using the "Reset Encoder" global variable *before* you enter the while loop/first case, and that way you can be sure they will start at 0. It advances to the next case if both encoders have reached 50cm.

Last edited by propionate : 10-02-2013 at 02:57.
Reply With Quote
  #4   Spotlight this post!  
Unread 10-02-2013, 09:43
bumblebee3339's Avatar
bumblebee3339 bumblebee3339 is offline
Team's main account
FRC #3339 (BumbleBee)
 
Join Date: Feb 2013
Rookie Year: 2009
Location: Israel
Posts: 34
bumblebee3339 is an unknown quantity at this point
Re: Autonomous code issue :(

Quote:
Originally Posted by bvisness View Post
It could be a motor safety problem, since you're only commanding the tank drive output once, and then entering your two loops. You should probably put the tank drive at 0.5 block inside the loop to avoid that problem.

Besides that, your code looks quite good! I'm not sure what your problem would be.
It might be the problem, I'll report as soon as I try to fix it agian. Thx.

Quote:
Originally Posted by propionate View Post
A few potential problems I see with the overall structure:

1. Your "Wheel Distance" VI's are both inside of a while loop. They will be constantly updating, so the drive motors will never actually reach their goal of 50cm.

2. There is no wait timer in the while loop. You may want to add one to avoid any potential cRIO lag issues.

3. You are writing to the drive motors in 3 separate places that I can see. This is generally not a good idea, as LabVIEW gets confused pretty quick if multiple VI's are giving commands to the same motor.

Number 3 is what is most likely causing the problem. Here is some code that should do what you want:

http://i.imgur.com/R1Ukf8Y.png

Instead of your custom VI, I just created a case structure as a placeholder. It works on the same principle as yours, except there is no need to add the 50cm and then subtract off. Simply reset the encoders using the "Reset Encoder" global variable *before* you enter the while loop/first case, and that way you can be sure they will start at 0. It advances to the next case if both encoders have reached 50cm.
1. I checked it, and the comparison is performed on the value before the loop + 50 and the current value so it can reach it (I moved the robot manually and it worked).

2. How much ms would be the best choice? is 10ms enough?

3. I dont write to the same motor at one time. on the left I give both the same value and on the right the upper controls the left motor and the lower controls the right motor. Is it still might be connected to the problem?

And thx for the code I'll try it !
BTW what is the "Reset Encoder" global variable? I know only about the encoder reset vi, is that the same?

Thx agian !!
Reply With Quote
  #5   Spotlight this post!  
Unread 10-02-2013, 14:08
propionate's Avatar
propionate propionate is offline
Team co-lead and LabVIEW programmer
AKA: Stephen
FRC #1732 (Hilltopper Robotics)
 
Join Date: Jan 2012
Rookie Year: 2009
Location: Milwaukee
Posts: 93
propionate is on a distinguished road
Re: Autonomous code issue :(

Quote:
Originally Posted by bumblebee3339 View Post
It might be the problem, I'll report as soon as I try to fix it agian. Thx.



1. I checked it, and the comparison is performed on the value before the loop + 50 and the current value so it can reach it (I moved the robot manually and it worked).

2. How much ms would be the best choice? is 10ms enough?

3. I dont write to the same motor at one time. on the left I give both the same value and on the right the upper controls the left motor and the lower controls the right motor. Is it still might be connected to the problem?

And thx for the code I'll try it !
BTW what is the "Reset Encoder" global variable? I know only about the encoder reset vi, is that the same?

Thx agian !!

1. Good catch - I wasn't considering my own advice about nested loops.
2. I would suggest something like 30 or 40ms. You can go lower, but it will eat up more CPU usage.
3. I think it will still be problematic because each iteration of the larger while loop contains two commands to each set of drive train motors.

The Reset Encoder global variable may have been more out of habit. I normally put the encoder code in periodic tasks, and you can use a global variable to reset the encoder from any other VI (in your case, autonomous). Using the Reset Encoder VI and a inputting a constant in autonomous will achieve the same result.
Reply With Quote
  #6   Spotlight this post!  
Unread 10-02-2013, 18:53
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Autonomous code issue :(

Your problem is almost certainly the motor safety. A tenth of a second after you enter the inner While loop, the drive motors will shut off because they're not being commanded. Moving the first Tank Drive inside the loop should correct that.

Quote:
Originally Posted by bumblebee3339 View Post
3. I dont write to the same motor at one time. on the left I give both the same value and on the right the upper controls the left motor and the lower controls the right motor. Is it still might be connected to the problem?
It's not connected to the problem you're working on right now, but it still is a problem. Tank Drive doesn't control individual motors. For example, if you don't connect anything to the Left input, it assumes a value of 0 and stops the motor anyway.

If you want to do things the way it looks like you're trying to, then you should have only a single inner While loop instead of the two parallel ones. Inside that loop, set the Left input to Tank Drive to either .5 or 0 depending on whether the left encoder has reached its target. Simultaneously set the Right input to either .5 or 0 depending on whether the right encoder has reached its target. If both encoders are at or above their set point, exit the While loop.
Reply With Quote
  #7   Spotlight this post!  
Unread 11-02-2013, 07:45
bumblebee3339's Avatar
bumblebee3339 bumblebee3339 is offline
Team's main account
FRC #3339 (BumbleBee)
 
Join Date: Feb 2013
Rookie Year: 2009
Location: Israel
Posts: 34
bumblebee3339 is an unknown quantity at this point
Solved !

Thx to all of you ! I got some great tips here and I finally got this to work..
The saftey config was the main problem, putting the drive command in the loops made it move - but it didn't move smoothly.
The second problem which I encountered was that the Crio couldn't handle both of the loops so it gave the right a value, stopped it, gave the other side a value and so on...
Finally I made one loop (to rule them all!) simiilar to Stephen's (propionate) idea, thanks alot !

I might be uploading an image of the correct code soon
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:50.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi