none
Using Microsoft Visual C# to create a GUI

    Question

  • Hi Fellow Programmers,

     

    I am currently doing my Final Year Project where I need to build a user interface through which children can program their robots to perform certain actions. I am using the Boe-bot with the EB500 module for bluetooth connectivity. My robot & the bluetooth connection has already been tested.

     

    To create the graphical user interface, I am using Microsoft Visual C# 2005 Express Edition. This is the first time I'm using Visual C#. My GUI needs to work in such a way where each action (eg: turn left, turn right, etc) is selected by the user --> combined into one --> and then downloaded as a whole onto the robot via bluetooth. I have not bee able to find ways in which i can combine these individual actions into 1 and then download them to the robot. Can anyone help me out there?? How would I do the programming in order to achieve this?

     

    Any help would be greatly appreciated! URGENT! Thanks!

     

    Best Rgds,

    Priya

    Friday, January 18, 2008 2:56 PM

Answers

  • Almost right :-)

     

    The last step about "downloading" to the robot is where you come unstuck. You can't download a whole sequence of operations to a Boe-Bot (like a macro command) unless you modify the PBASIC code on-board the robot.

     

    However, my previous question to you was more along the lines of "do you really need to download an instructions sequence?". If you are going to replay the sequence right now, then you can execute it in real-time using the existing Boe-Bot service. Bluetooth is used to transmit the commands to the EB500 one at a time, which is just the same as if you used the Dashboard to control the robot directly.

     

    On the other hand, if you want to send the set of instructions to the robot, then take it away somewhere without a Bluetooth connection, and re-run the instructions, then clearly they have to be loaded into the robot. I don't think this is what you want to do.

     

    Let's assume you have Record, Run, Save and Load buttons as well as the direction buttons.

     

    So, once you have recorded the sequence by clicking on the buttons, you simply replay the sequence and send the commands to the Boe-Bot. You probably want to pop up a dialog box each time the user clicks on a button to ask how long to move for.

     

    Here is how it might work:

    1. User clicks on Record. (Until they do this, the directions buttons actually work on the robot immediately -- this is just the Robotics Tutorial 4 - Drive By Wire)

    2. User clicks on Turn Right.

    3. Dialog pops up and user enters 2 seconds. (At this point you could execute the command)

    4. User clicks on Drive Forward.

    5. Dialog pops up and user enters 5 seconds.

    6. User clicks on Run.

    7. The program sends a sequence of commands to the Boe-Bot:

    Turn Right sent to Boe-Bot, waits 2 seconds, sends a Stop command to Boe-Bot,

    then sends Drive Forward to Boe-Bot, waits 5 seconds, and finally sends a Stop.

    8. Now the user is happy with this and wants to save it - Click on Save button.

     

    The Save function asks for a filename, and you write to a text file:

    Right,2000

    Forward,5000

     

    I used milliseconds in the text file so that you can have fractions of a second. You could simplify the format by just using a single character for each type of move. The interesting thing about this approach is that you can edit the text file in Notepad and easily copy/paste parts of sequences to repeat them, or just insert new commands.

     

    If you knew how long it took to turn 45 degrees or 90 degrees, you could write fancy "dance" routines in Notepad without using the GUI. However, the GUI gives you direct feedback on what is happening if the commands are executed immeditately after you enter them. Of course, that brings up the problem of what if the last command was NOT what you wanted? How do you erase commands in the GUI? Now we are talking about GUI design and not robotics.

     

    I hope this helps.

     

    Trevor

    Sunday, January 27, 2008 2:31 AM

All replies

  • You cannot do this with the standard Boe-Bot service and the monitor program from Parallax. You would have to modify the monitor program (written in PBASIC) on the Boe-Bot so that you could send it a series of commands and then have them "played back" later. This is not impossible, but if you are not familiar with the BASICStamp Editor and how the Boe-Bot protocol works it might not be easy either.

     

    I think you also need to supply parameters such as the amount of time to drive forward, how much to turn left, etc. Otherwise the commands would execute so quickly that you would not see anything!

     

    The monitor program for the Boe-Bot has a few "manoevers" built into it. Maybe you can use that code as a guide.

     

    Trevor

     

     

    Sunday, January 20, 2008 12:51 PM
  • Sorry, I jumped in and answered the technical question without asking what the objective of the task is.

     

    If you want the robot to execute a sequence of commands, why not let MSRS do this rather than "download" them to the robot? You could even record timestamps for key down/up events on the arrow keys and that way you could drive the robot around, recording as you go, and then just replay exactly the same sequence of drive operations later.

     

    Alternatively, if you wanted instructions like "Turn Left" to be selected from a menu or using push buttons, you could record the sequence of operations and even save them to a text file using some simple format for later recall and replay. Then to play them, just post the appropriate MSRS SetDrivePower messages.

     

    Be aware that the standard Parallax service does not support DriveDistance and RotateDegrees, but you can implement these using timers. The results will not be accurate, but it might be sufficient for your children to play with the robot and get it to do basic "dance" moves.

     

    This approach does not require any modifications of the Boe-Bot PBASIC code.

     

    Trevor

     

     

    Sunday, January 20, 2008 1:12 PM
  • Hi Trevor,

     

    Thanks for the info. I think my project relates better with your second idea, where you talk about using MSRS to send a sequence of instruction to the robot. Since this is my first time using Visal C# & MSRS, I understand the concept you're talking about, in fact, I was thinking of something along the similar lines. But the problem is, I dont know how to write it down as a program.

     

    I have already built the GUI which consists of 5 buttons (Turn left, Turn Right, Move Back, Move Forward, etc). So what you're saying is, the user can select a sequence of actions --> these actions get saved into a text file --> then later we can use MSRS to call back this sequence of actions saved in the text file and send them to the robot. Have I got it right?

     

    If yes, then once MSRS calls back these sequence of instruction, we would need a method to 'download' them to the robot right. Can't I make use of Bluetooth for this (using the EB500 module while I've already attached & tested to the Boe-bot)?? 

     

    Would the above approach still require modifications to the PBASIC monitor program for the Boe-bot?

     

    Rgds,

    Priya 

     

    Saturday, January 26, 2008 4:33 AM
  • Almost right :-)

     

    The last step about "downloading" to the robot is where you come unstuck. You can't download a whole sequence of operations to a Boe-Bot (like a macro command) unless you modify the PBASIC code on-board the robot.

     

    However, my previous question to you was more along the lines of "do you really need to download an instructions sequence?". If you are going to replay the sequence right now, then you can execute it in real-time using the existing Boe-Bot service. Bluetooth is used to transmit the commands to the EB500 one at a time, which is just the same as if you used the Dashboard to control the robot directly.

     

    On the other hand, if you want to send the set of instructions to the robot, then take it away somewhere without a Bluetooth connection, and re-run the instructions, then clearly they have to be loaded into the robot. I don't think this is what you want to do.

     

    Let's assume you have Record, Run, Save and Load buttons as well as the direction buttons.

     

    So, once you have recorded the sequence by clicking on the buttons, you simply replay the sequence and send the commands to the Boe-Bot. You probably want to pop up a dialog box each time the user clicks on a button to ask how long to move for.

     

    Here is how it might work:

    1. User clicks on Record. (Until they do this, the directions buttons actually work on the robot immediately -- this is just the Robotics Tutorial 4 - Drive By Wire)

    2. User clicks on Turn Right.

    3. Dialog pops up and user enters 2 seconds. (At this point you could execute the command)

    4. User clicks on Drive Forward.

    5. Dialog pops up and user enters 5 seconds.

    6. User clicks on Run.

    7. The program sends a sequence of commands to the Boe-Bot:

    Turn Right sent to Boe-Bot, waits 2 seconds, sends a Stop command to Boe-Bot,

    then sends Drive Forward to Boe-Bot, waits 5 seconds, and finally sends a Stop.

    8. Now the user is happy with this and wants to save it - Click on Save button.

     

    The Save function asks for a filename, and you write to a text file:

    Right,2000

    Forward,5000

     

    I used milliseconds in the text file so that you can have fractions of a second. You could simplify the format by just using a single character for each type of move. The interesting thing about this approach is that you can edit the text file in Notepad and easily copy/paste parts of sequences to repeat them, or just insert new commands.

     

    If you knew how long it took to turn 45 degrees or 90 degrees, you could write fancy "dance" routines in Notepad without using the GUI. However, the GUI gives you direct feedback on what is happening if the commands are executed immeditately after you enter them. Of course, that brings up the problem of what if the last command was NOT what you wanted? How do you erase commands in the GUI? Now we are talking about GUI design and not robotics.

     

    I hope this helps.

     

    Trevor

    Sunday, January 27, 2008 2:31 AM
  • Hey Trevor,

     

    That makes things a lot clearer. I understand your concept. But however, wht you say about "So, once you have recorded the sequence by clicking on the buttons, you simply replay the sequence and send the commands to the Boe-Bot." So, to send the commands to the robot, I have to send it via a USB to serial port cable?

     

    My purpose of using the bluetooth was to control the robot wirelessly. That is also one criteria of my project, that the boe-bot must be controlled wirelessly. The use selects the sequence of actions (like u said) --> records it down --> then sends these commands to the robot (wirelessly or wired??). This is what is puzzling me now.

     

    By the way, all the above programming will be done in Visual Studio 2005 with MSRS right? I would also need to burn a program into the BS2 to program the robot to move in the various directions, right? Is there a way to link between the GUI & the boe-bot. That means, what signal/command I send via the GUI, how will the BS2 recognize that signal & perform the particular action?

     

    Rgds,

    Priya

     

    Sunday, January 27, 2008 2:01 PM
  • Sorry, I did not notice that you had replied.

     

    If you already have Bluetooth built into your PC, such as a laptop, then you don't need a serial port to send commands to the robot. However, if you don't have Bluetooth then the usual approach is to buy a USB-to-Bluetooth device.

     

    When I refered to a USB-to-serial device, I just meant that you need some sort of serial port to download the new firmware to the robot. If you already have a COM port, then that will do and you don't need a USB-to-serial device.

     

    You do not need a cable attached to the Boe-Bot to send commands to it. Your pre-recorded commands can be sent wirelessly over Bluetooth.

     

    As far as the BS2 is concerned, there is software available from the Parallax site that you can download. It is a very simple procedure, but you cannot do it over Bluetooth -- you must plug your Boe-Bot directly into your PC for the download. This is where you DO need a serial port, although you can do it on any computer. So if you PC has Bluetooth but no serial port then use somebody else's PC that does have a serial port just to do the download. Once you have the monitor program loaded, you can disconnect the serial cable from the PC and just use Bluetooth with MSRS.

     

    Yes, all your programming will be in VS2005. There are already services for the Boe-Bot, and you can use it with the Simple Dashboard right now. You can also use Robotics Tutorial 4 - Drive by Wire which I think is what you have been looking at.

     

    It just occurred to me -- Do you have a Boe-Bot working with MSRS over Bluetooth already?

     

    Trevor

     

    Tuesday, February 05, 2008 1:15 AM
  • Hi Trevor,

     

    Yes, I already have a Boe-Bot working with MSRS using Bluetooth...I used to Dashboard example given in the MSRS .pdf file to test whether my boe-bot can run wirelessly. My laptop does have an in-built bluetooth and I will be running my robot wirelessly.

     

    I think all that you've mentioned about I've already done. Now, I am going to be programming my Visual C# (this is where my GUI is created), for the individual motion icons. I'm now stuck at how to let the user select a series of actions & then download them as one to the boe-bot. You have given me an idea on how to do this. Do you happen to have any examples or codes to do such programming? Cos I dont know how the programming would be like in order to save the selected actions into a test file and then re-call them back later to send to the boe-bot (like wht you've mentioned in one of your previous replys above - post the appropriate MSRS SetDrivePower messages).

     

    Secondly, I was wondering on how the signal via the GUI (that is, via Visual C# & MSRS), can be sent & translated to the boe-bot (in PBASIC language), for the boe-bot to go ahead & perform the necessary actions based on the signal that it has received from the GUI? Any help on this? Thanks a lot!

     

    Best Rgds,

    Priya

    Tuesday, February 05, 2008 12:13 PM
  • All you have to do is record every button click (on the GUI buttons) into a list or array. Just put a code into the list to indicate the type of operation. Then to replay it, you just use a for loop and send the commands again.

     

    You have a working Boe-Bot, so you don't have to worry about the PBASIC code. I should have asked you about your environment to begin with. Just ignore PBASIC. The work has already been done for you.

     

    It sounds like maybe you do not have any programming experience. If you don't, then it might be a difficult task for you unless you can get some help.

     

    Trevor

     

     

    Thursday, February 07, 2008 10:40 AM
  • Hi,

     

    Ok, thanks, will try that.

     

    Yeah, I dont have all that much of programming experience, especially none with Visual C#. That's why I turned to this forum for help.

     

    Thanks again, and will get back if I have any problems :-)

     

    Best Rgds,

    Priya

     

    Thursday, February 07, 2008 11:56 AM
  • Hi Trevor,

     

    I have gone through the Tutorial 4 in Robotics Studio, and I've more or less understood how the programs work. Do you have any website references or any other guide which gives an idea of how to program Visual C# to:

     

    1) Come up with a pop-up window to enter the time for movement, etc.

    2) On how to save the individual motion icons for later replay.

     

    Best Rgds,

    Priya

     

    Saturday, February 09, 2008 5:39 AM
  • These are basic programming questions so I think we should take this discussion off-line because it is not about MSRS.

     

    Please e--mail me at T.Taylor(at-sign)qut.edu.au

     

    Trevor

    Saturday, February 09, 2008 7:43 AM
  • Hi,

    I saw something similar to what you talking about at that WebSite.(download the "Player service").

    http://www.benaxelrod.com/MSRS/index.html

    It's some kind of a "player" service that recording the movements of a Pionner robot and than you can run the same sequence again- and as Trevor said, you can save the sequence in a txt file..

    Good Luck!

    Mendi

    Tuesday, February 12, 2008 12:38 AM
  •  

    HI

    I am using bluetooth to send and receive data. The senders end has a microcontroller attached to it which is ready to send digital data. Is there any GUI in in C# anyone has which will be really helpful to receive the data to the receivevers end?


    Thanks

     

    Thursday, February 21, 2008 12:37 AM
  • This is really a different topic so you should open a new thread.

     

    However, the short answer to your question is that there are no GUI applications in the MSRS samples that do what you want. Most of the samples use Bluetooth for communication, but the protocol that is used is specific to the robot. I assume that you have some sort of protocol defined for your application as well. For instance, you need to tell the microcontroller when to send and when to stop sending. Because these commands are specific to your application, you can't expect a general purpose GUI to handle them.

     

    Of course there might be somebody in the community who has done something similar.

     

    Trevor

     

     

    Saturday, February 23, 2008 5:32 AM