Pages

Tuesday, July 26, 2011

How to resolve - "HttpWebRbRequest: The request was aborted: The request was cancelled." error.

Yesterday, I came across this new error message when doing HttpWebRbRequests in C# (.NET 3.5).

After doing a quick search, I see that it is a common problem with several solutions that has worked for different applications. This link here points to different solutions: HttpWebRequest: The request was aborted: The request was canceled

In my application, I have upto 16 identical threads doing simultaneous HTTP requests. However, each of these threads are requesting from different webservers along with unique local endpoints. Now the function making these calls has 3 successive HTTP requests to make (to the same webserver).

None of the above solutions worked for me, but the following combination did however.


System.Net.ServicePointManager.DefaultConnectionLimit = 200;
System.Net.ServicePointManager.MaxServicePointIdleTime = 2000;
System.Net.ServicePointManager.MaxServicePoints = 1000;
System.Net.ServicePointManager.SetTcpKeepAlive(false, 0, 0);

HttpWebRequest webRequest1 = (HttpWebRequest)WebRequest.Create("http://" + gatewayIP
 + "/xslt?PAGE=J04");
webRequest1.KeepAlive = false;
webRequest1.Timeout = 2000;
//Do other stuff here...
//Close response stream

Thread.Sleep(2000); //This delay seems to help.

HttpWebRequest webRequest2 = (HttpWebRequest)WebRequest.Create("http://" + gatewayIP
 + "/xslt?PAGE=J04");
webRequest2.KeepAlive = false;
webRequest2.Timeout = 2000;
//Do other stuff here...
//and so on...




Monday, June 6, 2011

Mobot keeping an eye out for green things...

Mobot is attracted by round green things. Here is a candid video.



Notice the jitter in the servo used for up/down motion of the eye. This most often due to noise. However, in this case, I believe it's due to the servo itself. It has shown this behavior even when kept away from other circuits.

Sunday, May 29, 2011

A MoBot is born!

Say hello to my little friend!!


Mobot here is based on the Rover 5 chassis with four motors and encoders. It's motors are controlled by a Pololu Qik 2s9v1 Dual Serial Motor Controller. To keep cost down and also improve battery life, I am using only 2 of the motors. So I had to remove a key gear in the other two motor boxes to keep them free running.

The Qik Serial appears as a serial port in the Beagleboard and commands could sent simply by writing on the port file. In my case it was "/dev/ttyS1".

The encoders are level shifted and connected to the Beaglebaord's GPIO pins. A single thread running 1000 times a second keeps track of the quadrature encoder counts.

I have incorporated a PID loop for speed control and another PI loop for position control. The algorithm was derived from the book Embedded Robotics by Thomas Bräunl which has an excellent chapter on PID control for differential drive robots.

Mobot has a Logitech C120 webcam for an eye and can look around using a servo pan-tilt bracket.

Sunday, February 27, 2011

Ball Tracking with OPENCV

Again, mechomaniac's article gave me jump-start to tracking a ball.

Below is a video of the code in action. I had to tweak parameters to the cvHoughCircles() function and the HSV thresholds to prevent false detection.



An important thing to note is that OpenCV's HSV format stores the Hue component as an 8-bit integer in the range of 0-179. This is unlike other graphics software which use Hue values from 0-255.

I observed the following frame rates:

Frame rates vs Resolution
Resolution With Hough Circle detection Without Hough Circle detection
320x240 ~5fps ~9fps
640x480 ~2fps ~4fps

Based on the benchmark here, I agree with the author that there might be a USB bandwidth limitation that is resulting in low frame rates. I am looking at using the DSP on the board to speed up OpenCV and use a direct interface to a camera to acquire images.

Sunday, January 30, 2011

Camera capture using OpenCV

I had a Logitech C120 camera lying around and found that Angstrom had drivers for it. It was about 1:00am and I couldn't wait till I captured an image.

OpenCV is a popular library for image processing. I found this post which got me started with OpenCV. But you must also install opencv-dev to get the header files or the program will not compile.

To get OpenCV:

opkg update
opkg install task-native-sdk cpp gccmakedep
opkg install python-distutils python-compile python-compiler python-devel
opkg install ffmpeg-dev
opkg install opencv
opkg install opencv-dev
My wireless connection was not very good, so I got several package download failures with "wget returned 1". I just switched to USB Ethernet and it went smooth.

Also, if you get "But that file is already provided by package xxx" errors while installing opencv-dev, just uninstall opencv and try again from step 5. I am not sure what the problem was, but it worked the second time.

Finally, around 3:00am I captured the first images. I went to bed both satisfied and eager to get back to my desk and track a ball or something!

Sunday, January 9, 2011

Development using Netbeans

Angstrom comes with DropBear SSH a lightweight SSH. But it is recommended to use OpenSSH instead.

To install openssh:
opkg -force-removal-of-dependent-packages remove dropbear
opkg install openssh openssh-sftp-server
Tim Pitman has a neat article that explains how to setup Netbeans for remote development on a MAC.

To share the rootfs on Windows:
  1. Configure samba (/etc/samba/smb.conf) to allow access to the rootfs. You can do this by adding the following in the "Share Definitions" section.
    [public]
    path = /
    public = yes
    writable = yes
    printable = no

  2. Map \\BEAGLEBOARD\public as a network drive in Windows.

Sunday, January 2, 2011

BeagleBoard Networking

Wired networking
The BeagleBoard-xM has an in built Ethernet port. But I used a Linksys USB300M with my C4 version. Angstrom has drivers for the ASIX chip in the USB300M and it installs automatically as eth0 and defaults to DHCP. On Win7, I bridged this with my wireless connection to get internet access for my board.

I assigned a static IP to eth0 by adding this information to /etc/network/interfaces file:
#Bring up the interface automatically. 
#Otherwise, must use "ifup eth0" or "ifconfig eth0 up" everytime.
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.105 netmask 255.255.255.0 gateway 192.168.1.1

Wireless Networking
For WiFi, this table shows the supported chipsets and vendors. I use a Netgear WG111v3 adapter which has the rtl8187 chipset.
auto wlan0
iface wlan0 inet static
wireless-essid xxxxYourESSIDxxx wireless-key xxxx wireless-ap xx:xx:xx:xx:xx:xx address 192.168.1.10 netmask 255.255.255.0 gateway 192.168.1.1

Bringing up the Beagle

One of the important things to have for development on the BeagleBoard is another Linux machine. I have a Windows 7 PC, so I installed an Ubuntu virtual machine using Sun Virtual Box. Using the virtual machine additions, you can share USB devices and folders with the virtual machine.

I managed to get Angstrom up and running on a 2GB SD card following instructions from the beginner's tutorial here.

Once you log into the beagleboard, change the root password using the passwd command. This is a must for SSH-ing into the board.