Go to Post For some people FRC is an introduction into STEM and just a way to open someones eyes to a world they might not know exist. To other it is a lifestyle that makes crossfit look casual. - IronicDeadBird [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 06-02-2012, 19:33
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
"Squaring" robot

Hello -

I've ran into a little bit of a roadblock. We've got two rangefinders - One on the left and one on the right of our robot. I am trying to read the values of both of them, and if the difference between them is not within an acceptable, predefined distance, move the drive motors accordingly to "square" the robot with the nearest wall.

Now, I've confirmed that the two Rangefinders are working, as I have a numeric readout within Teleop.vi. I've written this code into Pereodic.vi within a Flat Sequence Structure which is triggered by a joystick button press. Here's the odd part...If the rangefinders are within the difference defined, the sequence continues on to the next frame. However, if the rangefinders are NOT within the defined difference, nothing happens.

Any help/suggestions? Thanks.

EDIT - I attached a picture of the code in question. Anyone need it in a .vi?
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	67
Size:	107.5 KB
ID:	11763  

Last edited by DominickC : 06-02-2012 at 19:43.
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2012, 19:54
JohnGilb JohnGilb is offline
Programming Mentor, Drive Mentor
FRC #0488
 
Join Date: Mar 2011
Rookie Year: 2003
Location: Redmond, WA
Posts: 116
JohnGilb has a spectacular aura aboutJohnGilb has a spectacular aura aboutJohnGilb has a spectacular aura about
Re: "Squaring" robot

You might need to add the VI - it's hard to read your wiring.

I do see a potential conflict. You have cases for:
  • One greater than another
  • Both within 5 of each other
  • One less than the other

However, it is possible to be in more than one case simultaneously. If A is 2 greater than B, you'll trigger the first case and the second case. In the first case you set motor values of of .1*, in the second case you set motor values of 0.

The robot will dutifully apply both, so you'll rapidly be switching between some power and no power. This could stop your robot from moving at all.


*On a side note, many robots won't even move unless the motor powers are ~.3 or even .4 depending on robot weight, friction in the drive train, trying to turn, etc. Try ramping up the power temporarily to make sure that isn't the problem.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-02-2012, 19:56
JohnGilb JohnGilb is offline
Programming Mentor, Drive Mentor
FRC #0488
 
Join Date: Mar 2011
Rookie Year: 2003
Location: Redmond, WA
Posts: 116
JohnGilb has a spectacular aura aboutJohnGilb has a spectacular aura aboutJohnGilb has a spectacular aura about
Re: "Squaring" robot

One way to make these conflicts more visible is by only having one "Drive" block at the very end that is always excuted, and have all this logic beforehand to determine what the inputs will be. That will ensure you never hit a scenario where two areas are trying to set different motor speeds.

That kind of layout also tends to make is easier to probe and figure out where the logic is going wrong.
Reply With Quote
  #4   Spotlight this post!  
Unread 06-02-2012, 20:00
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: "Squaring" robot

I've rewritten the code in a very minimal fashion, trying to make it as clear as possible while removing all superfluous actions.

I believe this should work. It's within a bunch of other code which runs every 20ms. Will I need to add a delay within the While loop?

When the rangefinders are within 5 to -5 inches of each other, I want to set all motor outputs to 0. How might I do that other than what I've got in this new image?

Thanks.
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	33
Size:	68.2 KB
ID:	11766  
Reply With Quote
  #5   Spotlight this post!  
Unread 06-02-2012, 20:03
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: "Squaring" robot

Quote:
Originally Posted by JohnGilb View Post

*On a side note, many robots won't even move unless the motor powers are ~.3 or even .4 depending on robot weight, friction in the drive train, trying to turn, etc. Try ramping up the power temporarily to make sure that isn't the problem.
I've got all my electronics mounted modularly on a board, and have no motors hooked up to the Jags. I'm just supplying arbitrary values and looking for a signal indicator on the Jags. (Flashing red/green)
Reply With Quote
  #6   Spotlight this post!  
Unread 06-02-2012, 20:20
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: "Squaring" robot

Another quick rewrite. It's a bit different now, so I'll include the VI and a picture.
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	22
Size:	66.2 KB
ID:	11768  
Attached Files
File Type: vi test.vi (18.5 KB, 1 views)
Reply With Quote
  #7   Spotlight this post!  
Unread 06-02-2012, 20:24
JohnGilb JohnGilb is offline
Programming Mentor, Drive Mentor
FRC #0488
 
Join Date: Mar 2011
Rookie Year: 2003
Location: Redmond, WA
Posts: 116
JohnGilb has a spectacular aura aboutJohnGilb has a spectacular aura aboutJohnGilb has a spectacular aura about
Re: "Squaring" robot

Attached are some simplified examples (didn't create the sensors, just made some variables for distance) that show what I mean.

Each case structure can "interrupt" the one before it, with the last one having priority. In this example, the last case structure is the "In Range" detection that keeps you from moving if you're centered enough.


*Some other small notes:
-It's better to get the references to motors/sensors once outside the loop and use them many times inside the loop. Calling into the refnum registry can be expensive if you're doing it all the time.
-Where does this code live? You said it's inside some other VI.
Attached Thumbnails
Click image for larger version

Name:	TrueCases.png
Views:	28
Size:	21.5 KB
ID:	11769  Click image for larger version

Name:	FalseCases.png
Views:	15
Size:	20.8 KB
ID:	11770  
Reply With Quote
  #8   Spotlight this post!  
Unread 06-02-2012, 20:29
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: "Squaring" robot

Ah, I see. Quite a clever way of working out the problem! I'll see if I can't implement it within my code.

This code is within Pereodic Tasks.vi, being run every 20ms. Am I able to place a Refnum Name outside of a while loop within Pereodic Tasks.vi and still have it work?
Reply With Quote
  #9   Spotlight this post!  
Unread 06-02-2012, 20:53
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: "Squaring" robot

That code doesn't do what was described.

Let me describe what it does.

It compares and subtracts two range sensors. If the difference is more than 5, it starts a loop that never ends -- the loop termination is guaranteed to be False wired to the Stop terminal. Inside that infinite loop, it sets the steering repeatedly to the same value with a small delay of 1ms. The motor controllers will only update every 5ms (Jags) or 20ms (Vics) by the way.

Equivalent code is something more like this ...

It only sets the value once to either 0.1 and -0.1, the opposite, or in the True frame it sets it to 0 and 0.

Greg McKaskle
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2012-02-06 at 7.48.00 PM.png
Views:	29
Size:	12.8 KB
ID:	11774  
Reply With Quote
  #10   Spotlight this post!  
Unread 06-02-2012, 21:11
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: "Squaring" robot

@Greg - I don't know what I thought I was going to accomplish with my first version of this code, it obviously didn't work! That can get really frustrating, really fast

I've created a piece of code very similar to what JohnGilb suggested, and I believe his code fits my physical needs best. I'll test it tomorrow and hope for the best.
Reply With Quote
  #11   Spotlight this post!  
Unread 06-02-2012, 21:23
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: "Squaring" robot

It is all about the learning. Good job putting your work out there, and asking questions. This gives you, and many other lurkers, the ability to see several different solutions to the problem and understand the issues more thoroughly.

Good luck.
Greg McKaskle
Reply With Quote
  #12   Spotlight this post!  
Unread 08-02-2012, 21:31
DominickC DominickC is offline
Registered User
FRC #0023 (PNTA)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 1620
Location: Boston
Posts: 435
DominickC is an unknown quantity at this point
Re: "Squaring" robot

Unfortunately, I had some problems today.

I placed an object in front of the left and right rangefinders at a difference which was within the tolerance written into the code. (5 inches in either direction), and the code would continue on to the next frame within the Flat Sequence.

However, once I placed it at a difference outside the tolerance, the code would pause (not move on to the next frame), and would not send values to any of our speed controllers.

I highlighted the execution to see what was wrong, and it appeared as if it was sending the motor output values I requested.

Any tips? Need a copy of the complete VI?

Dom
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:27.

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