Page 9 of 24 FirstFirst ... 567891011121319 ... LastLast
Results 81 to 90 of 236

Thread: PhantomX controlled by a Raspberry Pi

  1. #81
    Join Date
    Sep 2010
    Location
    ಠ_ಠ
    Posts
    2,188
    Images
    27
    Rep Power
    268

    Re: PhantomX controlled by a Raspberry Pi

    My brain is crap and I'm a little lost, but should there be a delay in the ReadFromXBee() function in diyxbee.cpp?
    My limited understanding makes it seem like the "check for timeout" while loop just continuously calls micro() without delaying until it times out, or am I just not looking in the right place for the actual contents of the "DoBackgroundProcess()" function. I see a blank define of "DoBackgroundProcess()" in Phoenix.h, but I cannot find an actual function like usleep(100) or similar.
    Please pardon the pedantry... and the profanity... and the convoluted speech pattern...
    "You have failed me, Brain!"
    bleh

  2. #82

    Re: PhantomX controlled by a Raspberry Pi

    Hi Tician,

    Yep you are right there should be some form of delay in that function. I need to make another pass through that. It has not shown up yet as I am spending most of my time working the the Arbotox commander input code as that is what others there have. But personally I would rather run the Pi using my DIY XBee remote.

    Yes - Background Process is a NOP for most setups (except Bioloid), But for Bioloid (except for Kevin's new stuff) all needed to have their method called to do the servo interpolation...

    Hi Kevin,

    Looks like you made some great progress on performance. May have to see where mine is taking up the time. Some things I am going to try include:
    1) THE LOOP - If no background process. compile it to a simple Delay(EndTime - current time). Which is what the code used to be before adapted to PhantomX. Note: this may help yours as well
    2) Try compiling out my Terminal monitor. If that helps perf, then maybe try switching monitor to another thread, that blocks on input from stdin, so no need for polling it.
    ...

    Kurt
    Last edited by KurtEck; 04-13-2013 at 09:39 AM.

  3. #83

    Re: PhantomX controlled by a Raspberry Pi

    Another quick update:

    I find if I change my delay in the CommanderEx from 250 to 1000 the CPU drops at idle to about 7% where it was hovering around 20%. Not sure how your get anything to run at 3% so need still to figure out where the CPU is going. Note: I was trying to make the XBee block on the read (getc), may need to see about using a read or the like instead? Or need to check and maybe set the stream block. I ifdefed out the code that was to make it unblock...

    Also for your idle going real high when you turn off the commander. Some things I changed in the last update
    1) If you look at the delta around line 772 in phoenix_code.cpp, you will see I changed the delay to 100 instead of 20. So you should make sure you have some form of delay there.
    2) When idle, each pass through it calls off to the ServoDriver::FreeServos. I was each time outputting the stuff to the SSC-32 to free the servos, when I only need to do it once... So in the Servo Driver (and in the Servo Driver definition), I added a flag to say the servos are active. When I do a commit, I set the flag, when I do the call to FreeServos, I check the flag and if necessary tell the SSC-32 to free up the servos and then clear the flag. This cut down on the idle CPU usage.

    Kurt

  4. #84

    Re: PhantomX controlled by a Raspberry Pi

    If you want to reduce the idle load, then you probably want to re-structure the program along modern Linux software styles. Then again, the CPU consumption at idle doesn't really matter -- it's how much work you can do when there's work to do that really matters :-)

    getc() uses file buffers, so it will typically read a big chunk of data at a time. This may end up introducing lag to the communications. You may be able to make the buffering smaller (down to 1 byte?) but that's not a good way to do it. Using read() for 1 character is better that getc() for device I/O.

    Also, to write high-efficiency Linux programs, you want to use select() or epoll() to block until some I/O is available on some file descriptor, and then go ahead and dispatch that particular I/O. If you also need to do periodic tasks, a timeout on the blocking call lets you wake up for those tasks. So, a correctly structured Linux program looks more like a state machine or event-driven automaton. The main loop just waits in select/epoll, and when there's I/O, it dispatches to a "read some data" function for each file descriptor that has data available. Repeat.

  5. #85

    Re: PhantomX controlled by a Raspberry Pi

    Thanks again jwatte,

    I hacked up my Commander version of the XBee stuff, to add in a call to select, to make it sleep for up to 1/4 of a second or until the xbee FD has data... This really did help knock down the idle stuff.

    Yep idle usage on most of my robots is a non issue as the robot is only doing one thing. But I may also want the pi to do other things like video streaming, so it is good to cleanup some of this.

    Kevin, I put a copy up on github with the select if you wish to play

    Kurt

  6. #86
    Join Date
    Dec 2012
    Location
    Los Angeles, CA
    Posts
    831
    Images
    25
    Rep Power
    80

    Re: PhantomX controlled by a Raspberry Pi

    I'll give it a go tonight. Yeah my idle is still low 90's. I checked walking and power off again today and they are still the same numbers as before. I wanted to check again just to make sure I wasn't seeing things last night. :P

  7. #87
    Join Date
    Dec 2012
    Location
    Los Angeles, CA
    Posts
    831
    Images
    25
    Rep Power
    80

    Re: PhantomX controlled by a Raspberry Pi

    I took a couple of shots of "Charlotte" since I'm toying with the idea of a web page to log my work. (Not sure yet.)

    Take a look Kurt!
    Last edited by KevinO; 04-13-2013 at 08:24 PM.

  8. #88
    Join Date
    Dec 2012
    Location
    Los Angeles, CA
    Posts
    831
    Images
    25
    Rep Power
    80

    Re: PhantomX controlled by a Raspberry Pi

    Not sure why it didn't link them. Trying again. :P
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	front.jpg 
Views:	87 
Size:	84.9 KB 
ID:	4627   Click image for larger version. 

Name:	quarter.jpg 
Views:	85 
Size:	84.7 KB 
ID:	4628  

  9. #89

    Re: PhantomX controlled by a Raspberry Pi

    Looks nice. Like the camera there.

    Have you tried using the webcam server software I have been playing with? Is it supported, Can you then pan and tilt from their web page?

    Also FYI, I checked in another simple change that if you don't have a background loop, the code simply does one delay of
    the End Time minus the current time (min 1)... This also knocked the usage down reasonably well!

    Kurt

  10. #90
    Join Date
    Dec 2012
    Location
    Los Angeles, CA
    Posts
    831
    Images
    25
    Rep Power
    80

    Re: PhantomX controlled by a Raspberry Pi

    I haven't tried that yet. The farthest I've gotten is playing around with OpenNI and OpenCV on my desktop. I did download your webcam stuff but haven't looked into it. Though that is the plan. It is the one reason I purchased the one with both the color cam and the depth sensors.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Question(s) Raspberry Pi
    By Robonaut in forum Robot Computers
    Replies: 20
    Last Post: 07-07-2013, 11:46 AM
  2. Raspberry Pi Camera coming soon
    By sarendt in forum Robotics General Discussion
    Replies: 1
    Last Post: 03-16-2013, 11:15 PM
  3. About to give up on the Raspberry Pi
    By jwatte in forum Software and Programming
    Replies: 5
    Last Post: 01-14-2013, 11:57 AM
  4. Just For Fun My Raspberry PI
    By rebel in forum Arbotix, Microcontrollers, Arduino
    Replies: 0
    Last Post: 12-31-2012, 06:57 PM
  5. For learning: PhantomX Hexapod vs PhantomX Quadruped
    By Leugim in forum Humanoids, Walkers & Crawlers
    Replies: 4
    Last Post: 10-26-2012, 09:50 AM

Tags for this Thread

Posting Permissions

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