Skip to main content

Posts

Showing posts with the label java

Introduction to rosjava at ROSCon 2012

I just got back from my trip to the inaugural ROSCon. Putting faces to names within the ROS community was a great experience. Beyond that, many of the sponsors brought in some hardware to play with! My rosjava talk was well attended and the video is now up on YouTube. It's aimed at developers who are already familiar with both ROS and Java. After just a single year since its release, I was pleasantly surprised by the number of awesome projects using rosjava. With a 1.0 release of rosjava nearing, it is becoming easier to use. I hope that improves traction and I can't wait to see what people start doing with it this year.
Read more

Android Fling Detection

I found existing tutorials on how to do this to be a bit complicated. Here's how to do simple fling detection in four directions: public interface FlingListener { void onTopToBottom(); void onBottomToTop(); void onLeftToRight(); void onRightToLeft(); } public class FlingDetector { static final int SWIPE_MIN_DISTANCE = 120; static final int SWIPE_MAX_OFF_PATH = 250; static final int SWIPE_THRESHOLD_VELOCITY = 200; private final GestureDetector gestureDetector; public FlingDetector(final FlingListener listener) { gestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() { @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) { if (Math.abs(e1.getX() - e2.getX()) > SWIPE_MAX_OFF_PATH || Math.abs(velocityY) SWIPE_MIN_DISTANCE) { listener.onBottomToTop(); ...
Read more

Flying the Parrot AR.Drone with a Wiimote and Nunchuck

I received a Parrot AR.Drone for Christmas this year! However, I don't have an iPhone and that makes it harder to get started. So far, the best solution I've found is flying it with a Wiimote and Nunchuck. Checkout the source for FitAR.Drone . Download osgi.core.jar from the OSGi Alliance  and copy it to the FitAR.Drone source directory. Import the project into Eclipse. Add all the JARs in the source directory to the project's build path. Now, connect your computer to the ardrone_xxx ad hoc network and check that Bluetooth is enabled on your computer. Then, build and run Main.java from org.fitardrone.main and follow the directions printed to the console: press 1 and 2 together on the Wiimote to initiate the connection, wait for the console to indicate that the Nunchuck was found, press 1 to take off, and fly! Oh, and: press 2 to land, home to kill the motors (i.e. emergency), use the D-pad to turn and adjust altitude, and use the analog stick to move. The...
Read more

MJPEG Streaming Protocol

MJPEG is a popular format for webcam streams. It's probably popular because it's so simple to do and the performance is surprisingly good. Unfortunately, I found it quite difficult to scrape together enough information to implement a streamer myself. In an effort to help the next poor, frustrated soul, here's a simple method for streaming an MJPEG to a socket in Java. public void handleConnection(Socket socket, JpegProvider jpegProvider) throws Exception { byte[] data = jpegProvider.getJpeg(); OutputStream outputStream = socket.getOutputStream(); outputStream.write(( "HTTP/1.0 200 OK\r\n" + "Server: YourServerName\r\n" + "Connection: close\r\n" + "Max-Age: 0\r\n" + "Expires: 0\r\n" + "Cache-Control: no-cache, private\r\n" + "Pragma: no-cache\r\n" + "Content-Type: multipart/x-mixed-replace; " + "boundary=--BoundaryString\r\n\r\n...
Read more

Make Eclipse Ignore .svn Directories

I've struggled with this for a while now. But, I think I've found all the appropriate settings now. Project > Properties > Java Build Path For each source folder, edit Excluded to include the pattern "**/.svn*" Project > Properties > Java Compiler > Building > Enable project specific settings Check the box. Project > Properties > Java Compiler > Building > Output folder > Filtered resources Add ".svn/" so that it reads "*.launch, .svn/" YMMV :)
Read more

OneSwarm is what I've been waiting for!

OneSwarm is a friend-to-friend (F2F) file sharing network built on BitTorrent and SSL. This is an idea I've been tossing around for awhile and now, I'm happy to say, I don't have to write it myself. Here are the main selling points: Open source. Hooray! Cross platform. OneSwarm is written in Java and they have binaries for OS X, Windows, and Linux. Friend-to-friend. I'm not interested in sharing with the world, just amongst my friends. BitTorrent based transfers. That means swarming for common files shared among your friends. My previous F2F client WASTE doesn't offer that. Point to point SSL encryption. I feel much better about SSL than the encryption scheme used by WASTE. Google Talk integration. OneSwarm piggybacks key distribution over GTalk. That really makes life easy. Web interface. It lends itself to remote administration. I've only just started using it, so I'll post again with my experiences later.
Read more

Relearning Java

The last time I wrote Java code was my freshman and sophomore year of college. Six years later, Java has had 2 "minor" revisions and the nutshell book has tripled in size. Java in a Nutshell is the kind of nut only an African swallow could carry. But, I'll try to keep an open mind.
Read more