mpMain.c
Go to the documentation of this file.
00001 /* mp_main.c - MotoPlus Test Application for Real Time Process */
00002 // History:
00003 // 06/12/2013: Fix reply to ROS_MSG_JOINT_TRAJ_PT_FULL message
00004 // 06/12/2013: Release v.1.0.1
00005 // 07/15/2013: Added DX100 compiler option
00006 //                 Change "REMOTE" mode I/O signal to #80011
00007 //                         Listen for skill send
00008 // 08/14/2013: Check initialization success and added extra I/O Feedback 
00009 //             Release v.1.1.1
00010 // June 2014:   Release v1.2.0
00011 //                              Add support for multiple control groups.
00012 //                              Add support for DX200 controller.
00013 /*
00014 * Software License Agreement (BSD License) 
00015 *
00016 * Copyright (c) 2013, Yaskawa America, Inc.
00017 * All rights reserved.
00018 *
00019 * Redistribution and use in binary form, with or without modification,
00020 * is permitted provided that the following conditions are met:
00021 *
00022 *       * Redistributions in binary form must reproduce the above copyright
00023 *       notice, this list of conditions and the following disclaimer in the
00024 *       documentation and/or other materials provided with the distribution.
00025 *       * Neither the name of the Yaskawa America, Inc., nor the names 
00026 *       of its contributors may be used to endorse or promote products derived
00027 *       from this software without specific prior written permission.
00028 *
00029 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00030 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00031 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00032 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00033 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00034 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00035 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00036 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00037 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00038 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00039 * POSSIBILITY OF SUCH DAMAGE.
00040 */ 
00041 
00042 #include "MotoROS.h"
00043 
00044 
00045 #ifdef DEBUG
00046         #warning Debug messages in MotoPlus *will* affect application performance (disable this in SimpleMessage.h)
00047 #endif
00048 
00049 //GLOBAL DATA DEFINITIONS
00050 
00051 void RosInitTask();
00052 int RosInitTaskID;
00053 
00054 void mpUsrRoot(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10)
00055 {
00056 
00057 #ifdef DX100
00058         Ros_Sleep(10000);  // 10 sec. delay to enable DX100 system to complete initialization
00059 #endif
00060         
00061         //Creates and starts a new task in a seperate thread of execution.
00062         //All arguments will be passed to the new task if the function
00063         //prototype will accept them.
00064         RosInitTaskID = mpCreateTask(MP_PRI_TIME_NORMAL, MP_STACK_SIZE, (FUNCPTR)RosInitTask,
00065                                                 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
00066                                                                         
00067         //Ends the initialization task.
00068         mpExitUsrRoot;
00069 }
00070 
00071 void RosInitTask()
00072 {
00073         Controller ros_controller;
00074 
00075         if(!Ros_Controller_Init(&ros_controller))
00076         {
00077                 //set feedback signal to notify failure
00078                 Ros_Controller_SetIOState(IO_FEEDBACK_FAILURE, TRUE);
00079                 mpDeleteSelf;
00080                 return;
00081         }
00082 
00083         ros_controller.tidConnectionSrv = mpCreateTask(MP_PRI_TIME_NORMAL, MP_STACK_SIZE, 
00084                                                 (FUNCPTR)Ros_Controller_ConnectionServer_Start,
00085                                                 (int)&ros_controller, 0, 0, 0, 0, 0, 0, 0, 0, 0);
00086                 
00087 #ifdef DX100
00088         // DX100 need to execute a SKILLSEND command prior to the WAIT in order for the 
00089         // incremental motion function to work.  These tasks monitor for those commands
00090         // This supports a maximum of two robots which should be assigned to slave id
00091         // MP_SL_ID1 and MP_SL_ID2 respectively.
00092         
00093         // first robot
00094         ros_controller.RosListenForSkillID[0] = mpCreateTask(MP_PRI_TIME_NORMAL, MP_STACK_SIZE, 
00095                                                 (FUNCPTR)Ros_Controller_ListenForSkill,
00096                                                 (int)&ros_controller, MP_SL_ID1, 0, 0, 0, 0, 0, 0, 0, 0);
00097         // if second robot
00098         if(ros_controller.numRobot > 1)
00099         {
00100                 ros_controller.RosListenForSkillID[1] = mpCreateTask(MP_PRI_TIME_NORMAL, MP_STACK_SIZE, 
00101                                                         (FUNCPTR)Ros_Controller_ListenForSkill,
00102                                                         (int)&ros_controller, MP_SL_ID2, 0, 0, 0, 0, 0, 0, 0, 0);       
00103         }
00104         else
00105         {
00106                 ros_controller.RosListenForSkillID[1] = INVALID_TASK;
00107         }
00108 #endif
00109                 
00110         // start loop to monitor controller state
00111         FOREVER
00112         {
00113                 // Check controller status
00114                 if (!Ros_Controller_StatusUpdate(&ros_controller))
00115                         puts("Failed to update controller status.  Check robot parameters.");
00116         
00117                 Ros_Sleep(CONTROLLER_STATUS_UPDATE_PERIOD);
00118         }
00119 }
00120 


motoman_driver
Author(s): Jeremy Zoss (Southwest Research Institute)
autogenerated on Sat Jun 8 2019 19:06:58