Plotting the position of a robot.

Hi, I am building a GUI that receives data from a serial port. Once the information has been handle, I divide the stream into pieces and display the numbers they contain into JTextFields. Each of these pieces indicate the x-y coordinates, of a moving robot, which I want to show inside of a panel.
I can do the basics: draw a filled circle, the background, etc, but I dont know how to pass those numbers into the method that creates the draw. Also, I don't want to delete the "n-1" filled circles, so that at the end, I can see the path the robot took from the first position to the final one.
Thanks I really appreciate your help!

First of all thanks for your prompt reply.
I have considered the option number one as well. As you can see in the following two classes, I call from InfoGpsGui the Dibujo class which makes the circle with variables "a" and "b". My problem is that I dont know how to implement that iteration that you mentioned, since I can't modify the parameters at the paintComponent method in Dibujo, so to be able to introduce these variables "a" and "b" from InfoGpsGui as it is receiving them from my serial port class.
I will appreciate any snippet or code that can give a hint on the matter.
// class Dibujo
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Arc2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Rectangle2D;
import javax.swing.JPanel;
public class Dibujo extends JPanel {
     public static float a, b;
     public Graphics2D comp2D;
     public void paintComponent(Graphics comp) {
          // Creates a Java 2D object
          comp2D = (Graphics2D)comp;
          // Defines the color of the rectangle that is going to be built
          // to make a background
          comp2D.setColor(Color.white);
          Rectangle2D.Float background = new Rectangle2D.Float(
                    0F, 0F, (float)getSize().width, (float)getSize().height);
          comp2D.fill(background);
//           Defines a color-filled circle inside of the background
          comp2D.setColor(Color.black);
        BasicStroke pen2 = new BasicStroke();
        comp2D.setStroke(pen2);
        Ellipse2D.Float e1 = new Ellipse2D.Float(a, b, 15, 15);
        comp2D.fill(e1);
// Class InfoGpsGui
import java.awt.Container;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import javax.swing.*;
public class InfoGpsGui extends JFrame{
     static JTextField alt, lon, pos;
     public static char[] letras = new char[5];
     public static byte [] otroBuffer;
     public static Dibujo map = new Dibujo();
     private static Graphics comp;
     public InfoGpsGui(){
          //Characteristics of the frame
          super("GPS Info");
          setSize(650, 450);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          //Outside-most frame, will contain the draw and info panels
          JPanel pane = new JPanel();
          pane.setLayout(new GridLayout(1, 0));
          //Left sided frame, contains the drawing
          JPanel draw = new JPanel();
          //Container content = getContentPane();
          draw.setLayout(new GridLayout(1,0));
        draw.add(map);
          pane.add(draw);
          //Right sided frame, contains the info from the GPS
          JPanel info = new JPanel();
          info.setLayout(new GridLayout(3, 2));
          JLabel altitudeLabel = new JLabel("Altitude: ");
          alt = new JTextField(letras[0]);
          JLabel positionLabel = new JLabel("Position: ");
          pos = new JTextField(letras[1]);
          JLabel longitudeLabel = new JLabel("Longitude: ");
          lon = new JTextField(letras[2]);
          //info.add(map);
          info.add(altitudeLabel);
          info.add(alt);
          info.add(positionLabel);
          info.add(pos);
          info.add(longitudeLabel);
          info.add(lon);
          pane.add(info);
          setContentPane(pane);
          setVisible(true);
     // Updates the values of the JTextFields in the GUI
     public static void updateValues(String c, String d, String e){
          alt.setText(c);
          pos.setText(d);
          lon.setText(e);
     public static void main(String[] args){
          InfoGpsGui berf = new InfoGpsGui();
          SerialEcho input = new SerialEcho("COM4", 9600);
//          Map prueba = new Map();
          while (true) { // Keeps open the link between the serial port and the GUI
               if (input.serialData) { // if there's data
                    otroBuffer = input.getData();
                    for (int i = 0; i < otroBuffer.length; i++) {
                         // System.out.print((char)otroBuffer);
                         letras = (char) otroBuffer; // Store data in letras
                    //System.out.println();
                    updateValues(Character.toString(letras[0]),Character.toString(letras[1]),
                              Character.toString(letras[2]));

Similar Messages

  • How can I find the position of a robotic arm with a cFP-CTR card?

    Hello,
    I use a CTR-500 to measure the pulses of 3 encoders.
    The encoders are related to the 3 axis (x,y,z), to which a robotic arm is moving.
    Each encoder has 2 channels (A,B) which go to each pair of Count Inputs of the CTR card.
    When the robotic arm is moving on one axis, the corresponding pair of Count Inputs is increasing, but there is a phase between the one Count Input and the second one. What is more, the Count Inputs do not decrease when the robotic arm is moving to the other direction, but they still increase.
    So, I cannot find easily the position of the robotic arm.
    What I have done, is to try finding the position, by using only one Counter Input for each axis. This means that I use the value of the encoder as a counter, and I calculate the position with some software tricks. But for some reason, it does not work properly.
    I have heard that the method I use is not proper. Instead, I have been told that I must use the phase of the 2 Count Inputs, in order to find the direction to which the robotic arm is moving. But, the Count Inputs of the CTR are augmenting in parallel, when the robotic arm is moving forward or backward.
    How can I find the position of the robotic arm, as it is moving like a CNC ?
    Thank you very much.
    Message Edited by nikosfs on 08-21-2009 12:27 PM

    You don't want to use a cFP-CTR-500 card.  What you have are quadrature signals.  You should be using the cFP-QUAD-510.  It has 4 channels that can handle both the A and B signals of a quadrature encoder.  It has the built in circuitry do determine the phasing of A vs. B to know when to count up vs. count down.

  • I'm doing a scan around a line by sampling data 360 degrees for every value of z(z is the position on the line). So, that mean I have a double for-loop where I collect the data. The problem comes when I try to plot the data. How should I do?

    I'm doing a scan around a line by sampling data 360 degrees for every value of z(z is the position on the line). So, that mean I have a double for-loop where I collect the data. The problem comes when I try to plot the data. How should I do?

    Jonas,
    I think what you want is a 3D plot of a cylinder. I have attached an example using a parametric 3D plot.
    You will probably want to duplicate the points for the first theta value to close the cylinder. I'm not sure what properties of the graph can be manipulated to make it easier to see.
    Bruce
    Bruce Ammons
    Ammons Engineering
    Attachments:
    Cylinder_Plot_3D.vi ‏76 KB

  • Plotting the best increasing dynamic temparatur​e data from several channels

    Hi All !    
    I want to plot dynamic temparature data in real time. I have 8 sensors to acquire signal through USB. I want to plot  the best increasing signals amaong them. How Can I do this?    
    I can plot all of them togather but not getting the clue how could I choose which has the increaseing profile and discard those which does not have any temarature increase.
    Should I need to store the data first and then do some gradient masurement on those or any other method?
    But still do not know to make gradient masurement on dynamically acquiring data..    
    Thanks and Regards,
    Hasan

    Hi Hasan,
    There are probably many ways you can do this. First of you probably need to convert the data from dynamic data type to waveform or double. If you still want the timing information I would go for waveform. Then slipt the Y data out and do some kind of liner fit on all channels. Then take the channel that give you the steepest positive slop to see which one increased the most.
    If you are only looking to which one that has the highest value. Then I would go for a MAX&Min function to determin which array (channel) that has the highest value (temperature) and then take out that row (Channel) from the wave form 2D array to only plot that one.
    Does this make sense to you?
    Best Regards
    Jonas Mäki
    Applications Engineering
    National Instruments

  • Read out the position of 3D cursors

    I would like to read out the position (x,y,z) of defined cursors of a 3D plot. How to create the right property node?
    Best regards
    Daniel H.

    reply # 10 of this thread
    http://forums.ni.com/ni/board/message?board.id=170​&message.id=143663&jump=true
    I show you how to manipulate a cursor.
    I hope that helps,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • The position of the worker, from which table can I get?

    Hi,
    Whether a person with a given pernr, how can I know whether he is a manager or an employee etc.
    Which table and which field of this table.
    Thanks.

    Hi,
    To get the position for a person you need to go to table PA0001 table (PLANS field).
    Once you get the position, to check whether that position is Manager's position
    You need to go to table HRP1001 and check whether is there any entry exist for the position with relationship 'B002' (SUBTY field), if entry exists then the position is manager's position. The all the entries in SOBID fields are subordinate position to the managers position.
    Hope this helps,
    Shrinivas

  • How to Change the position of Column in ALV report

    Hi Follks,
        Is is possible to change the position of column in ALV report?.If yes then how?
        Basically my requirement is, that user want afacility where , he should be able to change the position
        of column aftre he runs the report.
        Eg: After running the report , user felt that column 5 should be at position 2 , in that case he should   
               be able to drag column 5 at position 2 and vice versa.
        Please help me, how to solve this issue.
        Note : I am using NW 7.0 SP 9
        Regards
        PG
    Edited by: PG on Apr 13, 2009 11:10 AM

    HI PG,
    do below whie filling the filed catlog
    wa_fieldcat-fieldname        = 'Field1".
    wa_fieldcat-COL_POS = '1',
    append wa_fieldcat to it_fieldcat.
    wa_fieldcat-fieldname         = 'Field2".
    wa_fieldcat-COL_POS = '2',
    wa_fieldcat-fieldname         = 'Field3".
    wa_fieldcat-COL_POS = '3',
    Thanks!

  • Help ! To Lock  The Position Of a JFrame ?!!

    hi..
    How can i lock the Position of a JFrme..
    my requirement is to lock the position of a JFrame.. so that it cannot be dragged on a screen.. but must be resizable... is that possible ?
    any suggestions ??
    Thanking You in advance...
    _rG.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    well sorry..
    i guess you are speaking with respect to windows ..
    well i left out to tell ya..
    i'm working on a macintosh..
    so i need the requirement as per the client to lock its position but not the size...
    the desktop on a macintosh can be viewed else with short keys..
    any help ?!!
    _rG.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to make the graph follows the position of the video frame

    Hai..
    I want to open the video (. avi) and graph together in one VI.. The videos and graphs can be controlled (forwarded or rewind) in the desired position.. However, the graph should follow where's the position of the video frame..   The graph generated from the data in excel, after reading data, then there is the processing of signals, such as filter, mean, find the peak, etc.. After that the result will appear in the graph..
    Until now, I've been able to display video and graph.. I'm trying to use WMP and also IMAQ..
    Because I want to show the position of the graph or signal when the video plays, I was making a cursor or a line on a graph that follows the position of the video..
    First, I'm trying using WMP.. I can forward and rewind video using WMP, after that I make a cursor on the graph and the position of cursor I put in the position video.. And then when I run the program, the signal that arises from the right, but the cursor in the graph follow the position of the video (the cursor appears on the left) different side with the signal..
    I also tried using IMAQ when I tried to use the video controls, so the video can be forward or rewind using the slide, and I made a graph control to follow the video.. But the video isn't playing, it just show only images or frame in the video..
    Can we create a graph that can follow the position of the video? (graph can be in forward and rewind just like with video)
    I've tried many ways but until now have not been successful.. can someone help me?
    Any help is greatly appreciated thank you.

    This should do pretty much what you want, assuming that a slider is how you are controlling your video position. You are going to have to play around with it a little but it should give you the basic idea.
    Attachments:
    Slider.vi ‏35 KB

  • How to set the position in SAP Script

    Hi Professionals,
    Can anyone tell me that How can I set the position of an bitmap Image (after inserting) in SAP Script ?
    by default position is in Left, I need to align it in center or somewhere else.
    Anybody knows, kindly reply!
    Thanks
    Devinder

    Hi,
    But Can we assign a window under another window. Because I want to insert a bmp picture on particular position.
    example:- there is a digital signature and wanted to insert upon a name.
    So, there is a text (which is customer name) and digital signature (in bmp picture format) upon it.
    Thanks
    Devinder

  • How can I show a value according to the position of the mouse arrow ?

    Hi Everyone,
    I am changing the color of the background of some indicators according to temperature measures. Each background is linked to one temperature. I would like to show the value of a temperature when passing the arrow of my mouse over the indicator. I don't want to over charge the Front Diagram with all of the temperatures.
    Is this possible? The temperature could appear in a unique and fixed indicator, or linked to the arrow,...
    Any help would be great,
    Thanks,
    User
    Solved!
    Go to Solution.

    Hi Ravens and Dan,
    Thanks for your answers.
    Ravens, I would rather not use the arrow position because I need to do this overs 100 indicator, and that would be a bit long. Added to that if I need to change the positions of the indicators (whch I will) that would mean to redefine the positions of the indicators....But perhaps your solution is the only possible?
    Dan, I have taken out and simplified the piece of my program. Setting the value of the indicator to transparent except when the mouse is over the indicator could be an example of presentating the values but I still don't know how to this (without having to define the position of each box)
    Thanks again
    User
    Attachments:
    forum 14 02 10.vi ‏9 KB

  • How to get the position of a tag in XML,when i am using the org.xml.sax

    Hi,
    I am able to parse a xml document.I want to get the position of a tag in the document.So that by keeping that as reference, i can access other tags.Plz help me.I am using org.xml.sax API.

    Hello Friends
    After research , I could also find another way to check the existence of a node .We can even use CHOOSE to check the existence.
    <xsl:choose>
          <xsl:when test="(/mynode)">
              your action if the mynode is found
          </xsl:when>
          <xsl:otherwise>
                    action if mynode is not found
          </xsl:otherwise>
    </xsl:choose>
    Thanks.
    Wishes
    Richa

  • Can the position and szing of a control element in a View be controlled from the ViewModel?

    Is it possible to change the position of a control, say a label, as a response to some action/operation from the ViewModel?  Like if one response to something is true then place the label in the top left corner.  If false, place the label
    in the lower right corner.  I realize you could have a label in each position and just set the visibility.  But can the position and sizing of said label be controlled from the View Model?  What would be a sample coding of this?  would
    it be in the xaml or combination of a method in the ViewModel and the xaml? 
    Rich P

    First off Rich, say TextBlock to yourself ten times.
    Use a TextBlock rather than a label.
    There are a bunch of different ways to do this and the easiest is to have two controls whose text is bound to the one property.
    Bind the Visibility of each to another 2 properties in the viewmodel.
    Collapse one and Visible the other.
    The reason for that is that it's easier.
    Technically, you could put one textblock in a grid and use margin to control this.  You could animate x y co-ordinates and move the textblock mysteriously across the window if you put your mind to it.
    Or you could put it in a row/column "cell" of a grid and change which cell it goes in - but that would involve some mechanism like messaging from the viewmodel to the view and is not really ideal if you can avoid it.
    I'd have a pair of textblocks, here's one:
    <TextBlock Name="TopLeftMsg"
    Text="{Binding Msg}"
    Visiblity="{Binding TopLeftVis}"
    Both would bind to a public string property msg in the viewmodel.
    They each get their own public visibility property  and that'd be switched between Visibility.Visible and Visibility.Collapsed.
    Sizing of textblocks is best fitted to content because all you see is the text.
    Textboxes are arguably different because you can see the things.
    Hope that helps.
    Recent Technet articles:
    Property List Editing;  
    Dynamic XAML

  • Is it possible to change the position of beining of text in a standard report

    Hi,
         I am wondering wether it is possible to change the position of the test (the starting point) in a standard report. I would like to print a label with different texts at different positions. If its not possible in a standard report is there any other way to do it.
    Thank you,
    Mudda.

    Hi Mudda, I don't see any way myself to set any particular starting position for your text. It looks like the best way to emulate this behavior would be to add a new line with lots of tab characters or spaces to place your new text at a specific offset from the left. You can also use Append Table to Report and wire in a 2D string array with only a few positions filled in with your various text labels as shown below. This will space text labels pretty well across the page. Try it out and see if it works for you. You could be more clever and build the 2D array programmatically if you wanted more control over position.
    Message Edited by Jarrod S. on 06-02-2006 05:37 PM
    Jarrod S.
    National Instruments
    Attachments:
    Set_Report_Position.JPG ‏69 KB

  • How to get the position of a selected cell in a table ?

    Hi,
    How can I get the position of a selected cell in a table or in a list multicolumn cmd ?
    Thanks.

    Invoke node >>> point to Row Column
    Ben
    Message Edited by Ben on 07-19-2007 03:14 PM
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Attachments:
    Point_To_Row_Column.PNG ‏22 KB

Maybe you are looking for

  • Web Clipping portlet and pdf files

    Hi, I have created a web clipping portlet which just includes a set of links to HTML and pdf files. When I try to open a link to a pdf file the web clipping portlet fails, but links to the html content work fine Is it possible using web clipping to o

  • How can i insert new updated values in a table??

    Hi , Can any one suggest me is there any way to insert the recently added data from one table to another table where both the tables have the same structure. Suppose i have 10 rows in both table T1 and T2 and now if we add another 4 new rows in the t

  • Cisco Connect won't open due to Unsupported Operating System

    I have a Mac with OS X version 10.7.4, however when I try to open Cisco Connect I get an error message that says: Unsupported operating system The router works with these operating systems: - Mac OS X 10.4.9 or later - Mac OS X 10.5.8 or later - Mac

  • Official Remito Numbers Missing

    Dear Sapiants, While posting delivery document official Remito number (stores in LIKP-XBLNR) is skipped by one number i.e., instead of running number of 12066 it is given 12067 number (Production client). But 12066 is not posted with any document. Si

  • Hide saplogonpad  7.20 edit button

    Hi, In the old saplogonpad (6.20/7.10) the buttons on the right hand side where hidden. This was very useful in our company because we have an alternative / controlled method for users to manage their saplogon.ini. In the new 7.20 the edit button is