Esempio n. 1
0
/* The CANbus card must be initialized and called from a realtime thread.
 * The rt_thread is spun off from main() to handle the initial communications.
 */
void can_thd_function(void *thd)
{
   int err;

   /* Probe and initialize the robot actuators */
   err = InitializeSystem();
   if(err) {
      syslog(LOG_ERR, "InitializeSystem returned err = %d", err);
      exit(1);
   }
    
   /* Initialize and get a handle to the robot on the first bus */
   if (ignore_calibration)
      wam = OpenWAM("*../../wam.conf", 0);
   else
      wam = OpenWAM("../../wam.conf", 0);   
   if(!wam)
   {
      syslog(LOG_ERR, "OpenWAM failed");
      exit(1);
   }
   
   /* setSafetyLimits(bus, joint rad/s, tip m/s, elbow m/s);
    * For now, the joint and tip velocities are ignored and
    * the elbow velocity provided is used for all three limits.
    */
   setSafetyLimits(0, 1.5, 1.5, 1.5);  // Limit to 1.5 m/s

   /* Set the puck torque safety limits (TL1 = Warning, TL2 = Critical).
    * Note: The pucks are limited internally to 3441 (see 'MT' in btsystem.c) 
    * Note: btsystem.c bounds the outbound torque to 8191, so entering a
    * value of 9000 for TL2 would tell the safety system to never register a 
    * critical fault.
    */
   setProperty(0, SAFETY_MODULE, TL2, FALSE, 4700);
   setProperty(0, SAFETY_MODULE, TL1, FALSE, 1800);
   
   /* Notify main() thread that the initialization is complete */
   startDone = 1;
   
   /* Spin until we are told to exit */
   while (!btrt_thread_done((btrt_thread_struct*)thd))
      usleep(10000);
   
   /* Close the system */
   CloseSystem();
   
   /* Remove this thread from the realtime scheduler */
   btrt_thread_exit((btrt_thread_struct*)thd);
}
Esempio n. 2
0
/* Exit the realtime threads and close the system */
void Cleanup(){
   /* Turn off Datalogging */
   DLoff(&(wam->log));
   
   wam_thd.done = TRUE;
   usleep(10000);
   
   /* Close the log file */
   CloseDL(&(wam->log));
   
   /* Decode the file from binary->text */
   DecodeDL("datafile.dat", "dat.csv", 1);
   
   CloseSystem();
   rt_thd.done = TRUE;
   printf("\n\n");
}
Esempio n. 3
0
CSoundPlayer::~CSoundPlayer()
{
	if (system) CloseSystem();
	delete[] channel;
	delete[] sound;
}