0
$\begingroup$

Rosanswers logo

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 "forward.sh":

#!/bin/bash
/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 (forward.sh) from the php page (run.php), it appears to call the script because the sleep command and the echo command in the forward.sh seem to work, however, the roomba does not receive the rostopic commands:

<h3>Executing Roomba Forward.sh</h3>
<?php
echo shell_exec('/usr/lib/cgi-bin/forward.sh');
# echo shell_exec('sudo -u kevin /usr/lib/cgi-bin/forward.sh <
/home/kevin/passwordfile');
?>
<p> This is after the shell script runs </p>

The forward.sh 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?


Originally posted by kleekru on ROS Answers with karma: 71 on 2011-10-20

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by dornhege with karma: 31395 on 2011-10-20

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by kleekru on 2011-10-22:
That worked! Thank you!!! Now I just need to figure out how to break out of the rostopic command after it starts. Thanks

Comment by dornhege on 2011-10-22:
I would put it in the script you execute.

Comment by kleekru on 2011-10-21:
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?

Comment by Tvlad on 2016-09-14:
But need to put the full line with command "source" or without command?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.