Shop OBEX P1 Docs P2 Docs Learn Events
Open Propeller Project #5: BlocklyProp - Page 4 — Parallax Forums

Open Propeller Project #5: BlocklyProp

1246789

Comments

  • Michel LMichel L Posts: 141
    edited 2014-05-06 14:24
    Today, I've been working on the previous stated problem using a couple references:
    All about differential steering and Odometry

    http://rossum.sourceforge.net/papers/DiffSteer/
    http://planning.cs.uiuc.edu/node659.html
    http://rossum.sourceforge.net/papers/CalculationsForRobotics/CompendiumForKinematics.htm
    https://www.cs.princeton.edu/courses/archive/fall11/cos495/COS495-Lecture5-Odometry.pdf

    I've almost completed the algoritm for the rotations. I've managed to calculate the angle and distance to rotation center. Now I need to combine this with the current position and angle, that will be for tomorrow.

    While thinking about what else I need to put in the application I thought about prop-gcc. I've not yet used it myself, but I think it'll be quite easy to add it also. Then there will be 3 versions of the editor: one for the Scribbler, one for Spin and a third for Prop-gcc.
    Is this something that would be useful?
  • Michel LMichel L Posts: 141
    edited 2014-05-13 14:17
    On request I've created a serial terminal this weekend. Today, I've added it to BlocklyProp.

    I'm going to have to have a look at the interface around the Blockly editor, because I don't like that line of buttons on the top right. As well as implement the com port selection.
    After that I'll get back to creating some more blocks.

    Any one with ideas?
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2014-05-14 02:49
    Michel,
    Sorry I have not been giving much feedback, been kind of busy with other stuff. I do have one minor feedback for you on the Ping block. It should be returning a value so it can be attached to things like a variable or math number can (attachment on the left side). Usage is like this: item := Ping.inches(n)

    I'll be able to do more testing and give more feedback next week when I get back home.
  • Ken GraceyKen Gracey Posts: 7,390
    edited 2014-05-14 06:50
    Michel,

    I see a really big opportunity for Blockly around the S2/S3. Last night I spent some time with Blockly - Roy (above) and Daniel Harris (our engineer) and six others were at Parallax so we had time to discuss how it could be used for S2/S3. My initial thought for the development process is that Blockly should proceed on the path you're on and at some point it should be adapted as an additional version for the S2/S3. A S2/S3 Blockly would have robot-specific blocks similar to what we see in the S2 GUI for commands like Drive, for example. This block would have to be a higher-level, abstract combination of something that includes:

    - PWM for driving the robot motors
    - encoder feedback, which isn't (at present time) visible to the user but part of the Drive block, but could be exposed
    - distance, speed, or time of travel (maybe two blocks - one for time/speed and another one for speed/encoder counts)
    - C or Spin (ouch, I'm sure)

    It seems to me that where you're headed is on the right path - a "high level, low-level" design in that the blocks create code, but they're still tied to I/O functions, and in the future we'd need to make a "robot layer" that takes it a step to "high level, high-level" in which the blocks create code but several I/O functions (drive speed, distance, including encoder counts) are encapsulated into a block.

    Am I explaining it right, in a way that makes sense? If not, it's because I can't articulate what's needed too easily.

    Where you are headed will take us there, as I see it. Also, there's an unexpected opportunity that will come out of the current effort. We would be able to use Blockly with the Propeller Activity Board's features to teach programming on Propeller to middle school students. Being able to use Blockly to access the A/D (serial block or maybe an A/D block), LEDs (done already, needs to go up to P27), XBee (a serial block), sensors, etc.

    Do you have Propeller Activity Boards?

    Your effort here is a big one for our community and we appreciate it.

    Ken Gracey
  • Michel LMichel L Posts: 141
    edited 2014-05-14 07:06
    Ken,

    I'm glad you like what I'm doing. More high level blocks will come soon as well as a C version

    Concerning the hardware: all I have is a demo-board, 2 proto-boards and a eezee prop.
    I sadly have not been able to acquire a propeller boe-bot or any other boards yet.

    Michel
  • Ken GraceyKen Gracey Posts: 7,390
    edited 2014-05-14 07:15
    Michel L wrote: »
    Ken,

    I'm glad you like what I'm doing. More high level blocks will come soon as well as a C version

    Concerning the hardware: all I have is a demo-board, 2 proto-boards and a eezee prop.
    I sadly have not been able to acquire a propeller boe-bot or any other boards yet.

    Michel

    That's changing today. Two S2s were shipped yesterday and now I'm sending some Propeller Activity Boards and sensors. I asked our sales staff to make sure the invoice is "gift" so you don't have to pay any EU VATs or customs. If you do, I'll reimburse those costs too.

    I didn't think of an ActivityBot until you mentioned it, but I can get you one of those too.

    I see that you've got to make a lot of decisions along the way with this project.

    Ken Gracey
  • Michel LMichel L Posts: 141
    edited 2014-05-14 13:59
    Roy Eltham wrote: »
    Michel,
    Sorry I have not been giving much feedback, been kind of busy with other stuff. I do have one minor feedback for you on the Ping block. It should be returning a value so it can be attached to things like a variable or math number can (attachment on the left side). Usage is like this: item := Ping.inches(n)

    I'll be able to do more testing and give more feedback next week when I get back home.

    Roy, I was already missing your input. To welcome you back I've fixed the bug with the Ping.

    @Ken,

    Thanks, that will make testing the blocks much easier. And all the features on the boards and all the sensor make a good to do list.

    Other things I did today: I introduced a dialog when loading the application to select the target board.
    Depending on this, the IO pins you can use freely are matched to the board. I still have to look at each board schematic to provide an accurate list. Currently the demo-board, the prototype board and the 'other' are done.

    I've provided also a multi-selection for extra modules. Just to limit the amount of block categories. I've put in some modules, but it doesn't do anything yet.

    Last, but not least, I've started setting up the Prop-c version. Not that you can see, but it's a start.

    Michel
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-05-14 16:18
    So how exactly do I install this? I downloaded what I thought was the correct zip file but there are 2 zip and 1 tar file in the directory.
  • Michel LMichel L Posts: 141
    edited 2014-05-15 01:28
    NWCCTV wrote: »
    So how exactly do I install this? I downloaded what I thought was the correct zip file but there are 2 zip and 1 tar file in the directory.

    The BlocklyProp-1.0-SNAPSHOT-dist is the one you'll want.
    I provide a zip and a tar.gz file but their contents is identical, pick the one you can work the easiest with.
    Just extract somewhere and run. (on windows, use the .bat file, on linux do: java -jar blocklyprop...jar)
    If you have trouble starting it, you might want to take a look at http://forums.parallax.com/showthread.php/155208-Open-Propeller-Project-5-BlocklyProp?p=1261996&viewfull=1#post1261996

    The "-demo" version is the one I put online on http://blocklyprop.creatingfuture.eu, This doesn't allow you to compile, load into the prop or any of the other server features.

    A little note: BlocklyProp requires java 1.7. Unlike the propeller-web-loader project, I've not ported this back to java 1.6, also MacOS is not yet supported with BlocklyProp. In the near future I'll copy that functionality from the propeller-web-loader.

    I hope this helps, if you have any further problems, let me know.

    Michel
  • Michel LMichel L Posts: 141
    edited 2014-05-15 14:25
    I've continued working on a C version. It's now available, although no blocks are currently available.

    I also have to work on the compiler in the next few days. (All that while having my first steps using Propeller C)

    Michel
  • Michel LMichel L Posts: 141
    edited 2014-05-17 11:47
    6 hours later,...

    The first C program was created, compiled and loaded into the prop.

    Still a long way to go: A lot of Blocks need to be added to be useful.
    Also the libraries need to be added as needed and the memory model needs to be selected.

    And the planned features list is still long :P

    EDIT: Forgot to mention: the propeller gcc toolchain is not bundled in BlocklyProp and needs to be installed on its own. So that the compiler binaries are in PATH.
  • jazzedjazzed Posts: 11,803
    edited 2014-05-17 11:53
    Michel L wrote: »
    Also the libraries need to be added as needed and the memory model needs to be selected.


    Just use CMM. Don't even bother with other options.

    On a phone for example there isn't much room for extras anyway.


    I hope the Learn library documentation provides some insight to what blocks may be possible.

    It would be useful to get the latest workspace from source control here.
  • Michel LMichel L Posts: 141
    edited 2014-05-17 13:01
    jazzed wrote: »
    Just use CMM. Don't even bother with other options.

    On a phone for example there isn't much room for extras anyway.

    It's not a priority, but it's on the list of possible functionality.

    jazzed wrote: »
    I hope the Learn library documentation provides some insight to what blocks may be possible.

    It would be useful to get the latest workspace from source control here.

    I'll check it out, thanks.
  • Ken GraceyKen Gracey Posts: 7,390
    edited 2014-05-19 11:40
    Michel L wrote: »
    6 hours later,...

    The first C program was created, compiled and loaded into the prop.

    Whoa! Big step!

    Keep burning it up Michel, but don't burn out!

    Ken Gracey
  • Michel LMichel L Posts: 141
    edited 2014-05-19 13:49
    Not much done today, only added some C blocks.
    • Loops and conditions
    • Math
    • Logic
    • Variables
    • Functions
    :P

    Todo: bitwise operations, some more in-out, cog-new. And then the peripherals.

    Maybe, those of you that are used to program in C for the prop can check some of the generated code. Thanks
    I do use the blocks and check that it compiles, but not much more.
  • Michel LMichel L Posts: 141
    edited 2014-05-20 13:03
    Michel L wrote: »
    Todo: bitwise operations, some more in-out, cog-new. And then the peripherals.

    All in out blocks from the spin version have been ported, and the bitwise operations were added except for the rotate functions.

    I've looked at C syntax but apparently rotate is not operator in C. Is it available in Prop-C?
  • jazzedjazzed Posts: 11,803
    edited 2014-05-20 19:19
    @Michel L.

    Sorry for not having time to test your C blocks code. Will spend some time this weekend.


    >> I've looked at C syntax but apparently rotate is not operator in C. Is it available in Prop-C?

    Unfortunately the ANSI committee didn't read the SPIN Manual in 1988 ;-) (right Rick?) Just define a function.

    The easiest thing to do is use shift left/right operators << and >> ... there is a trick involving xor, but i forgot it.

    Look at this page.
  • Michel LMichel L Posts: 141
    edited 2014-05-21 01:08
    jazzed wrote: »
    Sorry for not having time to test your C blocks code. Will spend some time this weekend.

    Thanks

    jazzed wrote: »
    >> I've looked at C syntax but apparently rotate is not operator in C. Is it available in Prop-C?

    Unfortunately the ANSI committee didn't read the SPIN Manual in 1988 ;-) (right Rick?) Just define a function.

    The easiest thing to do is use shift left/right operators << and >> ... there is a trick involving xor, but i forgot it.

    Look at this page.

    Wouldn't it be easier if it was one of the functions in the simpletools lib. As far as I know the purpose of that lib is to make prop-specific stuff easier.
    I'll maybe create a lib specific for Blockly so that some blocks can be simplified. I don't want to have to include the rotate function in each program when you use the block.
  • jazzedjazzed Posts: 11,803
    edited 2014-05-21 08:23
    Michel L wrote: »
    Wouldn't it be easier if it was one of the functions in the simpletools lib. As far as I know the purpose of that lib is to make prop-specific stuff easier.
    I'll maybe create a lib specific for Blockly so that some blocks can be simplified. I don't want to have to include the rotate function in each program when you use the block.


    Yes, it would. It should be easy to extend libsimpletools by creating a libblockly project and add things you need. It could #include "simpletools.h" or just add some of the necessary libraries that simpletools uses (simpletools is huge).
  • Michel LMichel L Posts: 141
    edited 2014-05-21 13:19
    Serial print command working together with the serial console.

    Because I've not yet implemented serial port selection the serial console is still hardcoded to COM4. But here's a little preview:

    hello blocks.png
    hello terminal.png
    230 x 122 - 4K
    362 x 161 - 3K
  • jazzedjazzed Posts: 11,803
    edited 2014-05-21 13:46
    Michel L wrote: »
    But here's a little preview:


    :-) sweet. Thanks for sharing.
  • Michel LMichel L Posts: 141
    edited 2014-05-22 12:24
    Michel L wrote: »
    Because I've not yet implemented serial port selection the serial console is still hardcoded to COM4.

    And that's now changed. From now on you can/have to select your com port. This is both for loading the application into the prop as well as the terminal.

    That was it for today, time to figure out what to add tomorrow.
  • Michel LMichel L Posts: 141
    edited 2014-05-24 15:24
    One evening and an entire day and I have the base for the next part:

    BlocklyProp Community

    It's far from finished: currently there is only 1 project in the database. And you can't yet add new one. And there is not yet a link back to the community page.

    Planned for the community:
    - user accounts to save and load projects
    - friend (can see all your projects that are not marked as private)
    - share project with everyone
    - create new version of a project
    - create a new version of someone else's project

    Do you guys like this? Any proposals?
  • JonnyMacJonnyMac Posts: 9,085
    edited 2014-05-24 19:03
    It's great that you've added the ability to launch methods into separate Spin cogs. Remember that each cog has its own dira, outa, and ina registers -- methods writing to pins that get launched into separate cogs will have to update the dira register in that cog.

    Suggestion: If you have an empty repeat loop, put a waitcnt in it to put the cog into low-power mode most of the time
    repeat
        waitcnt(0)
    
  • Michel LMichel L Posts: 141
    edited 2014-05-25 08:49
    JonnyMac wrote: »
    It's great that you've added the ability to launch methods into separate Spin cogs. Remember that each cog has its own dira, outa, and ina registers -- methods writing to pins that get launched into separate cogs will have to update the dira register in that cog.

    Thanks for reminding me. I totally forgot about this. I fixed it by always setting outa each time you write. Determining if it is already set for a given core is very complex.
    JonnyMac wrote: »
    Suggestion: If you have an empty repeat loop, put a waitcnt in it to put the cog into low-power mode most of the time
    repeat
        waitcnt(0)
    

    Jon, nice proposal. I've now added this. Only for the infinite repeat, because the repeat x times block might be used to create a little delay (although I wouldn't recommend that)

    pinwrite and empty repeat.PNG


    Now generates:
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
    
    
    VAR
    
    PUB Setup
      Start
    
    
    PUB Start
    
      dira[16]~~
      outa[16] := 1
      repeat
        waitcnt(0)
    
  • Michel LMichel L Posts: 141
    edited 2014-05-25 08:55
    BlocklyProp Community is now getting a bit more usable. Although there are still no users you can now create projects.
    I added 3 projects to start. In the spin and prop-c editor there are now buttons on the top right to save the project and to go to the community page.

    Have a look, give it a try, and let me know how you like it please.

    BlocklyProp

    If something doesn't work a hard refresh might be needed. As I've noticed that cached files regularly give problems.
  • JonnyMacJonnyMac Posts: 9,085
    edited 2014-05-25 10:52
    May I suggest that for consistency, you stick with := 1 and := 0 for pin output and direction assignments.

    I've done a timing test and
    dira[16] := 1
    


    is faster (608 system ticks) than
    dira[16]~~
    


    at 656 system ticks.
  • Michel LMichel L Posts: 141
    edited 2014-05-29 11:19
    JonnyMac wrote: »
    May I suggest that for consistency, you stick with := 1 and := 0 for pin output and direction assignments.

    I've done a timing test and
    dira[16] := 1
    


    is faster (608 system ticks) than
    dira[16]~~
    


    at 656 system ticks.

    Jon, I changed it. It's not only faster and more consistent, but it's also easier to understand. I originally implemented it this way because of the recommendations in the manuals.
  • Michel LMichel L Posts: 141
    edited 2014-05-29 11:31
    The last few days I haven't posted anything as I have continued to work on some big changes.

    The community version brings a lot of added value (I think) but then it's not possible to compile or communicate with your prop.
    Today I have created a client that does the compiling, loading and serial console. To get away from the dependency on Java I wrote it in Python.

    When you load the BlocklyProp editor it will check if the client is running (currently only on localhost). And if so it will change from demo mode to a functional mode. (I still have to create some polling system that regularly checks for the client)

    I currently have built the client to a Windows EXE using PyInstaller. This means python doesn't need to be installed, it is included in the client.
    Just unpack the zip and run BlocklyPropClient.exe before you load the web page.
  • jazzedjazzed Posts: 11,803
    edited 2014-05-29 12:05
    Excellent!

    Ran the app, went to the web page and selected the programming type. Compiled.

    Will do more later after paying gig is done and the grass is cut.
Sign In or Register to comment.