ros2djs
ros2djs copied to clipboard
ROS2D.PathShape usage
Can anyone help me with how to use this function considering I am able to pass proper parameters but I'm not able to see anything happening to my 2d viewer?
path = new ROSLIB.Topic({
ros: ros,
name: '/move_base/NavfnROS/plan',
messageType: 'nav_msgs/Path'
});
path.subscribe(function (message) {
//alert('Received message on ' + path.name + ': ' + JSON.stringify(message));
targetPath = new ROS2D.PathShape({
ros: ros,
path: message
});
targetPath.setPath(message);
//path.unsubscribe();
});
please correct me if I'm doing anything wrong and also do share some working code for PathShape func.
Thanks.
you have to use addChild function for targetPath with rootObject to get the line to display in the browser
Hi - did you ever manage to get this to work. I've hacked some code together but it's not playing ball
Cheers
Mark
Can you solve this problem? @CycleMark
@alliansmover @CycleMark Yes I did solve this particular problem.
I subscribed the topic '/move_base/NavfnROS/plan' and plotted the received points on top of canvas using addChild to rootObject.
Hi, thanks for explaining. I'm trying to do that, but I'm still not seeing the path. Could you help me understand where I'm going wrong? My code is :
` var pathShape = new window.ROS2D.PathShape({ strokeSize : 3, });
var listenerforPath = new ROSLIB.Topic ({
ros : this.ros,
name : '/move_base/NavfnROS/plan',
messageType : 'nav_msgs/Path'
});
viewer2D.scene.addChild(pathShape);
listenerforPath.subscribe((message)=> {
console.log(message)
pathShape.setPath(message);
//listener.unsubscribe(); });`
Could someone please provide a code snippet for this issue. I too am unable to plot the path though I am receiving the points through the subscriber.
Thanks @rvipin17 @richuzzz for the solution.
For everyone who requested a snippet, and for everyone else who might need it in future, following code worked for me.
pathView = new ROS2D.PathShape({
ros: ros,
strokeSize: 0.02,
strokeColor: "green",
});
gridClient.rootObject.addChild(pathView);
pathTopic = new ROSLIB.Topic({
ros: ros,
name: '/plan',
messageType: 'nav_msgs/Path'
});
pathTopic.subscribe(function(message) {
pathView.setPath(message);
});`
Solution can be found in https://github.com/RobotWebTools/ros2djs/issues/38#issuecomment-1422759813