Permalink
Browse files

Updated urdf composer: populates comboboxes and lists using pluginlib.

  • Loading branch information...
oscillare committed Sep 27, 2012
1 parent 5344262 commit f17554e40b46102d08836d4c37aed80160dcc045
Showing with 119 additions and 39 deletions.
  1. +5 −0 ihe_hardware/turtlebot_metric_description/README
  2. BIN ihe_hardware/turtlebot_metric_description/images/turtlebot_metric.png
  3. BIN ihe_hardware/turtlebot_metric_description/images/turtlebot_metric_minimal.png
  4. +7 −2 ihe_hardware/turtlebot_metric_description/manifest.xml
  5. +6 −0 ihe_hardware/turtlebot_metric_description/urdf/turtlebot_metric.uraf
  6. +5 −1 ihe_hardware/turtlebot_metric_description/urdf/turtlebot_metric.urdf.xacro
  7. +9 −0 ihe_hardware/turtlebot_metric_description/urdf/turtlebot_metric_minimal.urdf.xacro
  8. BIN ihe_hardware/{urdf_compose → turtlebot_xtion_top_description}/images/xtension.png
  9. BIN ihe_hardware/{urdf_compose → turtlebot_xtion_top_description}/images/xtion.png
  10. +5 −2 ihe_hardware/turtlebot_xtion_top_description/manifest.xml
  11. +3 −2 ihe_hardware/turtlebot_xtion_top_description/urdf/{info_xtion.yaml → xtion.uraf}
  12. +1 −0 ihe_hardware/urdf_compose/.gitignore
  13. BIN ihe_hardware/urdf_compose/images/{turtlebot.png → turtlebot_minimal.png}
  14. +5 −2 ihe_hardware/urdf_compose/manifest.xml
  15. +0 −6 ihe_hardware/urdf_compose/src/gui/files.yaml
  16. +57 −18 ihe_hardware/urdf_compose/src/gui/gui.py
  17. +7 −3 ihe_hardware/urdf_compose/src/gui/guiFilePopups.py
  18. +0 −3 ihe_hardware/urdf_compose/src/gui/robots.yaml
  19. +1 −0 ihe_hardware/urdf_compose/urdf/{info_kinect.yaml → kinect.uraf}
  20. +3 −0 ihe_hardware/urdf_compose/urdf/turtlebot.uraf
  21. +5 −0 ihe_hardware/urdf_compose/urdf/turtlebot_minimal.urdf.xacro
@@ -0,0 +1,5 @@
+Demo usage:
+
+1) Launch the test file:
+
+ roslaunch turtlebot_metric_description test.launch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -9,6 +9,11 @@
<review status="unreviewed" notes=""/>
<url>http://ros.org/wiki/turtlebot_metric_description</url>
-</package>
-
+ <depend package="urdf"/>
+ <depend package="xacro"/>
+ <depend package="pluginlib"/>
+ <export>
+ <urdf base="${prefix}/urdf/turtlebot_metric.uraf"/>
+ </export>
+</package>
@@ -0,0 +1,6 @@
+-
+ file: urdf/turtlebot_metric.urdf.xacro
+ image: images/turtlebot_metric.png
+-
+ file: urdf/turtlebot_metric_minimal.urdf.xacro
+ image: images/turtlebot_metric_minimal.png
@@ -1,5 +1,9 @@
<?xml version="1.0" ?>
-<robot name="turtlebot" xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller" xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor" xmlns:xacro="http://ros.org/wiki/xacro">
+<robot name="turtlebot"
+ xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
+ xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"
+ xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"
+ xmlns:xacro="http://ros.org/wiki/xacro">
<include filename="$(find turtlebot_metric_description)/urdf/turtlebot_metric.xacro"/>
<turtlebot_body/>
<include filename="$(find urdf_compose)/urdf/kinect.xacro"/>
@@ -0,0 +1,9 @@
+<?xml version="1.0" ?>
+<robot name="turtlebot"
+ xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"
+ xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"
+ xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"
+ xmlns:xacro="http://ros.org/wiki/xacro">
+ <include filename="$(find turtlebot_metric_description)/urdf/turtlebot_metric.xacro"/>
+ <turtlebot_body/>
+</robot>
@@ -8,9 +8,12 @@
<license>BSD</license>
<review status="unreviewed" notes=""/>
<url>http://ros.org/wiki/turtlebot_xtion_top_description</url>
+
<depend package="urdf"/>
<depend package="xacro"/>
+ <depend package="pluginlib"/>
+ <export>
+ <urdf plugin="${prefix}/urdf/xtion.uraf"/>
+ </export>
</package>
-
-
@@ -1,5 +1,6 @@
+urdf: $(find turtlebot_xtion_top_description)/urdf/xtion.xacro
xtion:
- image: $(find urdf_compose)/images/xtion.png
+ image: $(find turtlebot_xtion_top_description)/images/xtion.png
description: >
The ASUS Xtion PRO LIVE uses infrared sensors, adaptive depth detection
technology, color image sensing and audio stream to capture a users'
@@ -248,7 +249,7 @@ xtion:
z_loc: "0.22655"
plate_xtension:
- image: $(find urdf_compose)/images/xtension.png
+ image: $(find turtlebot_xtion_top_description)/images/xtension.png
description: >
An extension that provides your ASUS Xtion PRO LIVE with enough height
for your TurtleBot to see an attached arm.
@@ -1,3 +1,4 @@
*.pyc
+*.py~
*.urdf.xacro
*.swp
@@ -15,7 +15,10 @@
<depend package="rviz"/>
<depend package="joint_state_publisher"/>
<depend package="robot_state_publisher"/>
+ <depend package="pluginlib"/>
+ <export>
+ <urdf base="${prefix}/urdf/turtlebot.uraf"/>
+ <urdf plugin="${prefix}/urdf/kinect.uraf"/>
+ </export>
</package>
-
-
@@ -1,6 +0,0 @@
-kinect.xacro (urdf_compose):
- file: $(find urdf_compose)/urdf/kinect.xacro
- description: $(find urdf_compose)/urdf/info_kinect.yaml
-xtion.xacro (turtlebot_xtion_top_description):
- file: $(find turtlebot_xtion_top_description)/urdf/xtion.xacro
- description: $(find turtlebot_xtion_top_description)/urdf/info_xtion.yaml
@@ -120,16 +120,43 @@ def initImages(self):
self.img_robot.setAlignment(QtCore.Qt.AlignCenter)
def initComboBoxes(self):
- path = self.urdf_compose + "/src/gui/robots.yaml"
+ cmd = ["rospack", "plugins", "--attrib=base", "urdf"]
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ result = p.communicate()[0].split()
+
+ self.robots = {}
+ i = 0
+
+ while i < len(result):
+ if re.findall(r".uraf$", result[i+1]):
+ with open(result[i+1], 'r') as f:
+ data = yaml.load(f)
+ for robot in data:
+ find = "$(find %s)" % result[i]
+ path = robot['file']
+ path = find + "/" + path
+ fpath = resolvePkgPaths(path)
+
+ with open(fpath, 'r') as f:
+ data = parse(f)
+
+ data = data.getElementsByTagName("robot")[0]
+ robotKey = data.getAttribute("name")
+ robotKey += " (%s : %s)" % (result[i],
+ os.path.basename(fpath))
+ self.robots[robotKey] = {'file':path,
+ 'image':find + "/" + robot['image']}
+ else:
+ with open(result[i+1], 'r') as f:
+ data = parse(f)
- try:
- self.robots = yaml.load(open(path, 'r'))
- except IOError, e:
- print "Could not open/missing file \"%s\"." % path
- sys.exit(1)
- except yaml.YAMLError, e:
- print e
- sys.exit(1)
+ data = data.getElementsByTagName("robot")[0]
+ robotKey = data.getAttribute("name")
+ robotKey += " (%s : %s)" % (result[i],
+ os.path.basename(result[i+1]))
+ self.robots[robotKey] = {'file':getResolveString(result[i+1]),
+ 'image':''}
+ i += 2
self.cb_robots = QtGui.QComboBox()
@@ -147,16 +174,28 @@ def initComboBoxes(self):
self.cb_robots.currentIndexChanged[str].connect(self.updateRobot)
def initLists(self):
- path = self.urdf_compose + "/src/gui/files.yaml"
+ cmd = ["rospack", "plugins", "--attrib=plugin", "urdf"]
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ result = p.communicate()[0].split()
- try:
- self.files = yaml.load(open(path, 'r'))
- except IOError, e:
- print "Could not open/missing file \"%s\"." % path
- sys.exit(1)
- except yaml.YAMLError, e:
- print e
- sys.exit(1)
+ self.files = {}
+ i = 0
+
+ while i < len(result):
+ if re.findall(r".uraf$", result[i+1]):
+ with open(result[i+1], 'r') as f:
+ data = yaml.load(f)
+
+ urdf = data['urdf']
+ description = result[i+1]
+ else:
+ urdf = result[i+1]
+ description = ""
+
+ accKey = os.path.basename(urdf)
+ accKey += " (%s)" % (result[i])
+ self.files[accKey] = {'file': urdf, 'description':description}
+ i += 2
self.list_attAcc = QtGui.QListWidget()
self.list_files = QtGui.QListWidget()
@@ -1,3 +1,4 @@
+import os
import re
import yaml
from xml.dom.minidom import parse
@@ -127,16 +128,19 @@ def get_f2(self):
self.le_f2.setText(image)
def add(self):
- file_path = getResolveString(self.le_f1.text())
+ fpath = self.le_f1.text()
+ file_path = getResolveString(fpath)
image_path = getResolveString(self.le_f2.text())
result = {"file": file_path, "image": image_path}
with open(self.le_f1.text(), 'r') as f:
urdf = parse(f)
robotTag = urdf.getElementsByTagName("robot")[0]
- robotName = robotTag.getAttribute("name")
+ robotKey = robotTag.getAttribute("name")
+ robotKey += " (%s : %s)" % (roslib.packages.get_dir_pkg(fpath)[1],
+ os.path.basename(fpath))
- self.parent.addRobotToComboBox(robotName, result)
+ self.parent.addRobotToComboBox(robotKey, result)
class AddAccessoryFileDialog(GetTwoFilesDialog):
def __init__(self, parent):
@@ -1,3 +0,0 @@
-turtlebot:
- file: $(find urdf_compose)/urdf/turtlebot_body.urdf.xacro
- image: $(find urdf_compose)/images/turtlebot.png
@@ -1,3 +1,4 @@
+urdf: $(find urdf_compose)/urdf/kinect.xacro
turtlebot_kinect:
image: $(find urdf_compose)/images/kinect.png
description: >
@@ -0,0 +1,3 @@
+-
+ file: urdf/turtlebot_minimal.urdf.xacro
+ image: images/turtlebot_minimal.png
@@ -0,0 +1,5 @@
+<?xml version="1.0" ?>
+<robot name="turtlebot" xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller" xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface" xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor" xmlns:xacro="http://ros.org/wiki/xacro">
+ <include filename="$(find urdf_compose)/urdf/turtlebot_body.xacro"/>
+ <turtlebot_body/>
+</robot>

0 comments on commit f17554e

Please sign in to comment.