Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixed in SceneNode #21

Merged
merged 2 commits into from
Apr 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DEVEL - **r4**
* Initial pose now set in SceneNode (rctoris)

2013-04-03 - **r3**
* ColladaLoader2 added as third-party module (rctoris)
Expand Down
50 changes: 33 additions & 17 deletions build/ros3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -1958,25 +1958,41 @@ ROS3D.SceneNode = function(options) {
// add the model
this.add(object);

// set the inital pose
this.updatePose(this.pose);

// listen for TF updates
tfClient.subscribe(frameID,
function(msg) {
// apply the transform
var tf = new ROSLIB.Transform(msg);
var poseTransformed = new ROSLIB.Pose(that.pose);
poseTransformed.applyTransform(tf);

// update the world
that.position.x = poseTransformed.position.x;
that.position.y = poseTransformed.position.y;
that.position.z = poseTransformed.position.z;
that.quaternion = new THREE.Quaternion(poseTransformed.orientation.x,
poseTransformed.orientation.y, poseTransformed.orientation.z,
poseTransformed.orientation.w);
that.updateMatrixWorld(true);
});
tfClient.subscribe(frameID, function(msg) {
if (that.TMP !== '/base_link') {
console.log(msg);
console.log(that.TMP);
}

// apply the transform
var tf = new ROSLIB.Transform(msg);
var poseTransformed = new ROSLIB.Pose(that.pose);
poseTransformed.applyTransform(tf);

// update the world
that.updatePose(poseTransformed);
});
};
ROS3D.SceneNode.prototype.__proto__ = THREE.Object3D.prototype;/**
ROS3D.SceneNode.prototype.__proto__ = THREE.Object3D.prototype;

/**
* Set the pose of the associated model.
*
* @param pose - the pose to update with
*/
ROS3D.SceneNode.prototype.updatePose = function(pose) {
this.position.x = pose.position.x;
this.position.y = pose.position.y;
this.position.z = pose.position.z;
this.quaternion = new THREE.Quaternion(pose.orientation.x, pose.orientation.y,
pose.orientation.z, pose.orientation.w);
this.updateMatrixWorld(true);
};
/**
* @author David Gossow - [email protected]
* @author Russell Toris - [email protected]
* @author Jihoon Lee - [email protected]
Expand Down
2 changes: 1 addition & 1 deletion build/ros3d.min.js

Large diffs are not rendered by default.

49 changes: 32 additions & 17 deletions src/visualization/SceneNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,37 @@ ROS3D.SceneNode = function(options) {
// add the model
this.add(object);

// set the inital pose
this.updatePose(this.pose);

// listen for TF updates
tfClient.subscribe(frameID,
function(msg) {
// apply the transform
var tf = new ROSLIB.Transform(msg);
var poseTransformed = new ROSLIB.Pose(that.pose);
poseTransformed.applyTransform(tf);

// update the world
that.position.x = poseTransformed.position.x;
that.position.y = poseTransformed.position.y;
that.position.z = poseTransformed.position.z;
that.quaternion = new THREE.Quaternion(poseTransformed.orientation.x,
poseTransformed.orientation.y, poseTransformed.orientation.z,
poseTransformed.orientation.w);
that.updateMatrixWorld(true);
});
tfClient.subscribe(frameID, function(msg) {
if (that.TMP !== '/base_link') {
console.log(msg);
console.log(that.TMP);
}

// apply the transform
var tf = new ROSLIB.Transform(msg);
var poseTransformed = new ROSLIB.Pose(that.pose);
poseTransformed.applyTransform(tf);

// update the world
that.updatePose(poseTransformed);
});
};
ROS3D.SceneNode.prototype.__proto__ = THREE.Object3D.prototype;

/**
* Set the pose of the associated model.
*
* @param pose - the pose to update with
*/
ROS3D.SceneNode.prototype.updatePose = function(pose) {
this.position.x = pose.position.x;
this.position.y = pose.position.y;
this.position.z = pose.position.z;
this.quaternion = new THREE.Quaternion(pose.orientation.x, pose.orientation.y,
pose.orientation.z, pose.orientation.w);
this.updateMatrixWorld(true);
};
ROS3D.SceneNode.prototype.__proto__ = THREE.Object3D.prototype;