Recommended Posts

1 hour ago, ord said:

My instinct is to say no, as it could take  resources away from developing the current IDE - which is so good and has features that I'm looking forward to.

Agree 100%

Share this post


Link to post
Share on other sites

There are already block based like

https://bricklife.com/scratch-gui/

Share this post


Link to post
Share on other sites

Alright my mans, got my Bluetooth thingy today and Cat and Volvo work. Had to use MS Edge, no BT on Firefox?

Reinstalled Volvo software, and also the Cat works now with the controll!

some questions:

1. The Volvo pulls ever so slightly to the left! Anyway to re-center the steering? Did a calibration in the Lego App just before the conversion...

I tried steering speed on 900 and 1000, and steering hardness on 3 and 4...

2. What does the random white blinking mean on the control when you use it for some time?

3. How do i programm while the hub is connected? To change things "live"?

4. Where do i set how long it blinks blue after you turned the hub off?

 

Edited by Polarlicht

Share this post


Link to post
Share on other sites
21 hours ago, Polarlicht said:

Had to use MS Edge, no BT on Firefox?

No.

21 hours ago, Polarlicht said:

What does the random white blinking mean on the control when you use it for some time?

Low Battery?

 

21 hours ago, Polarlicht said:

How do i programm while the hub is connected? To change things "live"?

You have the programm in the editor window on code.pybricks.com, just edit and load and start with the ">" Botton

21 hours ago, Polarlicht said:

Where do i set how long it blinks blue after you turned the hub off?

If you turn the hub off it cannot blink anymore?

 

 

Share this post


Link to post
Share on other sites

Hey @Polarlicht, glad to hear you got it working!

For your questions, I recommend playing around with just a hub and a motor, instead of everything built in.

Then you can easily see what the lights do, what happens when you run motors, what happens when you turn it off, and so on.

You can try many of the short example programs in the documentation on the right hand side to get some ideas.

For specific questions about example projects like the volvo, please start a discussion here: https://github.com/pybricks/support/discussions

That way the community member who made that program can help you. And others with the same question will be able to find it later.

Share this post


Link to post
Share on other sites

Hi @Pybricks,

just had the experience that motors with rotation sensor don't reach the same rotational speed when using "run" compared with "dc".

"motor.run" results in app. 1000 (according to control.limits), "motor.dc" app. 1500.

Changing "1000" into higher values (2000) shows no effect, neither in "run" command nor in "control.limits."
How to improve?

 

from pybricks.pupdevices import Motor
from pybricks.parameters import Port
from pybricks.tools import wait

# Initialize two XL-motors on port A and B.
m1 = Motor(Port.A)
m2 = Motor(Port.B)

#start both motors
m1.run(1000)
m2.dc(100)

#wait and show results
wait(1000)
print(m1.speed(),m2.speed())

Results:

991 1555
960 1570
960 1570
991 1555
991 1555

 

 

 

Share this post


Link to post
Share on other sites

Hello all,

I have a question on using memory in EV3. I want to run a program in two modes. In the first one, I am going to do some calibration based on measurements from sensors and computation, and after that to store the computed values. This should be done only occasionally, especially in case when the working environment changes. In the main mode, the program should retrieve those stored values and use them for its repeated runs.

What is the best way to do it in Pybricks?

Share this post


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

Changing "1000" into higher values (2000) shows no effect, neither in "run" command nor in "control.limits."
 

That is strange.

In my experience, doing:

                        m1.control.limits(speed=2000)

before calling run() should work.

Try also changing the acceleration, if I remember the default is a bit slow

                        m1.control.limits(speed=2000, acceleration=2000)

Have fun!

Share this post


Link to post
Share on other sites

Thanks a lot;

I thougth this speed limit "1000" is a property of the motor, cause reading it when starting programm shows always the "1000"

I can't test cause it is not possble to install new FW, "the Hub took too long to respond". So it's dead. :pir-bawling:

Share this post


Link to post
Share on other sites

Yes, works as you described @vascolp my hub was disordered.....

But what is the "correct" value for m1.run(xx) ? How to resolve it for the different motor types?

 

 

Share this post


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

But what is the "correct" value for m1.run(xx) ? How to resolve it for the different motor types?

Good question! I think there is no generic solution for that.

I do it like this (using excelent Philo stuff!):

    # Mode _bla_STP_SPEED assumes maximum speeds for each type of motor.
    # There are lots of motors, each one with its own characteristics, which makes it a bit difficult
    # to have a general purpose  thing... 
    # I got no-load speeds in https://www.philohome.com/motors/motorcomp.htm, multiplied by 0.9
    # and got a list of maximum speeds per device. If the device does not match... it uses 1000deg/s (why not?).
    #
    # 1  Powered Up Medium Motor
    # 2  Powered Up Train Motor
    # 38 BOOST Interactive Motor
    # 46 Technic Control+ Large Motor
    # 47 Technic Control+ XL Motor
    # 48 SPIKE Prime Medium Motor
    # 49 SPIKE Prime Large Motor
    # 75 Technic Medium Angular Motor, gray
    # 76 Technic Large Angular motor, gray
        devs_max_speed = { 38:1377, 46:1700, 47:1780, 48:1230, 49:1150, 75:1230, 76:1150 }

I got the above list of id numbers somewhere from pybricks github stuff, but I can´t find it right now ...

You can get that id number from a port by doing:

PUPDevice(Port.A).info()['id']

So, to get a device maxium speed on Port A I do:

s=devs_max_speed.get(PUPDevice(Ports.A).info()['id'], 1000)

Hope it helps!

Share this post


Link to post
Share on other sites

Yes it helps. thanks

The table is already there, because the programm supports all kinds of motors and changes method (run or dc) accordingly when starting.

And the routine was already there, because I'm pretty sure that when first realesed the were values other than 1000, I think I rember 1400 for the Boost motor.

I  think it would be useful if Pybricks would offer the correct values when reading control.limits()

 

 

Share this post


Link to post
Share on other sites

I'm considering buying some more hardware to use with PyBricks in making more Mindstorms-esque stuff than I have to date, but I'd appreciate some clarification of its capabilities before I spend any money.

1. What options and limitations are there when using multiple hubs with PyBricks? I'd plan on using two Technic hubs, but I seem to recall hearing that PyBricks doesn't allow hub-to-hub communication. Is this true? What would the implications be for a model using two hubs?

2. Does PyBricks support all of the sensors available with the new style plug, whether Boost, Spike Prime, WeDo, or Mindstorms?

I'd appreciate whatever clarification I can get!

Edited by 2GodBDGlory

Share this post


Link to post
Share on other sites
19 minutes ago, 2GodBDGlory said:

1. What options and limitations are there when using multiple hubs with PyBricks? I'd plan on using two Technic hubs, but I seem to recall hearing that PyBricks doesn't allow hub-to-hub communication. Is this true? What would the implications be for a model using two hubs?

 

This  is planned.
Implication is that the hubs are independent, but you can use one port at one hub as sender and one port on the other as receiver, so you can transfer information, but reduces ports to six.
Or wait for the Pybricks hub-to-hub (perhabs its already available on beta)

19 minutes ago, 2GodBDGlory said:

2. Does PyBricks support all of the sensors available with the new style plug, whether Boost, Spike Prime, WeDo, or Mindstorms?

You find them all on "code.pybricks.com" on the right side, look at "powered Up devices" ; if they are suppoeted with every hub? Suppose not.

 

 

Edited by Lok24

Share this post


Link to post
Share on other sites
On 7/13/2022 at 12:18 PM, Jonas said:

Hello all,

I have a question on using memory in EV3. I want to run a program in two modes. In the first one, I am going to do some calibration based on measurements from sensors and computation, and after that to store the computed values. This should be done only occasionally, especially in case when the working environment changes. In the main mode, the program should retrieve those stored values and use them for its repeated runs.

What is the best way to do it in Pybricks?

You can save the calibration values to a file.

In the calibration program, add something like this:

import ujson

calibration = {}

calibration['value1'] = ...
calibration['value2'] = ...
calibration['value3'] = ...

with open('calibration', 'w') as f:
    ujson.dump(calibration, f)

In the main program, add something like this:

import ujson

with open('calibration', 'r') as f:
    calibration = ujson.load(f)

value1 = calibration['value1']
value2 = calibration['value2']
value3 = calibration['value3']

 

Edited by David Lechner

Share this post


Link to post
Share on other sites
On 7/13/2022 at 7:18 PM, Jonas said:

Hello all,

I have a question on using memory in EV3. I want to run a program in two modes. In the first one, I am going to do some calibration based on measurements from sensors and computation, and after that to store the computed values. This should be done only occasionally, especially in case when the working environment changes. In the main mode, the program should retrieve those stored values and use them for its repeated runs.

What is the best way to do it in Pybricks?

#Removing the wms file for whatever reason you might need to delete it
#os.remove("wms_hb_boxstatus.txt")

 

#Create new file on first start ever
create_file = open("wms_hb_boxstatus.txt", "a")
create_file.write("")
create_file.close()
 
#Reading from offline file, store them in online list
with open("wms_hb_boxstatus.txt") as retrieve_wms:
    wms_online_list = retrieve_wms.read().splitlines()
 
#Adding extra positions at first start ever or expanding racks
for x in range(total_storage_positions - len(wms_online_list)):
    wms_online_list.append("No box present")
 
#Deleting extra positions when downsizing the racks
for x in range(len(wms_online_list) - total_storage_positions):
    del wms_online_list[total_storage_positions:]
 
#Store values from online list to the offline file
def save_offline_wms():
    with open("wms_hb_boxstatus.txt", "w") as backup_wms:
        for current_state in wms_online_list:
            backup_wms.write(current_state + "\n")
def override_wms():
    override_list = ["Gear 12T LBG", "Tile 3L LBG", "Tile 4L Black", "Liftarm 3L Yellow", "Pin 2L Black", "Gear 20T Blue", "Axle 2L Red", "Liftarm 11L Yellow", "MOTUS HANDLING", \
        "Medium Actuator", "Small Chain Black", "Pin 3L Blue", "Gear Half 12T Tan", "Pin 3L Red", "Liftarm L 4x2 LBG", "Axle Hole Conn T1 LBG", "4Pin Conn LBG"]
    for x in range(len(wms_online_list)):
        if x < len(override_list):
            wms_online_list[x] = override_list[x]
        else:
            wms_online_list[x] = "No box present"
    os.remove("wms_hb_outsidestatus.txt")
#Use hashtag # infront of next line of code if you DO NOT want to override!
#override_wms()
 
save_offline_wms()

 

This is what I do in my warehouse to save the positions/names offline in a .txt file.

Share this post


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

This  is planned.
Implication is that the hubs are independent, but you can use one port at one hub as sender and one port on the other as receiver, so you can transfer information, but reduces ports to six.
Or wait for the Pybricks hub-to-hub (perhabs its already available on beta)

You find them all on "code.pybricks.com" on the right side, look at "powered Up devices" ; if they are suppoeted with every hub? Suppose not.

Thanks! It's be nice to know for sure about sensor compatibility with that specific hub, but I guess there's not a lot of people trying to use sensors with that hub.

Share this post


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

Thanks! It's be nice to know for sure about sensor compatibility with that specific hub, but I guess there's not a lot of people trying to use sensors with that hub.

I think that it should work, @David Lechner @Pybricks should be able to answer that question; what I know is that there are some restrictions concerning the Move Hub.

Share this post


Link to post
Share on other sites
Quote

2. Does PyBricks support all of the sensors available with the new style plug, whether Boost, Spike Prime, WeDo, or Mindstorms?

Yes. And to be sure, you can click on "compatibility" next to each sensor. You'll see a list of all the hubs with a checkmark if it's compatible.

For example, try it for the infrared sensor here.

Which hub and which sensor would you like to use? Maybe we have an example program already.

 

 

 

Quote

just had the experience that motors with rotation sensor don't reach the same rotational speed when using "run" compared with "dc".

We've recently made some corrections to this. The default values are defined here. For each motor, you can see the value for "settings->speed_max". Let me know if you think that some of these values are not right.

To try the new firmware with these fixes before we release it officially, you can follow these instructions.

Quote

But what is the "correct" value for m1.run(xx) ? How to resolve it for the different motor types?

Quote

Good question! I think there is no generic solution for that.

You can read the settings from the motor like this:

from pybricks.pupdevices import Motor
from pybricks.parameters import Port

my_motor = Motor(Port.A)

max_speed, acceleration, max_torque = my_motor.control.limits()

print("max speed:", max_speed)
print("acceleration:", acceleration)
print("max torque:", max_torque)

 

Share this post


Link to post
Share on other sites
13 hours ago, David Lechner said:

You can save the calibration values to a file.

.....

Thank you David for this useful hint.

Also thanks to Jos for his one.

Share this post


Link to post
Share on other sites
12 hours ago, Pybricks said:

You can read the settings from the motor like this:

Cool, thats an improvment!

I just tested for the two motors I have at hand: I get:

pybricks:

  • 47 - Technic Control+ XL Motor:1525 
  • 76 - Technic Large Angular motor: 970

The values I used were 90% of philohome no-load characteristics, which are:

  • 47 - Technic Control+ XL Motor: 1980 (330*6)
  • 76 - Technic Large Angular motor: 1278 (213*6)

What is the rationale of your values?

Note, I am not telling that my rationale is better (on the contrary as I have no way of mesuring speeds). Just trying to learn.

Thanks!

Share this post


Link to post
Share on other sites

We use the values stored in the motor itself. We believe LEGO choose these so that most users can actually reach that speed. Without Philo’s special 9V supply :)

But it is possible that the Powered Up app uses different defaults. To find out, just let the motor run at 50% speed and use a stopwatch to let it run for two minutes. Write down how much the motor moved in this time. Do it a few times for each motor type.

Then we can calculate the speed. We’re happy to update our defaults to make them the same.

Share this post


Link to post
Share on other sites

Ok thank you. That seems indid the correct approach. I will start to use those values.

Currently only on beta version, right?

Share this post


Link to post
Share on other sites
21 minutes ago, vascolp said:

Currently only on beta version, right? 

That's the problem, actual version code.pybricks.com (which is 3.1) always says

max speed: 1000
acceleration: 2500
max torque: 260

for all XL, L and Boost motors

And is was different a year ago, there I remember higher values.
 

 

 

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.