Alberto Bietti

Hi,

I was running an MSRS service I made to control a Lego NXT robot with an xbox 360 wireless controller with wireless receiver, and I noticed that sometimes there are some problems with notifications: the robot keeps going in the direction he was going before, even though I made a 'fast' change on the controller's thumbstick. It looks like there's a problem with notifications, I think.

Since the controller service sends a notification only if its state has changed, I think the problem is not here, because the new state should be received. Maybe it's the bluetooth communication with the robot: maybe the nxt didn't get the message, or maybe the problem is my computer (Acer Extensa laptop, intel centrino 1.7GHz, almost 3 years old), or my bluetooth device (integrated in the laptop, and I think it's pretty bad quality, using bluesoleil)

Thanks in advance,

Alberto




Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Dave Lee

Hello Alberto.

You might try checking the TimeStamp on the notification. Since MSRS is an asynchronous message based system, it is possible to get messages out of order. This is more common from services that send notifications very fast -- I've seen this happen with my joystick.

In your service, keep track of the TimeStamp of the last notification. Each time you get a new notification, compare it to the prior notification and skip it if it is older. Otherwise, process the command and set the priorNotification from this new TimeStamp.






Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Alberto Bietti

Thank you for your answer.
Could you explain in more detail what you mean by checking the TimeStamp on the notification or link to somewhere explaining it (I never used this kind of things before... and I'll probably have to read more of your documentation...)

Does the TimeStamp hold the time at which the notification was sent





Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Alberto Bietti

Here is my new Handler for ThumbsticksChanged messages, even though I'm not sure I understood well what you said:


Code Block

private void ThumbsticksChangedHandler(gamepad.ThumbsticksChanged thumbsticksChanged)
{
if (thumbsticksChanged.Body.TimeStamp > _state.lastTimeStamp)
{
drive.SetDrivePowerRequest request = new drive.SetDrivePowerRequest();
request.LeftWheelPower = thumbsticksChanged.Body.LeftY;
request.RightWheelPower = thumbsticksChanged.Body.RightY;

_drivePort.SetDrivePower(request);

_state.lastTimeStamp = thumbsticksChanged.Body.TimeStamp;
}
}



But I still get the same problem: for instance, if I move rapidly a thumstick up, and release it immediately, the corresponding wheel sometimes keeps turning, even though the thumbstick is back at rest. And it still turns until I move the thumbstick again.
If my code is wrong, what code should I use Do I have to change the handler or something else





Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Dave Lee

This is exactly what I was suggesting. I've seen this work in a similar situations.

Here is another suggestion to track down your issue -- place LogInfo messages in your handlers. For instance, in the above handler, you could do this one:

Code Block

if (thumbsticksChanged.Body.TimeStamp > _state.lastTimeStamp)
{
drive.SetDrivePowerRequest request = new drive.SetDrivePowerRequest();
request.LeftWheelPower = thumbsticksChanged.Body.LeftY;
request.RightWheelPower = thumbsticksChanged.Body.RightY;


LogInfo(LogGroups.Console, string.Format("SetDrivePower({0}, {1})",

thumbsticksChanged.Body.LeftY, thumbsticksChanged.Body.RightY));


_drivePort.SetDrivePower(request);

_state.lastTimeStamp = thumbsticksChanged.Body.TimeStamp;
}

else

{

LogInfo(LogGroups.Console, "Skipping out of order notification.");

}

You can view the messages by using SysInternals DbgView, or by navigating to the service console output at http://localhost:50000/console/output (where 50000 is the port you are running your service from).

Perhaps you are sending a SetDrivePower message that is being ignored, or perhaps letting go of the stick abruptly is sending unusual readings.

Dave






Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Alberto Bietti

Thanks for your advice

It looks like the SetDrivePower message is being ignored: when (eg) the right wheel keeps turning, and the thumbstick is a pos 0, I can see on the console that the last two logs are SetDrivePower(0, 1) and after it, SetDrivePower(0, 0), so I guess it should be sending that to the robot, but there is a problem... Is it possible that it's just my bluetooth device that doesn't send just one message
And BTW, according to the console, it never got an out of order notification!

Suggestions





Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Alberto Bietti

I'm trying to do it with the new NXT services (added the nxtbrick proxy reference, and a using drive = Microsoft.Robotics.Services.Sample.Lego.Nxt.Drive.Proxy)
But when I run that, the page that opens up on the web browser says "Connected: false", although there's the MSRS image on the NXT, I hear the beep, and when I end the MSRS program, I get that yellow message on the console saying the msrs program was ended.

But I do see all the SetDrivePower logs on the console

Actually I got that same "connected: false" when I tried the new VPL samples for the new NXT services...

Thanks in advance





Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Dave Lee

Try checking the result of the Drive command:

yield return Arbiter.Choice(_drivePort.SetDrivePower(request);,

delegate(DefaultUpdateResponseType rsp)

{

LogInfo(LogGroups.Console, "LEGO NXT Drive Request Succeeded");

},

delegate(Fault fault)

{

LogError(LogGroups.Console, "LEGO NXT Drive Request Failed", fault);

});






Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Alberto Bietti

With the old services, I always get Succeeded, even when it sends a (0, 0) request.

With the new ones (I'm using SetDriveRequest request and _drivePort.DriveDistance(request) with LeftPower and RightPower assigned, only), I always get Failed (Not connected)





Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Dave Lee

This is significant. It indicates a configuration or communication error.

Can you paste the full error text

Take a look at the service directory [1] when this is running. You may have a startup issue in which multiple Drive services are being started, but only one is connected. Since this service implements an alternate contract, you should see two drive services (one for the generic drive, and one for the Lego specific drive -- both with the same guid at the end), but if you instead see four drive services, this would narrow down the problem.

Also, can you open your manifest using the DssMe.exe tool This is our manifest editor and it may find an issue with the way you are loading your service(s).

[1] http://localhost:50000/directory

Dave




Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Alberto Bietti

Here's the error from the console/output page:
NXT Drive Request Failed: System.InvalidOperationException: Not Connected: http://www.w3.org/2003/05/soap-envelope:Receiver -> Fault
Category Console
Level Error
Time 2007-10-23T19:06:49.0625+02:00
Subject NXT Drive Request Failed: System.InvalidOperationException: Not Connected: http://www.w3.org/2003/05/soap-envelope:Receiver -> Fault
Source http://acer-alberto:50000/lego360
CodeSite Void <ThumbsticksChangedHandler>b__3(W3C.Soap.Fault)() at line:104, fileC:\Microsoft Robotics Studio (1.5)\Lego360\Lego360.cs


An here are the drive services running, from the directory page:
/lego/nxt/drive/58bf3c3b-0374-44b9-a58e-eaf41f972874
/lego/nxt/drive/58bf3c3b-0374-44b9-a58e-eaf41f972874/generic
/legonxtdrive/5accf7aa-adaa-403d-86f9-5c90b65d88d6
/legonxtdrive/5accf7aa-adaa-403d-86f9-5c90b65d88d6/drive

And from the DSS Manifest Editor, I only have Lego NXT Drive (v2) and XInput Controller under my "Lego360" manifest





Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Alberto Bietti

oh, and the VPL samples worked when I changed the COM port on VPL, so I guess I would just have to tell my project the com port, as I did on VPL

ps: thank you very much for your help!





Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Alberto Bietti

Why is there a SetDrivePower message available in VPL, but not in C#, for the v2 NXT drive service The only message I can post is DriveDistance. I guess it just does the same thing...





Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Alberto Bietti

wow I just did a little VPL diagram with the new services, and now the nxt robot goes perfectly with the xbox 360 controller! With only 3 drag'n'drop and a connection!





Re: Microsoft Robotics - Hardware Configuration and Troubleshooting 360 controller with NXT communication problems

Dave Lee

Hi Alberto - yes, you needed to configure the serial port. I'm glad you sorted that out -- and using LEGO NXT with VPL is very easy and powerful.

To answer your other question about SetDrivePower, the main Nxt Drive service implements LEGO specific drive commands. However, it also implements the generic drive contract, which contains the SetDrivePower operation. To use this command, you need to partner with the generic drive port, and then post the SetDrivePower message to the generic port instead of the LEGO specific port. Does that make sense

Code Block

using drive = Microsoft.Robotics.Services.Sample.Lego.Nxt.Drive.Proxy;
using gendrive = Microsoft.Robotics.Services.Drive.Proxy;

Code Block

[Partner("NxtDrive",

Contract = drive.Contract.Identifier,

CreationPolicy = PartnerCreationPolicy.UsePartnerListEntry)]
drive.DriveOperations _nxtDrivePort = new drive.DriveOperations();

[Partner("NxtDrive_drive",

Contract = gendrive.Contract.Identifier,

CreationPolicy = PartnerCreationPolicy.UsePartnerListEntry)]
gendrive.DriveOperations _genericDrivePort = new gendrive.DriveOperations();

Dave