mk_test3.cpp
Go to the documentation of this file.
00001 /*
00002  * mk_test1.cpp
00003  *
00004  *  Created on: Nov 25, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #include <tk_mkinterface/MKInterfaceConnection.hpp>
00009 
00010 #include <tk_mkinterface/MKData.hpp>
00011 
00012 #include <telekyb_base/TeleKyb.hpp>
00013 
00014 #include <ros/ros.h>
00015 
00016 using namespace telekyb;
00017 
00018 
00019 
00020 int main(int argc, char **argv) {
00021 
00022 
00023         TeleKyb::init(argc,argv,"mk_test3");
00024 
00025 #ifdef __APPLE__
00026         MKInterfaceConnection* c = new MKInterfaceConnection("/dev/tty.usbserial-A600eG5l");
00027 #else
00028         MKInterfaceConnection* c = new MKInterfaceConnection("/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A600eG5l-if00-port0");
00029 #endif
00030         if (c->isOpen()) {
00031                 c->updateValue(MKDataDefines::FIRMWARE_REVISION);
00032 
00033                 MKValue* robotID = c->getMKDataRef().getValueByID(MKDataDefines::ROBOT_ID);
00034                 ROS_INFO("PRE RobotID: %d", robotID->getValue());
00035                 ROS_INFO_STREAM("PRE Time: " << robotID->getStamp().dateTimeToString());
00036 
00037                 c->updateValue(MKDataDefines::ROBOT_ID);
00038 
00039                 ROS_INFO("Post RobotID: %d", robotID->getValue());
00040                 ROS_INFO_STREAM("POST Time: " << robotID->getStamp().dateTimeToString());
00041 
00042 
00043                 MKValue* mirrorActive = c->getMKDataRef().getValueByID(MKDataDefines::MIRROR_DATA_ACTIVE);
00044 
00045 
00046                 c->updateValue(mirrorActive->getID());
00047                 ROS_INFO("MirrorActive: %d", mirrorActive->getValue());
00048 
00049                 // set Init!
00050                 if ( c->setValue(mirrorActive->getMKSingleValuePacketWithValue(1)) ) {
00051                         ROS_INFO("Set Successful!");
00052                 }
00053 
00054                 sleep(5);
00055                 MKActiveIDs pattern = c->getMKDataRef().getPattern(MKDataPattern::RawImuAttEst);
00056                 c->setActiveDataIDs(pattern);
00057 
00058 
00059 //              MotorState state(motorState->getValue());
00060 //              ROS_INFO("Current Motorstate: %s, %d", state.str(), state.value());
00061 //
00062                 sleep(5);
00063                 MKValue* motorState = c->getMKDataRef().getValueByID(MKDataDefines::MOTOR_STATE);
00064                 c->setValue(motorState->getMKSingleValuePacketWithValue(MotorState::Init));
00065 
00066                 sleep(5);
00067                 c->setValue(motorState->getMKSingleValuePacketWithValue(MotorState::Off));
00068 
00069 
00070 
00071         }
00072 
00073         ros::waitForShutdown();
00074 
00075         delete c;
00076 
00077         TeleKyb::shutdown();
00078 
00079         return EXIT_SUCCESS;
00080 }
00081 
00082 
00083 
00084 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


tk_mkinterface
Author(s): Martin Riedel
autogenerated on Wed Apr 24 2013 11:29:54