Skip to content

Instantly share code, notes, and snippets.

@PierrickKoch
Last active June 24, 2016 08:29
Show Gist options
  • Save PierrickKoch/0c0b1b103cca30277407a04763c9f825 to your computer and use it in GitHub Desktop.
Save PierrickKoch/0c0b1b103cca30277407a04763c9f825 to your computer and use it in GitHub Desktop.
morse viz quad matlab

multinode

The form of the message is:

["node_name", {"robot_name": [[x , y, z], [roll, pitch, yaw]]}]\n

(rotation order is 'XYZ' see doc)

using telnet

$ telnet localhost 65000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
["telnet", {"cat": [[1, 2, 3], [0.1, 0.2, 0.4]]}]

using StreamJSON

python3

from pymorse import StreamJSON, PollThread
node_stream = StreamJSON('localhost', 65000)
poll_thread = PollThread()
poll_thread.start()
node_stream.publish(['py3', {'cat': [(1, 2, 3), (0.1, 0.2, 0.3)]}])

using matlab

tcpobj = tcpip('localhost', 65000)
fopen(tcpobj)
fprintf(tcpobj, '["matlab", {"cat": [[1, 2, 3], [0.1, 0.2, 0.4]]}]\n')


fprintf(tcpobj, sprintf('["matlab", {"cat": [[%7.3f, %7.3f, %7.3f], [%7.3f, %7.3f, %7.3f]]}]\n', x, y, z, roll, pitch, yaw))

morse socket

see: http://www.openrobots.org/morse/doc/latest/user/middlewares/socket.html

uncomment the Teleport actuator in the builder script

using telnet

$ telnet localhost 60000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
{"x": 1, "y": 2, "z": 5, "roll": 0, "pitch": 0, "yaw": 6}

using pymorse

python3

from pymorse import Morse
sim = Morse()
sim.cat.teleport.publish({'x': 1, 'y': 2, 'z': 5, 'roll': 0, 'pitch': 0, 'yaw': 6})

using matlab

tcpobj = tcpip('localhost', 60000)
fopen(tcpobj)
fprintf(tcpobj, '{"x": 1, "y": 2, "z": 4, "roll": 0, "pitch": 0, "yaw": 6}\n')


fprintf(tcpobj, sprintf('{"x": %7.3f, "y": %7.3f, "z": %7.3f, "roll": %7.3f, "pitch": %7.3f, "yaw": %7.3f}\n', x, y, z, roll, pitch, yaw))
from morse.builder import *
cat = Quadrotor()
cat.translate(z = 2)
cat.set_use_record_animation()
# using socket client:
# teleport = Teleport()
# cat.append(teleport)
# teleport.add_stream('socket')
env = Environment('outdoors')
env.set_camera_clip(clip_end=500)
env.set_log_level('morse.multinode.socket', 'info')
env.set_animation_record()
env.configure_multinode(protocol="socket", distribution={"nodeA": [cat.name]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment