July 19, 20213 yr 1 hour ago, Lok24 said: Thanks @Mr Jos I see. The idea was to accelerate slow, but to "brake" faster. Perhaps I could add a stop and then immidiately the run commend again, we'll see, feeder_belt.control.limits(880, 150, 100) ##########~~~~~~~~~~MAXIMUM SPEED, MAXIMUM ACCELERATION, MAXIMUM POWER~~~~~~~~~~########## for x in range(10, 710, 10): feeder_belt.run(x) #It will accelerate starting with 10°/s speed, and adding 10°/s every loop until set speed -1 step (710-10 =700°/s) wait(100) #With the wait time you can make the acceleration slower or faster. This will give a slow acceleration in this example, total 69steps of 100ms = near 7seconds acceleration wait(10000) #It will run for 10 seconds feeder_belt.run(0) #It will decelerate at the maximim set deceleration (150°/sec here set) from 700 to 0 /150 = Near 5 seconds deceleration. Edited July 19, 20213 yr by Mr Jos
July 19, 20213 yr I tried to make it for your case you posted before; FB = Remote() MotorA = Motor(Port.A) MotorA.control.limits(acceleration=500) # < --- works while True: pressed = FB.buttons.pressed() if Button.LEFT_PLUS in pressed: for x in range(MotorA.speed(), 710, 10): #If braking a little, and powering up again, it will start ramping up at the current speed. MotorA.run(x) #It will accelerate starting with 10°/s speed, and adding 10°/s every loop until set speed -1 step (710-10 =700°/s) if Button.LEFT_MINUS in pressed ((((or Button.LEFT_PLUS not pressed))))): #I don't know exactly how to write the part in 5 brackets, as I don't know your system, I only know EV3. break #Stop the acceleration if you hit the braking button on the remote control or stop pushing acceleration button. wait(100) #With the wait time you can make the acceleration slower or faster. if Button.LEFT_MINUS in pressed: MotorA.run(0) It should accelerate slowly when you push the forward button, and stop accelerating when releasing it, but keeps going at current speed. when hitting the braking button it should decelerate quicker then the acceleration was and go to a full stop. Only thing I'm not sure about is the break out IF statement, it should check if your not braking and still pushing the acceleration button. Edited July 19, 20213 yr by Mr Jos
July 19, 20213 yr Author @Mr Jos is right indeed. Also note that the error ‘the device is busy’ when you tried to change the motor settings is an indicator of what the issue could be. The docs at https://docs.pybricks.com/en/latest/ are a bit newer and cover powered up as well, but most of the control stuff is indeed the same. All motor trajectories are computed in advance, when you give the command. So that’s why we currently don’t allow the settings to be changed while it is moving. For most settings this is good enough. You usually choose them at the start of your script. It sounds like @Lok24 might be interested in a separate deceleration setting, instead of using the same acceleration value both ways. This is something we could consider if there is a good use case and a lot of people want it.
July 20, 20213 yr Hi @Mr Jos, thanks for the solution, but that doesn't use the control limits, if I understand correctly. My solution is as expected: while True: pressed = FB.buttons.pressed() if Button.LEFT_PLUS in pressed: v = 1000 MotorA.stop() MotorA.control.limits(acceleration=100) if Button.LEFT_MINUS in pressed: v = 0 MotorA.stop() MotorA.control.limits(acceleration=1000) MotorA.run(v) Slow acceleration, quick deceleration. For a longer program you might better duplicate the .run and insert into the conditions directly after the .control.limits I want to avoid any "wait" commands, as they block the further execution, I use StopWatch() instead so program runs as fast as possible. Did someone find out how to save the code with a name other than "main.py"? Or how to import classes from local stored files like "c:\py\MyClasses.py" Edited July 20, 20213 yr by Lok24
July 20, 20213 yr 2 minutes ago, Lok24 said: Hi @Mr Jos, thanks for the solution, but that doesn't use the control limits, if I understand correctly. Did someone find out how to save the code with a name other than "main.py"? File -> Save As... Give it the name you want. Then in the Explorer tab go to .VSCODE, click on Launch.JSON "program": "/home/robot/${workspaceRootFolderName}/6dof_left_ps4.py", change name main with the name you have just given it. a space stays a space, my name had underscores in it. Click on save, it should now run the new named program. I don't have time at the moment to see deeper in what you need, going for a swim, will be back later on it.
July 20, 20213 yr Thanks , I use Chrome and the page https://code.pybricks.com/ , there is no menu but only the symbol for "download file" (floppy disk)? Do you use something different?
July 20, 20213 yr 3 hours ago, Lok24 said: Thanks , I use Chrome and the page https://code.pybricks.com/ , there is no menu but only the symbol for "download file" (floppy disk)? Do you use something different? Yes, I use the free software; Visual Studio Code. At the top there is "File" and you can save it under a new name. Edit: Extra info for sending motor commands and not waiting for it, you can send the motor to run (certain amount of degrees), and not having to wait for it to finish by just adding wait=False. I use this for my 6Degrees of Freedom to send constantly new target points for all 6 motors at the same time (2by bluetooth, 4 on the master with wait=false.) ##########~~~~~~~~~~SEND ACTUAL MOTOR SPEED AND DESIRED POSITION~~~~~~~~~~########## def move_all_motors(axis1, axis2, axis3, axis4, axis5, axis6, sp1, sp2, sp3, sp4, sp5, sp6): yaw_base_bt_sp.send( int(max_speed)) yaw_base_bt_num.send( int(axis1 * yaw_base_gear)) pitch_base.run_target(sp2, int(axis2 * pitch_base_gear * th2_switch), then=Stop.COAST, wait=False) pitch_arm.run_target( sp3, int(axis3 * pitch_arm_gear * th3_switch), then=Stop.COAST, wait=False) roll_arm.run_target( sp4, int(axis4 * roll_arm_gear), then=Stop.COAST, wait=False) yaw_arm.run_target( sp5, int((axis5 * yaw_arm_gear) + (axis4 / roll_arm_gear * yaw_arm_gear)), then=Stop.COAST, wait=False) roll_head_bt_sp.send( int(max_speed*1.5)) roll_head_bt_num.send(int((axis6 * roll_head_gear) - (axis4 * 1) + (axis5 * 4 / roll_head_gear))) And one more, if you would want to not having the wait block in acceleration stop anything else in the program, run it in a multithread. If you call this after the previous lines I made it will start that sub-routine and meanwhile continue with the rest of the program. Put a While True: loop inside it and it will run forever in that program, and you can do other things meanwhile. ##########~~~~~~~~~~CREATING MULTITHREADS~~~~~~~~~~########## sub_find_position = Thread(target=move_all_motors) #Create an instance for multiple threads sub_find_position.start() #Start looping the thread for finding realtime XYZ position in the background (NOT USED) Edited July 20, 20213 yr by Mr Jos I did edit some things, they don't actually work together. But the principle works.
July 21, 20213 yr Author @Mr Jos: @Lok24 is using Powered Up Hubs using our online editor. All of the newer hubs use this. These hubs are much less powerful than EV3, so they can support only one script at the time. There is no Visual Studio Code support at this time. Quote Did someone find out how to save the code with a name other than "main.py"? You can change this setting in your browser, so it will ask where to save the file and choose a name. Instead of putting everything in Downloads. Also quite useful in general. Quote Or how to import classes from local stored files like "c:\py\MyClasses.py" Powered Up hubs have limited storage and processing power, so you can have only one main script, without additional modules.
July 21, 20213 yr 2 hours ago, Pybricks said: @Mr Jos: @Lok24 is using Powered Up Hubs using our online editor. All of the newer hubs use this. These hubs are much less powerful than EV3, so they can support only one script at the time. There is no Visual Studio Code support at this time. You can change this setting in your browser, so it will ask where to save the file and choose a name. Instead of putting everything in Downloads. Also quite useful in general. Powered Up hubs have limited storage and processing power, so you can have only one main script, without additional modules. Ah alright, thanks for the info didn't know it could not be programmed with VSC. 1 more reason for me to not buy anything else then EV3's (maybe RI if I ever see the need for it as it can be programmed with VSC aswell.) On a side note; The project I'm making now, Technic pin sorter is running sometimes into a bug. The motors are switched off/on very fast if 2 pins are to close to eachother to create a gap, the acceleration is set very high for good length/color detection, only the feeding belt ramps up slowly again. 1 in 100 times you can hear the quick belt not accelerating all the way to 700°/s and hesitating, and also a 1/500 chance a feeder belt does not get turned off when the color belt does(they always get both the command at the same time). When stopping the program with the brick button, also a small chance that the feeder belt keeps running slowly even though no program is running anymore at all. Only way to stop it is start running new program. (or unplug the wire)
July 21, 20213 yr Thanks for your response, 6 hours ago, Pybricks said: You can change this setting in your browser, so it will ask where to save the file and choose a name. Instead of putting everything in Downloads. Also quite useful in general. Yes, but this is general for all downloads, which is not desired at all. I'll see if it is possible to set up different profiles (like in FF) to solve this. And when I open a file "x:\myprog.py" the download (=save) always proposes "main.py" and not "myprog.py", thats what I meant, sorry for any missunderstanding. 6 hours ago, Pybricks said: Powered Up hubs have limited storage and processing power, so you can have only one main script, without additional modules. Isnt't there something while downloading the source code to the hub to insert source code from a file? How could I use the same routines in different progs without copying them manually? That was my idea/intention.
July 21, 20213 yr Author Quote Ah alright, thanks for the info didn't know it could not be programmed with VSC. 1 more reason for me to not buy anything else then EV3's It's not impossible in a technical sense; we just haven't made a Visual Studio Code extension (yet). The same applies for multi-file projects like @Lok24 suggests. It's all a matter of priorities and focusing on the most-requested features. It's open source and we welcome volunteers to help us make all that happen. Sponsoring is possible too and greatly appreciated.
July 22, 20213 yr @Pybricks I started with Pybricks more than a year ago and published some articles and examples. But It never satisfied my needs without the connection to a remote control, thats why I switched to ESP32. Now, as the remote is available, I restarted, thats why the questions pop up right now, and the intention is not to critise what's missing, but to learn about the possibilites. 13 hours ago, Pybricks said: It's all a matter of priorities and focusing on the most-requested features. My most requested feature is the completion of the class remote, like address (using and reading) or Button Up/released, reconnect and so on. (and, as already discussed, a very simple time line somewhere: "what's new")
July 23, 20213 yr Author Sounds good! We recently switched to a new code editor within our app, which should make code autocompletion possible in the future. Reading which buttons on the remote are released is already possible, and reconnecting too. Let us know if we should add a particular example. Quote a very simple time line somewhere: "what's new" We're keeping a changelog ever since the stable 3.0 release. To suggest new features, it is strongly encouraged to post something here so we don't forget about it.
July 23, 20213 yr 52 minutes ago, Pybricks said: Reading which buttons on the remote are released is already possible, and reconnecting too. Let us know if we should add a particular example. We're keeping a changelog ever since the stable 3.0 release. To suggest new features, it is strongly encouraged to post something here so we don't forget about it. Thanks. The remote is not documented in code.pybricks.com, but in beta, and there I only found a method called "pressed". And the class "buttons" without further description, this is why I thought it's not quite finished yet, sorry.
July 26, 20213 yr 19 hours ago, Pybricks said: To check that a button is released, just check that it is not pressed . Yes, that's what I do now ;-) LEFT_DOWN,RIGHT_DOWN, LEFT_UP , RIGHT_UP, DOWN, UP, BEACON aren't used? On 7/23/2021 at 2:59 PM, Pybricks said: ..... is already possible, and reconnecting too. Let us know if we should add a particular example. Yes, I have some code here that does a reconnect, but with any remote I assume, because "address" cannot yet be checked, true? Edited July 26, 20213 yr by Lok24
July 26, 20213 yr Author That's right. Use LEFT_MINUS or LEFT_PLUS, and so on for the Powered Up Remote. We chose these names because they still work if you rotate the buttons. The other buttons you mention are used for other devices, like the EV3 (up, down, etc.) and the EV3 IR Remote. And you're also right about connecting to any remote. Feel free to open an issue for specifying the name/address. We tend to prioritize the most popular features. That is why the Powered Up remote was added. A ton of people gave that one a thumbs up :)
July 27, 20213 yr 15 hours ago, Pybricks said: And you're also right about connecting to any remote. Feel free to open an issue for specifying the name/address. Hi, thanks, I may do that. Thought it would be possible here as well, as you wroteYou're also welcome to post ideas and requests for new Pybricks features. Feel free to get creative here! From beginnig of the discussion in Dec 20 here https://github.com/pybricks/support/issues/186 specifying the address was mentioned and it was agreed on the first day that this is urgently needed. The background is that on exhibitions you have a dozen of remotes belonging to different users and models that might connect. 15 hours ago, Pybricks said: We tend to prioritize the most popular features. That is why the Powered Up remote was added. A ton of people gave that one a thumbs up :) So did I, it is a very great step foward and I'm really happy with that. But yet it's not completed, and as it's on your list "in work" https://github.com/orgs/pybricks/projects/10#card-63705066 it seemed to me that it is - in a way - priorized. Same is with light, I have no chance to show the different modes the remote is in for complex models (i.E.using a 4-Port Hub with one remote) without using the LEDs in the remote. Or to show battery level of hub, or so on.... So: no new needs! What about a "disconnect"? Edited July 27, 20213 yr by Lok24
July 30, 20213 yr Is it possible to communicate between two hubs (PU-devices) with pybricks (server-client)? I saw it is possible with two EV3 bricks, but it is unclear to me if this is also possible with two hubs.
August 2, 20213 yr Author 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.
August 14, 20213 yr Hi, just programmed a solution without the use of control.limits, but it designed for trains, find the article here and the program and description here: https://github.com/falk12/MotorControl the construction of the program is unusual, feel free to ask or discuss (then in a seperate thread?) Thanks to the Pybricks crew, it's really great! Edited August 14, 20213 yr by Lok24
August 20, 20213 yr Lok24, this is really great, thanks so much for all the effort, and the PyBricks team too. I have been using another version alos one I tried myself, but this makes it very universal for all different types of configurations. I have it running on the Lego Croc loco with a large PU motor. One question I have is how do you know which profile you are running, other than the speed.. also is it a quick press or long press of the middle button to change profiles? It would be really good if the led on the remote or hub changed color or maybe blinked once to indicate it was changing profile…. But that is only minor. I also run the BAP layout program, which I think I saw you had made some contributions… I love using it also. Cheers, John
August 20, 20213 yr Hi John, you really did a test with my program? Thanks a lot, you're the first! 17 minutes ago, TekyTek said: One question I have is how do you know which profile you are running, other than the speed.. also is it a quick press or long press of the middle button to change profiles? It would be really good if the led on the remote or hub changed color or maybe blinked once to indicate it was changing profile…. But that is only minor. You have two speed profiles and can change with the center button, no matter how long you press. If you run the program from the browser you can see in the lower section what happens (there appear all speed steps, when pressing green button a "1" or "2" for the selected profile) And yes, it's all beta, and the Pybricks team is working on supporting the LED in the remote (like the one in the hub), this not released yet in Pybricks beta. If so you could then i.e. show different colors for the profiles. And blinking when hub(!) battery level is low. And so on. Edited August 20, 20213 yr by Lok24
August 20, 20213 yr Yes! I really did try it 😀 You should put it on the PyBricks site as it is really good!! I understand about the LED situation on the Remote, I think I saw that it was coming in a future release on the PyBricks site. I’m now going to try it with some of my other trains which I am converting to PU. Thanks again and keep up the good work, you clearly love coding, I wish I could, but I have tried for many years, but don’t have the acumen. Mechanics and building are my “thing”, even though my work job is SQL application support for a large international company. 😳 Cheers, John.
August 20, 20213 yr 12 minutes ago, TekyTek said: I understand about the LED situation on the Remote, I think I saw that it was coming in a future release on the PyBricks site. That's it, stable is 3.0, in 3.1 "light" will be available!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.