Skip to content

Commit

Permalink
Merge pull request RobotWebTools#57 from rk4an/devel
Browse files Browse the repository at this point in the history
add tfPrefix for multi-robots support
  • Loading branch information
rctoris committed Nov 28, 2013
2 parents 13bb906 + da67f6b commit 580fa17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/urdf/Urdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
* * urdfModel - the ROSLIB.UrdfModel to load
* * tfClient - the TF client handle to use
* * path (optional) - the base path to the associated Collada models that will be loaded
* * tfPrefix (optional) - the TF prefix to used for multi-robots
*/
ROS3D.Urdf = function(options) {
options = options || {};
var urdfModel = options.urdfModel;
var path = options.path || '/';
var tfClient = options.tfClient;
var tfPrefix = options.tfPrefix || '';

THREE.Object3D.call(this);
this.useQuaternion = true;
Expand All @@ -27,7 +29,7 @@ ROS3D.Urdf = function(options) {
var link = links[l];
if (link.visual && link.visual.geometry) {
if (link.visual.geometry.type === ROSLIB.URDF_MESH) {
var frameID = '/' + link.name;
var frameID = tfPrefix + '/' + link.name;
var uri = link.visual.geometry.filename;
var fileType = uri.substr(-4).toLowerCase();

Expand Down
5 changes: 4 additions & 1 deletion src/urdf/UrdfClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* * tfClient - the TF client handle to use
* * path (optional) - the base path to the associated Collada models that will be loaded
* * rootObject (optional) - the root object to add this marker to
* * tfPrefix (optional) - the TF prefix to used for multi-robots
*/
ROS3D.UrdfClient = function(options) {
var that = this;
Expand All @@ -26,6 +27,7 @@ ROS3D.UrdfClient = function(options) {
this.path = options.path || '/';
this.tfClient = options.tfClient;
this.rootObject = options.rootObject || new THREE.Object3D();
var tfPrefix = options.tfPrefix || '';

// get the URDF value from ROS
var getParam = new ROSLIB.Param({
Expand All @@ -42,7 +44,8 @@ ROS3D.UrdfClient = function(options) {
that.rootObject.add(new ROS3D.Urdf({
urdfModel : urdfModel,
path : that.path,
tfClient : that.tfClient
tfClient : that.tfClient,
tfPrefix : tfPrefix
}));
});
};

0 comments on commit 580fa17

Please sign in to comment.