-
Notifications
You must be signed in to change notification settings - Fork 5
/
Robot_Arm_Control_v6.json
1 lines (1 loc) · 17 KB
/
Robot_Arm_Control_v6.json
1
[{"id":"b54a9919.7a8758","type":"function","z":"3b6c97c6.3d4888","name":"Just get preset","func":"global.set(\"servos_preset\", msg.payload.payload);\n\nvar preset = [];\nvar m = [];\npreset = global.get(\"servos_preset\");\nvar robot_speed = global.get(\"robot_speed\");\nvar servo_command = \"\";\n\nfor (var i=0;i<6;i++)\n{\n m[i] = { payload: preset[i] };\n \n var id = i+1;\n servo_command = servo_command + id + \":\" + preset[i] + \":\" + robot_speed;\n if (id == 6) {\n servo_command = servo_command + \"!\";\n }\n else {\n servo_command = servo_command + \"&\";\n }\n}\n\nm[6] = {payload: servo_command};\n\nreturn m;\n","outputs":7,"noerr":0,"x":880,"y":300,"wires":[["e65ceccc.17115"],["e7420806.bf4398"],["f2c6164e.f34128"],["77ca45d0.8a01fc"],["6dbb7189.cc221"],["51da304f.d9d81"],["a29beed3.cc488","f9c5b4e1.714ab8"]]},{"id":"31686c0f.8b5064","type":"ui_template","z":"3b6c97c6.3d4888","group":"58439175.ff9d1","name":"DMX LOG","order":1,"width":"6","height":"12","format":"<ul>\n <li ng-repeat=\"x in msg.payload\">\n <font color=\"red\">{{x.topic}}</font>\n <ul>\n <li>{{x.payload}}</li>\n </ul>\n </li>\n</ul>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":1910,"y":160,"wires":[[]]},{"id":"e7420806.bf4398","type":"ui_slider","z":"3b6c97c6.3d4888","name":"Servo2","label":"Servo 2","group":"8fc5a5bf.97fba8","order":2,"width":0,"height":0,"passthru":false,"topic":"Slider","min":0,"max":"1000","step":1,"x":1080,"y":380,"wires":[["9f15bcef.9755f","48735083.a2267"]]},{"id":"9a8343c2.e3745","type":"ui_slider","z":"3b6c97c6.3d4888","name":"RobotSpeed","label":"Robot Speed","group":"8fc5a5bf.97fba8","order":7,"width":0,"height":0,"passthru":true,"topic":"Slider","min":0,"max":"3000","step":1,"x":1090,"y":760,"wires":[["41740032.36ee"]]},{"id":"51da304f.d9d81","type":"ui_slider","z":"3b6c97c6.3d4888","name":"Servo6","label":"Servo 6","group":"8fc5a5bf.97fba8","order":6,"width":0,"height":0,"passthru":false,"topic":"Slider","min":0,"max":"1000","step":1,"x":1080,"y":700,"wires":[["c4d4e44d.99f888","2aa0d815.b7a628"]]},{"id":"6dbb7189.cc221","type":"ui_slider","z":"3b6c97c6.3d4888","name":"Servo5","label":"Servo 5","group":"8fc5a5bf.97fba8","order":5,"width":0,"height":0,"passthru":false,"topic":"Slider","min":0,"max":"1000","step":1,"x":1080,"y":620,"wires":[["e8e9117f.4adb6","ad3fc0be.3d6eb"]]},{"id":"77ca45d0.8a01fc","type":"ui_slider","z":"3b6c97c6.3d4888","name":"Servo4","label":"Servo 4","group":"8fc5a5bf.97fba8","order":4,"width":0,"height":0,"passthru":false,"topic":"Slider","min":0,"max":"1000","step":1,"x":1080,"y":540,"wires":[["4b3d9f7e.a5059","50ba722e.81abcc"]]},{"id":"f2c6164e.f34128","type":"ui_slider","z":"3b6c97c6.3d4888","name":"Servo3","label":"Servo 3","group":"8fc5a5bf.97fba8","order":3,"width":0,"height":0,"passthru":false,"topic":"Slider","min":0,"max":"1000","step":1,"x":1080,"y":460,"wires":[["27f55b51.ba2264","7505bba0.72ae24"]]},{"id":"1c1436c6.c529a9","type":"change","z":"3b6c97c6.3d4888","name":"save to Global Servos1","rules":[{"t":"set","p":"servos_preset[0]","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":320,"wires":[[]]},{"id":"9f15bcef.9755f","type":"change","z":"3b6c97c6.3d4888","name":"save to Global Servos2","rules":[{"t":"set","p":"servos_preset[1]","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":400,"wires":[[]]},{"id":"27f55b51.ba2264","type":"change","z":"3b6c97c6.3d4888","name":"save to Global Servos3","rules":[{"t":"set","p":"servos_preset[2]","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":480,"wires":[[]]},{"id":"4b3d9f7e.a5059","type":"change","z":"3b6c97c6.3d4888","name":"save to Global Servos4","rules":[{"t":"set","p":"servos_preset[3]","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":560,"wires":[[]]},{"id":"e8e9117f.4adb6","type":"change","z":"3b6c97c6.3d4888","name":"save to Global Servos5","rules":[{"t":"set","p":"servos_preset[4]","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":640,"wires":[[]]},{"id":"c4d4e44d.99f888","type":"change","z":"3b6c97c6.3d4888","name":"save to Global Servos6","rules":[{"t":"set","p":"servos_preset[5]","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1310,"y":720,"wires":[[]]},{"id":"41740032.36ee","type":"change","z":"3b6c97c6.3d4888","name":"save to Global RobotSpeed","rules":[{"t":"set","p":"robot_speed","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1320,"y":760,"wires":[[]]},{"id":"917485d5.4e6ad8","type":"function","z":"3b6c97c6.3d4888","name":"insert preset","func":"var preset = [];\npreset = global.get(\"servos_preset\");\nvar newMsg = {};\nnewMsg.collection = 'servos_presets';\nnewMsg.payload = [\n {topic: msg.payload},\n {\n \"$set\": {\n \"payload\": preset\n }\n },\n {upsert:true}\n];\n\nreturn newMsg;\n","outputs":1,"noerr":0,"x":375,"y":21.5,"wires":[["22a0cc81.e1a404"]]},{"id":"22a0cc81.e1a404","type":"mongodb2 in","z":"3b6c97c6.3d4888","service":"_ext_","configNode":"10b19456.f31fac","name":"Store Data into MongoDB","collection":"robot_arm_presets","operation":"findOneAndUpdate","x":586,"y":22.5,"wires":[["b0b8834.0e2e48","6af7b445.7848cc"]]},{"id":"b7c1c4b9.501e08","type":"function","z":"3b6c97c6.3d4888","name":"init global variables","func":"global.set(\"servos_preset\",[0,0,0,0,0,0]); \nmsg.payload = global.get(\"servos_preset\");\nreturn msg;","outputs":1,"noerr":0,"x":394,"y":436.5,"wires":[["bccf97bc.c7e018","cebc1d43.6453c"]]},{"id":"947363fa.75328","type":"inject","z":"3b6c97c6.3d4888","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":199,"y":437,"wires":[["b7c1c4b9.501e08"]]},{"id":"bccf97bc.c7e018","type":"debug","z":"3b6c97c6.3d4888","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":601,"y":436.5,"wires":[]},{"id":"a07aeb12.03b5e8","type":"debug","z":"3b6c97c6.3d4888","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":600,"y":518.5,"wires":[]},{"id":"f29c8fdc.eac68","type":"function","z":"3b6c97c6.3d4888","name":"check global preset","func":"msg.payload = global.get(\"servos_preset\");\nreturn msg;","outputs":1,"noerr":0,"x":393,"y":519.5,"wires":[["a07aeb12.03b5e8","cebc1d43.6453c"]]},{"id":"1e9c87a6.95e578","type":"inject","z":"3b6c97c6.3d4888","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":192,"y":514,"wires":[["f29c8fdc.eac68"]]},{"id":"cebc1d43.6453c","type":"function","z":"3b6c97c6.3d4888","name":"Reset from global","func":"var preset = [];\nvar m = [];\npreset = global.get(\"servos_preset\");\n\n\nfor (var i=0;i<7;i++)\n{\n m[i] = { payload: preset[i] };\n}\nreturn m;\n","outputs":6,"noerr":0,"x":842.5,"y":528.5,"wires":[["e65ceccc.17115"],["e7420806.bf4398"],["f2c6164e.f34128"],["77ca45d0.8a01fc"],["6dbb7189.cc221"],["51da304f.d9d81"]]},{"id":"6af7b445.7848cc","type":"function","z":"3b6c97c6.3d4888","name":"DASHBOARD FORMATTING","func":"var dashboardLog = context.get('dashboardLog')|| [];\n\ndashboardLog.push(msg);\nif (dashboardLog.length > 20){\n // Supprime le plus anciens message si > 20\n // Delete oldest message if > 20\n dashboardLog.shift();\n dashboardLog.length = 20;\n} \n\n// Enregistre les messages du dashboard pour le prochain affichage\n// store the value back\ncontext.set('dashboardLog',dashboardLog);\n\n// Affiche le journal des messages\n// make it part of the outgoing msg object\nmsg = {};\nmsg.payload = dashboardLog;\nreturn msg;\n","outputs":1,"noerr":0,"x":1630,"y":160,"wires":[["31686c0f.8b5064"]]},{"id":"e65ceccc.17115","type":"ui_slider","z":"3b6c97c6.3d4888","name":"Servo1","label":"Servo 1","group":"8fc5a5bf.97fba8","order":1,"width":0,"height":0,"passthru":false,"topic":"Slider","min":0,"max":"1000","step":1,"x":1080,"y":300,"wires":[["1c1436c6.c529a9","ec963eac.ef34f"]]},{"id":"3e7b4f5.567e3b","type":"mongodb2 in","z":"3b6c97c6.3d4888","service":"_ext_","configNode":"10b19456.f31fac","name":"Mongo DB dynamic operation","collection":"robot_arm_presets","operation":"","x":496,"y":142.5,"wires":[["b355794f.377df8"]]},{"id":"b0b8834.0e2e48","type":"function","z":"3b6c97c6.3d4888","name":"findOne","func":"var newMsg = {};\nnewMsg.operation = 'find.toArray';\nnewMsg.payload = {};\nreturn newMsg;","outputs":1,"noerr":0,"x":262,"y":139.5,"wires":[["3e7b4f5.567e3b"]]},{"id":"18c333e1.15034c","type":"ui_dropdown","z":"3b6c97c6.3d4888","name":"Recall Pulldown","label":"Recall","place":"Select option","group":"9398d2a.468cc3","order":2,"width":0,"height":0,"passthru":false,"options":[],"payload":"","topic":"","x":980,"y":100,"wires":[["b54a9919.7a8758","6af7b445.7848cc","e0d633af.d2b9d"]]},{"id":"b355794f.377df8","type":"function","z":"3b6c97c6.3d4888","name":"Format Preset Pulldown","func":"var msg_array = [];\nfor (var i=0; i< msg.payload.length; i++)\n{\n var tmp_object = {};\n var msg_object = msg.payload[i];\n if (msg_object.topic != undefined){\n tmp_object[msg_object.topic] = {\"topic\": msg_object.topic, \"payload\": msg_object.payload};\n msg_array[i] = tmp_object;\n }\n}\nmsg.options = msg_array;\nreturn msg;","outputs":1,"noerr":0,"x":778,"y":142,"wires":[["18c333e1.15034c"]]},{"id":"1e424502.1ba1cb","type":"inject","z":"3b6c97c6.3d4888","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":113,"y":138,"wires":[["b0b8834.0e2e48"]]},{"id":"fa7ffe59.72c09","type":"ui_text_input","z":"3b6c97c6.3d4888","name":"","label":"Edit Preset Name","group":"9398d2a.468cc3","order":4,"width":0,"height":0,"passthru":true,"mode":"text","delay":"300","topic":"","x":1359,"y":65.5,"wires":[["bf16f4bb.81cfe8"]]},{"id":"d467c5f5.33f828","type":"ui_button","z":"3b6c97c6.3d4888","name":"Save","group":"9398d2a.468cc3","order":5,"width":0,"height":0,"passthru":false,"label":"Save Preset","color":"#FFF","bgcolor":"#FF0000","icon":"","payload":"","payloadType":"date","topic":"","x":55,"y":20,"wires":[["8c54d5c0.b272a8"]]},{"id":"bf16f4bb.81cfe8","type":"function","z":"3b6c97c6.3d4888","name":"set global preset name","func":"global.set(\"robot_arm_preset_name\", msg.payload);","outputs":1,"noerr":0,"x":1600,"y":60,"wires":[[]]},{"id":"8c54d5c0.b272a8","type":"function","z":"3b6c97c6.3d4888","name":"save preset","func":"msg.payload = global.get(\"robot_arm_preset_name\");\nreturn msg;","outputs":1,"noerr":0,"x":207,"y":20.5,"wires":[["917485d5.4e6ad8"]]},{"id":"e0d633af.d2b9d","type":"function","z":"3b6c97c6.3d4888","name":"get preset name","func":"msg.payload = msg.payload.topic;\nreturn msg;","outputs":1,"noerr":0,"x":1164,"y":67,"wires":[["fa7ffe59.72c09"]]},{"id":"1da0dc71.decd14","type":"ui_text","z":"3b6c97c6.3d4888","group":"9398d2a.468cc3","order":3,"width":0,"height":0,"name":"","label":"SAVE PRESET","format":"{{msg.payload}}","layout":"row-left","x":231,"y":271.5,"wires":[]},{"id":"d867d0ce.0e55e","type":"ui_text","z":"3b6c97c6.3d4888","group":"9398d2a.468cc3","order":1,"width":0,"height":0,"name":"","label":"RECALL PRESET","format":"{{msg.payload}}","layout":"row-left","x":241,"y":193.5,"wires":[]},{"id":"bb9adb8d.10be78","type":"function","z":"3b6c97c6.3d4888","name":"delete preset","func":"var newMsg = {};\nnewMsg.operation = 'deleteOne';\nnewMsg.payload = {'topic' : msg.payload};\nreturn newMsg;","outputs":1,"noerr":0,"x":376,"y":80.5,"wires":[["cd64e91b.5591a8"]]},{"id":"cd64e91b.5591a8","type":"mongodb2 in","z":"3b6c97c6.3d4888","service":"_ext_","configNode":"10b19456.f31fac","name":"Store Data into MongoDB","collection":"robot_arm_presets","operation":"","x":587,"y":81.5,"wires":[["b0b8834.0e2e48","6af7b445.7848cc"]]},{"id":"74c45ff0.af533","type":"ui_button","z":"3b6c97c6.3d4888","name":"Delete","group":"9398d2a.468cc3","order":5,"width":0,"height":0,"passthru":false,"label":"Delete Preset","color":"#FFF","bgcolor":"#FF00FF","icon":"","payload":"","payloadType":"date","topic":"","x":56,"y":79,"wires":[["dd9efda9.1f917"]]},{"id":"dd9efda9.1f917","type":"function","z":"3b6c97c6.3d4888","name":"delete preset","func":"msg.payload = global.get(\"robot_arm_preset_name\");\nreturn msg;","outputs":1,"noerr":0,"x":208,"y":79.5,"wires":[["bb9adb8d.10be78"]]},{"id":"f9c5b4e1.714ab8","type":"serial out","z":"3b6c97c6.3d4888","name":"","serial":"69b521b4.6f6ec","x":1830,"y":500,"wires":[]},{"id":"476ae93b.c58558","type":"serial in","z":"3b6c97c6.3d4888","name":"","serial":"69b521b4.6f6ec","x":460,"y":820,"wires":[["e3f52c85.3e06f"]]},{"id":"e3f52c85.3e06f","type":"debug","z":"3b6c97c6.3d4888","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":820,"wires":[]},{"id":"ec963eac.ef34f","type":"function","z":"3b6c97c6.3d4888","name":"send servo data","func":"var robot_speed = global.get(\"robot_speed\");\nmsg.payload = \"1:\" + msg.payload + \":\" + robot_speed + \"!\";\nreturn msg;","outputs":1,"noerr":0,"x":1280,"y":280,"wires":[["f9c5b4e1.714ab8"]]},{"id":"2aa0d815.b7a628","type":"function","z":"3b6c97c6.3d4888","name":"send servo data","func":"var robot_speed = global.get(\"robot_speed\");\nmsg.payload = \"6:\" + msg.payload + \":\" + robot_speed + \"!\";\nreturn msg;","outputs":1,"noerr":0,"x":1280,"y":680,"wires":[["f9c5b4e1.714ab8"]]},{"id":"ad3fc0be.3d6eb","type":"function","z":"3b6c97c6.3d4888","name":"send servo data","func":"var robot_speed = global.get(\"robot_speed\");\nmsg.payload = \"5:\" + msg.payload + \":\" + robot_speed + \"!\";\nreturn msg;","outputs":1,"noerr":0,"x":1280,"y":600,"wires":[["f9c5b4e1.714ab8"]]},{"id":"50ba722e.81abcc","type":"function","z":"3b6c97c6.3d4888","name":"send servo data","func":"var robot_speed = global.get(\"robot_speed\");\nmsg.payload = \"4:\" + msg.payload + \":\" + robot_speed + \"!\";\nreturn msg;","outputs":1,"noerr":0,"x":1280,"y":520,"wires":[["f9c5b4e1.714ab8"]]},{"id":"7505bba0.72ae24","type":"function","z":"3b6c97c6.3d4888","name":"send servo data","func":"var robot_speed = global.get(\"robot_speed\");\nmsg.payload = \"3:\" + msg.payload + \":\" + robot_speed + \"!\";\nreturn msg;","outputs":1,"noerr":0,"x":1280,"y":440,"wires":[["f9c5b4e1.714ab8"]]},{"id":"48735083.a2267","type":"function","z":"3b6c97c6.3d4888","name":"send servo data","func":"var robot_speed = global.get(\"robot_speed\");\nmsg.payload = \"2:\" + msg.payload + \":\" + robot_speed + \"!\";\nreturn msg;","outputs":1,"noerr":0,"x":1280,"y":360,"wires":[["f9c5b4e1.714ab8"]]},{"id":"42a6dddc.937264","type":"function","z":"3b6c97c6.3d4888","name":"send servo data","func":"var robot_speed = global.get(\"robot_speed\");\nvar servos_preset = global.get(\"servos_preset\");\nvar servo_command = \"\";\nfor (var i=0; i<servos_preset.length; i++){\n var id = i+1;\n servo_command = servo_command + id + \":\" + servos_preset[i] + \":\" + robot_speed;\n if (id == servos_preset.length) {\n servo_command = servo_command + \"!\";\n }\n else {\n servo_command = servo_command + \"&\";\n }\n}\nmsg.payload = servo_command;\nreturn msg;","outputs":1,"noerr":0,"x":1200,"y":200,"wires":[[]]},{"id":"a29beed3.cc488","type":"debug","z":"3b6c97c6.3d4888","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1150,"y":160,"wires":[]},{"id":"e57333bd.ec823","type":"ui_button","z":"3b6c97c6.3d4888","name":"RESET SERVO POSITIONS","group":"8fc5a5bf.97fba8","order":0,"width":0,"height":0,"passthru":false,"label":"RESET SERVO POSITIONS","color":"","bgcolor":"","icon":"","payload":"1:500:1000&2:500:1000&3:500:1000&4:500:1000&5:500:1000&6:500:1000!","payloadType":"str","topic":"","x":1640,"y":300,"wires":[["f9c5b4e1.714ab8","d075dca3.c5aef","cebc1d43.6453c"]]},{"id":"d075dca3.c5aef","type":"function","z":"3b6c97c6.3d4888","name":"save global reset","func":"global.set(\"servos_preset\", [500,500,500,500,500,500]);\nreturn msg;","outputs":1,"noerr":0,"x":1910,"y":300,"wires":[[]]},{"id":"d1d2c520.939d68","type":"inject","z":"3b6c97c6.3d4888","name":"","topic":"","payload":"1000","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":890,"y":760,"wires":[["9a8343c2.e3745"]]},{"id":"58439175.ff9d1","type":"ui_group","z":"3b6c97c6.3d4888","name":"SERVO LOG","tab":"45caa18f.53906","order":4,"disp":true,"width":"6","collapse":true},{"id":"8fc5a5bf.97fba8","type":"ui_group","z":"","name":"SERVO SLIDERS","tab":"45caa18f.53906","order":3,"disp":true,"width":"8","collapse":true},{"id":"10b19456.f31fac","type":"mongodb2","z":"","uri":"mongodb://127.0.0.1:27017/cinebrain","name":"cinebrain db","options":"","parallelism":"-1"},{"id":"9398d2a.468cc3","type":"ui_group","z":"","name":"PRESETS","tab":"45caa18f.53906","order":1,"disp":false,"width":"6","collapse":false},{"id":"69b521b4.6f6ec","type":"serial-port","z":"","serialport":"COM5","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","newline":"\\n","bin":"false","out":"char","addchar":false},{"id":"45caa18f.53906","type":"ui_tab","z":"","name":"ROBOT ARM DASHBOARD","icon":"home","order":2}]