diff --git a/ProjectFiles/js/ros_scripts.js b/ProjectFiles/js/ros_scripts.js index 6b5c08b..8de6320 100644 --- a/ProjectFiles/js/ros_scripts.js +++ b/ProjectFiles/js/ros_scripts.js @@ -3,9 +3,11 @@ var ros = new ROSLIB.Ros(); ros.topics = []; ros.nodes = []; -ros.connectioninfo = ['ws://', '192', '168', '0', '100', '9090']; -// ros.connectionName = 'ws://localhost:9090'; +ros.recording = false; + + ros.connectionName = 'ws://192.168.0.100:9090'; + // If there is an error on the backend, an 'error' emit will be emitted. ros.on('error', function(error) { document.getElementById("ConnectionIPForm").className = "form-group has-warning has-feedback"; @@ -47,6 +49,56 @@ ros.on('close', function() { ros.connect(ros.connectionName); +/////////////////////////////////////////////////////////////////////////////////// +// Publishers +/////////////////////////////////////////////////////////////////////////////////// + +function publishBagMessage(bagFilename) +{ + var bagMessage = new ROSLIB.Message({ + data : bagFilename + }) + bagPublisher.publish(bagMessage) +} + +//////////////////////////////////////////////////////////////// +// Topics +//////////////////////////////////////////////////////////////// + +var bagPublisher = new ROSLIB.Topic({ + ros : ros, + name : 'bag_publisher', + messageType : 'std_msgs/String' +}); + +var bagNotifier = new ROSLIB.Topic({ + ros : ros, + name : 'bag_notifier', + messageType : 'std_msgs/String' +}); + +//////////////////////////////////////////////////////////////// +// Subscribers +//////////////////////////////////////////////////////////////// + + +bagNotifier.subscribe(function(message) { + if (message.data === "STARTED") { + document.getElementById("recordButtonText").innerHTML = "Stop" + document.getElementById("recordButton").className = "btn btn-danger" + } else { + document.getElementById("recordButtonText").innerHTML = "Start" + document.getElementById("recordButton").className = "btn btn-primary" + } +}); + + +/////////////////////////////////////////////////////////////////////////////////// +// Functions +/////////////////////////////////////////////////////////////////////////////////// + + + // attept to connect to the ros master from the IP given orgrab it from the form ros.attemptConnection = function(ipAddress) { @@ -113,4 +165,17 @@ function getTime() { console.log("Getting Time..."); console.log(result.time.secs); }); -}; \ No newline at end of file +}; + +function toggleRecording() +{ + document.getElementById("recordButtonText").innerHTML = "Wait" + document.getElementById("recordButton").className = "btn btn-warning" + if (!ros.recording) { + ros.recording = true + publishBagMessage(document.getElementById("recordText").value) + } else { + ros.recording = false + publishBagMessage("STOP") + } +} \ No newline at end of file diff --git a/data/_2015-06-01-12-38-44.bag b/data/_2015-06-01-12-38-44.bag new file mode 100644 index 0000000..a81b3f5 Binary files /dev/null and b/data/_2015-06-01-12-38-44.bag differ diff --git a/index.html b/index.html index ab3ff5b..aa67242 100644 --- a/index.html +++ b/index.html @@ -66,7 +66,7 @@ - +
@@ -75,9 +75,18 @@
- +
+
+ + + + +
+
@@ -91,87 +100,115 @@
+
- + +
No data recieved yet.
+ +
+ + + +
+ N/A +
+ +
+ +
+ + + +
+ N/A +
+ +
+
-
- -
- N/A -
-
+ - + -
+
-
-
-
-
+
+
- + +
+ + + + + +
+ + + + +
+
-
-
-
- - -
+ +
+
+ +
+
+ ROS Topics +
+
+ +
+ N/A
- - -
-
- -
-
- ROS Topics -
-
- -
- N/A
-
-
-
- ROS Nodes -
-
+
+
+ ROS Nodes +
+
-
- N/A +
+ N/A +
-
+
-
- - + + diff --git a/launch/all.launch b/launch/all.launch index fd379e5..2424b89 100644 --- a/launch/all.launch +++ b/launch/all.launch @@ -1,4 +1,5 @@ + \ No newline at end of file diff --git a/launch/talker.launch b/launch/talker.launch new file mode 100644 index 0000000..c39f905 --- /dev/null +++ b/launch/talker.launch @@ -0,0 +1,3 @@ + + + diff --git a/src/bagger.py b/src/bagger.py index ae7b8d2..58acc4d 100755 --- a/src/bagger.py +++ b/src/bagger.py @@ -23,8 +23,7 @@ class Bagger(object): else: bag_file = os.path.join(self.data_path, msg.data) self.proc = subprocess.Popen(["rosbag", "record", - "kinect2/depth_lowres/points", "kinect2/rgb_lowres/image", - "tf", "imu/data", "-o", bag_file], preexec_fn=os.setsid) + "--all", "-o", bag_file], preexec_fn=os.setsid) self.pub.publish("STARTED") diff --git a/src/bagger.py~ b/src/bagger.py~ new file mode 100755 index 0000000..ae7b8d2 --- /dev/null +++ b/src/bagger.py~ @@ -0,0 +1,33 @@ +#!/usr/bin/env python +import rospy +from std_msgs.msg import String +import rospkg +import subprocess +import os +import signal + +class Bagger(object): + + def __init__(self): + rospy.init_node("bagger", anonymous=True) + rospy.Subscriber("bag_publisher", String, self.callback) + self.pub = rospy.Publisher("bag_notifier", String, queue_size=10) + self.proc = None + rospack = rospkg.RosPack() + self.data_path = os.path.join(rospack.get_path("rosbridge_GUI_example"), "data") + + def callback(self, msg): + if msg.data == "STOP" and self.proc is not None: + os.killpg(self.proc.pid, signal.SIGINT) + self.pub.publish("STOPPED") + else: + bag_file = os.path.join(self.data_path, msg.data) + self.proc = subprocess.Popen(["rosbag", "record", + "kinect2/depth_lowres/points", "kinect2/rgb_lowres/image", + "tf", "imu/data", "-o", bag_file], preexec_fn=os.setsid) + self.pub.publish("STARTED") + + +if __name__ == '__main__': + Bagger() + rospy.spin() diff --git a/src/talker.py b/src/talker.py new file mode 100755 index 0000000..b4bc6f6 --- /dev/null +++ b/src/talker.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# license removed for brevity +import rospy +from std_msgs.msg import String + +def talker(): + pub = rospy.Publisher('chatter', String, queue_size=10) + rospy.init_node('talker', anonymous=True) + rate = rospy.Rate(10) # 10hz + while not rospy.is_shutdown(): + hello_str = "hello world %s" % rospy.get_time() + rospy.loginfo(hello_str) + pub.publish(hello_str) + rate.sleep() + +if __name__ == '__main__': + try: + talker() + except rospy.ROSInterruptException: + pass diff --git a/src/talker.py~ b/src/talker.py~ new file mode 100644 index 0000000..e69de29