locked
DssHost and WinForms. Three questions. RRS feed

  • Question

  • Good Morning to ALL!

     

    I have two questions, maybe three?. Is that allowed? Old man here so be patient with me! Life is getting very short.. :>)

    Besides, I would probably forget to post the other questions once I leave here!

     

    1.) DssHost closes on error.. Not that I make many.. :>)

     

    I use to know a way with a DOS batch file to prevent the command prompt from closing before you can read what happened! BUT I was much yonger then. Wait for a key press on error?

     

    As in putting something into the  C# Express Debug Command Line Args after ...

     

    Sample:

    -p:50000 -t:50001 -m:"samples\\MyJoyStick\MyJoyStick.manifest.xml" -m:"samples\config\LEGO.NXT.MotorTouchSensor.manifest.xml"..  Something added...

    Can you run a batch file from there withought causing problems?

     

    2.) There are many samples using services from C# but all seem to use a 'bumper'.. I'd like to use the LEGO

    HiTechnic Compass sensor but have not been able to make it work. Syntax? or just me?. Anybody know of a good example to use from a WindowsForm? As for example.. I have a Form with a user control that I would like to receive the current compass reading and send this to my control (and others for different services). So far I'M NOT smart enought to do it!

     

    OK.. I'll stop at three.. I think this is a hard one?

    3.)

     

    This is from the SimpleDashboard example..

     

    System.Windows.Forms.Form CreateForm()

    {

    return new DriveControl(_eventsPort);

    }

     

    Yes, I know I'm not smart enought to be doing this but knowledge never stopped me before!

     

    Thank you in advance for any ideas..

     

    Have a GREAT DAY!

     

     

    Any way to return multiple ports?

    Thursday, March 6, 2008 4:39 PM

Answers

  • No response yet, so I will have a go.

     

    1. I think the command you are looking for is pause. However you can't insert this at the end of the command in Visual Studio in the Debug Properties. What you can do though is create a batch file that runs the command and then run it. So copy the command-line parameters from VS and put them following a dsshost command in a batch file. On the next line put a pause. Save this in your MSRS folder and then open a MSRS command prompt and run it.

     

    For example, create a file called myjoystick.cmd and enter the commands:

     

    Code Snippet

    dsshost -p:50000 -t:50001 -m:"samples\MyJoyStick\MyJoyStick.manifest.xml"

    -m:"samples\config\LEGO.NXT.MotorTouchSensor.manifest.xml"

    pause

     

     

    NOTE: The code above has wrapped. All of the dsshost command-line parameters are supposed to be on the first line.

    Also, I'm not sure why your example has a double backslash in the middle.

     

    Edit: I've just noticed that the manifest you have specified is for the old version of the LEGO NXT services. You need to use the V2 services to support the compass. Maybe the best idea is to use the Manifest Editor to create a new manifest and select the LEGO V2 and then add the compass as a partner.

     

    2. I have a HiTechnic compass and it works fine. If you start up the LEGO NXT V2 with an appropriate manifest then you can examine the compass reading using a web browser by going to http://localhost:50000 and selecting the Service Directory and then the HiTechnic Compass service. A sample manifest is a bit long to post here. Maybe I can e-mail it to you.

     

    In a program, you need to partner with the compass and then subscribe to it to get noticiations. It is a generic Analog Sensor. This probably does not mean much to you, but unfortunately I don't have a simple code snippet to give you.

     

    3. I'm not sure what question 3 is! The code snippet you gave creates a new form and passes it a port so that it can post back messages. The CreateForm method returns a handle to the new form. You can use this later in your main service code if you want to execute code inside the form by using FormInvoke.

     

    Trevor

     

     

     

    Saturday, March 8, 2008 8:25 AM
  • Here are some instructions for getting the compass to work using the Manifest Editor. I realise that there are a lot of steps, but it is actually quite easy when you get the hang of it.

     

    1. Open the Manifest Editor from the Start Menu in the Robotics Studio 1.5 folder

    2. Locate the Lego NXT Brick (v2) in the Services list. (Do NOT select the Lego NXT Brick I/O (v2))

    3. Drag the brick service to the Manifest panel.

    4. Click on the Create Initial State button in the Properties panel.

    5. Expand the Configuration and set the SerialPort to the correct COM port number for your Bluetooth connection and the BaudRate to 115200. Also check the box that says ShowInBrowser.

    6. Drag a Lego NXT Drive (v2) to the Manifest panel.

    7. In the Properties panel under Partners select LegoNXTBrickv2 from the drop-down list.

    8. Click on the Create Initial State button.

    9. For the LeftWheel, select MotorC from the drop-down list. For the RightWheel, select MotorB from the drop-down list.

    10. Locate the HiTechnic Compass Sensor in the Services list.

    11. Drag the compass sensor to the Manifest panel.

    12. In the Properties panel under Partners select LegoNXTBrickv2 from the drop-down list (same as you did before).

    13. Click on Create Initial State.

    14. Select the sensor port that the compass is plugged into e.g. Sensor3 in my case.

    15. Locate the Simple Dashboard in the Services list.

    16. Drag the Simple Dashboard to the Manifest panel. (It does not require any configuration)

    17. Save your manifest somewhere and remember where!

    18. Exit the manifest editor.

    19. Open a MSRS command prompt window (from Start menu \ Robotics Studio 1.5) and type:

    Code Snippet
    dsshost /p:50000 /t:50001 /m:"insert-your-manifest-path-and-filename-here"

     

     

    20. After the DSS node starts up, a browser window should open. You should see a web page for the NXT brick listing the motors and sensors.

    21. Click on the hyperlink beside the sensor for the compass.

    22. The compass service is displayed with a picture of a compass.

    23. Move your NXT around.

    24. Have fun!


    Trevor

     

    P.S. You can connect to the NXT using the Dashboard and drive it around while you watch the compass in the web browser.

    Saturday, March 8, 2008 9:27 AM

All replies

  • No response yet, so I will have a go.

     

    1. I think the command you are looking for is pause. However you can't insert this at the end of the command in Visual Studio in the Debug Properties. What you can do though is create a batch file that runs the command and then run it. So copy the command-line parameters from VS and put them following a dsshost command in a batch file. On the next line put a pause. Save this in your MSRS folder and then open a MSRS command prompt and run it.

     

    For example, create a file called myjoystick.cmd and enter the commands:

     

    Code Snippet

    dsshost -p:50000 -t:50001 -m:"samples\MyJoyStick\MyJoyStick.manifest.xml"

    -m:"samples\config\LEGO.NXT.MotorTouchSensor.manifest.xml"

    pause

     

     

    NOTE: The code above has wrapped. All of the dsshost command-line parameters are supposed to be on the first line.

    Also, I'm not sure why your example has a double backslash in the middle.

     

    Edit: I've just noticed that the manifest you have specified is for the old version of the LEGO NXT services. You need to use the V2 services to support the compass. Maybe the best idea is to use the Manifest Editor to create a new manifest and select the LEGO V2 and then add the compass as a partner.

     

    2. I have a HiTechnic compass and it works fine. If you start up the LEGO NXT V2 with an appropriate manifest then you can examine the compass reading using a web browser by going to http://localhost:50000 and selecting the Service Directory and then the HiTechnic Compass service. A sample manifest is a bit long to post here. Maybe I can e-mail it to you.

     

    In a program, you need to partner with the compass and then subscribe to it to get noticiations. It is a generic Analog Sensor. This probably does not mean much to you, but unfortunately I don't have a simple code snippet to give you.

     

    3. I'm not sure what question 3 is! The code snippet you gave creates a new form and passes it a port so that it can post back messages. The CreateForm method returns a handle to the new form. You can use this later in your main service code if you want to execute code inside the form by using FormInvoke.

     

    Trevor

     

     

     

    Saturday, March 8, 2008 8:25 AM
  • Here are some instructions for getting the compass to work using the Manifest Editor. I realise that there are a lot of steps, but it is actually quite easy when you get the hang of it.

     

    1. Open the Manifest Editor from the Start Menu in the Robotics Studio 1.5 folder

    2. Locate the Lego NXT Brick (v2) in the Services list. (Do NOT select the Lego NXT Brick I/O (v2))

    3. Drag the brick service to the Manifest panel.

    4. Click on the Create Initial State button in the Properties panel.

    5. Expand the Configuration and set the SerialPort to the correct COM port number for your Bluetooth connection and the BaudRate to 115200. Also check the box that says ShowInBrowser.

    6. Drag a Lego NXT Drive (v2) to the Manifest panel.

    7. In the Properties panel under Partners select LegoNXTBrickv2 from the drop-down list.

    8. Click on the Create Initial State button.

    9. For the LeftWheel, select MotorC from the drop-down list. For the RightWheel, select MotorB from the drop-down list.

    10. Locate the HiTechnic Compass Sensor in the Services list.

    11. Drag the compass sensor to the Manifest panel.

    12. In the Properties panel under Partners select LegoNXTBrickv2 from the drop-down list (same as you did before).

    13. Click on Create Initial State.

    14. Select the sensor port that the compass is plugged into e.g. Sensor3 in my case.

    15. Locate the Simple Dashboard in the Services list.

    16. Drag the Simple Dashboard to the Manifest panel. (It does not require any configuration)

    17. Save your manifest somewhere and remember where!

    18. Exit the manifest editor.

    19. Open a MSRS command prompt window (from Start menu \ Robotics Studio 1.5) and type:

    Code Snippet
    dsshost /p:50000 /t:50001 /m:"insert-your-manifest-path-and-filename-here"

     

     

    20. After the DSS node starts up, a browser window should open. You should see a web page for the NXT brick listing the motors and sensors.

    21. Click on the hyperlink beside the sensor for the compass.

    22. The compass service is displayed with a picture of a compass.

    23. Move your NXT around.

    24. Have fun!


    Trevor

     

    P.S. You can connect to the NXT using the Dashboard and drive it around while you watch the compass in the web browser.

    Saturday, March 8, 2008 9:27 AM
  •  

    Yes I made a reply to myself.. I can be a bit strange :>)

     

    Thank You ALL for your help! I will try each suggestion posted and see what happens.

     

    Actually.. I can do many (BUT NOT everything) using VPL. My real problem is trying to do the same thing from a Windows Form in C#..  If I compile my VPL to a Service I can reference the code generated. However.. The code generated is WAY OVER MY HEAD..  I'm not that skilled at the syntax used. But I try!

     

    Thanks for taking the time!

     

    Have a GREAT DAY!

    Saturday, March 8, 2008 6:26 PM