mpMain.c
Go to the documentation of this file.
1 /* mp_main.c - MotoPlus Test Application for Real Time Process */
2 // History:
3 // 06/12/2013: Fix reply to ROS_MSG_JOINT_TRAJ_PT_FULL message
4 // 06/12/2013: Release v.1.0.1
5 // 07/15/2013: Added DX100 compiler option
6 // Change "REMOTE" mode I/O signal to #80011
7 // Listen for skill send
8 // 08/14/2013: Check initialization success and added extra I/O Feedback
9 // Release v.1.1.1
10 // June 2014: Release v1.2.0
11 // Add support for multiple control groups.
12 // Add support for DX200 controller.
13 /*
14 * Software License Agreement (BSD License)
15 *
16 * Copyright (c) 2013, Yaskawa America, Inc.
17 * All rights reserved.
18 *
19 * Redistribution and use in binary form, with or without modification,
20 * is permitted provided that the following conditions are met:
21 *
22 * * Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * * Neither the name of the Yaskawa America, Inc., nor the names
26 * of its contributors may be used to endorse or promote products derived
27 * from this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
33 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 */
41 
42 #include "MotoROS.h"
43 
44 
45 #ifdef DEBUG
46  #warning Debug messages in MotoPlus *will* affect application performance (disable this in SimpleMessage.h)
47 #endif
48 
49 //GLOBAL DATA DEFINITIONS
50 
51 void RosInitTask();
53 
54 void mpUsrRoot(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10)
55 {
56 
57 #ifdef DX100
58  Ros_Sleep(10000); // 10 sec. delay to enable DX100 system to complete initialization
59 #endif
60 
61  //Creates and starts a new task in a seperate thread of execution.
62  //All arguments will be passed to the new task if the function
63  //prototype will accept them.
64  RosInitTaskID = mpCreateTask(MP_PRI_TIME_NORMAL, MP_STACK_SIZE, (FUNCPTR)RosInitTask,
65  arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
66  if (RosInitTaskID == ERROR)
67  mpSetAlarm(8004, "MOTOROS FAILED TO CREATE TASK", 1);
68 
69  //Ends the initialization task.
70  mpExitUsrRoot;
71 }
72 
74 {
75  Controller ros_controller;
76 
77  if(!Ros_Controller_Init(&ros_controller))
78  {
79  //set feedback signal to notify failure
81  mpDeleteSelf;
82  return;
83  }
84 
85  ros_controller.tidConnectionSrv = mpCreateTask(MP_PRI_TIME_NORMAL, MP_STACK_SIZE,
87  (int)&ros_controller, 0, 0, 0, 0, 0, 0, 0, 0, 0);
88 
89  if(ros_controller.tidConnectionSrv == ERROR)
90  mpSetAlarm(8004, "MOTOROS FAILED TO CREATE TASK", 2);
91 
92 #ifdef DX100
93  // DX100 need to execute a SKILLSEND command prior to the WAIT in order for the
94  // incremental motion function to work. These tasks monitor for those commands
95  // This supports a maximum of two robots which should be assigned to slave id
96  // MP_SL_ID1 and MP_SL_ID2 respectively.
97 
98  // first robot
99  ros_controller.RosListenForSkillID[0] = mpCreateTask(MP_PRI_TIME_NORMAL, MP_STACK_SIZE,
100  (FUNCPTR)Ros_Controller_ListenForSkill,
101  (int)&ros_controller, MP_SL_ID1, 0, 0, 0, 0, 0, 0, 0, 0);
102  // if second robot
103  if(ros_controller.numRobot > 1)
104  {
105  ros_controller.RosListenForSkillID[1] = mpCreateTask(MP_PRI_TIME_NORMAL, MP_STACK_SIZE,
106  (FUNCPTR)Ros_Controller_ListenForSkill,
107  (int)&ros_controller, MP_SL_ID2, 0, 0, 0, 0, 0, 0, 0, 0);
108  }
109  else
110  {
111  ros_controller.RosListenForSkillID[1] = INVALID_TASK;
112  }
113 #endif
114 
115  // start loop to monitor controller state
116  FOREVER
117  {
118  // Check controller status
119  if (!Ros_Controller_StatusUpdate(&ros_controller))
120  puts("Failed to update controller status. Check robot parameters.");
121 
123  }
124 }
125 
void Ros_Controller_SetIOState(ULONG signal, BOOL status)
Definition: Controller.c:793
BOOL Ros_Controller_Init(Controller *controller)
Definition: Controller.c:99
#define INVALID_TASK
Definition: Controller.h:68
int tidConnectionSrv
Definition: Controller.h:127
#define IO_FEEDBACK_FAILURE
Definition: Controller.h:46
void mpUsrRoot(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10)
Definition: mpMain.c:54
void Ros_Controller_ConnectionServer_Start(Controller *controller)
Definition: Controller.c:314
#define CONTROLLER_STATUS_UPDATE_PERIOD
Definition: Controller.h:78
void RosInitTask()
Definition: mpMain.c:73
void Ros_Sleep(float milliseconds)
Definition: Controller.c:999
BOOL Ros_Controller_StatusUpdate(Controller *controller)
Definition: Controller.c:695
int RosInitTaskID
Definition: mpMain.c:52


motoman_driver
Author(s): Jeremy Zoss (Southwest Research Institute), Ted Miller (MotoROS) (Yaskawa Motoman), Eric Marcil (MotoROS) (Yaskawa Motoman)
autogenerated on Sat May 8 2021 02:27:44