Page 3 of 7 FirstFirst 1234567 LastLast
Results 21 to 30 of 63

Thread: An robot programming idea in Python

  1. #21
    Join Date
    Feb 2010
    Location
    Silicon Valley, CA
    Posts
    321
    Images
    1
    Rep Power
    40

    Re: An robot programming idea in Python

    > When I found ROS, I realized, I was doing a very similar thing -- except they had 20x the manpower, and had a 100x better implementation.

    Fergs, I think you got those numbers reversed.
    Maybe because you are too modest about your coding skills and also underestimate how amny people are involved in ROS now.

  2. #22
    Join Date
    May 2008
    Posts
    2,228
    Images
    155
    Rep Power
    126

    Re: An robot programming idea in Python

    Quote Originally Posted by RobotNV View Post
    I think ROS is just the thing we all should adopt, so that we can combine our efforts and not reinvent the wheel again and again.
    Well, ROS hasn't really avoided the reinventing the wheel aspect -- for instance, I know of at least 4 separate labs that have released ROS wrappers for ARToolkit. They all effectively do the same thing -- but with quite different interfaces.

    It's also probably not for everyone. It's really targeted at Ubuntu systems. C++/Python are the main languages (although there is beta-level support for Java and a few other languages). The biggest thing is: the learning curve is a bit steep -- especially given what *most* hobbyists are really doing. There is a lot of very good documentation -- but it's going to take most people quite a bit of time to really get up and running well.

    Quote Originally Posted by RobotNV View Post
    > When I found ROS, I realized, I was doing a very similar thing -- except they had 20x the manpower, and had a 100x better implementation.

    Fergs, I think you got those numbers reversed.
    Maybe because you are too modest about your coding skills and also underestimate how amny people are involved in ROS now.
    At the time that I found ROS, there weren't nearly as many people working on it-- but yeah, today there are a lot (I have 3 people just at my little lab using ROS on robots).

    -Fergs

  3. #23
    Join Date
    Feb 2010
    Location
    Silicon Valley, CA
    Posts
    321
    Images
    1
    Rep Power
    40

    Re: An robot programming idea in Python

    > I know of at least 4 separate labs that have released ROS wrappers for ARToolkit.

    That's unavoidable. Those 4 labs probably started at around the same time, or, more likely, just ported their existing projects to ROS. But you, Mike, now know about all 4 of them and can compare them.
    And, the best part - you are not about to write the 5th, are you?
    Over time, chances are at most 2 out of those 4 projects will survive and the rest will switch over or just die.

    > At the time that I found ROS, there weren't nearly as many people working on it-- but yeah, today there are a lot
    See, and this is just what happened in 18 months.

    But please, let's continue this type of conversation on another thread I started a few minutes ago.

  4. #24
    Join Date
    May 2008
    Posts
    2,228
    Images
    155
    Rep Power
    126

    Re: An robot programming idea in Python

    Quote Originally Posted by RobotNV View Post
    That's unavoidable. Those 4 labs probably started at around the same time, or, more likely, just ported their existing projects to ROS. But you, Mike, now know about all 4 of them and can compare them.
    And, the best part - you are not about to write the 5th, are you?
    Actually, our lab uses a modified version of Reactivision (a tool similar to ARToolkit), so we may... hehe

  5. #25
    Join Date
    Apr 2009
    Location
    Stanford, CA USA
    Posts
    590
    Rep Power
    49

    Re: An robot programming idea in Python

    Quote Originally Posted by iBot View Post
    My understanding is that the synchronize uses the sync_write and there is no sync_read. The f_m library defines the cached registers for read, and they do not seem to be the ones you use. At a couple of ms per bus read, that adds up.
    Thanks to iBot, I have modified my Dynamixel polling loop to use the ReadAll() method in the Forest Moon library instead of reading each register individually. I then read the cached values when publishing a particular value to the message board. Below are the results in terms of the fastest polling rate I can obtain comparing this new method versus my old method. The hardware setup I have is:

    * USB2Dynamixel controller in TTL mode connected to a USB 2.0 port on a DLink USB hub
    * USB port Latency Timer set to 1 msec down from default 16 msec
    * 11 AX-12+ servos
    * Windows XP SP3 on an Acer Core 2 Duo 3 Ghz PC
    * Iron Python 2.6
    * PySerial 2.4

    My polling loop queries Current Position, Current Speed, Current Load, Current Temperature, Moving status, Torque Enable status, Moving Speed and Goal Position. It also sets Moving Speed, Goal Position and Torque Enable if these values have changed. See code block below for details.

    NOTE: I do not use time.sleep() at all in the loop anymore so I am driving it as fast as it will go.

    RESULTS: Average time to complete one polling loop across all 11 servos

    Old Method (not using cached values): 66 msec (16 Hz)
    New Method (using ReadAll): 22 msec (45 Hz)

    BTW, these numbers hold up even when using RoboRealm in a second thread to head track a colored object at 30 frames per second.

    Here now is the new polling loop:

    Code:
    class ActuatorThread(threading.Thread):
        def __init__(self, myDynaNet, myActuators, myMessages):
            threading.Thread.__init__(self)
            self.finished = threading.Event()
            self.daemon = True
            self.myDynaNet = myDynaNet
            self.myActuators = myActuators
            self.myMessages = myMessages
            self.Count = 0
    
        def run(self):
            clock = 0
            while not self.finished.isSet():
                start = time.clock()
                for aName in self.myActuators.All:
                    
                    self.aActuator = self.myActuators.All[aName]
                    
                    self.aActuator.Dyn.ReadAll()
                    
                    self.myMessages.pubValue(aName + "_CurrentPosition", self.aActuator.getCurrentPosition())               
                    self.myMessages.pubValue(aName + "_CurrentSpeed", self.aActuator.getCurrentSpeed())
                    self.myMessages.pubValue(aName + "_isMoving", self.aActuator.isMoving())
                    self.myMessages.pubValue(aName + "_CurrentLoad", self.aActuator.getCurrentLoad())
                    self.myMessages.pubValue(aName + "_CurrentTemperature", self.aActuator.getCurrentTemperature())     
    
                    TorqueEnabled = self.myMessages.getValue(aName + '_TorqueEnabled')
                    CurrentTorqueEnabled = self.aActuator.getTorqueEnabled()
                    if TorqueEnabled != None and TorqueEnabled != CurrentTorqueEnabled:
                        self.aActuator.setTorqueEnabled(TorqueEnabled)
                    
                    if (TorqueEnabled != False):
                        GoalPosition = self.myMessages.getValue(aName + '_GoalPosition')
                        CurrentGoalPosition = self.aActuator.getGoalPosition()
                        if GoalPosition != None and GoalPosition != CurrentGoalPosition:
                            self.aActuator.setGoalPosition(GoalPosition)
                        
                        MovingSpeed = self.myMessages.getValue(aName + '_MovingSpeed')
                        CurrentMovingSpeed = self.aActuator.getMovingSpeed()
                        if MovingSpeed != None and MovingSpeed != CurrentMovingSpeed:
                            self.aActuator.setMovingSpeed(MovingSpeed)
                                          
                        if self.myMessages.getValue(aName + "_StopRequested"):
                            self.aActuator.stop()
                            self.myMessages.pubValue(aName + "_StopRequested", False)
                
                self.Count += 1
                                     
                self.myDynaNet.Synchronize()
                
                delta = time.clock() - start
                clock += delta
                print "Current Time:", delta, "Ave Time:", clock / self.Count 
                
        def stop(self):
            print "Stopping servos ...",
            self.finished.set()
            self.join()
            print "Done."
    And I read the cached values like this:

    Code:
    def getCurrentPosition(self):  
        return self.Dyn.Item[Register.CurrentPosition]
    ---
    Pi Robot
    http://www.pirobot.org
    Last edited by Pi Robot; 07-10-2010 at 10:41 AM.

  6. #26

    Re: An robot programming idea in Python

    I did some testing too, and would agree that you have now have the best performance.
    Basically a read transaction, or any transaction with a reply takes of the order of 2 ms. This is mainly driven by the latency in the full speed USB driver in the PC and the latency value (1ms) in the FTDI chip of the USB2Dynamixel for the reply. So best as you do, to do it all in one go with a readall().
    The writes are best using sync writes, both because they talk to many devices, and they have no reply. Sync writes take of the order of 1 ms.
    I have tried my high speed multiport FTDI FT4232H under XP with dissapointing results. I changed the latency in the registry to 0 to reduce the latency value from 1ms to 125us. The FTDI tries to send every 125us which overwealms the OS, and the overall performance is actually slower than 1ms setting despite a faster bus transaction. Multiport is an advantage, but would require a rewrite of the library to support the overlapped transactions.
    Based on what you have found, the F-M library might be simplified greatly if the proven inefficient parts were dropped.
    To go any faster coupling of Dynamixels to PC requires an external processor to concentrate the individual servo data to a single message as proposed above, but I hope the performance now meets you needs.
    And your architecture is still intact. Great.

  7. #27
    Join Date
    Apr 2009
    Location
    Stanford, CA USA
    Posts
    590
    Rep Power
    49

    Re: An robot programming idea in Python

    Very cool. And many thanks again for your suggestions. I can't believe I'm getting 3x the polling rate after implementing your suggestions. Head tracking now seems almost instantaneous.
    The Pi Robot Project
    http://www.pirobot.org

  8. #28
    Join Date
    Apr 2009
    Location
    Stanford, CA USA
    Posts
    590
    Rep Power
    49

    Re: An robot programming idea in Python

    Quote Originally Posted by lnxfergy View Post
    Well, ROS hasn't really avoided the reinventing the wheel aspect -- for instance, I know of at least 4 separate labs that have released ROS wrappers for ARToolkit. They all effectively do the same thing -- but with quite different interfaces.

    It's also probably not for everyone. It's really targeted at Ubuntu systems. C++/Python are the main languages (although there is beta-level support for Java and a few other languages). The biggest thing is: the learning curve is a bit steep -- especially given what *most* hobbyists are really doing. There is a lot of very good documentation -- but it's going to take most people quite a bit of time to really get up and running well.
    -Fergs
    I believe Fergs has already seen this article because he made a comment at the bottom of it. In the meantime, I think this write-up gives you a good taste of what it's like working with ROS, open source and multiple independent developers.

    From I Heart Robotics - Testing ROS USB Cameras

    http://www.iheartrobotics.com/2010/0...a-drivers.html

    In the meantime, I wonder if Fergs would be willing to list his set of pros and cons so far when working with ROS?
    The Pi Robot Project
    http://www.pirobot.org

  9. #29
    Join Date
    Apr 2009
    Location
    Stanford, CA USA
    Posts
    590
    Rep Power
    49

    Re: An robot programming idea in Python

    Just to throw another iron in the fire: has anyone looked at Urbi from Gostai? It is now open source, runs on Linux, Windows and MacOS X, and has support for a number of popular robot platforms including Robotis. The home page is at:

    http://www.gostai.com/
    The Pi Robot Project
    http://www.pirobot.org

  10. #30
    Join Date
    May 2008
    Posts
    2,228
    Images
    155
    Rep Power
    126

    Re: An robot programming idea in Python

    Quote Originally Posted by Pi Robot View Post
    In the meantime, I wonder if Fergs would be willing to list his set of pros and cons so far when working with ROS?
    Tiny bit of background: I've been running ROS for about 2-3 months now, on our University bots (iCreate + laptop, and Nelson), and on my own bots (a ArbotiX+FitPC rover, and ArbotiX+FitPC based Issy3). Most people by now probably have noticed that I love Python, so ROS is quite easy for me to attach my existing code onto. It also has very good support for C++, and beta-level support for Java/Octave and several other languages.

    Which brings me to an interesting point that I like -- ROS is ROS-agnostic. The current paradigm is to take your existing code and put a thin ROS wrapper around it. Each piece becomes a node in the runtime graph. We've got a lot of code in our lab (control stuff, emotional systems for Nelson, little visual routines), and it's been a breeze to move the stuff over into an ROS system -- far easier than it was to hook them onto our old framework (Tekkotsu) originally.

    That said -- ROS really is targeted at experienced programmers. It's a massive system, and although it's well documented, most of the documentation assumes a certain level of experience, I'd say the equivalent of an Undergraduate Minor in CS, or several years of programming experiance is a pre-requisite to really develop inside ROS (a less experienced person may be able to setup a basic system and run existing code, but any real development will take some knowledge). It's a very powerful framework, especially because of how many new modules keep getting released (as open source) into the community.

    -Fergs

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Contest Entry RC truck robot conversion
    By Orac in forum Project Showcase
    Replies: 24
    Last Post: 11-14-2012, 12:50 AM
  2. Contest Entry The eyeRobot: Robot Blind Aid
    By Shrimpy in forum Project Showcase
    Replies: 16
    Last Post: 02-07-2011, 10:20 AM
  3. Question(s) Writing an educatonal book on robotics
    By darkback2 in forum Robotics General Discussion
    Replies: 107
    Last Post: 05-25-2010, 12:51 AM
  4. Project New Post For Fresh Start On Robot Butler
    By ROBOTMAN in forum Project Showcase
    Replies: 11
    Last Post: 10-31-2009, 01:50 PM
  5. [ANNOUNCE] Rat's Life: robot programming contest
    By omichel in forum Robotics General Discussion
    Replies: 4
    Last Post: 09-19-2008, 03:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •