Replies: 4 comments
-
You can make any function with blocks or Python and mix them as you like. Just as with Python, it's best to do the setup in only one file. You can still make generic motor/drivebase functions by passing in the object. You can find the objects on the variables tab. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much @laurensvalk. I once saw the devices under the variables tab, but then completely forgot them. The robot starts orthogonal to a black line, then drives straight up to it. He crosses the line to have the axle on it and turns to the right to then start line following. |
Beta Was this translation helpful? Give feedback.
-
Hi @ggramlich . Nice! I had the opposite in mind but yes, yours works too. I'll add my example for reference. I was imagining a library that is usable independently. This could have reusable functions without any setup. Instead, the setup would happen in the application. For example, here is a library with a countdown display and polygon drive function: And the application would pass in its devices to use the library functions: |
Beta Was this translation helpful? Give feedback.
-
@laurensvalk That makes perfect sense to me. Thanks for adding the example. We will see, how we are going to use it. |
Beta Was this translation helpful? Give feedback.
-
I was hoping that we could define some functions with a drivebase, in one Blocks program (library.py) and then import it into another one (mission.py).
Syntactically this is possible, but as both programs need to have a setup for the drivebase, the code in library.py is executed on import and mission.py cannot define the motors on its own (error message that the port is already in use). It is possible to import motors and drivebase, from library.py, but then mission.py does not know their type and you cannot use them.
I do understand how to build library.py in Python. Do you see any way to support building a library in Blocks?
I thought, perhaps just something like this pattern is missing, but did not think this through:
Beta Was this translation helpful? Give feedback.
All reactions