.bottom-leds > .minicolors-theme-default.minicolors { margin: 5px 0; }
.top-leds > .minicolors-theme-default.minicolors { margin-top: 70px; }
.wt-icon {background: url('assets/images/wt_top.png'); background-size: cover; background-size: 100%; background-repeat: no-repeat; background-position: center; height: 260px;}
+ .cmd_vel_circle {
+ height: 250px;
+ width: 250px;
+ background-color: #bbb;
+ border-radius: 50%;
+ display: inline-block;
+ }
</style>
<script type="text/javascript">
var sensorTopic = new ROSLIB.Topic({ros: ros, name: '/sensors', messageType: 'wild_thumper/Sensor'});
var batteryTopic = new ROSLIB.Topic({ros: ros, name: '/battery', messageType: 'sensor_msgs/BatteryState'});
var ledStripeTopic = new ROSLIB.Topic({ros: ros, name: '/led_stripe', messageType: 'wild_thumper/LedStripe'});
+ var cmdVelTopic = new ROSLIB.Topic({ros: ros, name: '/teleop/cmd_vel', messageType: 'geometry_msgs/Twist'});
poseTopic.subscribe(function(message) {
var now = new Date();
// Initialize the teleop.
teleop = new KEYBOARDTELEOP.Teleop({
ros : ros,
- topic : '/cmd_vel'
+ topic : '/teleop/cmd_vel'
});
// Create a UI slider using JQuery UI.
ledStripeTopic.publish(msg);
}
});
+
+ function setSpeed(trans, rot) {
+ var msg = new ROSLIB.Message({
+ linear: {
+ x : trans,
+ y : 0,
+ z : 0
+ },
+ angular: {
+ x : 0,
+ y : 0,
+ z : rot
+ },
+ });
+ cmdVelTopic.publish(msg);
+ }
+
+ $('.cmd_vel_circle')
+ .bind('mousedown touchstart', function(e) {
+ isDragging = true;
+ })
+ .bind('mouseup touchend mouseleave', function(e) {
+ isDragging = false;
+ setSpeed(0, 0);
+ })
+ .bind('mousemove touchmove', function(e) {
+ if (isDragging) {
+ // absolute click position
+ var X,Y;
+ if (e.originalEvent.touches) {
+ X = e.originalEvent.touches[0].pageX;
+ Y = e.originalEvent.touches[0].pageY;
+ } else {
+ X = e.pageX;
+ Y = e.pageY;
+ }
+ // relative click position
+ var Xrel = X - this.offsetLeft - $(this).width()/2;
+ var Yrel = Y - this.offsetTop - $(this).height()/2;
+ // scale to -1..+1
+ var trans = -Yrel / ($(this).height()/2);
+ var rot = -Xrel / ($(this).width()/2);
+ setSpeed(trans, rot*3);
+ }
+ });
}
</script>
<title>Wild Thumper control</title>
<li class="nav-item">
<a class="nav-link" href="#lights" data-toggle="tab" role="tab">Lights</a>
</li>
+ <li class="nav-item">
+ <a class="nav-link" href="#drive" data-toggle="tab" role="tab">Drive</a>
+ </li>
</ul>
</nav>
<div class="tab-content">
</div>
</div>
</div>
+ <div id="drive" class="tab-pane" role="tabpanel">
+ <div class="cmd_vel_circle"></div>
+ </div>
</div>
</div>
<script src="assets/javascripts/jquery-3.3.1.min.js"></script>