Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
John Collins committed Sep 28, 2019
1 parent 3753865 commit bb5dc20
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# clj-rosbag

Clojure(Script) ROS bag reader.
2 changes: 0 additions & 2 deletions src/clj/clj-rosbag/core.clj

This file was deleted.

12 changes: 3 additions & 9 deletions src/clj/clj_rosbag/core.clj
Original file line number Diff line number Diff line change
@@ -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])

Expand Down Expand Up @@ -43,7 +43,7 @@

(defn from-bag-msg
([msg] (->RosMessage (.getTopic msg)
(.getMessage msg)
(msg-type->map (.getMessage msg))
(.getTimestamp msg))))

(defn open
Expand All @@ -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)))))
16 changes: 8 additions & 8 deletions src/cljs/clj_rosbag/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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))

0 comments on commit bb5dc20

Please sign in to comment.