battery_test.cc: Application that writes the Roomba's battery status to stdout repeatedly
authorsvnhieber <svnhieber@f8795833-4959-0410-8ae9-8bcb0cfab428>
Wed, 1 Dec 2010 21:09:16 +0000 (21:09 +0000)
committersvnhieber <svnhieber@f8795833-4959-0410-8ae9-8bcb0cfab428>
Wed, 1 Dec 2010 21:09:16 +0000 (21:09 +0000)
git-svn-id: https://svn.itm.uni-luebeck.de/wisebed/wiselib/trunk/pc_apps/roomba_tests@3660 f8795833-4959-0410-8ae9-8bcb0cfab428

Makefile
battery_test.cc [new file with mode: 0644]

index be04c1b..752a33f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,3 +6,6 @@ export CXXFLAGS=-I/usr/include/qt4 -I/usr/include/qt4/QtCore \
        -I/usr/include/QtGui -lQtGui 
 
 include ../Makefile.base
+
+battery_test: battery_test.cc
+       $(CXX) -I$(WISELIB_STABLE) -I$(WISELIB_TESTING) -lpthread -o battery_test battery_test.cc
diff --git a/battery_test.cc b/battery_test.cc
new file mode 100644 (file)
index 0000000..e884c42
--- /dev/null
@@ -0,0 +1,75 @@
+/**
+ * @file battery_test.cc
+ * @date 1 Dec 2010
+ * @author Roland Hieber <rohieb@rohieb.name>
+ *
+ * Application that writes the Roomba's battery status to stdout repeatedly.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <iostream>
+#include <stdint.h>
+#include <external_interface/pc/pc_os_model.h>
+#include <external_interface/pc/pc_com_uart.h>
+#include <external_interface/pc/pc_timer.h>
+#include <intermediate/robot/roomba/roomba.h>
+#include <intermediate/robot/controlled_motion.h>
+
+using namespace std;
+
+// UART port on which we communicate with the Roomba
+char uart[] = "/dev/ttyUSB0";
+
+typedef wiselib::PCOsModel OsModel;
+typedef wiselib::StandaloneMath Math;
+typedef wiselib::PCComUartModel<OsModel, uart> RoombaUart;
+typedef wiselib::RoombaModel<OsModel, RoombaUart> Roomba;
+typedef wiselib::ControlledMotion<OsModel, Roomba> ControlledMotion;
+
+/**
+ * main function
+ */
+int main(int argc, char ** argv) {
+
+  OsModel::Os os;
+  OsModel::Timer::self_t timer;
+  Roomba roomba;
+  RoombaUart roomba_uart(os);
+  ControlledMotion ctrl_motion;
+
+  // init stuff
+  roomba_uart.set_baudrate(19200);
+  roomba_uart.enable_serial_comm();
+  roomba.init(roomba_uart, timer, Roomba::POSITION
+    | Roomba::BATTERY_AND_TEMPERATURE);
+
+  cout << "Got roomba at " << roomba_uart.address() << endl;
+
+  roomba.reset_distance();
+  roomba.reset_angle();
+  ctrl_motion.init(roomba);
+
+  while(true) {
+    cout << "batt_charge=" << roomba().charge << " batt_capacity="
+      << roomba().capacity << " batt_voltage=" << roomba().voltage
+      << " batt_current=" << roomba().current << endl;
+    sleep(1);
+  }
+}
This page took 0.024606 seconds and 4 git commands to generate.