Another XMas, another vehicle
Got the ground station converted to UDP as planned. A UDP client in Java is straightforward,
Send to server:
dgram = new DatagramSocket();
inetAddress = InetAddress.getByName(hostname);
dpIn = new DatagramPacket(buffer, buffer.length, inetAddress, port);
Read response from server after sending:
dpOut = new DatagramPacket(buffer, buffer.length);
A UDP server in C is convoluted:
Wait for client to send something:
socket_fd = socket(PF_INET, SOCK_DGRAM, 0);
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = htonl(INADDR_ANY);
bind(socket_fd, (struct sockaddr*)&addr, sizeof(addr)) >= 0)
struct sockaddr_in si_other;
int slen = sizeof(si_other);
recvfrom(socket_fd, buffer, BUFFER_SIZE, 0, (struct sockaddr *)&si_other, &slen);
Send response to client:
sendto(socket_fd, data, size, 0, (struct sockaddr *)&si_other, slen);
A UDP client in C is a bit more bearable:
struct sockaddr_in name;
struct hostent *hostinfo;
name.sin_family = AF_INET;
name.sin_port = htons(port);
hostinfo = gethostbyname(hostname);
name.sin_addr = *(struct in_addr *)hostinfo->h_addr;
connect(socket, (struct sockaddr*)&name, sizeof(name))
write(socket, buffer, BUFFER_SIZE);
read(socket, buffer, BUFFER_SIZE);
The read call needs to have enough buffer space to hold a complete packet or it truncates the packet.
The key is using recvfrom for the server to get the port to send the response to, because even though UDP is connectionless, each packet sent from the client contains an ephemeral port number the same socket can receive on.
Things were much more reliable in UDP.
Anyways, decided to begin the next vehicle, another rover. The rover 5 platform seems to have a high degree of motor speed control. There is a better document than the one on $parkfun:
But still missing is the fact that the encoder outputs are 0-5V, so you don't need to amplify the photodiode levels. This vehicle is going to take some time to bring up. Once again, it uses bare minimum software video compression, leading to a horrible but cheap, digital picture.
It could probably fit the Canon T4I with ancient 2.4Ghz video transmitter, giving a higher quality feed, but it wouldn't support wifi.
|Category||Thread||Thread Starter||Forum||Replies||Last Post|
|Video||ModelAero.com Drifter Surface Vehicle Video||Syner01||Car Talk||3||May 05, 2013 05:56 PM|
|Question||Frequency control for surface vehicles||Andy W||SEFF 2012||6||Mar 12, 2012 04:00 PM|
|Discussion||Quadcopters as flying vehicles||mun35||Multirotor Talk||6||Mar 09, 2012 09:50 AM|
|Question||best(xmas) sub micro for my son(8) and I (xmas)?||ant141110||Coaxial Helicopters||23||Dec 19, 2009 10:29 AM|