-
Notifications
You must be signed in to change notification settings - Fork 215
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
MORE 3D OBJECTS #123
Merged
Merged
MORE 3D OBJECTS #123
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5f2bf7e
Path display
DLu c221f42
Renaming folders
DLu cbe3e12
Path cleanup and remove unsub from PC2
DLu b4d6347
Merge branch 'pc_update' into nav_tools
DLu 5c3b94f
LaserScan
DLu bbd1563
Polygon
DLu 21346fc
Pose
DLu dc038f1
Pose Array
DLu 4a515cb
Odometry
DLu 7b01b4d
Point
DLu e74ac0b
Merge remote-tracking branch 'upstream/develop' into nav_tools
DLu 67b8927
White space hacking
DLu e83a762
White space hacking 2
DLu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* @author David V. Lu!! - [email protected] | ||
*/ | ||
|
||
/** | ||
* An Odometry client | ||
* | ||
* @constructor | ||
* @param options - object with following keys: | ||
* | ||
* * ros - the ROSLIB.Ros connection handle | ||
* * topic - the marker topic to listen to | ||
* * tfClient - the TF client handle to use | ||
* * rootObject (optional) - the root object to add this marker to | ||
* * keep (optional) - number of markers to keep around (default: 1) | ||
* * color (optional) - color for line (default: 0xcc00ff) | ||
* * length (optional) - the length of the arrow (default: 1.0) | ||
* * headLength (optional) - the head length of the arrow (default: 0.2) | ||
* * shaftDiameter (optional) - the shaft diameter of the arrow (default: 0.05) | ||
* * headDiameter (optional) - the head diameter of the arrow (default: 0.1) | ||
*/ | ||
ROS3D.Odometry = function(options) { | ||
this.options = options || {}; | ||
var ros = options.ros; | ||
var topic = options.topic || '/particlecloud'; | ||
this.tfClient = options.tfClient; | ||
this.color = options.color || 0xcc00ff; | ||
this.length = options.length || 1.0; | ||
this.rootObject = options.rootObject || new THREE.Object3D(); | ||
this.keep = options.keep || 1; | ||
var that = this; | ||
THREE.Object3D.call(this); | ||
|
||
this.sns = []; | ||
|
||
var rosTopic = new ROSLIB.Topic({ | ||
ros : ros, | ||
name : topic, | ||
messageType : 'nav_msgs/Odometry' | ||
}); | ||
|
||
rosTopic.subscribe(function(message) { | ||
if(that.sns.length >= that.keep) { | ||
that.rootObject.remove(that.sns[0]); | ||
that.sns.shift(); | ||
} | ||
|
||
that.options.origin = new THREE.Vector3( message.pose.pose.position.x, message.pose.pose.position.y, | ||
message.pose.pose.position.z); | ||
|
||
var rot = new THREE.Quaternion(message.pose.pose.orientation.x, message.pose.pose.orientation.y, | ||
message.pose.pose.orientation.z, message.pose.pose.orientation.w); | ||
that.options.direction = new THREE.Vector3(1,0,0); | ||
that.options.direction.applyQuaternion(rot); | ||
that.options.material = new THREE.MeshBasicMaterial({color: that.color}); | ||
var arrow = new ROS3D.Arrow(that.options); | ||
|
||
that.sns.push(new ROS3D.SceneNode({ | ||
frameID : message.header.frame_id, | ||
tfClient : that.tfClient, | ||
object : arrow | ||
})); | ||
|
||
that.rootObject.add(that.sns[ that.sns.length - 1]); | ||
}); | ||
|
||
|
||
}; | ||
ROS3D.Odometry.prototype.__proto__ = THREE.Object3D.prototype; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* @author David V. Lu!! - [email protected] | ||
*/ | ||
|
||
/** | ||
* A Path client that listens to a given topic and displays a line connecting the poses. | ||
* | ||
* @constructor | ||
* @param options - object with following keys: | ||
* | ||
* * ros - the ROSLIB.Ros connection handle | ||
* * topic - the marker topic to listen to | ||
* * tfClient - the TF client handle to use | ||
* * rootObject (optional) - the root object to add this marker to | ||
* * color (optional) - color for line (default: 0xcc00ff) | ||
*/ | ||
ROS3D.Path = function(options) { | ||
options = options || {}; | ||
var ros = options.ros; | ||
var topic = options.topic || '/path'; | ||
this.tfClient = options.tfClient; | ||
this.color = options.color || 0xcc00ff; | ||
this.rootObject = options.rootObject || new THREE.Object3D(); | ||
var that = this; | ||
THREE.Object3D.call(this); | ||
|
||
this.sn = null; | ||
this.line = null; | ||
|
||
var rosTopic = new ROSLIB.Topic({ | ||
ros : ros, | ||
name : topic, | ||
messageType : 'nav_msgs/Path' | ||
}); | ||
|
||
rosTopic.subscribe(function(message) { | ||
if(that.sn!==null){ | ||
that.rootObject.remove(that.sn); | ||
} | ||
|
||
var lineGeometry = new THREE.Geometry(); | ||
for(var i=0; i<message.poses.length;i++){ | ||
var v3 = new THREE.Vector3( message.poses[i].pose.position.x, message.poses[i].pose.position.y, | ||
message.poses[i].pose.position.z); | ||
lineGeometry.vertices.push(v3); | ||
} | ||
|
||
lineGeometry.computeLineDistances(); | ||
var lineMaterial = new THREE.LineBasicMaterial( { color: that.color } ); | ||
var line = new THREE.Line( lineGeometry, lineMaterial ); | ||
|
||
that.sn = new ROS3D.SceneNode({ | ||
frameID : message.header.frame_id, | ||
tfClient : that.tfClient, | ||
object : line | ||
}); | ||
|
||
that.rootObject.add(that.sn); | ||
}); | ||
|
||
|
||
}; | ||
ROS3D.Path.prototype.__proto__ = THREE.Object3D.prototype; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* @author David V. Lu!! - [email protected] | ||
*/ | ||
|
||
/** | ||
* A PointStamped client | ||
* | ||
* @constructor | ||
* @param options - object with following keys: | ||
* | ||
* * ros - the ROSLIB.Ros connection handle | ||
* * topic - the marker topic to listen to | ||
* * tfClient - the TF client handle to use | ||
* * rootObject (optional) - the root object to add this marker to | ||
* * color (optional) - color for line (default: 0xcc00ff) | ||
* * radius (optional) - radius of the point (default: 0.2) | ||
*/ | ||
ROS3D.Point = function(options) { | ||
this.options = options || {}; | ||
var ros = options.ros; | ||
var topic = options.topic || '/point'; | ||
this.tfClient = options.tfClient; | ||
this.color = options.color || 0xcc00ff; | ||
this.rootObject = options.rootObject || new THREE.Object3D(); | ||
this.radius = options.radius || 0.2; | ||
var that = this; | ||
THREE.Object3D.call(this); | ||
|
||
this.sn = null; | ||
|
||
var rosTopic = new ROSLIB.Topic({ | ||
ros : ros, | ||
name : topic, | ||
messageType : 'geometry_msgs/PointStamped' | ||
}); | ||
|
||
rosTopic.subscribe(function(message) { | ||
if(that.sn!==null){ | ||
that.rootObject.remove(that.sn); | ||
} | ||
|
||
var sphereGeometry = new THREE.SphereGeometry( that.radius ); | ||
var sphereMaterial = new THREE.MeshBasicMaterial( {color: that.color} ); | ||
var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial); | ||
sphere.position.set(message.point.x, message.point.y, message.point.z); | ||
|
||
that.sn = new ROS3D.SceneNode({ | ||
frameID : message.header.frame_id, | ||
tfClient : that.tfClient, | ||
object : sphere | ||
}); | ||
|
||
that.rootObject.add(that.sn); | ||
}); | ||
|
||
|
||
}; | ||
ROS3D.Point.prototype.__proto__ = THREE.Object3D.prototype; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* @author David V. Lu!! - [email protected] | ||
*/ | ||
|
||
/** | ||
* A PolygonStamped client that listens to a given topic and displays the polygon | ||
* | ||
* @constructor | ||
* @param options - object with following keys: | ||
* | ||
* * ros - the ROSLIB.Ros connection handle | ||
* * topic - the marker topic to listen to | ||
* * tfClient - the TF client handle to use | ||
* * rootObject (optional) - the root object to add this marker to | ||
* * color (optional) - color for line (default: 0xcc00ff) | ||
*/ | ||
ROS3D.Polygon = function(options) { | ||
options = options || {}; | ||
var ros = options.ros; | ||
var topic = options.topic || '/path'; | ||
this.tfClient = options.tfClient; | ||
this.color = options.color || 0xcc00ff; | ||
this.rootObject = options.rootObject || new THREE.Object3D(); | ||
var that = this; | ||
THREE.Object3D.call(this); | ||
|
||
this.sn = null; | ||
this.line = null; | ||
|
||
var rosTopic = new ROSLIB.Topic({ | ||
ros : ros, | ||
name : topic, | ||
messageType : 'geometry_msgs/PolygonStamped' | ||
}); | ||
|
||
rosTopic.subscribe(function(message) { | ||
if(that.sn!==null){ | ||
that.rootObject.remove(that.sn); | ||
} | ||
|
||
var lineGeometry = new THREE.Geometry(); | ||
var v3; | ||
for(var i=0; i<message.polygon.points.length;i++){ | ||
v3 = new THREE.Vector3( message.polygon.points[i].x, message.polygon.points[i].y, | ||
message.polygon.points[i].z); | ||
lineGeometry.vertices.push(v3); | ||
} | ||
v3 = new THREE.Vector3( message.polygon.points[0].x, message.polygon.points[0].y, | ||
message.polygon.points[0].z); | ||
lineGeometry.vertices.push(v3); | ||
|
||
|
||
lineGeometry.computeLineDistances(); | ||
var lineMaterial = new THREE.LineBasicMaterial( { color: that.color } ); | ||
var line = new THREE.Line( lineGeometry, lineMaterial ); | ||
|
||
that.sn = new ROS3D.SceneNode({ | ||
frameID : message.header.frame_id, | ||
tfClient : that.tfClient, | ||
object : line | ||
}); | ||
|
||
that.rootObject.add(that.sn); | ||
}); | ||
|
||
|
||
}; | ||
ROS3D.Polygon.prototype.__proto__ = THREE.Object3D.prototype; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @author David V. Lu!! - [email protected] | ||
*/ | ||
|
||
/** | ||
* A PoseStamped client | ||
* | ||
* @constructor | ||
* @param options - object with following keys: | ||
* | ||
* * ros - the ROSLIB.Ros connection handle | ||
* * topic - the marker topic to listen to | ||
* * tfClient - the TF client handle to use | ||
* * rootObject (optional) - the root object to add this marker to | ||
* * color (optional) - color for line (default: 0xcc00ff) | ||
* * length (optional) - the length of the arrow (default: 1.0) | ||
* * headLength (optional) - the head length of the arrow (default: 0.2) | ||
* * shaftDiameter (optional) - the shaft diameter of the arrow (default: 0.05) | ||
* * headDiameter (optional) - the head diameter of the arrow (default: 0.1) | ||
*/ | ||
ROS3D.Pose = function(options) { | ||
this.options = options || {}; | ||
var ros = options.ros; | ||
var topic = options.topic || '/pose'; | ||
this.tfClient = options.tfClient; | ||
this.color = options.color || 0xcc00ff; | ||
this.rootObject = options.rootObject || new THREE.Object3D(); | ||
var that = this; | ||
THREE.Object3D.call(this); | ||
|
||
this.sn = null; | ||
|
||
var rosTopic = new ROSLIB.Topic({ | ||
ros : ros, | ||
name : topic, | ||
messageType : 'geometry_msgs/PoseStamped' | ||
}); | ||
|
||
rosTopic.subscribe(function(message) { | ||
if(that.sn!==null){ | ||
that.rootObject.remove(that.sn); | ||
} | ||
|
||
that.options.origin = new THREE.Vector3( message.pose.position.x, message.pose.position.y, | ||
message.pose.position.z); | ||
|
||
var rot = new THREE.Quaternion(message.pose.orientation.x, message.pose.orientation.y, | ||
message.pose.orientation.z, message.pose.orientation.w); | ||
that.options.direction = new THREE.Vector3(1,0,0); | ||
that.options.direction.applyQuaternion(rot); | ||
that.options.material = new THREE.MeshBasicMaterial({color: that.color}); | ||
var arrow = new ROS3D.Arrow(that.options); | ||
|
||
that.sn = new ROS3D.SceneNode({ | ||
frameID : message.header.frame_id, | ||
tfClient : that.tfClient, | ||
object : arrow | ||
}); | ||
|
||
that.rootObject.add(that.sn); | ||
}); | ||
|
||
|
||
}; | ||
ROS3D.Pose.prototype.__proto__ = THREE.Object3D.prototype; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the indentation is off for this subscribe call
Edit: Actually, it's off for all of the new classes.