Update of /cvsroot/playerstage/code/player/server/drivers/mixed/erratic
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv792

Modified Files:
        erratic.cc erratic.h 
Log Message:


Index: erratic.cc
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/mixed/erratic/erratic.cc,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** erratic.cc  18 Dec 2006 06:03:27 -0000      1.11
--- erratic.cc  18 Dec 2006 07:38:20 -0000      1.12
***************
*** 473,477 ****
        }
  
!       printf(" done.\n  Connected to \"%s\", a %s %s\n", name, type, subtype);
  
        // Set the robot type statically for now (there is only one!)
--- 473,477 ----
        }
  
!       printf(" done.\n  Connected to <%s>, a %s %s\n", name, type, subtype);
  
        // Set the robot type statically for now (there is only one!)
***************
*** 691,695 ****
        }
        
!       printf("Erratic has been shutdown");
  
        return(0);
--- 691,695 ----
        }
        
!       printf("Erratic has been shut down");
  
        return(0);
***************
*** 792,796 ****
                //Lock();
                
!               switch(packet.packet[3]) {
                        case (reply_e)motor:
                        case (reply_e)motor+2:
--- 792,797 ----
                //Lock();
                
!               switch(packet.packet[3]) 
!                       {
                        case (reply_e)motor:
                        case (reply_e)motor+2:
***************
*** 802,813 ****
                                }
                                break;
                        case (reply_e)config:
-                               
                                break;
                        case (reply_e)ain:
                                // This data goes in two places, analog input 
and ir rangers
                                erratic_data.aio.voltages_count = 
packet.packet[4];
                                erratic_data.ir.voltages_count = 
RobotParams[this->param_idx]->NumIR;
!                               erratic_data.ir.ranges_count = 2;
                                unsigned int i_voltage;
                                for (i_voltage = 0; i_voltage < 
erratic_data.aio.voltages_count ;i_voltage++) 
--- 803,815 ----
                                }
                                break;
+ 
                        case (reply_e)config:
                                break;
+ 
                        case (reply_e)ain:
                                // This data goes in two places, analog input 
and ir rangers
                                erratic_data.aio.voltages_count = 
packet.packet[4];
                                erratic_data.ir.voltages_count = 
RobotParams[this->param_idx]->NumIR;
!                               erratic_data.ir.ranges_count = 
RobotParams[this->param_idx]->NumIR;;
                                unsigned int i_voltage;
                                for (i_voltage = 0; i_voltage < 
erratic_data.aio.voltages_count ;i_voltage++) 
***************
*** 818,826 ****
                                                                        + 
256*packet.packet[6+i_voltage*2]) * (1.0 / 1024.0) * CPU_VOLTAGE;
                                                
erratic_data.ir.voltages[i_voltage] = (packet.packet[5+i_voltage*2]
!                                                     + 
256*packet.packet[6+i_voltage*2]) * (1.0 / 1024.0) * CPU_VOLTAGE;
!                                               
erratic_data.ir.ranges[i_voltage] = 
IRRangeFromVoltage(erratic_data.ir.voltages[i_voltage]);
                                        }
  
                                // add digital inputs, four E port bits
                                for (int i=0; i < 4; i++) 
                                        {
--- 820,829 ----
                                                                        + 
256*packet.packet[6+i_voltage*2]) * (1.0 / 1024.0) * CPU_VOLTAGE;
                                                
erratic_data.ir.voltages[i_voltage] = (packet.packet[5+i_voltage*2]
!                                                                       + 
256*packet.packet[6+i_voltage*2]) * (1.0 / 1024.0) * CPU_VOLTAGE;
! //                                            
erratic_data.ir.ranges[i_voltage] = 
IRRangeFromVoltage(erratic_data.ir.voltages[i_voltage]);
                                        }
  
                                // add digital inputs, four E port bits
+                               erratic_data.aio.voltages_count += 4;
                                for (int i=0; i < 4; i++) 
                                        {
***************
*** 828,836 ****
                                                        continue;
                                                
erratic_data.aio.voltages[i_voltage+i] = 
!                                                       
(packet.packet[5+i_voltage*2] & (0x1 << i+4)) ? 1 : 0;
!                                               
erratic_data.ir.voltages[i_voltage+1] = 
!                                                       
(packet.packet[5+i_voltage*2] & (0x1 << i+4)) ? 1 : 0;
!                                               
erratic_data.ir.ranges[i_voltage+i] = 
!                IRRangeFromVoltage(erratic_data.ir.voltages[i_voltage+i]);
                                        }
  
--- 831,839 ----
                                                        continue;
                                                
erratic_data.aio.voltages[i_voltage+i] = 
!                                                       
(packet.packet[5+i_voltage*2] & (0x1 << i+4)) ? 1.0 : 0.0;
!                                               erratic_data.ir.voltages[i] = 
!                                                       
(packet.packet[5+i_voltage*2] & (0x1 << i+4)) ? 1.0 : 0.0;
!                                               erratic_data.ir.ranges[i] = 
!                                                       
IRFloorRange(erratic_data.ir.voltages[i]);
                                        }
  
***************
*** 840,843 ****
--- 843,847 ----
                                PublishIR();
                                break;
+ 
                        case (reply_e)debug:
                                if (debug_mode) {
***************
*** 848,851 ****
--- 852,856 ----
                                }
                                break;
+ 
                        default:
                                if (debug_mode) {
***************
*** 853,857 ****
                                        packet.Print();
                                }
!               }
                
                //Unlock();
--- 858,862 ----
                                        packet.Print();
                                }
!                       }
                
                //Unlock();
***************
*** 953,957 ****
  
  // Enable or disable analog input reporting
! void Erratic::ToggleAIn(unsigned char val) {
        unsigned char command[4];
        ErraticPacket *packet = new ErraticPacket();
--- 958,963 ----
  
  // Enable or disable analog input reporting
! void Erratic::ToggleAIn(unsigned char val) 
! {
        unsigned char command[4];
        ErraticPacket *packet = new ErraticPacket();
***************
*** 967,975 ****
  
  // This describes the IR hardware
! float Erratic::IRRangeFromVoltage(float voltage) {
!       // This is values for the Sharp 2Y0A02, 150 cm ranger
        return -.2475 + .1756 * voltage + .7455 / voltage - .0446 * voltage * 
voltage;
  }
  
  
  /** Talking to the Player architecture **/
--- 973,992 ----
  
  // This describes the IR hardware
! float Erratic::IRRangeFromVoltage(float voltage) 
! {
!       // This is for the Sharp 2Y0A02, 150 cm ranger
        return -.2475 + .1756 * voltage + .7455 / voltage - .0446 * voltage * 
voltage;
  }
  
+ float Erratic::IRFloorRange(float value) 
+ {
+       printf("Floor value: %0.1f\n", value);
+       // floor range is 1 (floor present) or 0 (no floor)
+       if (value >= 0.9)
+               return 0.10;                                                    
        // approximate location of floor from sensors
+       else
+               return 1.0;                                                     
                // far away
+ }
+ 
  
  /** Talking to the Player architecture **/
***************
*** 985,989 ****
  
                // Wait for some instructions
!               Wait();
  
                this->Lock();
--- 1002,1007 ----
  
                // Wait for some instructions
!               //              Wait();
!               usleep(10000);                                                  
// Wait() blocks too much, doesn't get subscriptions
  
                this->Lock();

Index: erratic.h
===================================================================
RCS file: 
/cvsroot/playerstage/code/player/server/drivers/mixed/erratic/erratic.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** erratic.h   18 Dec 2006 06:03:27 -0000      1.7
--- erratic.h   18 Dec 2006 07:38:20 -0000      1.8
***************
*** 165,168 ****
--- 165,169 ----
                
    float IRRangeFromVoltage(float voltage);
+   float IRFloorRange(float value);
                
    void StartThreads();


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to