diff --git a/README.md b/README.md index 41a7786..c073664 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # clj-rosbag + Clojure(Script) ROS bag reader. diff --git a/src/clj/clj-rosbag/core.clj b/src/clj/clj-rosbag/core.clj deleted file mode 100644 index 971dd54..0000000 --- a/src/clj/clj-rosbag/core.clj +++ /dev/null @@ -1,2 +0,0 @@ -(ns clj-rosbag.core) - diff --git a/src/clj/clj_rosbag/core.clj b/src/clj/clj_rosbag/core.clj index eb13dcb..9667a1b 100644 --- a/src/clj/clj_rosbag/core.clj +++ b/src/clj/clj_rosbag/core.clj @@ -1,6 +1,6 @@ (ns clj-rosbag.core (:import [com.github.swrirobotics.bags.reader BagFile] - [com.github.swrirobotics.bags.reader.messages.serialization BagMessage MessageType ArrayType])) + [com.github.swrirobotics.bags.reader.messages.serialization MessageType ArrayType])) (defrecord RosMessage [topic message time]) @@ -43,7 +43,7 @@ (defn from-bag-msg ([msg] (->RosMessage (.getTopic msg) - (.getMessage msg) + (msg-type->map (.getMessage msg)) (.getTimestamp msg)))) (defn open @@ -65,10 +65,4 @@ (def file (File. "resources/planar_lidar.bag")) (def bag (open (.getPath file))) (def msgs (read-messages bag)) - (def msg (:message (first msgs))) - (def field-names (.getFieldNames msg)) - (def angle-increment (.getField msg "angle_increment")) - (def angle-increment-type (.getType angle-increment)) - (def ranges (.getField msg "ranges")) - (def ranges-type (.getType ranges)) - (msg-type->map msg))) + (def msg (:message (first msgs))))) diff --git a/src/cljs/clj_rosbag/core.cljs b/src/cljs/clj_rosbag/core.cljs index f6706d1..40b786c 100644 --- a/src/cljs/clj_rosbag/core.cljs +++ b/src/cljs/clj_rosbag/core.cljs @@ -13,14 +13,7 @@ (fn [msg] (put! ch msg)))))) -(defn read-messages - "Asyncronously reads messages into a channel." - ([bag] (read-messages (chan))) - ([bag ch compression] - (read-bag ch bag) - ch)) - -(defn open-bag +(defn open [bag-str] (let [size (.-length bag-str) char-codes (js/Array. size) @@ -29,3 +22,10 @@ byte-array (js/Uint8Array. char-codes) blob (js/Blob. #js[byte-array])] (Rosbag/open blob))) + +(defn read-messages + "Asyncronously reads messages into a channel." + ([bag] (read-messages (chan))) + ([bag ch compression] + (read-bag ch bag) + ch))