actionlib.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2015 Airbus
00004 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00005 #
00006 # Licensed under the Apache License, Version 2.0 (the "License");
00007 # you may not use this file except in compliance with the License.
00008 # You may obtain a copy of the License at
00009 #
00010 #   http://www.apache.org/licenses/LICENSE-2.0
00011 #
00012 # Unless required by applicable law or agreed to in writing, software
00013 # distributed under the License is distributed on an "AS IS" BASIS,
00014 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 # See the License for the specific language governing permissions and
00016 # limitations under the License.
00017 
00018 from airbus_docgen.digraph.digraph import *
00019 from airbus_docgen.digraph.model.topic import *
00020 from airbus_docgen.digraph.model.package import *
00021 
00022 class IO_TYPE:
00023     Input  = 'Input'
00024     Output = 'Output'
00025 
00026 def getActionTRModel(io_type, topic_name, data_class, bgcolor=RgbColor.White, align = ALIGN.Left):
00027     
00028     model = TR()
00029     
00030     model.addTD(getStandardTDModel(io_type, bgcolor, align))
00031     model.addTD(getStandardTDModel(topic_name, bgcolor, align))
00032     model.addTD(getStandardTDModel(data_class, bgcolor, align))
00033     
00034     return model
00035 
00036 
00037 class ActionClientModel(NODE):
00038     
00039     def __init__(self, server_name, action_msg):
00040         
00041         NODE.__init__(self, server_name)
00042         
00043         table = TABLE()
00044         table.setAttrib(TABLE.BORDER, 0)
00045         table.setAttrib(TABLE.CELLBORDER, 1)
00046         table.setAttrib(TABLE.CELLSPACING, 0)
00047         table.setAttrib(TABLE.BGCOLOR, RgbColor.White)
00048         
00049         title = TD()
00050         title.setAttrib(TD.ALIGN, ALIGN.Center)
00051         title.setAttrib(TD.BGCOLOR, RgbColor.LightGreen)
00052         title.setAttrib(TD.COLSPAN, 3)
00053         title.setText('Action client "%s"'%server_name)
00054         table.addTR(TR(title))
00055         
00056         header = getActionTRModel("I/O", "Topic name", "Message type", bgcolor=RgbColor.LightGray, align=ALIGN.Center)
00057         table.addTR(header)
00058         
00059         goal = getActionTRModel(IO_TYPE.Output, "%s/goal"%server_name, "%sGoal"%action_msg)
00060         table.addTR(goal)
00061         
00062         cancel = getActionTRModel(IO_TYPE.Output, "%s/cancel"%server_name, "actionlib_msgs::GoalID")
00063         table.addTR(cancel)
00064         
00065         status = getActionTRModel(IO_TYPE.Input, "%s/status"%server_name, "actionlib_msgs::GoalStatus")
00066         table.addTR(status)
00067         
00068         feedback = getActionTRModel(IO_TYPE.Input, "%s/feedback"%server_name, "%sFeedback"%action_msg)
00069         table.addTR(feedback)
00070         
00071         result = getActionTRModel(IO_TYPE.Input, "%s/result"%server_name, "%sResult"%action_msg)
00072         table.addTR(result)
00073         
00074         self.setHtml(table)
00075     
00076 class ActionServerModel(NODE):
00077     
00078     def __init__(self, server_name, action_msg):
00079         
00080         NODE.__init__(self, server_name)
00081         
00082         table = TABLE()
00083         table.setAttrib(TABLE.BORDER, 0)
00084         table.setAttrib(TABLE.CELLBORDER, 1)
00085         table.setAttrib(TABLE.CELLSPACING, 0)
00086         table.setAttrib(TABLE.BGCOLOR, RgbColor.White)
00087         
00088         title = TD()
00089         title.setAttrib(TD.ALIGN, ALIGN.Center)
00090         title.setAttrib(TD.BGCOLOR, RgbColor.LightGreen)
00091         title.setAttrib(TD.COLSPAN, 3)
00092         title.setText('Action server "%s"'%server_name)
00093         table.addTR(TR(title))
00094         
00095         header = getActionTRModel("I/O", "Topic name", "Message type", bgcolor=RgbColor.LightGray, align=ALIGN.Center)
00096         table.addTR(header)
00097         
00098         goal = getActionTRModel(IO_TYPE.Input, "%s/goal"%server_name, "%sGoal"%action_msg)
00099         table.addTR(goal)
00100         
00101         cancel = getActionTRModel(IO_TYPE.Input, "%s/cancel"%server_name, "actionlib_msgs::GoalID")
00102         table.addTR(cancel)
00103         
00104         status = getActionTRModel(IO_TYPE.Output, "%s/status"%server_name, "actionlib_msgs::GoalStatus")
00105         table.addTR(status)
00106         
00107         feedback = getActionTRModel(IO_TYPE.Output, "%s/feedback"%server_name, "%sFeedback"%action_msg)
00108         table.addTR(feedback)
00109         
00110         result = getActionTRModel(IO_TYPE.Output, "%s/result"%server_name, "%sResult"%action_msg)
00111         table.addTR(result)
00112         
00113         self.setHtml(table)
00114         
00115 def digraph_test():
00116     
00117     digraph = Digraph("digraph_test")
00118     digraph.setAttrib(Digraph.NODESEP, 0.8)
00119     
00120     nconf = NODE("node")
00121     nconf.setAttrib(NODE.SHAPE, SHAPE.Plaintext)
00122     digraph.addNode(nconf)
00123     
00124     pkg = NODE("joint_trajectory_executor_node")
00125     pkg.setAttrib(NODE.SHAPE, SHAPE.Ellipse)
00126     pkg.setAttrib(NODE.STYLE, STYLE.FILLED)
00127     pkg.setAttrib(NODE.COLOR, RgbColor.CornflowerBlue)
00128     pkg.setAttrib(NODE.FONTSIZE, 22)
00129     digraph.addNode(pkg)
00130     
00131     ns = ActionServerModel("/joint_path_command", "trajectory_msgs::JointTrajectory")
00132     digraph.addNode(ns)
00133     
00134     subs = SubscribersModel()
00135     subs.addSubscriber("/joint_path_command","geometry_msgs::Twist1")
00136     subs.addSubscriber("/joint_path_command","geometry_msgs::Twist2")
00137     subs.addSubscriber("/joint_path_command","geometry_msgs::Twist3")
00138     subs.addSubscriber("/joint_path_command","geometry_msgs::Twist4")
00139     digraph.addNode(subs)
00140     
00141     pubs = PublishersModel()
00142     pubs.addSubscriber("/joint_path_command","geometry_msgs::Twist1")
00143     pubs.addSubscriber("/joint_path_command","geometry_msgs::Twist2")
00144     pubs.addSubscriber("/joint_path_command","geometry_msgs::Twist3")
00145     pubs.addSubscriber("/joint_path_command","geometry_msgs::Twist4")
00146     digraph.addNode(pubs)
00147     
00148     digraph.connect(ns, pkg, Edge(Edge.DIR, "both"))
00149     digraph.connect(subs, pkg)
00150     digraph.connect(pkg, pubs)
00151     
00152     print str(digraph)
00153     
00154     digraph.saveDot("/home/ihm-pma/Documents/dot_test/ns_test.dot")
00155     digraph.dotToPng("/home/ihm-pma/Documents/dot_test/ns_test.png")
00156     
00157 
00158 if __name__ == '__main__':
00159     
00160     digraph_test()
00161     


airbus_docgen
Author(s): Matignon Martin
autogenerated on Thu Jun 6 2019 17:59:08