XInputController and 3 motors

I am trying to control the motors on a lego NXT brick using an Xbox controller. I would like to control MotorA and MotorB on the left thumbstick and MotorC on the right thumbstick.

I have worked through the Tutorials and looked at Brian Peeks' coding for fun article.

The problem is that they use the differential drive service tha controls only two motors.

I tried the straight foward method of dragging three NXTmotors and the XInputController onto the workspace and connected them. This does not return any errors until I try to run it. Then VPL tries to make three seperate connections through blue tooth to the NXT motors. The second two fail.

This leads me to believe that I need to connect the controller to LegoNXTBrick and then from the brick to the motors, but i have not been able to figure out how to pass the data from the brick to the individual motors.

Can Anyone help

Thanks

Dom Larkin

[1006 byte] By [doml25] at [2008-2-23]
# 1

Hi,

you are right you have to connect the motors to the brick service. However, you need not to worry about how to get the data back and forth between the motor services and the brick service.

Double click on one of the motor services. Select "Set initial configuration" and drag a next brick onto the brick partner. Do the same thing for the other two motor, when prompted select the existing brick service (i.e. don't create a new one). Now all your motors talk to the same brick.

You still need to configure the brick (serial port etc).

Hope this helps,

Andreas

AndreasUlbrich at 2007-10-2 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Visual Programming Language...
# 2

Thank you that solved part of the problem. The services for all three motors now load, I had already tried something similar but was unable to drag and drop because I did not drop it in the right place on the window.

When I run the new program I received no errors but the NXT motors do not respond to the XinputController.

I am able to control MotorA with the XinputController by creating a data connection directly to the controller without the brick partner.

I am unable to control any other motor this way and if I partner with the brick I loose control of MotorA.

Now I believe I need to partner the XInputController with the motor or the Brick so they know to watch for messages from the controller, but I can not find a way.

I am also allowing the program to use the default configuration file for the NXT. Is this wrong? It worked for the other programs.

Thanks

Dom Larkin

doml25 at 2007-10-2 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Visual Programming Language...
# 3

You need to specify the motor in the configuration of the brick service. The default configuration will not work. Also, one each motor service you have to configure which motor (A, B, or C) it is.

Andreas

AndreasUlbrich at 2007-10-2 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Visual Programming Language...
# 4

Now I am even more lost.

My understanding of how services work is: that the XinputController service must be partnered to the Brick service and the brick partnered to each of the motors.

I am able to control each motor using the web-based control (http://localhost:50000/leognxt/4476a53d-0699-4c12-bd21-73a1f603a6b3) with no problem, which suggests to me that each motor partnered successfully to the brick and the brick is configured properly.

I do not see anywhere to partner the controller to the brick or motors, is this done implicitly somehow? How does the brick know that is to listen for messages from the controller service?

I tried different methods of configuring the brick; all seem to have the same result with me able to control each motor from the web browser but not the Xbox controller. (ie I have tried to set initial configuration, I have used config.xml files from the motortest sample program and few other variations).

You did mention addressing the motors as A, B, C. I have been using Hardware identifier 0,1,2 or 1, 2, 3 for the three motors although I call the services MotorA, MotorB, and MotorC. I could not find anyplace in the configuration that would call them A, B, or C. Am I confused about this?

Thanks

doml25

doml25 at 2007-10-2 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Visual Programming Language...
# 5

Each of your LEGO NXT Motor services must partner with the same LEGO NXT Brick service. The reason the web page works is that it talks only to the brick service directly.

In order to use three motor services, you need to configure the HardwareIdentifier to 1,2, & 3 respectively for each of the NxtGenericMotor services.

The XInputController doesn't know about the LEGO Brick or the motor service, so you don't need to create a formal partner for the XInputController service.

Instead, you need to capture the ThumbstickChange notifications from the XInputController to a Calculate activity and transform one of the LeftX, LeftY, RightX, RightY axis from the thumbsticks into a number between -1.0 and +1.0 and connect the calculate activity to one of your NxtGenericMotor blocks.

Do this step two more times, with two more calculate activies. Choose a different axis, and connect them to the remaining two NxtGenericMotor blocks.

This should get you going.

David

DaveLee at 2007-10-2 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Visual Programming Language...
# 6

Thanks I finally figured it out.

The problem was clarified when I read KamikazeHamster's post in the Channel 9 Sandbox.

http://channel9.msdn.com/ShowPost.aspx?PostID=330511

He sugested just hooking up the game control to the simple dashboard. Once I did this I was able to see the values that the gamecontroller generated.

I then used Dave Lee's sugestion of the calculate activity to convert the values into an acceptable range and I was able to control the motors.

Doml25

doml25 at 2007-10-2 > top of Msdn Tech,Microsoft Robotics Studio,Microsoft Robotics - Visual Programming Language...

Microsoft Robotics Studio

Site Classified