Go to Post (pfft, kid... I sound like I'm Baker's age) - Amanda Morrison [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 27-09-2008, 01:12
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
help with another VI

What this VI is intended to do is give a direction and distance to travel, if your robot is at the pixel point "reference" and you want it to go to the pixel point labelled "target".
The distance part is working fine, but the direction clearly isn't.



It runs properly, but some part of my math isn't correct.

Any help would be greatly appreciated; this is part of the control system for telling a robot where to go.
Other stuff I've done (mostly working) can be found at http://sotabot.com/robot/programming.html
Attached Files
File Type: vi distance and direction.vi (24.7 KB, 104 views)
__________________
-- Marshal Horn

Last edited by kamocat : 27-09-2008 at 03:20.
  #2   Spotlight this post!  
Unread 27-09-2008, 09:06
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,753
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: help with another VI

I don't understand the units and coordinate system you are using, but you usually want to take atan of y/x instead of x/y. Give that a try.

Another suggestion is to use the atan2 node. Atan can't give you correct quadrant info all the way around the circle since y/x and (-y)/(-x) look the same as an input. Same for distinguishing (-y)/x and y/(-x). It also helps you keep from flipping them.

Using divisions of 360, seems like it might give degrees. The diagram then computes the angle as the (atan result in radians) * 180/2pi. But to convert to degrees you'd either use 360/2pi or 180/pi. Without understanding the coordinate systems I can't say for sure this is a bug, but that also looks funny to me.


Greg McKaskle
  #3   Spotlight this post!  
Unread 27-09-2008, 11:57
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
Re: help with another VI

I'm using pixels in a picture, so I'm dealing with the 4th quadrant with the y axis negated.
And you're right. It should y÷x (rise÷run). Still doesn't seem to work, unfortunately.
I might try building a VI to find the closest match to any given real number so that I can use an array for this instead of the atan function.

EDIT:
For simplification (and because at this point I just don't need 360 divisions), I'm using 24 divisions (every 15 degrees). I might change it to 72 or 360 later.
__________________
-- Marshal Horn

Last edited by kamocat : 27-09-2008 at 12:00.
  #4   Spotlight this post!  
Unread 27-09-2008, 14:06
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,753
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: help with another VI

Setting divisions to 360, I think I was able to get it working the way you want by making the following changes.

Use Atan2.

Drop the conditional amount you are adding, and add div/2 all the time. Let Atan2 do this for you.

Multiply by (div/2)/ pi. Or make sure your units are correct. They seemed to be off by 2x.

The other changes shown in the picture are just to show some other ways of doing things.

You can do math on arrays and clusters. In many cases such, this allows you to have fewer wires and think in terms of points, rects, etc. I added a picture control to hover over to quickly get an easy to control input to the code.

I didn't use your pythag VI simply because I didn't have it. I deleted the file stuff to clarify the code.

Also, you can of course use integers if you like, but they are much more error prone, and in many cases aren't any faster. Similarly, using file I/O to load values rather than compute them will likely be hundreds or thousands of times slower than computing it.

Hope this helps.

http://www.chiefdelphi.com/forums/images/attach/png.gif
Attached Thumbnails
Click image for larger version

Name:	AngleDist.png
Views:	78
Size:	12.0 KB
ID:	6846  
  #5   Spotlight this post!  
Unread 27-09-2008, 18:35
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
Re: help with another VI

Thanks!
I found that 3/4 * "divisions" should be added to the angle returned (instead of 1/2 * "divisions"), assuming you want zero to be up.
I'm certainly glad using the ATAN function is faster than using an array, however, I'm curios as to why that might be. Is the time-consuming part in the opening of the file, or the recalling of it?

Anyways, thank you! It works now, and I can get on to implementing it. Where would I look to find that mouse pointer control?
__________________
-- Marshal Horn
  #6   Spotlight this post!  
Unread 27-09-2008, 22:14
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,753
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: help with another VI

The picture control is in the graphs submenu. I drew a rect that included negative numbers and positive numbers, then scrolled it to have zero centered.

The property node for the picture control will easily give the mouse position, or you could use the event structure to get mouse info.

Greg McKaskle
  #7   Spotlight this post!  
Unread 29-09-2008, 10:15
Russ Beavis Russ Beavis is offline
Registered User
no team
 
Join Date: Nov 2005
Location: Manchester, NH - DEKA R&D Corp.
Posts: 341
Russ Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond repute
Re: help with another VI

I apologize if these VIs aren't included in your LabVIEW package (they may only be available in the Full and/or Pro installations). You might want to consider converting your XY Cartesian coordinates to polar coordinates and using LabVIEW's complex math capabilities (see the attached VI in LabVIEW 8.2 format).

Russ
Attached Files
File Type: vi distance and direction between 2d cartesian coordinates.vi (16.8 KB, 65 views)
File Type: pdf distance and direction.pdf (16.0 KB, 66 views)
  #8   Spotlight this post!  
Unread 29-09-2008, 20:53
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
Re: help with another VI

Well, that's certainly an easy way to do it! It'd also make it simple to do the reverse: place objects the robot sees on the field on this image itself. Thank you!

And yes, I do have the full version, which is part of why I can deal with images in the first place.

Anyways, thanks! This makes my life a lot easier.
__________________
-- Marshal Horn
  #9   Spotlight this post!  
Unread 30-09-2008, 09:42
Russ Beavis Russ Beavis is offline
Registered User
no team
 
Join Date: Nov 2005
Location: Manchester, NH - DEKA R&D Corp.
Posts: 341
Russ Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond reputeRuss Beavis has a reputation beyond repute
Re: help with another VI

I wanted to make a few other points about the VI that I offered for consideration. I made use of a few features in LabVIEW that are super useful. I recognize that other languages have similar features but these really shine in LabVIEW (IMHO).

1) Polymorphism - almost every VI that NI provides (especially in the various math routines like add/subtract/multiply/divide) support automatic detection of data type with support for a WIDE array of inputs. For example, the "multiply" VI can operate on fixed x fixed, float x fixed, float x float, array x array, array x scalar, cluster x cluster, etc. You might be surprised to learn that almost ANY data type can be multiplied. In my example, I subtracted the two clusters of position directly without needing to unbundle them and wire them separately

2) Clusters (aka structures in C) - VERY USEFUL!! THESE ARE YOUR FRIENDS!! This is a great way to encapsulate a set of data (including disparate data types)

Happy G coding!
Russ
  #10   Spotlight this post!  
Unread 30-09-2008, 21:57
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
Re: many thanks

Thanks to both of you, I was able simplify my robot tracker VI so that it didn't operate on any subVIs (and most likely operates a lot more efficiently because of that). This "robot tracker" VI simply plots the path of both driven sides of a 10px wide robot. This could be useful in autonomous mode, to tell where on the field the robot is.
Attached Thumbnails
Click image for larger version

Name:	robot tracker2.png
Views:	38
Size:	28.4 KB
ID:	6853  
Attached Files
File Type: vi robot tracker2.vi (30.2 KB, 40 views)
__________________
-- Marshal Horn
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fluent in another language? Your help is needed! Knippschild General Forum 55 18-02-2007 18:34
Ultrasonic will not work with another Ultrasonic plz help Jackel148 Programming 10 10-05-2006 15:31
Help Genia Get Taller and Win Another Prize Eugenia Gabrielov Chit-Chat 41 24-02-2005 10:42
Need interupts help, and another question... Kevin Karan Programming 7 22-02-2004 11:20
Help out, another question archiver 2001 1 24-06-2002 01:01


All times are GMT -5. The time now is 19:23.

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