qa_player_setmotor.cpp

00001 
00002 /***************************************************************************
00003  *  qa_player_setmotor.cpp - Player QA App: set motor values
00004  *
00005  *  Created: Tue Sep 30 23:40:57 2008
00006  *  Copyright  2006-2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #include <blackboard/remote.h>
00024 #include <interfaces/MotorInterface.h>
00025 
00026 #include <unistd.h>
00027 #include <cstdio>
00028 
00029 using namespace fawkes;
00030 
00031 int
00032 main(int argc, char **argv)
00033 {
00034   BlackBoard *bb = new RemoteBlackBoard("localhost", 1910);
00035 
00036   MotorInterface *motor = bb->open_for_reading<MotorInterface>("Player Motor");
00037   motor->read();
00038 
00039   printf("Motor x=%f   y=%f   z=%f\n",
00040          motor->odometry_position_x(), motor->odometry_position_y(),
00041          motor->odometry_orientation());
00042 
00043   printf("Setting relative (2, 0, 0), this is (%f, %f, %f) global\n",
00044          motor->odometry_position_x() + 2, motor->odometry_position_y(),
00045          motor->odometry_orientation());
00046 
00047   motor->msgq_enqueue(new MotorInterface::GotoMessage(motor->odometry_position_x() + 2,
00048                                                       motor->odometry_position_y(),
00049                                                       motor->odometry_orientation(),
00050                                                       1 /* sec */));
00051 
00052   bb->close(motor);
00053 
00054   delete bb;
00055   return 0;
00056 }