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    try
00014    {
00015       PlayerClient robot(gHostname, gPort);
00016       Position2dProxy pp(&robot, gIndex);
00017    
00018       // Speed and turn settings
00019       double turn_rate = -0.5;
00020       double move_speed = 0.20;
00021       
00022       timespec move_sleep = { 5, 0 };
00023       timespec turn_sleep = { 3, 0 };
00024       timespec stop_sleep = { 10, 0 };
00025    
00026       // read from the proxies
00027       robot.Read();
00028    
00029       // move 1, turn 1
00030       pp.SetSpeed(move_speed, 0);
00031       nanosleep(&move_sleep, NULL);
00032       pp.SetSpeed(0, turn_rate);
00033       nanosleep(&turn_sleep, NULL);
00034    
00035       // move 2, turn 2
00036       pp.SetSpeed(move_speed, 0);
00037       nanosleep(&move_sleep, NULL);
00038       pp.SetSpeed(0, turn_rate);
00039       nanosleep(&turn_sleep, NULL);
00040    
00041       // move 3, turn 3
00042       pp.SetSpeed(move_speed, 0);
00043       nanosleep(&move_sleep, NULL);
00044       pp.SetSpeed(0, turn_rate);
00045       nanosleep(&turn_sleep, NULL);
00046    
00047       // move 4, turn 4
00048       pp.SetSpeed(move_speed, 0);
00049       nanosleep(&move_sleep, NULL);
00050       pp.SetSpeed(0, turn_rate);
00051       nanosleep(&turn_sleep, NULL);
00052    
00053       // Set motor stop command and wait so they can propagate
00054       pp.SetSpeed(0, 0);
00055       nanosleep(&stop_sleep, NULL);
00056    } //end try
00057   catch (PlayerCc::PlayerError e)
00058   {
00059    std::cerr << e << std::endl;
00060     return -1;
00061   }
00062 }

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