Ask Your Question

invoke rostopic (remote control) from a web page button

asked 2011-10-20 03:18:52 -0500

kleekru gravatar image

updated 2011-10-23 05:24:41 -0500

kwc gravatar image

I'm working on getting remote control of a Roomba via web page running.

I have made some progress by installing Apache and PHP on the Roomba laptop and was able to basically make it a web server that serves up a page to the internet. However, I ran into a problem and I can't find a way around it.  I'm hoping someone has a suggestion.

I created a php page that calls a shell script called "":

/opt/ros/diamondback/ros/bin/rostopic pub /cmd_vel geometry_msgs/Twist -r 20
'[-0.1,-0.1,-0.1]' '[0,0,0]'
sleep 2
/opt/ros/diamondback/ros/bin/rostopic pub /cmd_vel geometry_msgs/Twist -r 20
'[0,0,0]' '[0,0,0]'
echo "<p> This is just a test </p>"

This shell script works when I launch it from command line, however, when I call the shell script ( from the php page (run.php), it appears to call the script because the sleep command and the echo command in the seem to work, however, the roomba does not receive the rostopic commands:

<h3>Executing Roomba</h3>
echo shell_exec('/usr/lib/cgi-bin/');
# echo shell_exec('sudo -u kevin /usr/lib/cgi-bin/ <
<p> This is after the shell script runs </p>

The script works. The Roomba moves forward... It never breaks out of the first rostopic command but I realize that is a separate issue. However, the rostopic commands do not work when the shell script is launched when the php file loads.... Interestingly, the "This is just a test" message shows up on the page and increasing the sleep time increases the load time of the page.

Any thoughts?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2011-10-20 05:15:12 -0500

dornhege gravatar image

I think you are missing the ROS setup when running from the webpage, i.e. sourcing /opt/ros/diamondback/setup.bash and possibly setting the ROS_PACKAGE_PATH.

Even if the webserver is running as the same user where you tested it the .bashrc might not have been sourced.

edit flag offensive delete link more


I think you are right but I don't know specifically how and where to source this... Do I add a "source" line in the php script or somewhere else?
kleekru gravatar image kleekru  ( 2011-10-21 07:25:56 -0500 )edit
I would put it in the script you execute.
dornhege gravatar image dornhege  ( 2011-10-22 03:31:08 -0500 )edit
That worked! Thank you!!! Now I just need to figure out how to break out of the rostopic command after it starts. Thanks
kleekru gravatar image kleekru  ( 2011-10-22 03:35:50 -0500 )edit

But need to put the full line with command "source" or without command?

Tvlad gravatar image Tvlad  ( 2016-09-14 01:59:33 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-10-20 03:18:52 -0500

Seen: 621 times

Last updated: Oct 20 '11