ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to launch a python file from html

asked 2017-09-28 20:52:49 -0500

JohnPa gravatar image

Hy Guys,

I just have a little question. I'll appreciate your support.

I have worked with rosbridge and I don`t have any problem, But I want to launch a python file from html file. Something like that:

<html lang="en"> .... rosrun filename.py.

Thanks. I'll appreciate your support.

John

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-09-28 22:51:11 -0500

ahendrix gravatar image

I suspect this is not possible, but I have not used rosbridge much.

edit flag offensive delete link more

Comments

No, this is not possible. @JohnPa: rosbridge is really just that, a bridge. It allows you to connect to a ROS node graph using a JSON based API. Anything you can do with a regular ROS node can be done from javascript. If you want a "python file" to be started based on some event, ..

gvdhoorn gravatar image gvdhoorn  ( 2017-09-29 02:21:47 -0500 )edit

.. you'll have to create a ROS node that either listens on a topic and publish a message to that topic from javascript, or make the node expose a service and have your html page (again, with javascript) invoke that service. That ROS node can then do anything, including starting your Python file.

gvdhoorn gravatar image gvdhoorn  ( 2017-09-29 02:22:55 -0500 )edit

Thanks! So much. @gvdhoom

Due to your answer I have understood better. But Right now I have this problem.

JohnPa gravatar image JohnPa  ( 2017-09-30 08:21:03 -0500 )edit
0

answered 2017-09-29 16:57:43 -0500

JohnPa gravatar image

updated 2017-10-02 13:45:22 -0500

jayess gravatar image

Thanks! So much. @gvdhoom

Due to your answer I have understood better. This is the solution:

var listener2 = new ROSLIB.Topic({
    ros : rbServer,
    name : '/chatter',
    messageType : 'std_msgs/String'
});

listener2.subscribe(function(message) {
    console.log('Received message on ' + listener2.name + ': ' + message.data);
    document.write(message.data);
    //listener.unsubscribe();
    var str = new ROSLIB.Message({
        data : message.data
    });
    jptopic.publish(str);
});


var jptopic = new ROSLIB.Topic({
    ros : rbServer,
    name : '/chatter2',
    messageType : 'std_msgs/String'
  });
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-09-28 20:52:49 -0500

Seen: 259 times

Last updated: Oct 02 '17