Recommended Posts

header.png?raw=True

Hey,

Recently I've been tinkering with the browser's experimental Bluetooth API and cooked something called "MOC Commander" (formerly known as 'webPoweredApp') as my hobby project.
It's an open-source progressive web app designed to control LEGO PoweredUP MOCs using physical input. It can be run straight from the browser or installed as a standalone application for an offline use.

 

I'm not sure how to embed a YouTube video here, so here's the link to my introductory video with a step-by-step demonstration of basic usage.

The app utilizes LEGO Wireless Protocol and relies solely on dynamic IO capabilities discovery. In theory, it *should* support any LWP-compliant device with capabilities that the app can handle and know of.
However, there is a downside in this approach: non-LWP devices are not supported (BuWizz, etc).

 

Supported platforms (essentially anything that can run Chrome-based browsers and has Bluetooth):

  • Windows PC
  • Linux (with a little tinkering the app can be installed on a Steam Deck, which doubles the fun)
    sd-tracks.gif?raw=True
  • macOS
  • Android

With the exception of iOS devices (iPhones, iPads), which currently lack support for the Web Bluetooth API.

 

Implemented operation modes:

  • Speed (separate inputs for 'forwards', 'backwards' and 'brake')
  • Set Angle (to designate an angle within a range of -180 degrees to +180 degrees)
  • Servo (with separate 'clockwise' and 'counter-clockwise' inputs, auto-calibration, up to a 1440-degree range)
  • Stepper
  • Train (allows iteration over arbitrary number of pre-assigned speeds)
  • Gearbox (switch between arbitrary numbers of motor positions within a range of -180 degrees to +180 degrees)

 

Supported controllers:

  • Up to four gamepads (tested with DualShock, Xbox 360 and Nintendo Joy-Cons)
  • LEGO 88010 Remote Control
  • Keyboard
  • Hubs and RC Handsets' green buttons

 

Additionally, the app has widgets that can display control scheme runtime information, such as:

  • Voltage
  • Separate widgets for the hub's pitch, yaw, and roll
  • Temperature (I'm not sure who needs this, but it's there)

 

Plus:

  • The app theoretically supports simultaneous connections to any number of hubs (the app does not impose any limits on this, and I have only a couple of hubs and a handset to test its limits)
  • Highly customizable gamepad configurations (including active zone settings and input trimming for non-centered sticks)
  • Axial direction awareness for most inputs (e.g., moving the left stick to the left rotates the servo clockwise, and moving the right stick up rotates it counter-clockwise)
  • Dark and light theme
  • Import and export of control schemes
  • Backup and restore of app internal state
  • Support for native acceleration/deceleration profiles for all motor operation modes

 

The current app version is v1.2.6. The app and the underlying LWP-interface library are in an active development stage and may (and absolutely do) contain bugs.

It's a fun project that I'm having a blast working on, and though it's a niche thing, I hope someone may find it useful.

Your feedback (e.g. bug reports, feature suggestions, compatibility issues, or usability feedback) is greatly appreciated.

 

And of course, LEGO® is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this application.

Edited by nvsukhanov
gif added

Share this post


Link to post
Share on other sites
47 minutes ago, nvsukhanov said:

 

Hey,
Recently I've been experimenting with the browser's Bluetooth API and cooked something called "webPoweredUp".
It's an open-source web app designed to control LEGO PoweredUP MOCs right from the browser using keyboard, gamepads, the LEGO 88010 RC, or that mysterious green button on the hub.

Currently the project is in its alpha stage and has been tested only with a very limited subset of LEGO PoweredUP-family devices.

The app utilizes LEGO Wireless Protocol and relies solely on dynamic IO capabilities discovery. In theory, it *should* support any LWP-compliant device with capabilities that the app can handle and know of.
However, there is a downside in this approach: non-LWP devices are not supported (BuWizz, etc).

Currently implemented operation modes: speed, servo, stepper, angle setting, speed shift (train control), and angle shift (useful for gearboxes).
Additionally, it has some nice features like acceleration/deceleration profiles (trains again), import/export control schemes, input gain configuration (linear/log/exp), gamepad active zone customization.

The Web Bluetooth API is an experimental feature, and it's currently supported only by Chromium-based browsers (Chrome, Edge, Opera, and so on). While I've primarily targeted desktop usage, the app also functions on Android tablets and phones. Unfortunately, iOS browsers are not supported due to the lack of Bluetooth support.

 

It's a fun project I'm working on, and though it's a niche thing, I hope someone may find it useful. Your feedback is greatly appreciated.

 

ooh kinda like pybricks i guess, thats cool! maybe all mindstorms hubs can also be supported ?

Share this post


Link to post
Share on other sites
6 hours ago, glowytheglowbug said:

ooh kinda like pybricks i guess,

I think no, it's completely different. With Pybricks you do programming, program resides in the hub
No External device needed while controlling

WebPoweredUp "only" translates commands while controlling the model. And you configure what actions (press button)  result in action (run motor A)
Device with browser needed while controlling.
 

@nvsukhanov

Great work, can start (chrome), can easily add Controllers (oops, writing this my PC Keybord popped up....)

Brilliant.

But how to "connect" a hub and the remote?

Is there an example I could Import? A short description?

 

 

 

 

 

Edited by Lok24

Share this post


Link to post
Share on other sites
30 minutes ago, Lok24 said:

I think no, it's completely different. With Pybricks you do programming, program resides in the hub
No External device needed while controlling

WebPoweredUp "only" translates commands while controlling the model. And you configure what actions (press button)  result in action (run motor A)
Device with browser needed while controlling

@Lok24 , you are absolutely correct!

Quote

But how to "connect" a hub and the remote?

Thanks for your feedback! Guess I should've composed a manual (and I will definitely do).

In a meantime, that one small button on the toolbar should initiate device discovery process (see attached pictures).

Just importing control scheme won't help because control scheme bindings are "bound" to hub by it's unique id. After importing you can replace "bounded" hub with the hub that you have discovered&connected, but that will require such hub.

Anyway, here's a sample control scheme import string, just in case:

0:3YCAgIJfgYCAgICAgIC9CArit6jM4OQ6Z8Ygr0y3Bq3N/aZxhB/CiFEE1mBrLiOP3j5fzMhDimX9p8D8GGlnMUoMf5V3N9Pu6V7Zxj0zPmPowOo9uGtfHhnoEmH3sUbr2zy05pAcDKgT0wV2Vk/+yPZS3KolkL3xPqJdNPXQtJj3cnNUNjVz7dHOQWZ0mrszG4aVkLctDVj7TzEZrb8egpideEWYIrVc5eJyFXOymY7JwoRX5K5OdeC/U5Mkf6xQ7hwjFvezBoIyQLZVOnFyRMlRRaEXut+X+SCtY8PtEDiRwVzEkwHN6yeebtd0Gyuq3fr8EbO1K7Vkf38k9uaA

 

 

 

connect.png

connect2.png

Edited by nvsukhanov
added second picture with hubs list

Share this post


Link to post
Share on other sites

@nvsukhanov

 

Thanks, helpful! No "manual" needes - at the moment -)

Here it is:

wpu1.jpg

And yes, it Works! Immediately.

Great.

How to run a motor permanently?

(is "milky way" the same time zone as Berlin?)

Share this post


Link to post
Share on other sites
10 minutes ago, Lok24 said:

@nvsukhanov

And yes, it Works! Immediately.

 

I'm really glad to hear it!

Quote

How to run a motor permanently?

Try "Speed shift" op mode. If you need a to bind a single input which turns motor "on" and "off", you'll have to set a Looping mode option to "Wrap" ("Mirror" will work too in that specific case).

Quote

(is "milky way" the same time zone as Berlin?)

No, it's GMT +4

Share this post


Link to post
Share on other sites

Ok, I'll try later today. But looks good!

It's a little bit like BrickController, but with out a special app

Share this post


Link to post
Share on other sites
6 hours ago, nvsukhanov said:

Try "Speed shift" op mode. If you need a to bind a single input which turns motor "on" and "off", you'll have to set a Looping mode option to "Wrap" ("Mirror" will work too in that specific case). 

 

Yes, indeed, works as designed.

Will now (which is weekend) take a look at "calibrating"

Nice tool!

BTW: where are the control schemes stored?

Share this post


Link to post
Share on other sites
1 hour ago, Lok24 said:

BTW: where are the control schemes stored?

Everything is stored locally, in your browsers localStorage. The app does not send any metrics or usage data to the mothership since there is no mothership to begin with)

Hoster may inject some scripts to collect web analytics, but the app has nothing to do with it.

Edited by nvsukhanov
add remark about hoster scripts

Share this post


Link to post
Share on other sites

Omg, this is so cool. I hope you find the time and energy to finish it properly. Now I only wish there was an easy way to have bluetooth on my desktop computer...

Share this post


Link to post
Share on other sites
12 minutes ago, howitzer said:

Omg, this is so cool. I hope you find the time and energy to finish it properly. Now I only wish there was an easy way to have bluetooth on my desktop computer...

But there is.... I got one of these because my laptop BT did not work properly with pybricks: TP-Link Bluetooth 5.0 USB Adapter, UB5A.

It works very well!

@nvsukhanov it looks very cool! Did not have time to test it yet but surely I will try it!

Share this post


Link to post
Share on other sites

Just tried it out, and it's cool! I'm not really sure what I might use it for (Ok, that comment goes for my PU in general!), but it's quite fun to be able to control my Lego from a keyboard! I couldn't get my Bluetooth controller to connect, but that could easily be a problem on my end, and my Lego controller paired nicely! Thanks for sharing!

Also, is there a way to use the mouse for control? I thought it could be a convenient way to get a sort of proportional control with the scroll wheel, but I couldn't figure a way out. Or is the assumption that if you bind the mouse to your Lego that you won't be able to control the computer anymore?

Share this post


Link to post
Share on other sites
8 hours ago, 2GodBDGlory said:

Also, is there a way to use the mouse for control? I thought it could be a convenient way to get a sort of proportional control with the scroll wheel, but I couldn't figure a way out. Or is the assumption that if you bind the mouse to your Lego that you won't be able to control the computer anymore? 

Hey, @2GodBDGlory, thank for your feedback!

Currently mouse scroll wheel input is not supported, but it definitely can be added in a way that won't block you from using mouse inside the app. I've added that feature request to the backlog.

Quote

I couldn't get my Bluetooth controller to connect

I assume that your controller present in the list of connected bluetooth devices on your PC, but pressing buttons or moving sticks of your controller didn't result in the controller appearing in the controllers list.

Could you please share the model name of your controller? I can PM you later when I have a chance to investigate it, if that's alright with you of course.

Share this post


Link to post
Share on other sites
9 hours ago, 2GodBDGlory said:

I couldn't get my Bluetooth controller to connect,

There are two steps:

- click the BT-button in WebPoweredUP
- window with all available BT-Devices  opens
- select one and pair

Does your controller appear in this list?
(mine does not .....)
Then it is an issue between OS, Browser and controller, and has nothing to do with the program.

 

 

 

 

 

Edited by Lok24

Share this post


Link to post
Share on other sites
14 hours ago, Lok24 said:

There are two steps:

- click the BT-button in WebPoweredUP
- window with all available BT-Devices  opens
- select one and pair

Does your controller appear in this list?
(mine does not .....)
Then it is an issue between OS, Browser and controller, and has nothing to do with the program.

No, mine doesn't appear there, but today when I tried it, it connected to my computer fine, and then the program recognized it, and allowed me to start controlling stuff with it!

 

14 hours ago, nvsukhanov said:

Hey, @2GodBDGlory, thank for your feedback!

Currently mouse scroll wheel input is not supported, but it definitely can be added in a way that won't block you from using mouse inside the app. I've added that feature request to the backlog.

I assume that your controller present in the list of connected bluetooth devices on your PC, but pressing buttons or moving sticks of your controller didn't result in the controller appearing in the controllers list.

Could you please share the model name of your controller? I can PM you later when I have a chance to investigate it, if that's alright with you of course.

Well, I got the controller paired now, but binding things to its controls doesn't seem to work very well. Whenever I try to set a bind, it pretty much just defaults to either the left or right on my D-pad, and it just immediately binds to that, and doesn't give me the opportunity to bind to any other control, or to any key on my keyboard. Then, even when I got drive bound to the left and right on my D-pad, it was running something like -63% speed with one button and -27% on the other one, and I don't see where I could have accidentally input something to make that happen.

The controller I'm using is a EVO VR MIC-VGP02-101.

Anyways, thanks for developing this project, even if I can't get it to work quite 100%

Share this post


Link to post
Share on other sites
On 9/16/2023 at 1:15 AM, 2GodBDGlory said:

Well, I got the controller paired now, but binding things to its controls doesn't seem to work very well. Whenever I try to set a bind, it pretty much just defaults to either the left or right on my D-pad, and it just immediately binds to that, and doesn't give me the opportunity to bind to any other control, or to any key on my keyboard. Then, even when I got drive bound to the left and right on my D-pad, it was running something like -63% speed with one button and -27% on the other one, and I don't see where I could have accidentally input something to make that happen.

The controller I'm using is a EVO VR MIC-VGP02-101.

@2GodBDGlory, many thanks for your feedback. I have attempted to address the issues you've encountered by introducing new gamepad configuration options. Off-center values can now be mitigated through the 'input trimming' option for button and axial inputs.

updated-controller-settings.thumb.png.0f1341cafba28cd964f5011eeede28b9.png

The latest update also includes several bug fixes, enhancements to accessibility (although there is still much work to be done in this area), reduced latency, an increase in connection stability, and minor UI tweaks.

Also I've changed the project name (links in the first post have been updated). The latest version of the app is available at both the old and new URLs.

Share this post


Link to post
Share on other sites
3 hours ago, nvsukhanov said:

@2GodBDGlory, many thanks for your feedback. I have attempted to address the issues you've encountered by introducing new gamepad configuration options. Off-center values can now be mitigated through the 'input trimming' option for button and axial inputs.

 

The latest update also includes several bug fixes, enhancements to accessibility (although there is still much work to be done in this area), reduced latency, an increase in connection stability, and minor UI tweaks.

Also I've changed the project name (links in the first post have been updated). The latest version of the app is available at both the old and new URLs.

Cool, thanks! I'll have to give it another go soon

Share this post


Link to post
Share on other sites

The app has moved out of its alpha stage and has gained some new features such as widgets, installing as a standalone PWA application and much more. Additionally, I've recorded an introductionary video (link in the starting post) because it was definitely needed.

The original post has been updated to reflect all these changes and improvements.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.