main.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 #include <stdio.h>
00003 #include <libplayerc++/playerc++.h>
00004 #include <args.h>
00005 using namespace PlayerCc;
00006 
00007 int
00008 main(int argc, char *argv[])
00009 {
00010    // Parse input arguments
00011   parse_args(argc,argv);
00012 
00013    
00014   // libplayerc++ throws a PlayerError exception when
00015   // it runs into trouble
00016    // The PlayerError is often more readable...
00017    try
00018    {
00019       PlayerClient robot(gHostname, gPort);
00020       Position2dProxy pp(&robot, gIndex);
00021 
00022       // Speed and turn settings
00023       double turnrate = dtor(0);
00024       double speed = 0.30;
00025 
00026       // read from the proxies
00027        robot.Read();
00028      
00029       // command the motors
00030       pp.SetCarlike(speed, turnrate);
00031       timespec sleep = {5, 0};
00032       nanosleep(&sleep, NULL);
00033     
00034       
00035       turnrate = dtor(-20);
00036        speed = 0.300;
00037       // command the motors
00038        pp.SetCarlike(speed, turnrate);
00039       nanosleep(&sleep, NULL);
00040   
00041       
00042       turnrate = dtor(0);
00043          speed = 0.300;
00044          // command the motors
00045          pp.SetCarlike(speed, turnrate);
00046     // Sleep for 5 seconds.  During this time, callbacks should be
00047       // fired on every read and output should show up on the display.
00048       nanosleep(&sleep, NULL);
00049   
00050       
00051       turnrate = dtor(-20);
00052       speed = 0.300;
00053       // command the motors
00054       pp.SetCarlike(speed, turnrate);
00055     // Sleep for 5 seconds.  During this time, callbacks should be
00056      // fired on every read and output should show up on the display.
00057    nanosleep(&sleep, NULL);
00058   
00059       // stopping
00060       turnrate = dtor(0);
00061    speed = 0;
00062      pp.SetCarlike(speed, turnrate);
00063    } //end try
00064   catch (PlayerCc::PlayerError e)
00065   {
00066     std::cerr << e << std::endl;
00067     return -1;
00068   } //end catch
00069 } //end main

Generated on Sat Jan 13 03:11:09 2007 for ERSP Player driver by  doxygen 1.5.1