Skip to content
Leeh1984 edited this page Apr 22, 2013 · 13 revisions

Welcome to the commandcenter wiki!

MQTT publish to control rov

  mosquitto_pub -h api.pinocc.io -t erictj/3pi-control -u erictj -P 321 -m '20:20'

you'll need to install mosquitto_client via apt-get (or "brew install mosquitto" on mac)

the message 20:20 is the left and right motor commands, respectively. Use negative values for reverse motor

Connect to Mosquito with Socket.io

var uri = 'api.pinocc.io';
var socket = io.connect(uri);
var topic = 'erictj/3pi-control';
socket.emit('publish', {topic: topic, message: "20:20"});

This is running off an HTML file:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <script src="socket.io.js"></script>
    </head>
    <body>
        <p>MQTT</p>
    </body>
</html>

Socket.io can be downloaded from http://api.pinocc.io/socket.io/socket.io.js

Web Page and Unity Communication

Unity Web Page comms

GameObject Name = "JavaScriptClient"

Function Name = "HandleMessage"

Javascript Function Name = "PublishMessage"

Message Structure

Motors:

{
  "Motor1":"20",
  "Motor2":"20",
  "Motor3":"-20"
}

Camera:

{
 "Camera":"-1"
}

Valid values are: -1, 0, 1

Brightness:

{
"Brightness":"0"
}

Valid values are: 0 to 8