Lego Mindstorm NXT 2.0 remote control over bluetooth from a computer
-
24-06-2021 - |
Pergunta
Can you control a Lego Mindstorm NXT 2.0 robot over bluetooth from a computer? For example using the arrow keys on the keyboard to make the robot move wirelessly (over bluetooth or something else)?
Solução
Yes absolutely. I like to use Microsoft Robotics Studio and with a simple program you could easily use just about anything you can get input from to control the robot. Here is a snippet of a program that uses an XBox controller.
private void GamePadAxisUpdated(UpdateAxes update)
{
LogInfo("Right x: " + (update.Body.Rx*.001).ToString(CultureInfo.InvariantCulture));
LogInfo("Right y: " + (update.Body.Ry * .001).ToString(CultureInfo.InvariantCulture));
LogInfo("Right z: " + (update.Body.Rz * .001).ToString(CultureInfo.InvariantCulture));
LogInfo(" Left x: " + (update.Body.X * .001).ToString(CultureInfo.InvariantCulture));
LogInfo(" Left y: " + (update.Body.Y*.001).ToString(CultureInfo.InvariantCulture));
LogInfo(" Left z: " + (update.Body.Z * .001).ToString(CultureInfo.InvariantCulture));
var req = new SetDriveRequest {LeftPower = (update.Body.Rx*.0005), RightPower = (update.Body.Y*-.0005)};
drivePort.DriveDistance(req);
}
You can easily imagine that we are using a keyboard or mouse or whatever. That fact is it's simple though.
see the whole thing here https://github.com/r0k3t/NxtMSRDS_XboxController
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow