summaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authorMartin Miller2017-03-17 18:37:25 -0500
committerMartin Miller2017-03-17 18:37:25 -0500
commit3a7c300cb0cb8956ca00dc1abb7aca111a0db8a0 (patch)
tree9f27009956f51c46048e3ea8c4b0665a0216a8e8 /src/main.h
parentc284c54738cf8ac85e509581f6c496a5222eaf99 (diff)
downloadrefslam-3a7c300cb0cb8956ca00dc1abb7aca111a0db8a0.zip
refslam-3a7c300cb0cb8956ca00dc1abb7aca111a0db8a0.tar.gz
Write C input parser.
Sensor inputs can be read in from stdin if compiled without USE_ROS. Now "callback" functions can be written.
Diffstat (limited to 'src/main.h')
-rw-r--r--src/main.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/main.h b/src/main.h
new file mode 100644
index 0000000..805e5a9
--- /dev/null
+++ b/src/main.h
@@ -0,0 +1,79 @@
+#ifndef main_INC
+#define main_INC
+
+//#define USE_ROS /* Uncomment to use with ROS */
+
+#ifndef USE_ROS
+#include <cstdio>
+#include <cstring>
+#endif /* ----- USE_ROS ----- */
+
+#include <iostream>
+#include <Eigen/Dense>
+
+#define MAXLINE 8192
+#define MAXFILENAME 1024
+
+// A struct for storing x,y,z data.
+typedef struct {
+ double x,y,z;
+} tuple;
+
+// A struct for storing velocity in world frame
+typedef struct {
+ double east, north, up;
+} velocity_t;
+
+// A struct for storing attitude data.
+typedef struct {
+ double roll,pitch,yaw;
+} attitude_t;
+
+// A struct for storing UTM data.
+typedef struct {
+ double northing,easting,up;
+ int zone_i;
+ char zone_c;
+} UTM;
+
+// A struct for storing GPS data.
+typedef struct {
+ double latitude, longitude, altitude;
+} gps;
+
+// Message types
+typedef enum {BESTUTM,IMG,INSCOVS,INSPVAS,RAWIMUS} message_type;
+
+/*
+ * The message struct is a general container for all message types. Not all
+ * members are used for all messages, so care must be taken not to use garbage
+ * values.
+ */
+typedef struct {
+ int secs,nsecs;
+} timestamp;
+
+typedef struct {
+ // These should always be set.
+ timestamp stamp;
+ message_type msg_type;
+
+ // Only the members needed by the msg_type are stored.
+ tuple angular_velocity;
+ attitude_t attitude;
+ char image_names[2][MAXFILENAME];
+ tuple linear_acceleration;
+ gps position;
+ UTM utm;
+ velocity_t velocity;
+} message;
+
+int parseLine(char *line, message *msg);
+
+#ifdef USE_ROS
+void imuCallback();
+#else /* ----- not USE_ROS ----- */
+void imuCallback(const message *msg);
+#endif /* ----- not USE_ROS ----- */
+
+#endif /* ----- #ifndef main_INC ----- */