00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2011, Yaskawa America, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions are met: 00009 * 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * * Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * * Neither the name of the Yaskawa America, Inc., nor the names 00016 * of its contributors may be used to endorse or promote products derived 00017 * from this software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00023 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00029 * POSSIBILITY OF SUCH DAMAGE. 00030 */ 00031 00032 00033 #include "ros/ros.h" 00034 #include "simple_message/socket/tcp_client.h" 00035 #include "simple_message/simple_message.h" 00036 #include "simple_message/ping_message.h" 00037 #include <iostream> 00038 00039 using namespace industrial::simple_socket; 00040 using namespace industrial::tcp_client; 00041 using namespace industrial::simple_message; 00042 using namespace industrial::ping_message; 00043 00044 00045 int main(int argc, char** argv) 00046 // Allows user to send commands to the robot 00047 { 00048 char ip[1024] = "192.168.10.3"; // Robot IP address 00049 bool exit = false; 00050 SimpleMessage reply, request; 00051 PingMessage tReply, tRequest; 00052 TcpClient connection; 00053 00054 ROS_INFO("Setting up tcp client"); 00055 connection.init(ip, StandardSocketPorts::SYSTEM); 00056 00057 ROS_INFO("Connecting to server"); 00058 if (connection.makeConnect()) 00059 { 00060 tRequest.init(); 00061 tRequest.toRequest(request); 00062 00063 do { 00064 ROS_INFO("Sending ping"); 00065 connection.sendAndReceiveMsg(request, reply); 00066 ROS_INFO("Ping recieved"); 00067 std::cout << "Type 1 to exit" << std::endl; 00068 std::cin >> exit; 00069 } while (!exit); 00070 00071 tReply.init(reply); 00072 } 00073 00074 00075 00076 /* 00077 int command; 00078 int reply_message[11]; 00079 00080 ros::init(argc, argv, "system_interface"); 00081 ros::NodeHandle n; 00082 00083 MotoSocket sock(buff, SYSTEM_PORT); 00084 00085 while (ros::ok()) 00086 { 00087 cout << "Enter command number (0 to exit) ==> "; 00088 cin >> command; 00089 if (command == 0) 00090 break; 00091 sock.sendMessage(command, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, true); 00092 sock.recvMessage(reply_message, true); 00093 for (short i = 0; i < 11; i++) 00094 cout << reply_message[i] << " "; 00095 cout << endl; 00096 } 00097 */ 00098 return 0; 00099 }