Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 import rospy
00020 import random
00021 from airbus_ssm_core import ssm_state
00022
00023 class Test1(ssm_state.ssmState):
00024 '''@SSM
00025 Description : Test skill that add +1 to a user data test and return sucess.
00026 User-data :
00027 - test : an int (if not created in the datamodel will be init to 0)
00028 Outcome :
00029 - success : sucessfully add +1 or created the data test
00030 '''
00031 def __init__(self):
00032 ssm_state.ssmState.__init__(self,outcomes=["success"], io_keys=["test"])
00033
00034 def execution(self, ud):
00035 rospy.sleep(2)
00036 if("test" in ud):
00037 ud.test = int(ud.test) + 1
00038 else:
00039 ud.test = 0
00040 print("Test : " + str(ud.test))
00041 return "success"
00042
00043 class Test2(ssm_state.ssmState):
00044 '''@SSM
00045 Description : A test state with a random outcomes using an inside counter
00046 User-data : None
00047 Outcome :
00048 - success : test if the counter inside the state is above 10
00049 - retry : test if the counter inside the state is above 5 and below 10
00050 - next : test if the counter inside the state is above 0 and below 5
00051 '''
00052 def __init__(self):
00053 ssm_state.ssmState.__init__(self,outcomes=["success","retry","next"])
00054 self.cpt_ = 0
00055
00056 def execution(self, ud):
00057 rospy.sleep(1)
00058 choice = random.randint(1,3)
00059 self.cpt_ = self.cpt_ + choice
00060 if(self.cpt_ > 10):
00061 print("Test2 : success")
00062 return "success"
00063 elif(self.cpt_ > 5):
00064 print("Test2 : Retry")
00065 return "retry"
00066 elif(self.cpt_> 0):
00067 print("Test2 : Next")
00068 return "next"
00069 else:
00070 print("Test2 : success")
00071 return "success"
00072
00073 class Test3(ssm_state.ssmState):
00074 '''@SSM
00075 Description : A test state with a random outcomes with a 50/50.
00076 User-data : None
00077 Outcome :
00078 - success : if the random int is equal to 1
00079 - failed : otherwise
00080 '''
00081 def __init__(self):
00082 ssm_state.ssmState.__init__(self,outcomes=["success","failed"])
00083
00084 def execution(self, ud):
00085 rospy.sleep(1)
00086 choice = random.randint(1,2)
00087 if(choice == 1):
00088 print("Test3 : success")
00089 return "success"
00090 else:
00091 print("Test3 : failed")
00092 return "failed"
00093
00094
00095
00096
00097
00098
00099
00100