Thread: Rostopic Pub

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    29
    Rep Power
    0

    Rostopic Pub


    when I type this in the terminal of ubuntu:

    rostopic pub -1 /cmd_mouth qbo_arduqbo/Mouth [0,0,'test'] [0,0,0,0,0,1,0,0,0,1,0,1,1,1,0,0,0,0,0,0]

    I get a smile on my robot.

    But, when I type it into the python script, I get a syntax error. I am just beginning to study python. It is version 2.7.

    Anyone have any ideas?

    Thanks in Advance!!
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480
    Sure. python and bash have different syntax rules.
    as do lisp, FORTRAN, DOS, and TRAC (https://en.wikipedia.org/wiki/TRAC_(programming_language)), APL, and j.

    Ted Nelson. Inventor of the term "hyperlink". My sister took a class by Ted. I sat in on one of the labs, my first college class...Ted struck me as, well, never mind. This must have been in the late '70s.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    29
    Rep Power
    0
    OK, do you know HOW to correctly say it? I don't.

    Thanks for the reply.

  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480
    Without your learning anything, without my understanding what you actually want,
    Code:
    import os
    os.system("rostopic pub -1 /cmd_mouth qbo_arduqbo/Mouth [0,0,'test'] [0,0,0,0,0,1,0,0,0,1,0,1,1,1,0,0,0,0,0,0]")
    Don't be too surprised if this annihilates your computer.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    29
    Rep Power
    0

    Thanks,


    I will let you know if it worked.

  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    29
    Rep Power
    0

    It worked!!! Thank you so much.


    I am a senior citizen. I was tired of building and setting up computers so i bought a factory one. Little did I know that I would have to learn to program python and C and learn ROS. I don't have the kind of time to spend too much on it.

    I will take that little nugget and apply it to many things. You have Blessed me and I really appreciate it.

    Thanks!

    You are a Genie!!! OUS!!!

  12. #7
  13. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480
    If you want to use shell commands it seems easier to me to enter them directly into the shell than to wrap them in python.

    Or write shell scripts or .bat files for complicated commands.

    Whatever. I'm glad you're satisfied.
    [code]Code tags[/code] are essential for python code and Makefiles!
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    29
    Rep Power
    0

    shell commands


    I am trying to learn Python and C++ for my Qbo Robot. I am building little blocks of code that do different things. One of them was making the robot smile. At some point, I will add all of these little blocks of code together and make a bigger program. That is why I needed to do it in a code package. Also, I will not be at the terminal when the robot is running. He will be doing his own thing. Therefore I could not enter at the terminal at that time without moving him and hooking him all up to kb,mouse,speaker,monitor.

    Thanks again.


IMN logo majestic logo threadwatch logo seochat tools logo