Recommended Posts

On 8/2/2021 at 11:29 AM, Pybricks said:

Not yet, but it will be possible to communicate between all hubs in the future.

We had to make a lot of progress on Bluetooth for the Powered Up Remote, and most of that will be useful when we add hub-to-hub communication later. However, this will have to wait until version V3.3.

First we are planning to release V3.1 and V3.2.

 

Thanks for the update on v3.1 and v3.2.  The changes planned for those releases sound very interesting.  I am also very interested in hub to hub communication.  This is my initial use case:

 

I want to be able to make a physical remote out of PoweredUp components.  I can then make a remote that is appropriate for the model being controlled.  My prototype uses the PoweredUp app but that has the huge downside of requiring a smart phone in addition to the controller.  I'm imagining with Pybricks, we will be able to eliminate that and make it simpler to use, possibly with better latency characteristics as well.

Do you have an idea of what the API will be for hub to hub communications?  I'm wondering if this use case will fit well with your proposed API.  The next thing beyond this is more complicated models.  Imagine making a physical controller for the Liebherr that has 7 channels and 2 hubs.  The controller would need 2 hubs as well.  Would that generalized use case also work with your planned API?

Share this post


Link to post
Share on other sites
18 hours ago, Glaysche said:

Do you have an idea of what the API will be for hub to hub communications?

At the most basic level, you'll be able to send data using something like hub1_connection.write(data) on one hub, and do data = hub2_connection.read() on the other end to read it. In this case, hub1_connection and hub2_connection are connection objects you could make at the start of your program. We're still working on making this as easy and efficient as possible.

The data is a sequence of bytes, such as bytes([1, 2, 3]) or b"Hello, world!". There will also be libraries to convert other data (like sensor values) to bytes and back again. We might add high-level APIs later like we did for the EV3, but we'd like to start with the basics first.

This could certainly be used for a physical remote built from Powered Up components.

Thanks for your question. Looking forward to see what you'll make :)

Share this post


Link to post
Share on other sites

Short question: Is it possible to connect multiple remotes to one hub and/or one remote to multiple hubs? :)

Share this post


Link to post
Share on other sites
4 hours ago, Gimmick said:

Short question: Is it possible to connect multiple remotes

I suppose: yes

4 hours ago, Gimmick said:

 and/or one remote to multiple hubs? :)

I'm pretty sure: no

Share this post


Link to post
Share on other sites

@Lok24

 

I have just found your decoupler train mod using PF. Another great idea!

https://www.eurobricks.com/forum/index.php?/forums/topic/114550-remote-decoupling-engine/

I like it a lot and I am thinking of building it using a PU wedo motor for the decoupler and a PU train motor in the front of the loco.

Question:

If I use your PyBricks program to control the 2 motors will it work?

 I know it will discover both motors, but will it be able to run the decoupler from the “B” buttons and not think both motors are used to drive the train?

Maybe you can advise which part of the code I need to change please?

 Cheers John.

 

Share this post


Link to post
Share on other sites
On 8/23/2021 at 10:30 AM, Pybricks said:

At the most basic level, you'll be able to send data using something like hub1_connection.write(data) on one hub, and do data = hub2_connection.read() on the other end to read it. In this case, hub1_connection and hub2_connection are connection objects you could make at the start of your program. We're still working on making this as easy and efficient as possible.

The data is a sequence of bytes, such as bytes([1, 2, 3]) or b"Hello, world!". There will also be libraries to convert other data (like sensor values) to bytes and back again. We might add high-level APIs later like we did for the EV3, but we'd like to start with the basics first.

This could certainly be used for a physical remote built from Powered Up components.

Thanks for your question. Looking forward to see what you'll make :)

Doing a low level API first makes a whole lot of sense.  Do you think the semantics will be closer to TCP (reliable stream of bytes) or perhaps reliable datagrams?  The difference being whether you maintain framing.

I’m not familiar with the higher level API for EV3.  What I was imagining for a high level API would be something like RemoteMotor or RemoteSensor.  It would have the same API as a local motor or sensor but with the communication layer in the middle.  I guess this would look the most like the PoweredUp app programming model.

Anyway, thanks again for all the great work.

Share this post


Link to post
Share on other sites

I have 42099 and I use PU remote control with Pybricks program: https://pybricks.com/projects/sets/technic/42099-off-roader/powered-up-remote/#program. I am very happy I can control it with phisicall remote control. :)

I want to add lights (Powered Up LED Light) to port D of the Technic hub. Can I control the lights by adding code to the program - for example to turn them on/off with one of the red buttons on the remote control? I don't understand programming. Would you help me.

Many thanks! :)

Edited by vladoniki

Share this post


Link to post
Share on other sites

@vladoniki

Yes, a light example can be found here

https://docs.pybricks.com/en/stable/pupdevices/light.html

If you compair your current program with the light example, you can see in the first line, that you have add "Light" to the import.

And then, add the light with port D, like in the example, below or above the motors in your current program.

And, again just like in your current program, add another check for a button:

if Button.RIGHT_PLUS in pressed:
        drive_speed += 1000
if Button.RIGHT_MINUS in pressed:
        drive_speed -= 1000
if Button.LEFT in pressed:
        light.on(100)
if Button.RIGHT in pressed:
        light.off()

Now the light turns on, when you press the left button and goes off if you press the right button.

I hope this helps, since I don't have any light :<

Share this post


Link to post
Share on other sites

Many, many thanks, Gimmick! Program works perfect and now I have remote controlled lights on my 42099. :)

Edited by vladoniki

Share this post


Link to post
Share on other sites

It is possible to set it with the pybricksdev command line tool, but not with Pybricks Code currently.

Edited by David Lechner

Share this post


Link to post
Share on other sites

Question after reading the pybricksdev source code: Will this add support for the LEGO BLE wireless protocol used in Powered Up devices to the SPIKE Prime and Mindstorms hubs?

Share this post


Link to post
Share on other sites

Hi there,

Is pybricks currently usable with the robot inventor hub? Whether I try with Bluetooth or USB, I just get a 'No compatible devices found' message come up.

I've been using the micropython software that LEGO provides for robot inventor, but it doesn't seem to let me control multiple motors simultaneously. Or at least I don't know how to do it. I saw some from another thread that pybricks lets you do that quite easily (I'm kind of an expert builder but novice programmer).

Any help would be greatly appreciated - I've made a couple of SCARA robots that would be right up the pybricks street!

Cheers,

Ibrahim

Edited by ibzyfitzy

Share this post


Link to post
Share on other sites
17 hours ago, ibzyfitzy said:

Is pybricks currently usable with the robot inventor hub? Whether I try with Bluetooth or USB, I just get a 'No compatible devices found' message come up.

 

As I understand (and know for the PU-Devices) you have to download the pybricks-FW, which is still in beta, to use RI

 

17 hours ago, ibzyfitzy said:

I've been using the micropython software that LEGO provides for robot inventor, but it doesn't seem to let me control multiple motors simultaneously.

Aren't there options in motor control command whether command has to be finished or programm continues immidiately?

Share this post


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

As I understand (and know for the PU-Devices) you have to download the pybricks-FW, which is still in beta, to use RI

I've tried going on pybricks.beta but it still doesn't find it.

31 minutes ago, Lok24 said:

Aren't there options in motor control command whether command has to be finished or programm continues immidiately?

That's what I was hoping for but I don't find it anywhere in the help section of the official lego micropython version. I have a feeling there's a way if you understand how to program at a deeper level, so I'm now looking for examples of python-based RI projects that I can hopefully learn from.

Thanks for your help :)

SCARA white.gif

Share this post


Link to post
Share on other sites

Hi

is wait=False not possible with run_until_stalled to move 2 motor in parallel?

Code:

      motorC.run_until_stalled(speed=800, duty_limit=30, wait=False)
      motorA.run_until_stalled(speed=-800, duty_limit=30)

Console:

     TypeError: extra keyword arguments given

Share this post


Link to post
Share on other sites

Quick question: What is the difference between the class PrimeHub and the class InventorHub?

Thanks and best
Thorsten

Share this post


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

quick question: What is the difference between the class PrimeHub and the class InventorHub?

 

Don't know, but there are different classes for technic hub and Hub No 4 as well, If you don't acess the hub you don't need them

Share this post


Link to post
Share on other sites

Hello again.

I'm currently working on a GBC module controlled by Pybricks.  I wanna start running motorC and motorA at the same, to save time,  time but they will stop at different time.

Original code:  (which is working)

motorC.run_until_stalled(speed=900, duty_limit=35)

motorA.run_until_stalled(speed=-1000, duty_limit=30)

motorB.run_angle(900, -3600)

Workaround code

motorC.control.limits(duty=35)
motorC.run_time(300,2000, then=Stop.COAST, wait=False)
motorA.run_until_stalled(speed=-1000, duty_limit=30)
while not motorC.control.stalled():
      wait(1)
motorC.brake()
motorB.run_angle(900, -3600)

can someone tell me why motorB is not starting?

thanks in advance

Daniel

Share this post


Link to post
Share on other sites

@dunes maybe this is stuck in a loop (motorC is never considered 'stalled'):

while not motorC.control.stalled():
      wait(1)

Have you tried done() instead?

while not motorC.control.done():
      wait(1)

As for wait=False being possible with run_until_stalled... I don't think it is. This is the workaround I use on my plotter project:

motor_y1.run(50)
motor_y2.run(50)
wait(50)
while motor_y1.speed() > 10 or motor_y2.speed() > 10:
	motor_y1.dc(30)
	motor_y2.dc(30)

 

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.