Added talker.py and ability to bag files
This commit is contained in:
@@ -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);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
BIN
data/_2015-06-01-12-38-44.bag
Normal file
BIN
data/_2015-06-01-12-38-44.bag
Normal file
Binary file not shown.
147
index.html
147
index.html
@@ -66,7 +66,7 @@
|
||||
<script src="../../include/js/bootstrap.min.js"></script>
|
||||
|
||||
|
||||
<!-- ##################################### ROS BAG PANEL ######################################### -->
|
||||
<!-- ##################################### ROS BAG PANEL ######################################### -->
|
||||
<!-- ROS Bag Panel -->
|
||||
<div class="panel panel-default">
|
||||
|
||||
@@ -75,9 +75,18 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<button id="ConnectionButton" type="button" >
|
||||
Connect
|
||||
</button>
|
||||
<div class="col-md-3">
|
||||
<div class="input-group">
|
||||
<input type="text" id="recordText" class="form-control" placeholder="bag_filename">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-primary" id="recordButton" type="button" onclick="toggleRecording()">
|
||||
<span id="recordButtonText">
|
||||
Start
|
||||
</span>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -91,87 +100,115 @@
|
||||
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="row">
|
||||
<label class="col-sm-2"> Bar Title </label>
|
||||
<label class="col-sm-2">
|
||||
Bar Title
|
||||
</label>
|
||||
|
||||
<div class="progress">
|
||||
<div id="progressBar1" class="progress-bar progress-bar-striped active" role="progressbar"
|
||||
aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:100%" >
|
||||
No data recieved yet. </div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<label class="col-sm-2">
|
||||
Up Time (s):
|
||||
</label>
|
||||
|
||||
<div class="col-sm-1" id="UpTime">
|
||||
N/A
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<label class="col-sm-2">
|
||||
Up Time (s):
|
||||
</label>
|
||||
|
||||
<div class="col-sm-1" id="UpTime">
|
||||
N/A
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<label class="col-sm-2"> Up Time (s): </label>
|
||||
<div class="col-sm-1" id="UpTime">
|
||||
N/A
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- ##################################### END ROS BAG PANEL ######################################### -->
|
||||
<!-- ##################################### END ROS BAG PANEL ######################################### -->
|
||||
|
||||
|
||||
<div class="tab-pane" id="rosbridgeconnection">
|
||||
<div class="tab-pane" id="rosbridgeconnection">
|
||||
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<form class="form-inline" role="form" onsubmit="return validateForm()">
|
||||
<div id="ConnectionIPForm" class="form-group has-warning" align="center">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
|
||||
<label id="ConnectionIPLabel" class="col-sm-3 control-label" for="inputWarning">
|
||||
Connection Warning
|
||||
</label>
|
||||
<form class="form-inline" role="form" onsubmit="return validateForm()">
|
||||
<div id="ConnectionIPForm" class="form-group has-warning" align="center">
|
||||
<span>
|
||||
<label id="ConnectionIPLabel" class="control-label" for="inputWarning">
|
||||
Connection Warning
|
||||
</label>
|
||||
</span>
|
||||
|
||||
<span>
|
||||
<div class="input-group">
|
||||
<input type="text" id="ConnectionIPInput" class="form-control" placeholder="bag_filename" value="No IP Address yet">
|
||||
<span class="input-group-btn">
|
||||
<button id="ConnectionButton" type="button" onclick="ros.attemptConnection()">
|
||||
Connect
|
||||
<script type="text/javascript">
|
||||
document.getElementById("ConnectionIPInput").value = ros.connectionName;
|
||||
</script>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" id="ConnectionIPInput" value="No IP Address yet"/>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-2">
|
||||
<button id="ConnectionButton" type="button" onclick="ros.attemptConnection()">
|
||||
Connect
|
||||
</button>
|
||||
<script type="text/javascript">
|
||||
document.getElementById("ConnectionIPInput").value = ros.connectionName;
|
||||
</script>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
ROS Topics
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="col-sm-1" id="ROSTopics">
|
||||
N/A
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
ROS Topics
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="col-sm-1" id="ROSTopics">
|
||||
N/A
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
ROS Nodes
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
ROS Nodes
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="col-sm-1" id="ROSNodes">
|
||||
N/A
|
||||
<div class="col-sm-1" id="ROSNodes">
|
||||
N/A
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<launch>
|
||||
<include file="$(find rosbridge_server)/launch/rosbridge_websocket.launch" />
|
||||
<include file="$(find rosbridge_GUI_example)/launch/bagger.launch" />
|
||||
<include file="$(find rosbridge_GUI_example)/launch/talker.launch" />
|
||||
</launch>
|
||||
3
launch/talker.launch
Normal file
3
launch/talker.launch
Normal file
@@ -0,0 +1,3 @@
|
||||
<launch>
|
||||
<node name="talker" pkg="rosbridge_GUI_example" type="talker.py" />
|
||||
</launch>
|
||||
@@ -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")
|
||||
|
||||
|
||||
|
||||
33
src/bagger.py~
Executable file
33
src/bagger.py~
Executable file
@@ -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()
|
||||
20
src/talker.py
Executable file
20
src/talker.py
Executable file
@@ -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
|
||||
0
src/talker.py~
Normal file
0
src/talker.py~
Normal file
Reference in New Issue
Block a user