mp_default_main.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  * Copyright (c) 2011, Southwest Research Institute
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 Southwest Research Institute, 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 #include "mp_default_main.h"
00033 #include "log_wrapper.h"
00034 #include "tcp_server.h"
00035 #include "message_manager.h"
00036 #include "input_handler.h"
00037 #include "joint_motion_handler.h"
00038 #include "joint_data.h"
00039 #include "joint_message.h"
00040 #include "simple_message.h"
00041 #include "ros_conversion.h"
00042 #include "mp_wrapper.h"
00043 
00044 #include "motoPlus.h"
00045 
00046 
00047 namespace motoman
00048 {
00049 namespace mp_default_main
00050 {
00051 
00052 void motionServer(void)
00053 // Persistent UDP server that receives motion messages from Motoros node (ROS interface) and relays to parseMotionMessage
00054 {
00055 
00056     using namespace industrial::simple_socket;
00057     using namespace industrial::tcp_server;
00058     using namespace industrial::message_manager;
00059     using namespace industrial::simple_message;
00060     using namespace motoman::joint_motion_handler;
00061   
00062     TcpServer connection;
00063     JointMotionHandler jmHandler;
00064     
00065     MessageManager manager;
00066     
00067     connection.init(StandardSocketPorts::MOTION);
00068     
00069 
00070     connection.makeConnect();
00071     
00072     manager.init(&connection);
00073     
00074     jmHandler.init(StandardMsgTypes::JOINT, &connection);
00075     manager.add(&jmHandler);
00076     manager.spin();
00077 
00078 
00079 }
00080 
00081 
00082 void systemServer(void)
00083 // Persistent UDP server that receives system messages from Motoros node (ROS interface) and relays to parseSystemMessage
00084 {
00085 
00086     using namespace industrial::simple_socket;
00087     using namespace industrial::tcp_server;
00088     using namespace industrial::message_manager;
00089     
00090     TcpServer connection;
00091     MessageManager manager;
00092     
00093     connection.init(StandardSocketPorts::SYSTEM);
00094     connection.makeConnect();
00095     
00096     manager.init(&connection);
00097     manager.spin();
00098 
00099 }
00100 
00101 
00102 
00103 void stateServer(void)
00104 {
00105 
00106     using namespace industrial::simple_socket;
00107     using namespace industrial::tcp_server;
00108     using namespace industrial::joint_message;
00109     using namespace industrial::joint_data;
00110     using namespace industrial::simple_message;
00111     using namespace motoman::ros_conversion;
00112     using namespace motoman::mp_wrapper;
00113     
00114     // Using TPC server for debugging (this should really be UDP)
00115     TcpServer connection;
00116     JointData rosJoints;
00117     JointMessage msg;
00118     SimpleMessage simpMsg;
00119     
00120     const int period = 100; //ticks
00121     
00122     connection.init(StandardSocketPorts::STATE);
00123     
00124     FOREVER
00125     {
00126       connection.makeConnect();
00127       
00128       while(connection.isConnected())
00129       {
00130         getRosFbPos(rosJoints);
00131         msg.init(0, rosJoints);
00132         msg.toTopic(simpMsg);
00133         connection.sendMsg(simpMsg);
00134         
00135         mpTaskDelay(period);
00136         
00137         
00138       }
00139       
00140 
00141     }
00142 
00143 }
00144 
00145 
00146 
00147 void ioServer(void)
00148 {
00149 /*
00150 
00151     using namespace industrial::simple_socket;
00152     using namespace industrial::tcp_server;
00153     using namespace industrial::message_manager;
00154     using namespace industrial::simple_message;
00155     using namespace motoman::input_handler;
00156     
00157     TcpServer connection;
00158     InputHandler iHandler;
00159     MessageManager manager;
00160     
00161     connection.init(StandardSocketPorts::IO);
00162     connection.makeConnect();
00163     
00164     manager.init(&connection);
00165     
00166     iHandler.init(StandardMsgTypes::WRITE_OUTPUT, &connection);
00167     manager.add(&iHandler);
00168     manager.spin();
00169  */
00170 
00171     
00172 }
00173 
00174 
00175 } //mp_wrapper
00176 } //motoman


dx100
Author(s): Shaun Edwards (Southwest Research Institute)
autogenerated on Thu Jan 2 2014 11:29:36