Eric,

        The protocol is the same across rflex robots.  Below is a solution compliments of Jon Klippenstein that worked for me.

Hi Douglas, Toby, et al.,

Here's my results of digging around in the rflex driver.  A 1ms usleep
in RFLEX::Main() at the end of the main loop, and a 0.5ms usleep in
cmdSend() in the loop to wait to ensure a command is executed properly
on the robot.  The values are pretty arbitrary, I haven't played with
them to try to get them lower, just went with the first thing that
worked. Just using the second delay, with no delay in RFLEX::Main() gets
the CPU usage down, but causes problems with queues overflowing or
something similar.  I found this worked in player 1.6.5 and 2.0.1.

For 2.0.1, I wasn't able to send commands to our rflex-based robot.  I
ended up resetting the command_type variable to zero whenever a velocity
command is received.  I can't quite discern the purpose of command_type,
but this seems to make things work properly, and I can drive the robot
around again.  Perhaps Toby can provide more of an explanation?

I've attached patches for 1.6.5 and 2.0.1.  Hopefully they are
well-formed, as I haven't had any experience creating diffs before.

Hope it's helpful.
-jon


Douglas A Few wrote:
>
> Jon,
>
>         Thanks, I just started digging into it this morning but it seems
> you have solved my woes.  I had not tried to command the robot however I
> suspected there may have been a problem when I forgot to comment-out the
> send_speed command in an example program and logic would have had the
> robot moving.  I am traveling all next week but I would appreciate if
> you sent the e-mail/patch to me directly as well as to the distribution
> list.
>

--
Jon Klippenstein, M.Sc. Candidate
Robotics Research Group
Dept. of Computing Science, University of Alberta
diff -r -u player-1.6.5-orig/server/drivers/mixed/rflex/rflex.cc player-1.6.5/server/drivers/mixed/rflex/rflex.cc
--- player-1.6.5-orig/server/drivers/mixed/rflex/rflex.cc                 2004-12-07 15:08:54.000000000 -0700
+++ player-1.6.5/server/drivers/mixed/rflex/rflex.cc                 2006-03-16 21:30:34.000000000 -0700
@@ -1214,6 +1214,8 @@
            NULL);

    pthread_testcancel();
+
+                 // release cpu somewhat so other threads can run.
+                 usleep(1000);
+
  }
  pthread_exit(NULL);
}
diff -r -u player-1.6.5-orig/server/drivers/mixed/rflex/rflex_commands.cc player-1.6.5/server/drivers/mixed/rflex/rflex_commands.cc
--- player-1.6.5-orig/server/drivers/mixed/rflex/rflex_commands.cc                 2004-11-17 15:00:28.000000000 -0700
+++ player-1.6.5/server/drivers/mixed/rflex/rflex_commands.cc                 2006-03-16 21:31:13.000000000 -0700
@@ -162,6 +162,7 @@
                                  if (count > 0 )
                                                   start = now;
                                  count = (now.tv_sec - start.tv_sec) * 1000000 + (now.tv_usec - start.tv_usec);
+
+                                  // release somewhat so other threads can run.
+                                  usleep(500);
                 } while (count < 10000);
diff -r -u player-2.0.1-orig/server/drivers/mixed/rflex/rflex.cc player-2.0.1/server/drivers/mixed/rflex/rflex.cc
--- player-2.0.1-orig/server/drivers/mixed/rflex/rflex.cc                 2006-01-26 06:31:11.000000000 -0700
+++ player-2.0.1/server/drivers/mixed/rflex/rflex.cc                 2006-05-17 11:26:41.000000000 -0600
@@ -514,7 +514,14 @@
    Lock();
    command = *reinterpret_cast<player_position2d_cmd_vel_t *> (data);
    Unlock();
-    return 0;
+    
+                 // reset command_type since we have a new
+                 // velocity command so we can get into the
+                 // velocity control section in RFLEX::Main()
+                
+                 command_type = 0;
+                
+                 return 0;
  }

  return -1;
@@ -1156,6 +1163,10 @@
    break;
  }
  Unlock();
+
+  // release cpu somewhat so other threads can run.
+  usleep(1000);
+  
  }
  pthread_exit(NULL);
}
diff -r -u player-2.0.1-orig/server/drivers/mixed/rflex/rflex_commands.cc player-2.0.1/server/drivers/mixed/rflex/rflex_commands.cc
--- player-2.0.1-orig/server/drivers/mixed/rflex/rflex_commands.cc                 2005-09-05 23:37:31.000000000 -0600
+++ player-2.0.1/server/drivers/mixed/rflex/rflex_commands.cc                 2006-05-17 11:27:09.000000000 -0600
@@ -166,6 +166,9 @@
                                  if (count > 0 )
                                                   start = now;
                                  count = (now.tv_sec - start.tv_sec) * 1000000 + (now.tv_usec - start.tv_usec);
+
+                                  // release somewhat so other threads can run.
+                                  usleep(500);
                 } while (count < 10000);




Douglas A Few
**************************************************
Idaho National Laboratory
Robotic, and Human Systems Group
Principal Research Scientist  
208 526-3077
208 526-4750  robot lab
www.inel.gov/adaptiverobotics
**************************************************



"Eric Innis" <eric.innis@gmail.com>
Sent by: playerstage-users-bounces@lists.sourceforge.net

06/26/2006 02:31 PM
Please respond to
playerstage-users@lists.sourceforge.net

To
playerstage-users@lists.sourceforge.net
cc
Subject
[Playerstage-users] rFlex broken for Magellans





I have been getting player 2.0.1 to work for our RWI/irobot Magellan
Pro robots running rFlex v.2.2.2.  Currently I have all the sensors
working, however the robot does not respond to motion commands.  Upon
further research I found that the rFlex driver had been changed to
work for the b21 robots, which I have been told use a slightly
different rFlex protocol.  If anyone has a fix for the problem or any
additional information about the difference between the two protocols
I would greatly appreciate it.

Thank you,

--
Eric Innis
Georgia Institute of Technology
Electrical and Computer Engineering: GRITS Lab.
Aerospace Engineering: Computational Combustion Lab.
404.312.0950

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Playerstage-users mailing list
Playerstage-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-users