Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

support for checking /rosout and change icon.

- ros_attention.svg
- make it a node
  • Loading branch information...
commit 3850d11f7196ddae6e7cee269a2c8adb02e38128 1 parent c88c000
@OTL OTL authored
View
2  unity_indicator/manifest.xml
@@ -14,5 +14,7 @@
<depend package="rosservice"/>
<depend package="rosparam"/>
<depend package="rosgraph"/>
+ <depend package="rosgraph_msgs"/>
+ <depend package="rospy"/>
</package>
View
157 unity_indicator/ros_attention.svg
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="378.24887"
+ height="375.96722"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.48.3.1 r9886"
+ sodipodi:docname="ros_attention.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.3727668"
+ inkscape:cx="229.64169"
+ inkscape:cy="194.76638"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1400"
+ inkscape:window-height="1026"
+ inkscape:window-x="0"
+ inkscape:window-y="24"
+ inkscape:window-maximized="1"
+ fit-margin-top="10"
+ fit-margin-right="10"
+ fit-margin-bottom="10"
+ fit-margin-left="10" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:groupmode="layer"
+ id="layer2"
+ inkscape:label="レイヤー"
+ style="display:none"
+ transform="translate(-202.57142,-306.36218)" />
+ <g
+ inkscape:label="レイヤー 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ style="display:inline"
+ transform="translate(-202.57142,-306.36218)">
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:none"
+ id="path2997"
+ sodipodi:cx="255.71428"
+ sodipodi:cy="359.50504"
+ sodipodi:rx="47.142857"
+ sodipodi:ry="47.142857"
+ d="m 302.85714,359.50504 c 0,26.03628 -21.10658,47.14285 -47.14286,47.14285 -26.03628,0 -47.14286,-21.10657 -47.14286,-47.14285 0,-26.03629 21.10658,-47.14286 47.14286,-47.14286 26.03628,0 47.14286,21.10657 47.14286,47.14286 z"
+ transform="translate(4,4)" />
+ <path
+ transform="translate(6.000007,130.28572)"
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:none;display:inline"
+ id="path2997-8"
+ sodipodi:cx="255.71428"
+ sodipodi:cy="359.50504"
+ sodipodi:rx="47.142857"
+ sodipodi:ry="47.142857"
+ d="m 302.85714,359.50504 c 0,26.03628 -21.10658,47.14285 -47.14286,47.14285 -26.03628,0 -47.14286,-21.10657 -47.14286,-47.14285 0,-26.03629 21.10658,-47.14286 47.14286,-47.14286 26.03628,0 47.14286,21.10657 47.14286,47.14286 z" />
+ <path
+ transform="translate(6.857149,264.85715)"
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:none;display:inline"
+ id="path2997-6"
+ sodipodi:cx="255.71428"
+ sodipodi:cy="359.50504"
+ sodipodi:rx="47.142857"
+ sodipodi:ry="47.142857"
+ d="m 302.85714,359.50504 c 0,26.03628 -21.10658,47.14285 -47.14286,47.14285 -26.03628,0 -47.14286,-21.10657 -47.14286,-47.14285 0,-26.03629 21.10658,-47.14286 47.14286,-47.14286 26.03628,0 47.14286,21.10657 47.14286,47.14286 z" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:none;display:inline"
+ id="path2997-4"
+ sodipodi:cx="255.71428"
+ sodipodi:cy="359.50504"
+ sodipodi:rx="47.142857"
+ sodipodi:ry="47.142857"
+ d="m 302.85714,359.50504 c 0,26.03628 -21.10658,47.14285 -47.14286,47.14285 -26.03628,0 -47.14286,-21.10657 -47.14286,-47.14285 0,-26.03629 21.10658,-47.14286 47.14286,-47.14286 26.03628,0 47.14286,21.10657 47.14286,47.14286 z"
+ transform="translate(136.77603,4.8243625)" />
+ <path
+ transform="translate(138.77603,131.11009)"
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:none;display:inline"
+ id="path2997-8-7"
+ sodipodi:cx="255.71428"
+ sodipodi:cy="359.50504"
+ sodipodi:rx="47.142857"
+ sodipodi:ry="47.142857"
+ d="m 302.85714,359.50504 c 0,26.03628 -21.10658,47.14285 -47.14286,47.14285 -26.03628,0 -47.14286,-21.10657 -47.14286,-47.14285 0,-26.03629 21.10658,-47.14286 47.14286,-47.14286 26.03628,0 47.14286,21.10657 47.14286,47.14286 z" />
+ <path
+ transform="translate(139.63318,265.68152)"
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:none;display:inline"
+ id="path2997-6-7"
+ sodipodi:cx="255.71428"
+ sodipodi:cy="359.50504"
+ sodipodi:rx="47.142857"
+ sodipodi:ry="47.142857"
+ d="m 302.85714,359.50504 c 0,26.03628 -21.10658,47.14285 -47.14286,47.14285 -26.03628,0 -47.14286,-21.10657 -47.14286,-47.14285 0,-26.03629 21.10658,-47.14286 47.14286,-47.14286 26.03628,0 47.14286,21.10657 47.14286,47.14286 z" />
+ <path
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:none;display:inline"
+ id="path2997-4-8"
+ sodipodi:cx="255.71428"
+ sodipodi:cy="359.50504"
+ sodipodi:rx="47.142857"
+ sodipodi:ry="47.142857"
+ d="m 302.85714,359.50504 c 0,26.03628 -21.10658,47.14285 -47.14286,47.14285 -26.03628,0 -47.14286,-21.10657 -47.14286,-47.14285 0,-26.03629 21.10658,-47.14286 47.14286,-47.14286 26.03628,0 47.14286,21.10657 47.14286,47.14286 z"
+ transform="translate(265.10601,4.8243626)" />
+ <path
+ transform="translate(267.10601,131.1101)"
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:none;display:inline"
+ id="path2997-8-7-9"
+ sodipodi:cx="255.71428"
+ sodipodi:cy="359.50504"
+ sodipodi:rx="47.142857"
+ sodipodi:ry="47.142857"
+ d="m 302.85714,359.50504 c 0,26.03628 -21.10658,47.14285 -47.14286,47.14285 -26.03628,0 -47.14286,-21.10657 -47.14286,-47.14285 0,-26.03629 21.10658,-47.14286 47.14286,-47.14286 26.03628,0 47.14286,21.10657 47.14286,47.14286 z" />
+ <path
+ transform="translate(267.96316,265.68152)"
+ sodipodi:type="arc"
+ style="fill:#ff0000;fill-rule:evenodd;stroke:none;display:inline"
+ id="path2997-6-7-8"
+ sodipodi:cx="255.71428"
+ sodipodi:cy="359.50504"
+ sodipodi:rx="47.142857"
+ sodipodi:ry="47.142857"
+ d="m 302.85714,359.50504 c 0,26.03628 -21.10658,47.14285 -47.14286,47.14285 -26.03628,0 -47.14286,-21.10657 -47.14286,-47.14285 0,-26.03629 21.10658,-47.14286 47.14286,-47.14286 26.03628,0 47.14286,21.10657 47.14286,47.14286 z" />
+ </g>
+</svg>
View
36 unity_indicator/ros_indicator
@@ -22,7 +22,8 @@ import rostopic
import rosservice
import rosparam
import rosgraph
-
+import rosgraph_msgs
+import rospy
def notify_with_icon(name, body):
""" Utility function for Notification"""
@@ -134,11 +135,10 @@ def build_node_submenu(menu, nodes):
def build_param_submenu(menu, params):
build_submenu(menu, params, [["Info", show_param_info],
- ["Delete", delete_param]])
+ ["Delete", delete_param]])
def build_topic_submenu(menu, topics):
- build_submenu(menu, topics, [["Info", show_topic_info],
- ["Kill", kill_node]])
+ build_submenu(menu, topics, [["Info", show_topic_info]])
def build_service_submenu(menu, services):
build_submenu(menu, services, [["Info", show_service_info]])
@@ -157,15 +157,25 @@ def check_master():
except socket.error:
return False
-def build_menu(menu, name, func):
+def build_menu(menu, name, func, ind):
""" build top level menu"""
node_item = gtk.MenuItem(name)
menu.append(node_item)
node_menu = gtk.Menu()
node_item.set_submenu(node_menu)
node_item.connect("activate", func, node_menu)
+ node_item.connect("activate", clear_status, ind)
return node_menu
+def rosout_callback(msg, ind):
+ if msg.level == rosgraph_msgs.msg.Log.ERROR or \
+ msg.level == rosgraph_msgs.msg.Log.FATAL:
+ ind.set_status(appindicator.STATUS_ATTENTION)
+
+def clear_status(w, ind):
+ if ind.get_status() == appindicator.STATUS_ATTENTION:
+ ind.set_status(appindicator.STATUS_ACTIVE)
+
def main():
if not check_master():
print "plase launch roscore at first"
@@ -175,8 +185,12 @@ def main():
ind = appindicator.Indicator ("ros-client",
"ros",
appindicator.CATEGORY_APPLICATION_STATUS)
+
ind.set_status (appindicator.STATUS_ACTIVE)
ind.set_icon_theme_path(os.path.abspath(os.path.abspath(os.path.dirname(__file__))))
+ ind.set_label("ROS")
+ rospy.init_node('ros_indicator', disable_signals=True)
+ rospy.Subscriber('/rosout', rosgraph_msgs.msg.Log, rosout_callback, ind)
# not used now
ind.set_attention_icon ("ros_attention")
@@ -191,33 +205,37 @@ def main():
# rxconsole
console_item = gtk.MenuItem("rxconsole")
console_item.connect("activate", launch_console)
+ console_item.connect("activate", clear_status, ind)
menu.append(console_item)
menu.append(gtk.SeparatorMenuItem())
# node menu
- node_menu = build_menu(menu, "node", selected_node_menu)
+ node_menu = build_menu(menu, "node", selected_node_menu, ind)
build_node_submenu(node_menu, [''])
# topic menu
- topic_menu = build_menu(menu, "topic", selected_topic_menu)
+ topic_menu = build_menu(menu, "topic", selected_topic_menu, ind)
build_topic_submenu(topic_menu, [''])
# service menu
- service_menu = build_menu(menu, "service", selected_service_menu)
+ service_menu = build_menu(menu, "service", selected_service_menu, ind)
build_service_submenu(service_menu, [''])
# param menu
- param_menu = build_menu(menu, "param", selected_param_menu)
+ param_menu = build_menu(menu, "param", selected_param_menu, ind)
build_param_submenu(param_menu, [''])
menu.show_all()
ind.set_menu(menu)
+ gtk.gdk.threads_init()
+
try:
gtk.main()
except KeyboardInterrupt:
pass
+ rospy.signal_shutdown("keyboard interrupt")
if __name__ == "__main__":
main()
Please sign in to comment.
Something went wrong with that request. Please try again.