Posts Tagged ‘arduino’

Kinect Car

 

 

De’Ranged Bot from Kazi Murtaza.

My FYP, just started

hello hi, as this is my final semester in my university Szabist doing Bs-Computing, and my final year project is Autonomous Obstacle Detection And Avoidance on Scaled Car Model, yes its a mouth full,
my objective is;

  • Navigating System, which controls the car for autonomous obstacle avoidance
  • System, Flexible enough to be implementing on other robots, or future projects.

Using state of art Technology Like; Kinect for computer vision, micro controllers  like; Raspberry Pi, Netduino and Arduino this could never be easier, achieving this goal is challenging but possible, this will be an interesting project at least. My basic draft concept at this point is;  a robot using four-wheeled, deferentially steered, The base of the robot is almost rectangular, The robot is equipped with two batteries, each 30 Ah 12 V, supplying the robot and the Kinect sensor with power. Besides the Kinect sensor, the robot is also equipped with range sensors. Four analogous SHARP IR sensors, GP2Y0A21YK, two placed in the robot’s direction of heading and the other two pointing in the opposite direction. In addition, the robot is equipped with two digital ultrasonic Maxsonar EZ1 from MaxBotix pointing forward. The IR and ultrasonic sensors are used for emergency situations only, bypassing the navigation system by braking the motors in case the risk of collision is imminent. The robot is equipped with four microcontrollers. Two of the microcontrollers read wheel encoder values and control the rotational speed of the two motors. The third microcontroller controls the power supply and monitors the charging of the batteries. The fourth microcontroller handles communication between the other controllers as well as processing of sensor input from the IR and ultrasonic sensors. It also handles the communication between the robot and the laptop running the navigation system. The robot and the Kinect sensor are connected via USB to the laptop placed on top of the robot.

So far what I have achieved is installed Kinect on my Machine for testing the steps I followed were listed at this site here; but I guess the steps were not updated and there is difference at some points, which I will list down below.

Step 0

Uninstall any previews drivers, such as CLNUI. Look at the end of this post if you want to see how you can have multiple drivers installed.

Step 1

  • Download Kinect Drivers and unzip.
  • Open the unzipped folder and navigate to Platform/Win32/Driver.
  • Run dpinst-x86.exe (if you have a 32-bit processor) or dpinst-amd64.exe (if you have a 64-bit processor).

Step 2

Download and install the latest stable or unstable OpenNI Binaries from OpenNI website.

the link in step is a 404 and you should go and install OPENNI SDK v1.5.4.0 from here

Step 3

Download and install the latest stable or unstable OpenNI Compliant Middleware Binaries (NITE) from OpenNI website.

again the is 404 and you should go and install NiTE v1.5.2.2.1 from here (scroll to bottom of the page you will see), guide also stated that it will require a PrimeSense key: 0KOIk2JeIBYClPWVnMoRKn5cdY4= , which it did not.

Step 4

Download and install the latest stable or unstable OpenNI Compliant Hardware Binaries from OpenNI website.
Both stable and unstable releases have worked for me. If you have trouble installing the unstable releases, just try the stable ones.

again 404, go here and install OpenNI-Compliant Sensor Driver v5.1.2.1

Step 5

  • Plug in your Kinect device and connect its USB port with your PC.
  • Wait until the driver software is found and applied.
  • Navigate to the Device Manager (Control Panel). You should see something like the following:

Kinect in the Device Manager window
You are nearly done.below steps were accurate;

Step 6

  • Download the KinectXMLs file and unzip. The extracted folders contain totally four XML files which are going to replace the ones OpenNI installed (the XMLs I provide simply contain the license key and the correct Kinect camera resolution).
  • Navigate to KinectXMLs\OpenNI folder and copy the SampleConfig.xml file. Navigate to C:\Program Files\OpenNI\Data (if you have a 32-bit processor) or C:\Program Files (x86)\OpenNI\Data (if you have a 64-bit processor) and replace SampleConfig.xml with the one you copied.
  • Navigate to KinectXMLs\NITE folder and copy the Sample-Scene.xml, Sample-Tracking.xml and Sample-User.xml files. Navigate to C:\Program Files\Prime Sense\NITE\Data (if you have a 32-bit processor) or C:\Program Files (x86)\Prime Sense\NITE\Data (if you have a 64-bit processor) and replace Sample-Scene.xml, Sample-Tracking.xml and Sample-User.xml with the ones you copied.

Step 7

Navigate to C:\Program Files\OpenNI\Samples\Bin\Release (or C:\Program Files (x86)\OpenNI\Samples\Bin\Release) and try out the existing demo applications. Try the demos found in C:\Program Files\Prime Sense\NITE\Samples\Bin\Release (or C:\Program Files (x86)\Prime Sense\NITE\Samples\Bin\Release), too. If they work properly, then you are done! Congratulations!

If they do not work, make sure that you have replaced the XML files I mentioned in step 5 with the ones I provided you. If the demos still do not work, try installing the stable version of OpenNI, middleware and hardware binaries. Personally, I have successfully installed OpenNI and NITE (both stable and unstable releases) in a 32-bit desktop and a 64-bit laptop following the methodology I described.

Step 8

You have successfully installed Kinect in your Windows PC! Read the documentation and familiarize yourself with the OpenNI and NITE API. You’ll find the proper assemblies in:

  • C:\Program Files\OpenNI\Bin (or C:\Program Files (x86)\OpenNI\Bin) and
  • C:\Program Files\Prime Sense\NITE\Bin (or C:\Program Files (x86)\Prime Sense\NITE\Bin)

OpenNI is the primary assembly you’ll need when developing Natural User Interfaces applications.

C# tutorials on using the managed OpenNI.net libraries coming soon! Stay tuned in this blog.

 
Original credit goes to, Software Developer Vangos Pterneas, a student of the Athens University of Economics and Business, Department of Informatics. This guide and any associated source codes and files is licensed under The Code Project website and also under the Code Project Open License. I wish to share this article to educate the Kinect community on how to install the Kinect to their Personal Computers. By doing so, we would like to advocate and promote the development of programs by developers worldwide.

Arduino WiFi Shield : JSON Parsing

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include ;
#include ;

char ssid[] = "Kazi-House"; // your network SSID (name)
char pass[] = "123456789"; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);

// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while(true);
}

// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network.
// Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);

// wait 10 seconds for connection:
delay(10000);
}
server.begin();
// you're connected now, so print out the status:
printWifiStatus();
pinMode(45, OUTPUT);
pinMode(46, OUTPUT);
pinMode(47, OUTPUT);
pinMode(48, OUTPUT);
pinMode(49, OUTPUT);
pinMode(51, OUTPUT);
}

void loop() {
// listen for incoming clients
WiFiClient client = server.available();
if (client) {
//Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
//Serial.write(c);
if(c=='1'){
if(client.read() == '=') {
char onoff = client.read();
if( onoff == '1'){
Serial.println("Center Bulb On");
digitalWrite(45,HIGH);
}
else if(onoff == '0'){
Serial.println("Center Bulb Off");
digitalWrite(45,LOW);
}
}
}
else if(c=='2'){
if(client.read() == '=') {
char onoff = client.read();
if( onoff == '1'){
Serial.println("No Device 1 On");
digitalWrite(46,HIGH);
}
else if(onoff == '0'){
Serial.println("No Device 1 Off");
digitalWrite(46,LOW);
}
}
}
else if(c=='3'){
if(client.read() == '=') {
char onoff = client.read();
if( onoff == '1'){
Serial.println("BathRoom TubeLight On");
digitalWrite(47,HIGH);
}
else if(onoff == '0'){
Serial.println("BathRoom TubeLight Off");
digitalWrite(47,LOW);
}
}
}
else if(c=='4'){
if(client.read() == '=') {
char onoff = client.read();
if( onoff == '1'){
Serial.println("No Device 2 On");
digitalWrite(48,HIGH);
}
else if(onoff == '0'){
Serial.println("No Device 2 Off");
digitalWrite(48,LOW);
}
}
}
else if(c=='5'){
if(client.read() == '=') {
char onoff = client.read();
if( onoff == '1'){
Serial.println("Room TubeLight On");
digitalWrite(49,HIGH);
}
else if(onoff == '0'){
Serial.println("Room TubeLight Off");
digitalWrite(49,LOW);
}
}
}
else if(c=='6'){
if(client.read() == '=') {
char onoff = client.read();
if( onoff == '1'){
Serial.println("No Device 3 On");
digitalWrite(51,HIGH);
}
else if(onoff == '0'){
Serial.println("No Device 3 Off");
digitalWrite(51,LOW);
}
}
}
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connnection: close");
client.println();
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
//Serial.println("client disonnected");
}
}

void printWifiStatus() {
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
}

Communication Mediums: Arduino WiFi, RN-42 Bluetooth, Netduino Ethernet

Hello, I have gotten my hands on couple of communication devices which could be used for android and Arduino/ Netduino communication, first RN-42 SMD bought from robotics.pk – link, Arduino WiFi Shield also bought from robotics.pk – link and third is Netduino it self which comes with Ethernet shield built-in, and Netduino is given to me by my teacher for educational purposes only, sad cant keep it.

Any ways lets start of with, RN-42 SMD is fairly cheap comparatively to others available for sale on spark fun  and is very easy to use you just need 4 connections VCC(3.3v),GND,RX and TX and you are done and by default RN-42 runs on 115200 braud rate, I found this to be very cheap and easy to use although for making connections on the smd, could be stressing, you would need small and steady hands, after making connections and connecting it to my Arduino Mega 2560, I used my serial Bluetooth android app and data transfer was done perfectly and fast, and range was acceptable, about 50 to 60 feet. it is perfect fit for short range, battery powered application.

Second device is WiFi Shield, which lets Arduino board connect to the internet using the 802.11 wireless specification and comes with a micro-SD card socket for saving of html pages and data logging,  we could either use the WiFi Shield as Server or Client and in my case I use it as a server, although Arduino cant process anything above HTML and JavaScript but we can do with these all so well, with WiFi Shield, we use Get and Post methods – (which I will explain in next post how?) to send and receive data from Arduino, from then on its same as serial monitor or Bluetooth. So from my android I send a request on the ip which is assigned to WiFi Shield through DHCP, request could be Get or Post and Arduino executes that request.

Arduino and WiFi Shield : Controlling my room lights from Kazi Murtaza on Vimeo.

Third device which is Netduino in-built Ethernet Shield, I have not gotten around to configure it yet, but will do it next. I feel the results will be same as Arduino WiFi Shield.

So in end I realized one thing, WiFi Shield is a bit buggy, sometimes requests in buffer of Arduino don’t really execute and if they do its 4-5 sec delay, I guess it takes time to process the request and its fairly new so needs a firmware update, so WiFi shield is not recommended for on second execution for example like WiFi controlled car, for such projects Bluetooth should be preferred, and for projects such as Home Automation and such WiFi is ideal.

 

 

things

Arduino: toggling leds through SERIAL monitor

ok here is a sample code which receives data from serial and toggles devices to test it you can plug in led’s to test it,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//for keeping the current status of leds
int status1 = 0;
int status2 = 0;
int status3 = 0;
int status4 = 0;
//leds connected to Arduino int pin1 = 2;
int pin2 = 4;
int pin3 = 6;
int pin4 = 8;
void setup() {
//open serial ports
Serial.begin(9600);
Serial.println("Serial Ready.");
Serial.println("Waiting...");
//open led ports
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
}
void loop() {
//keep the incoming byte, in readByte
int readByte;
boolean readSomething = false;
//read serial data
while(Serial.available() > 0 ){
readByte =  Serial.read();
readSomething = true;
Serial.println(readByte);
}
//if something was read toggle the selective device
if(readSomething){
readSomething = false;
if(readByte==1){ status1^=1; digitalWrite(pin1,status1);}
if(readByte==2){ status2^=1; digitalWrite(pin2, status2);}
if(readByte==3){ status3^=1; digitalWrite(pin3, status3);}
if(readByte==4){ status4^=1; digitalWrite(pin4, status4);}
}// status^=1 is xoring if its 0 it will be 1 and if its 1 it will be 0..
}