Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import cdpyr
from sample import robots
# from prettyprinter import pprint
from marshmallow import pprint, Schema
def main():
# c = cdpyr.robot.Cable(diameter=6.0/1000)
# cblschm: cdpyr.robot.CableSchema = cdpyr.robot.CableSchema()
# jsn = cblschm.dump(c)
# pprint(jsn.data)
#
# o = cblschm.load(jsn.data)
# pprint(o.data)
#
# get a sample robot
r = robots.ipanema_cuboid()
rschema = cdpyr.robot.RobotSchema()
# create an streams object
stream = cdpyr.streams.Stream(cdpyr.streams.parser.JSON())
# encode to a string
encoded_str = stream.encodes(r)
pprint(encoded_str)
# decode from a string
robot = stream.decodes(encoded_str)
pprint(robot)
# # encode to a file
# streams.encode(r, open('robot.json', 'w'))
# # decode from a file
# robot = streams.decode(open('robot.json', 'r'))
if __name__ == "__main__":
main()
@philipptempel

This comment has been minimized.

Copy link
Owner Author

philipptempel commented Sep 23, 2019

Create directory sandbox, save file as streams.py and then run it.
Noe you'll need https://gist.github.com/philipptempel/b5fc4a185b6317aa86bb45cdc29e8517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.