commit 807b0a818b6bb6c36e3592074181eb95f17e4ac7
Author: Tom Mullins <tmullins@andrew.cmu.edu>
Date:   Sun Apr 22 13:52:46 2012 -0400

    Added joystick_node for the new node_control system
    
    It can also enable/disable altitude_node's thrust messages, and publish
    its own instead.

diff --git a/mikrokopter/joystick_node/CMakeLists.txt b/mikrokopter/joystick_node/CMakeLists.txt
new file mode 100644
index 0000000..b92ccea
--- /dev/null
+++ b/mikrokopter/joystick_node/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 2.4.6)
+include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
+
+rosbuild_init()
+
+set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
+set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
+
+#rosbuild_genmsg()
+#rosbuild_gensrv()
+
+rosbuild_add_executable(${PROJECT_NAME} src/joystick_node.cpp)
diff --git a/mikrokopter/joystick_node/Makefile b/mikrokopter/joystick_node/Makefile
new file mode 100644
index 0000000..b75b928
--- /dev/null
+++ b/mikrokopter/joystick_node/Makefile
@@ -0,0 +1 @@
+include $(shell rospack find mk)/cmake.mk
\ No newline at end of file
diff --git a/mikrokopter/joystick_node/mainpage.dox b/mikrokopter/joystick_node/mainpage.dox
new file mode 100644
index 0000000..6cf7f8b
--- /dev/null
+++ b/mikrokopter/joystick_node/mainpage.dox
@@ -0,0 +1,26 @@
+/**
+\mainpage
+\htmlinclude manifest.html
+
+\b joystick_node is ... 
+
+<!-- 
+Provide an overview of your package.
+-->
+
+
+\section codeapi Code API
+
+<!--
+Provide links to specific auto-generated API documentation within your
+package that is of particular interest to a reader. Doxygen will
+document pretty much every part of your code, so do your best here to
+point the reader to the actual API.
+
+If your codebase is fairly large or has different sets of APIs, you
+should use the doxygen 'group' tag to keep these APIs together. For
+example, the roscpp documentation has 'libros' group.
+-->
+
+
+*/
diff --git a/mikrokopter/joystick_node/manifest.xml b/mikrokopter/joystick_node/manifest.xml
new file mode 100644
index 0000000..7684f47
--- /dev/null
+++ b/mikrokopter/joystick_node/manifest.xml
@@ -0,0 +1,15 @@
+<package>
+
+  <description brief="joystick_node">
+    Publishes roll/pitch/yaw settings to /mikrokopter/velocity and /mikrokopter/yaw
+  </description>
+  <author>Tom Mullins</author>
+  
+  <depend package="roscpp"/>
+  <depend package="std_msgs"/>
+  <depend package="sensor_msgs"/>
+  <depend package="mikrokopter"/>
+
+</package>
+
+
diff --git a/mikrokopter/joystick_node/src/joystick_node.cpp b/mikrokopter/joystick_node/src/joystick_node.cpp
new file mode 100644
index 0000000..92f918d
--- /dev/null
+++ b/mikrokopter/joystick_node/src/joystick_node.cpp
@@ -0,0 +1,76 @@
+#include "ros/ros.h"
+#include "std_msgs/Float64.h"
+#include "std_msgs/Bool.h"
+#include "sensor_msgs/Joy.h"
+#include "mikrokopter/Velocity2D.h"
+
+// TODO
+// publish to /altitude_node/enable based on a button
+// publish velocity like in joystick_control.cpp
+
+class JoystickNode
+{
+public:
+  JoystickNode();
+  void main_loop() {ros::spin();}
+  void joy_cb(const sensor_msgs::Joy::ConstPtr& joy);
+
+private:
+  bool altitude_enabled;
+  bool alt_en_pressed;
+  ros::NodeHandle nh;
+  ros::Subscriber joy_sub;
+  ros::Publisher velocity_pub;
+  ros::Publisher yaw_pub;
+  ros::Publisher thrust_pub;
+  ros::Publisher altitude_enable_pub;
+};
+
+JoystickNode::JoystickNode() : altitude_enabled(false), alt_en_pressed(false)
+{
+  joy_sub = nh.subscribe<sensor_msgs::Joy>("/joy", 100, &JoystickNode::joy_cb,
+      this);
+  velocity_pub = nh.advertise<mikrokopter::Velocity2D>("/mikrokopter/velocity",
+      100);
+  yaw_pub = nh.advertise<std_msgs::Float64>("/mikrokopter/yaw", 100);
+  thrust_pub = nh.advertise<std_msgs::Float64>("/mikrokopter/thrust", 100);
+  altitude_enable_pub = nh.advertise<std_msgs::Bool>("/altitude_node/enable",
+      100);
+}
+
+void JoystickNode::joy_cb(const sensor_msgs::Joy::ConstPtr& joy)
+{
+  mikrokopter::Velocity2D vel;
+  vel.forward = joy->axes[1];
+  vel.lateral = -joy->axes[0];
+  velocity_pub.publish(vel);
+  
+  std_msgs::Float64 yaw;
+  yaw.data = -joy->axes[2];
+  yaw_pub.publish(yaw);
+  
+  bool alt_en_down = joy->buttons[0];
+  if (alt_en_down && !alt_en_pressed) // toggle altitude control
+  {
+    altitude_enabled = !altitude_enabled;
+    
+    std_msgs::Bool enable;
+    enable.data = altitude_enabled;
+    altitude_enable_pub.publish(enable);
+  }
+  alt_en_pressed = alt_en_down;
+  
+  if (!altitude_enabled)
+  {
+    std_msgs::Float64 thrust;
+    thrust.data = (joy->axes[3]+1)/2;
+    thrust_pub.publish(thrust);
+  }
+}
+
+int main(int argc, char **argv) {
+  ros::init(argc, argv, "joystick_node");
+  JoystickNode jn = JoystickNode();
+  jn.main_loop();
+  return 0;
+}
