Dawn Robotics Forum Support and community forums for Dawn Robotics Ltd 2015-03-05T12:02:19+01:00 http://forum.dawnrobotics.co.uk/feed.php?f=5&t=1335 2015-03-05T12:02:19+01:00 2015-03-05T12:02:19+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1335&p=1693#p1693 <![CDATA[Re: make robot talk running script on terminal]]>
You can see the internals of the set_motor_speeds command by looking at line 467 of __init__.py in the py_websockets_bot library. Basically, this routine sends a string through a websocket (a network connection).

I think you're correct that the reason changing the SetMotorSpeeds line in robot_web_server.py doesn't do anything is because you need to restart the web server. You shouldn't need to reboot, just stop it from the command line (by pressing control+C if you've started it by typing sudo ./robot_web_server.py) and then start it up again. Putting in print statements like

print "Hello"

or

print "lineData[ 0 ] is", lineData[ 0 ]

can be really useful for trying to understand what the code is doing.

Regards

Alan

Statistics: Posted by Alan — Thu Mar 05, 2015 12:02 pm


]]>
2015-03-02T18:11:18+01:00 2015-03-02T18:11:18+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1335&p=1687#p1687 <![CDATA[Re: make robot talk running script on terminal]]> ran the commands suggested the bot then ceases to respond unless I reboot. It works fine then.

I get
Code:
pi@raspberrypi ~/raspberry_pi_camera_bot $ sudo ./robot_web_server.py
sockjs.tornado will use json module
Starting web server...
Read 0XACED 0.38
Expected 0XACED 0.38


Do I need to stop the webserver before running a script?

I assume the webserver is running. ok
I do not understand how my script communicates with it as the command
bot.set_motor_speeds( 30.0, 0.0 ) has underscores in it.

While in the webserver script
Code:
elif lineData[ 0 ] == "SetMotorSpeeds" and len( lineData ) >= 3:
                   
                    leftMotorSpeed = 0.0
                    rightMotorSpeed = 0.0


there are no underscores in "SetMotorSpeeds"? So how is my script calling the webserver? My scripts run as expected from terminal or local (after a reboot). I am clearly missing something out?
You say run put print statements in webserver script and run from bot command line. How does that test communication from my terminal. It does prove my webserver is running.

If i edit the line
Code:
elif lineData[ 0 ] == "SetMotorSpeeds" and len( lineData ) >= 3:


to

Code:
elif lineData[ 0 ] == "####SetMotorSpeeds" and len( lineData ) >= 3:


the command
Code:
bot.set_motor_speeds( 30.0, 0.0 )
works is that because I need to reboot? and then it would not?

Thanks :-)

Statistics: Posted by Adeste — Mon Mar 02, 2015 6:11 pm


]]>
2015-03-02T17:04:05+01:00 2015-03-02T17:04:05+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1335&p=1686#p1686 <![CDATA[Re: make robot talk running script on terminal]]> Statistics: Posted by Adeste — Mon Mar 02, 2015 5:04 pm


]]>
2015-03-02T08:55:06+01:00 2015-03-02T08:55:06+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1335&p=1685#p1685 <![CDATA[Re: make robot talk running script on terminal]]>
Your control script looks ok, although I can't see any reference to speaking?

Something that might help is if you put some print statements in robot_web_server.py and then run it from the command line on your robot. This way you can see if messages are getting through.

To run robot_web_server.py from the command line, log into your Pi and run the following commands

sudo service robot_web_server stop
cd /home/pi/raspberry_pi_camera_bot
sudo ./robot_web_server.py

Hope that helps.

Regards

Alan

Statistics: Posted by Alan — Mon Mar 02, 2015 8:55 am


]]>
2015-03-01T23:07:03+01:00 2015-03-01T23:07:03+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1335&p=1684#p1684 <![CDATA[Re: make robot talk running script on terminal]]> Editing the robot_web_server.py file seems to make no difference. The only version I can find of robot_web_server.py is in in raspberry_pi_camera_bot.
My script starts:

[code] #! /usr/bin/python

import time
import argparse
import py_websockets_bot
import os


#---------------------------------------------------------------------------------------------------
if __name__ == "__main__":

# Set up a parser for command line arguments
parser = argparse.ArgumentParser( "Moves the robot around" )
parser.add_argument( "hostname", default="192.168.42.1", nargs='?', help="The ip address of the robot" )

args = parser.parse_args()
bot = py_websockets_bot.WebsocketsBot( args.hostname )


def move():

# Connect to the robot
#bot = py_websockets_bot.WebsocketsBot( args.hostname )


# Drive rotate
bot.set_motor_speeds( 30.0, 0.0 )
time.sleep( 1 )

Statistics: Posted by Adeste — Sun Mar 01, 2015 11:07 pm


]]>
2015-02-20T07:35:17+01:00 2015-02-20T07:35:17+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1335&p=1681#p1681 <![CDATA[Re: make robot talk running script on terminal]]>
It makes perfect sense.

Cheers Ade

Statistics: Posted by Adeste — Fri Feb 20, 2015 7:35 am


]]>
2015-02-18T15:02:37+01:00 2015-02-18T15:02:37+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1335&p=1679#p1679 <![CDATA[Re: make robot talk running script on terminal]]>
To get this working on your robot, I would say that the quickest and easiest way would be to modify the websockets 'on_message' routine in robot_web_server.py to handle another command such as 'speak'. Then you can use py_websockets_bot to send a command to the robot like this

Code:
bot._websocket.send( "speak", "Hello" )


Hope that makes sense. Let me know if you need more info.

Regards

Alan

Statistics: Posted by Alan — Wed Feb 18, 2015 3:02 pm


]]>
2015-02-17T09:20:00+01:00 2015-02-17T09:20:00+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1335&p=1677#p1677 <![CDATA[make robot talk running script on terminal]]>
I have a script to make my bot talk containing

Code:
def robot(text):
        os.system("espeak ' " + text + " ' ")


This works fine if run locally on the bot. Obviously if run remotely it tries to access the OS on my terminal.
In general I would like to investigate calling of modules both locally and on my terminal from a script running on my terminal. Any ideas? Thanks

Statistics: Posted by Adeste — Tue Feb 17, 2015 9:20 am


]]>