Dawn Robotics Forum Support and community forums for Dawn Robotics Ltd 2014-12-16T21:17:30+01:00 http://forum.dawnrobotics.co.uk/feed.php?f=10&t=1297 2014-12-16T21:17:30+01:00 2014-12-16T21:17:30+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1297&p=1529#p1529 <![CDATA[Re: Speed of neck]]>
Sorry for the delayed reply. Had a git of a head cold over the last couple of days. :(

The cv2.waitKey( 1 ) line is needed to make the OpenCV debug windows appear. Basically if you don't have any calls to cv2.imshow then you don't need to call waitKey. The number is the time to wait in milliseconds for a keypress. If you use 0 then the program will pause.

Regards

Alan

Statistics: Posted by Alan — Tue Dec 16, 2014 9:17 pm


]]>
2014-12-14T14:12:56+01:00 2014-12-14T14:12:56+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1297&p=1527#p1527 <![CDATA[Re: Speed of neck]]>
I have found a sollution for the quick movement of the camera.
Now the camera pans a 160degrees and shows a picture.

Can you please tell me where the cv2.waitKey( 1 ) in line 61, is for?

Next step is to stop the camera when it finds a ball...

Code:
#! /usr/bin/python

# This example shows how to use the websockets interface to make the robot move around

import time
import argparse
import cv2
import py_websockets_bot

max_up_degrees = 30.0
max_down_degrees = 150.0
hor_degrees = 140.0
step = 1.0
pan_max = 180.0
pan_start = 10.0
pan_end = 170.0
latest_small_camera_image = None

#---------------------------------------------------------------------------------------------------
def camera_small_image_callback( image, image_time ):
   
    global latest_small_camera_image
   
    # Put image processing here...
   
    latest_small_camera_image = image 

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

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

    args = parser.parse_args()

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

    #center neck
    bot.centre_neck()
    time.sleep( 1.0 )

    # Look horizontal
    bot.set_neck_angles( pan_angle_degrees=90.0, tilt_angle_degrees=hor_degrees )
    time.sleep( 0.1 )

    # Start streaming images from the camera
    bot.start_streaming_small_camera_images( camera_small_image_callback )
    time.sleep ( 1.0 )

    # scan left to right
    try:
        for i in range(10,  170, 1):
            bot.set_neck_angles( pan_angle_degrees = i, tilt_angle_degrees=hor_degrees )
            bot.update()
            time.sleep( 0.5 )
            print i
            if latest_small_camera_image != None:
                cv2.imshow( "small_image", latest_small_camera_image )
            cv2.waitKey( 1 )       

    except KeyboardInterrupt:
        pass    # Catch Ctrl+C


    #center neck
    bot.centre_neck()
    time.sleep( 1.0 )

    # Stop
    bot.set_motor_speeds( 0.0, 0.0 )
    time.sleep( 0.75 )


    # Disconnect from the robot
    bot.disconnect()

Statistics: Posted by DannyM — Sun Dec 14, 2014 2:12 pm


]]>
2014-12-14T12:49:02+01:00 2014-12-14T12:49:02+01:00 http://forum.dawnrobotics.co.uk/viewtopic.php?t=1297&p=1526#p1526 <![CDATA[Speed of neck]]>
Is it possible to set the speed of the neck, like done in the speed of the wheels.
With motor_test.py the neck is rapidly changed.

Danny

Statistics: Posted by DannyM — Sun Dec 14, 2014 12:49 pm


]]>