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.topics = [];
|
||||||
ros.nodes = [];
|
ros.nodes = [];
|
||||||
|
|
||||||
ros.connectioninfo = ['ws://', '192', '168', '0', '100', '9090'];
|
ros.recording = false;
|
||||||
// ros.connectionName = 'ws://localhost:9090';
|
|
||||||
|
|
||||||
ros.connectionName = 'ws://192.168.0.100:9090';
|
ros.connectionName = 'ws://192.168.0.100:9090';
|
||||||
|
|
||||||
// If there is an error on the backend, an 'error' emit will be emitted.
|
// If there is an error on the backend, an 'error' emit will be emitted.
|
||||||
ros.on('error', function(error) {
|
ros.on('error', function(error) {
|
||||||
document.getElementById("ConnectionIPForm").className = "form-group has-warning has-feedback";
|
document.getElementById("ConnectionIPForm").className = "form-group has-warning has-feedback";
|
||||||
@@ -47,6 +49,56 @@ ros.on('close', function() {
|
|||||||
ros.connect(ros.connectionName);
|
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
|
// attept to connect to the ros master from the IP given orgrab it from the form
|
||||||
ros.attemptConnection = function(ipAddress)
|
ros.attemptConnection = function(ipAddress)
|
||||||
{
|
{
|
||||||
@@ -114,3 +166,16 @@ function getTime() {
|
|||||||
console.log(result.time.secs);
|
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>
|
<script src="../../include/js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<!-- ##################################### ROS BAG PANEL ######################################### -->
|
<!-- ##################################### ROS BAG PANEL ######################################### -->
|
||||||
<!-- ROS Bag Panel -->
|
<!-- ROS Bag Panel -->
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
|
|
||||||
@@ -75,9 +75,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<button id="ConnectionButton" type="button" >
|
<div class="col-md-3">
|
||||||
Connect
|
<div class="input-group">
|
||||||
</button>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -91,87 +100,115 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-sm-2"> Bar Title </label>
|
<label class="col-sm-2">
|
||||||
|
Bar Title
|
||||||
|
</label>
|
||||||
|
|
||||||
<div class="progress">
|
<div class="progress">
|
||||||
<div id="progressBar1" class="progress-bar progress-bar-striped active" role="progressbar"
|
<div id="progressBar1" class="progress-bar progress-bar-striped active" role="progressbar"
|
||||||
aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:100%" >
|
aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:100%" >
|
||||||
No data recieved yet. </div>
|
No data recieved yet. </div>
|
||||||
</div>
|
</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>
|
||||||
|
|
||||||
<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>
|
||||||
</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 panel-default">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form class="form-inline" role="form" onsubmit="return validateForm()">
|
|
||||||
<div id="ConnectionIPForm" class="form-group has-warning" align="center">
|
|
||||||
|
|
||||||
<label id="ConnectionIPLabel" class="col-sm-3 control-label" for="inputWarning">
|
<form class="form-inline" role="form" onsubmit="return validateForm()">
|
||||||
Connection Warning
|
<div id="ConnectionIPForm" class="form-group has-warning" align="center">
|
||||||
</label>
|
<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>
|
||||||
|
|
||||||
<div class="col-sm-2">
|
</form>
|
||||||
<button id="ConnectionButton" type="button" onclick="ros.attemptConnection()">
|
</div>
|
||||||
Connect
|
</div>
|
||||||
</button>
|
|
||||||
<script type="text/javascript">
|
<div class="panel panel-default">
|
||||||
document.getElementById("ConnectionIPInput").value = ros.connectionName;
|
<div class="panel-heading">
|
||||||
</script>
|
ROS Topics
|
||||||
</div>
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
|
||||||
|
<div class="col-sm-1" id="ROSTopics">
|
||||||
|
N/A
|
||||||
</div>
|
</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>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
ROS Nodes
|
ROS Nodes
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
<div class="col-sm-1" id="ROSNodes">
|
<div class="col-sm-1" id="ROSNodes">
|
||||||
N/A
|
N/A
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<launch>
|
<launch>
|
||||||
<include file="$(find rosbridge_server)/launch/rosbridge_websocket.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/bagger.launch" />
|
||||||
|
<include file="$(find rosbridge_GUI_example)/launch/talker.launch" />
|
||||||
</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:
|
else:
|
||||||
bag_file = os.path.join(self.data_path, msg.data)
|
bag_file = os.path.join(self.data_path, msg.data)
|
||||||
self.proc = subprocess.Popen(["rosbag", "record",
|
self.proc = subprocess.Popen(["rosbag", "record",
|
||||||
"kinect2/depth_lowres/points", "kinect2/rgb_lowres/image",
|
"--all", "-o", bag_file], preexec_fn=os.setsid)
|
||||||
"tf", "imu/data", "-o", bag_file], preexec_fn=os.setsid)
|
|
||||||
self.pub.publish("STARTED")
|
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