Go to the documentation of this file.00001
00002
00003
00004
00005
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_test1");
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
00032
00033 c->updateValue(MKDataDefines::FIRMWARE_REVISION);
00034
00035 MKValue* mkRobotID = c->getMKDataRef().getValueByID(MKDataDefines::ROBOT_ID);
00036 ROS_INFO("PRE RobotID: %d", mkRobotID->getValue());
00037 ROS_INFO_STREAM("PRE Time: " << mkRobotID->getStamp().dateTimeToString());
00038
00039 c->updateValue(MKDataDefines::ROBOT_ID);
00040
00041 ROS_INFO("Post RobotID: %d", mkRobotID->getValue());
00042 ROS_INFO_STREAM("POST Time: " << mkRobotID->getStamp().dateTimeToString());
00043
00044
00045 MKValue* motorState = c->getMKDataRef().getValueByID(MKDataDefines::MOTOR_STATE);
00046 c->updateValue(MKDataDefines::MOTOR_STATE);
00047
00048
00049 ROS_INFO("MotorState: %d", motorState->getValue());
00050
00051 MotorState state(motorState->getValue());
00052 ROS_INFO("Current Motorstate: %s, %d", state.str(), state.value());
00053
00054
00055
00056
00057 if ( c->setValue(motorState->getMKSingleValuePacketWithValue(MotorState::Init)) ) {
00058 ROS_INFO("Set Successful!");
00059 }
00060
00061
00062 c->updateValue(MKDataDefines::MOTOR_STATE);
00063
00064 state = (MotorState)motorState->getValue();
00065 ROS_INFO("Current Motorstate: %s, %d", state.str(), state.value());
00066
00067 sleep(5);
00068
00069 if ( c->setValue(motorState->getMKSingleValuePacketWithValue(MotorState::On)) ) {
00070 ROS_INFO("Set Successful!");
00071 }
00072
00073 sleep(10);
00074
00075
00076 if ( c->setValue(motorState->getMKSingleValuePacketWithValue(MotorState::Off)) ) {
00077 ROS_INFO("Set Successful!");
00078 }
00079
00080
00081 c->updateValue(MKDataDefines::MOTOR_STATE);
00082
00083 state = (MotorState)motorState->getValue();
00084 ROS_INFO("Current Motorstate: %s, %d", state.str(), state.value());
00085
00086 }
00087
00088 delete c;
00089
00090 TeleKyb::shutdown();
00091
00092 return EXIT_SUCCESS;
00093 }
00094
00095
00096
00097