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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
Create directory
sandbox
, save file asstreams.py
and then run it.Noe you'll need https://gist.github.com/philipptempel/b5fc4a185b6317aa86bb45cdc29e8517