Shop OBEX P1 Docs P2 Docs Learn Events
Python and Robotics — Parallax Forums

Python and Robotics

ashwikaaashwikaa Posts: 7
edited 2009-03-15 15:34 in Robotics
Hi,
I am writing a Python program to control the Scribbler Robot(it has·a Basic Stamp microcontroller in it). I am using the IPRE Fluke·to connect·it to·the PC(Bluetooth connection). Now I am trying to capture the data·sent to the microcontroller·and upload it in to the Scirbbler robot itself and make it work without the PC.

I would appreciate·help with this. Any·ideas/suggestions?

Thanks!

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-03-14 01:40
    Sounds fun, show us your code, both for the PC and the scribbler and perhaps we can help.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • ashwikaaashwikaa Posts: 7
    edited 2009-03-14 05:55
    I am trying to figure out how the scribbler code would look like from the interpreted Python code. The Python code can be anything as simple as a beep command. For instance,

    from myro import *
    initialize("com4")
    def sound():
    ··· beep(1,880)
    def main():
    ··· sound()
    main()



    My question here is how will this program look like when it goes to the microcontroller of the scribbler robot, that is when you execute the Python program.

    Thanks!
  • SRLMSRLM Posts: 5,045
    edited 2009-03-14 06:28
    You can't put python on a BS2. You can (I'd assume) use Python to communicate from a PC to the microcontroller (running PBASIC). You might be able to write some sort of compiler that will take the Python code you define and translate it into Pbasic so that you can 'use' Python on the BS2, but that's alot of work for little benefit.
  • ashwikaaashwikaa Posts: 7
    edited 2009-03-14 06:40
    Exactly. That is what I am looking for but I need some ideas/input on building that compiler. Any help?
  • SRLMSRLM Posts: 5,045
    edited 2009-03-14 07:22
    You'll want to learn PBASIC through and through first, then you can define what commands you want to use in Python, and what those would translate to in PBASIC. You can define your special "BS2 Python" language so that this python command == this pbasic command (or these pbasic commands). You can create a .Pbs2 file with your python basic stamp code. Then you can make a separate Python program that will take your BS2 python code (this could be called the 'compiler') and translates it line by line into a .bs2 file. You can run this .bs2 file through the parallax standalone compiler and downloader.

    I've never done this, but it should be fairly straight forward. Don't forget that you'll have to check for python syntax errors before you translate it into pbasic.
  • ashwikaaashwikaa Posts: 7
    edited 2009-03-14 23:11
    Sounds like an idea but then all available PBasic commands should be defined in Python, right? I don't know how feasible that would be. Any sample code for the idea?

    Thanks!
  • WhitWhit Posts: 4,191
    edited 2009-03-15 01:50
    ashiwikaa,

    I would suggest talking to the IPRE folks at their support. I understand they respond pretty quickly.

    Their software that you load on your Scribbler turns the Scribbler into a slave that recieves its instructions via the bluetooth from the PC. (I know that you know this already). The Python Programming environment on you PC sends the the converted program instructions to the Scibbler via the bluetooth. And of course, the Scibbler IPRE Fluke Dongle and the PC communicate back and fourth (for the camera and for feedback from the sensors on board the Scribbler).

    With the PC as the controller via the Python Program you have a hugh set of brains (memory and program space on the PC)·controlling the Scibbler with its small Stamp brain (so to speak). This amount of info that you have in program and options on your PC is probably too large to load to the Scribbler and have it do all that you can by communicating back and fourth between the two. That is the whole advantage of the system.

    If you want the Scribbler to perform autonomously with the Basic Stamp controller it has and no outside help - why not just write its program in PBasic or with the GUI? It will be limited by the on-board storage space of the Stamp.

    Otherwise you can have a much more sophisticated program running the Scribbler via the Bluetooth interface between the PC and the Scribbler.

    As far as what is sent from Bluetooth at PC to Bluetooth at the Scribbler, I imagine it is more like small sets of individual instructions and data from the the Scribbler's sensors back into the main program on the PC (in small little pieces as needed).

    Hope this helps. Let me know if I can clarify in any way.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+


    "We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney

    Post Edited (Whit) : 3/15/2009 12:24:55 PM GMT
  • ashwikaaashwikaa Posts: 7
    edited 2009-03-15 07:09
    I appreciate your help, Whit. Thats a lot of information. Basically this is for a school project (designing a course work for the students). So the main aim of doing this project is to teach them python as it will be more structured than the PBasic. Plus, having the robots operate independently(without thePC) will enable mobility (carrying around just the robot).

    I can understand the advantage of having the PC (memory plus program capabilities) but wanted to see if this could help in any way.

    I will email the Parallax team too and find out if they could help me out in any way.

    Thanks!
  • WhitWhit Posts: 4,191
    edited 2009-03-15 12:28
    ashiwikaa,

    No problem. To try to say things more simply, Python and the Python program written are all on the PC. The Scribbler becomes a remote control robot being run by the PC using its program. There is no program stored on the Scribbler, except the one making it a slave to the instructions coming from the PC via the Python program (the two do send info back and forth as regards sensor info).

    Good luck with your class.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+


    "We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney

    Post Edited (Whit) : 3/15/2009 5:08:38 PM GMT
  • ashwikaaashwikaa Posts: 7
    edited 2009-03-15 15:34
    sure thanks, Whit.
Sign In or Register to comment.