├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── .pylintrc
├── .vscode
└── settings.json
├── LICENSE
├── README.md
├── addon
├── __init__.py
├── blender_manifest.toml
├── ops
│ ├── __init__.py
│ ├── arduino_export.py
│ ├── base_export.py
│ ├── binary_export.py
│ ├── calibrate_servo.py
│ ├── json_export.py
│ ├── start_live_mode.py
│ └── stop_live_mode.py
├── props
│ ├── __init__.py
│ ├── bone_property_group.py
│ └── wm_property_group.py
├── ui
│ ├── __init__.py
│ ├── bone_panel.py
│ └── menu_panel.py
├── utils
│ ├── __init__.py
│ ├── converter.py
│ ├── live_mode.py
│ └── servo_settings.py
└── wheels
│ ├── pyserial-3.5-py2.py3-none-any.whl
│ └── websocket_client-1.5.1-py3-none-any.whl
├── examples
├── IK
│ ├── ik.bin
│ ├── ik.blend
│ ├── ik.h
│ └── ik.json
├── Scenes
│ ├── scene-a.bin
│ ├── scene-a.h
│ ├── scene-a.json
│ ├── scene-b.bin
│ ├── scene-b.h
│ ├── scene-b.json
│ └── scenes.blend
└── Simple
│ ├── simple.bin
│ ├── simple.blend
│ ├── simple.h
│ └── simple.json
├── images
├── calibrate_servo_button.png
├── calibrate_servo_dialog.png
├── export_menu.png
├── servo_settings.png
└── timeline_menu.png
├── requirements-dev.txt
├── scripts
├── build.sh
├── install.sh
├── prepare.sh
└── test.sh
└── tests
├── integration
├── test.blend
├── test_export.py
├── test_serial_live_mode.py
├── test_servo_calibration.py
└── test_socket_live_mode.py
├── prepare.py
└── test.py
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Continuous Integration
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 | name: "Build"
8 | runs-on: ubuntu-latest
9 | container: linuxserver/blender:latest
10 | steps:
11 | - uses: actions/checkout@v4
12 | - name: Build add-on
13 | run: |
14 | cp -R addon servo_animation
15 | cp README.md LICENSE servo_animation
16 | ./scripts/build.sh
17 | - name: Archive add-on ZIP
18 | uses: actions/upload-artifact@v4
19 | with:
20 | name: blender_servo_animation_addon.zip
21 | path: |
22 | blender_servo_animation_addon.zip
23 | lint:
24 | name: "Lint"
25 | runs-on: ubuntu-latest
26 | steps:
27 | - uses: actions/checkout@v4
28 | - name: Set up Python 3.10
29 | uses: actions/setup-python@v5
30 | with:
31 | python-version: "3.10"
32 | - name: Install dependencies
33 | run: |
34 | python -m pip install --upgrade pip
35 | pip install pylint
36 | - name: Analysing the code with pylint
37 | run: |
38 | pylint addon
39 | pylint -d duplicate-code tests
40 | test:
41 | name: "Test"
42 | needs: build
43 | strategy:
44 | fail-fast: false
45 | matrix:
46 | version:
47 | - "4.2.0"
48 | - "4.3.0"
49 | - "4.3.2"
50 | runs-on: ubuntu-latest
51 | container: linuxserver/blender:${{ matrix.version }}
52 | steps:
53 | - uses: actions/checkout@v4
54 | - name: Download add-on
55 | uses: actions/download-artifact@v4
56 | with:
57 | name: blender_servo_animation_addon.zip
58 | - name: Install add-on
59 | run: |
60 | ./scripts/install.sh
61 | - name: Install test dependencies inside Blender
62 | run: |
63 | ./scripts/prepare.sh
64 | - name: Run tests inside Blender
65 | run: |
66 | ./scripts/test.sh
67 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | __pycache__
2 | .vscode/*
3 | !.vscode/settings.json
4 | *.blend1
5 | tests/results.txt
6 | *.zip
--------------------------------------------------------------------------------
/.pylintrc:
--------------------------------------------------------------------------------
1 | [MASTER]
2 |
3 | # A comma-separated list of package or module names from where C extensions may
4 | # be loaded. Extensions are loading into the active Python interpreter and may
5 | # run arbitrary code.
6 | extension-pkg-whitelist=
7 |
8 | # Specify a score threshold to be exceeded before program exits with error.
9 | fail-under=10.0
10 |
11 | # Add files or directories to the blacklist. They should be base names, not
12 | # paths.
13 | ignore=CVS
14 |
15 | # Add files or directories matching the regex patterns to the blacklist. The
16 | # regex matches against base names, not paths.
17 | ignore-patterns=
18 |
19 | # Python code to execute, usually for sys.path manipulation such as
20 | # pygtk.require().
21 | #init-hook=
22 |
23 | # Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
24 | # number of processors available to use.
25 | jobs=1
26 |
27 | # Control the amount of potential inferred values when inferring a single
28 | # object. This can help the performance when dealing with large functions or
29 | # complex, nested conditions.
30 | limit-inference-results=100
31 |
32 | # List of plugins (as comma separated values of python module names) to load,
33 | # usually to register additional checkers.
34 | load-plugins=
35 |
36 | # Pickle collected data for later comparisons.
37 | persistent=yes
38 |
39 | # When enabled, pylint would attempt to guess common misconfiguration and emit
40 | # user-friendly hints instead of false-positive error messages.
41 | suggestion-mode=yes
42 |
43 | # Allow loading of arbitrary C extensions. Extensions are imported into the
44 | # active Python interpreter and may run arbitrary code.
45 | unsafe-load-any-extension=no
46 |
47 |
48 | [MESSAGES CONTROL]
49 |
50 | # Only show warnings with the listed confidence levels. Leave empty to show
51 | # all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
52 | confidence=
53 |
54 | # Disable the message, report, category or checker with the given id(s). You
55 | # can either give multiple identifiers separated by comma (,) or put this
56 | # option multiple times (only on the command line, not in the configuration
57 | # file where it should appear only once). You can also use "--disable=all" to
58 | # disable everything first and then reenable specific checks. For example, if
59 | # you want to run only the similarities checker, you can use "--disable=all
60 | # --enable=similarities". If you want to run only the classes checker, but have
61 | # no Warning level messages displayed, use "--disable=all --enable=classes
62 | # --disable=W".
63 | disable=raw-checker-failed,
64 | bad-inline-option,
65 | locally-disabled,
66 | file-ignored,
67 | suppressed-message,
68 | useless-suppression,
69 | deprecated-pragma,
70 | use-symbolic-message-instead,
71 | import-error,
72 | relative-beyond-top-level,
73 | assignment-from-no-return,
74 | missing-module-docstring,
75 | missing-function-docstring,
76 | missing-class-docstring,
77 | unsupported-assignment-operation,
78 | no-member,
79 | too-few-public-methods
80 |
81 | # Enable the message, report, category or checker with the given id(s). You can
82 | # either give multiple identifier separated by comma (,) or put this option
83 | # multiple time (only on the command line, not in the configuration file where
84 | # it should appear only once). See also the "--disable" option for examples.
85 | enable=c-extension-no-member
86 |
87 |
88 | [REPORTS]
89 |
90 | # Python expression which should return a score less than or equal to 10. You
91 | # have access to the variables 'error', 'warning', 'refactor', and 'convention'
92 | # which contain the number of messages in each category, as well as 'statement'
93 | # which is the total number of statements analyzed. This score is used by the
94 | # global evaluation report (RP0004).
95 | evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
96 |
97 | # Template used to display messages. This is a python new-style format string
98 | # used to format the message information. See doc for all details.
99 | #msg-template=
100 |
101 | # Set the output format. Available formats are text, parseable, colorized, json
102 | # and msvs (visual studio). You can also give a reporter class, e.g.
103 | # mypackage.mymodule.MyReporterClass.
104 | output-format=text
105 |
106 | # Tells whether to display a full report or only the messages.
107 | reports=no
108 |
109 | # Activate the evaluation score.
110 | score=yes
111 |
112 |
113 | [REFACTORING]
114 |
115 | # Maximum number of nested blocks for function / method body
116 | max-nested-blocks=5
117 |
118 | # Complete name of functions that never returns. When checking for
119 | # inconsistent-return-statements if a never returning function is called then
120 | # it will be considered as an explicit return statement and no message will be
121 | # printed.
122 | never-returning-functions=sys.exit
123 |
124 |
125 | [MISCELLANEOUS]
126 |
127 | # List of note tags to take in consideration, separated by a comma.
128 | notes=FIXME,
129 | XXX,
130 | TODO
131 |
132 | # Regular expression of note tags to take in consideration.
133 | #notes-rgx=
134 |
135 |
136 | [TYPECHECK]
137 |
138 | # List of decorators that produce context managers, such as
139 | # contextlib.contextmanager. Add to this list to register other decorators that
140 | # produce valid context managers.
141 | contextmanager-decorators=contextlib.contextmanager
142 |
143 | # List of members which are set dynamically and missed by pylint inference
144 | # system, and so shouldn't trigger E1101 when accessed. Python regular
145 | # expressions are accepted.
146 | generated-members=
147 |
148 | # Tells whether missing members accessed in mixin class should be ignored. A
149 | # mixin class is detected if its name ends with "mixin" (case insensitive).
150 | ignore-mixin-members=yes
151 |
152 | # Tells whether to warn about missing members when the owner of the attribute
153 | # is inferred to be None.
154 | ignore-none=yes
155 |
156 | # This flag controls whether pylint should warn about no-member and similar
157 | # checks whenever an opaque object is returned when inferring. The inference
158 | # can return multiple potential results while evaluating a Python object, but
159 | # some branches might not be evaluated, which results in partial inference. In
160 | # that case, it might be useful to still emit no-member and other checks for
161 | # the rest of the inferred objects.
162 | ignore-on-opaque-inference=yes
163 |
164 | # List of class names for which member attributes should not be checked (useful
165 | # for classes with dynamically set attributes). This supports the use of
166 | # qualified names.
167 | ignored-classes=optparse.Values,thread._local,_thread._local
168 |
169 | # List of module names for which member attributes should not be checked
170 | # (useful for modules/projects where namespaces are manipulated during runtime
171 | # and thus existing member attributes cannot be deduced by static analysis). It
172 | # supports qualified module names, as well as Unix pattern matching.
173 | ignored-modules=
174 |
175 | # Show a hint with possible names when a member name was not found. The aspect
176 | # of finding the hint is based on edit distance.
177 | missing-member-hint=yes
178 |
179 | # The minimum edit distance a name should have in order to be considered a
180 | # similar match for a missing member name.
181 | missing-member-hint-distance=1
182 |
183 | # The total number of similar names that should be taken in consideration when
184 | # showing a hint for a missing member.
185 | missing-member-max-choices=1
186 |
187 | # List of decorators that change the signature of a decorated function.
188 | signature-mutators=
189 |
190 |
191 | [STRING]
192 |
193 | # This flag controls whether inconsistent-quotes generates a warning when the
194 | # character used as a quote delimiter is used inconsistently within a module.
195 | check-quote-consistency=no
196 |
197 | # This flag controls whether the implicit-str-concat should generate a warning
198 | # on implicit string concatenation in sequences defined over several lines.
199 | check-str-concat-over-line-jumps=no
200 |
201 |
202 | [LOGGING]
203 |
204 | # The type of string formatting that logging methods do. `old` means using %
205 | # formatting, `new` is for `{}` formatting.
206 | logging-format-style=old
207 |
208 | # Logging modules to check that the string format arguments are in logging
209 | # function parameter format.
210 | logging-modules=logging
211 |
212 |
213 | [VARIABLES]
214 |
215 | # List of additional names supposed to be defined in builtins. Remember that
216 | # you should avoid defining new builtins when possible.
217 | additional-builtins=
218 |
219 | # Tells whether unused global variables should be treated as a violation.
220 | allow-global-unused-variables=yes
221 |
222 | # List of strings which can identify a callback function by name. A callback
223 | # name must start or end with one of those strings.
224 | callbacks=cb_,
225 | _cb
226 |
227 | # A regular expression matching the name of dummy variables (i.e. expected to
228 | # not be used).
229 | dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
230 |
231 | # Argument names that match this expression will be ignored. Default to name
232 | # with leading underscore.
233 | ignored-argument-names=_.*|^ignored_|^unused_
234 |
235 | # Tells whether we should check for unused import in __init__ files.
236 | init-import=no
237 |
238 | # List of qualified module names which can have objects that can redefine
239 | # builtins.
240 | redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
241 |
242 |
243 | [BASIC]
244 |
245 | # Naming style matching correct argument names.
246 | argument-naming-style=snake_case
247 |
248 | # Regular expression matching correct argument names. Overrides argument-
249 | # naming-style.
250 | #argument-rgx=
251 |
252 | # Naming style matching correct attribute names.
253 | attr-naming-style=snake_case
254 |
255 | # Regular expression matching correct attribute names. Overrides attr-naming-
256 | # style.
257 | #attr-rgx=
258 |
259 | # Bad variable names which should always be refused, separated by a comma.
260 | bad-names=foo,
261 | bar,
262 | baz,
263 | toto,
264 | tutu,
265 | tata
266 |
267 | # Bad variable names regexes, separated by a comma. If names match any regex,
268 | # they will always be refused
269 | bad-names-rgxs=
270 |
271 | # Naming style matching correct class attribute names.
272 | class-attribute-naming-style=any
273 |
274 | # Regular expression matching correct class attribute names. Overrides class-
275 | # attribute-naming-style.
276 | #class-attribute-rgx=
277 |
278 | # Naming style matching correct class names.
279 | class-naming-style=PascalCase
280 |
281 | # Regular expression matching correct class names. Overrides class-naming-
282 | # style.
283 | #class-rgx=
284 |
285 | # Naming style matching correct constant names.
286 | const-naming-style=UPPER_CASE
287 |
288 | # Regular expression matching correct constant names. Overrides const-naming-
289 | # style.
290 | #const-rgx=
291 |
292 | # Minimum line length for functions/classes that require docstrings, shorter
293 | # ones are exempt.
294 | docstring-min-length=-1
295 |
296 | # Naming style matching correct function names.
297 | function-naming-style=snake_case
298 |
299 | # Regular expression matching correct function names. Overrides function-
300 | # naming-style.
301 | #function-rgx=
302 |
303 | # Good variable names which should always be accepted, separated by a comma.
304 | good-names=i,
305 | j,
306 | k,
307 | ex,
308 | Run,
309 | _
310 |
311 | # Good variable names regexes, separated by a comma. If names match any regex,
312 | # they will always be accepted
313 | good-names-rgxs=
314 |
315 | # Include a hint for the correct naming format with invalid-name.
316 | include-naming-hint=no
317 |
318 | # Naming style matching correct inline iteration names.
319 | inlinevar-naming-style=any
320 |
321 | # Regular expression matching correct inline iteration names. Overrides
322 | # inlinevar-naming-style.
323 | #inlinevar-rgx=
324 |
325 | # Naming style matching correct method names.
326 | method-naming-style=snake_case
327 |
328 | # Regular expression matching correct method names. Overrides method-naming-
329 | # style.
330 | #method-rgx=
331 |
332 | # Naming style matching correct module names.
333 | module-naming-style=snake_case
334 |
335 | # Regular expression matching correct module names. Overrides module-naming-
336 | # style.
337 | #module-rgx=
338 |
339 | # Colon-delimited sets of names that determine each other's naming style when
340 | # the name regexes allow several styles.
341 | name-group=
342 |
343 | # Regular expression which should only match function or class names that do
344 | # not require a docstring.
345 | no-docstring-rgx=^_
346 |
347 | # List of decorators that produce properties, such as abc.abstractproperty. Add
348 | # to this list to register other decorators that produce valid properties.
349 | # These decorators are taken in consideration only for invalid-name.
350 | property-classes=abc.abstractproperty
351 |
352 | # Naming style matching correct variable names.
353 | variable-naming-style=snake_case
354 |
355 | # Regular expression matching correct variable names. Overrides variable-
356 | # naming-style.
357 | #variable-rgx=
358 |
359 |
360 | [SPELLING]
361 |
362 | # Limits count of emitted suggestions for spelling mistakes.
363 | max-spelling-suggestions=4
364 |
365 | # Spelling dictionary name. Available dictionaries: none. To make it work,
366 | # install the python-enchant package.
367 | spelling-dict=
368 |
369 | # List of comma separated words that should not be checked.
370 | spelling-ignore-words=
371 |
372 | # A path to a file that contains the private dictionary; one word per line.
373 | spelling-private-dict-file=
374 |
375 | # Tells whether to store unknown words to the private dictionary (see the
376 | # --spelling-private-dict-file option) instead of raising a message.
377 | spelling-store-unknown-words=no
378 |
379 |
380 | [SIMILARITIES]
381 |
382 | # Ignore comments when computing similarities.
383 | ignore-comments=yes
384 |
385 | # Ignore docstrings when computing similarities.
386 | ignore-docstrings=yes
387 |
388 | # Ignore imports when computing similarities.
389 | ignore-imports=yes
390 |
391 | # Minimum lines number of a similarity.
392 | min-similarity-lines=6
393 |
394 |
395 | [FORMAT]
396 |
397 | # Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
398 | expected-line-ending-format=
399 |
400 | # Regexp for a line that is allowed to be longer than the limit.
401 | ignore-long-lines=^\s*(# )??$
402 |
403 | # Number of spaces of indent required inside a hanging or continued line.
404 | indent-after-paren=4
405 |
406 | # String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
407 | # tab).
408 | indent-string=' '
409 |
410 | # Maximum number of characters on a single line.
411 | max-line-length=110
412 |
413 | # Maximum number of lines in a module.
414 | max-module-lines=1000
415 |
416 | # Allow the body of a class to be on the same line as the declaration if body
417 | # contains single statement.
418 | single-line-class-stmt=no
419 |
420 | # Allow the body of an if to be on the same line as the test if there is no
421 | # else.
422 | single-line-if-stmt=no
423 |
424 |
425 | [IMPORTS]
426 |
427 | # List of modules that can be imported at any level, not just the top level
428 | # one.
429 | allow-any-import-level=
430 |
431 | # Allow wildcard imports from modules that define __all__.
432 | allow-wildcard-with-all=no
433 |
434 | # Analyse import fallback blocks. This can be used to support both Python 2 and
435 | # 3 compatible code, which means that the block might have code that exists
436 | # only in one or another interpreter, leading to false positives when analysed.
437 | analyse-fallback-blocks=no
438 |
439 | # Deprecated modules which should not be used, separated by a comma.
440 | deprecated-modules=optparse,tkinter.tix
441 |
442 | # Create a graph of external dependencies in the given file (report RP0402 must
443 | # not be disabled).
444 | ext-import-graph=
445 |
446 | # Create a graph of every (i.e. internal and external) dependencies in the
447 | # given file (report RP0402 must not be disabled).
448 | import-graph=
449 |
450 | # Create a graph of internal dependencies in the given file (report RP0402 must
451 | # not be disabled).
452 | int-import-graph=
453 |
454 | # Force import order to recognize a module as part of the standard
455 | # compatibility libraries.
456 | known-standard-library=
457 |
458 | # Force import order to recognize a module as part of a third party library.
459 | known-third-party=enchant
460 |
461 | # Couples of modules and preferred modules, separated by a comma.
462 | preferred-modules=
463 |
464 |
465 | [DESIGN]
466 |
467 | # Maximum number of arguments for function / method.
468 | max-args=5
469 |
470 | # Maximum number of attributes for a class (see R0902).
471 | max-attributes=7
472 |
473 | # Maximum number of boolean expressions in an if statement (see R0916).
474 | max-bool-expr=5
475 |
476 | # Maximum number of branch for function / method body.
477 | max-branches=12
478 |
479 | # Maximum number of locals for function / method body.
480 | max-locals=15
481 |
482 | # Maximum number of parents for a class (see R0901).
483 | max-parents=7
484 |
485 | # Maximum number of public methods for a class (see R0904).
486 | max-public-methods=20
487 |
488 | # Maximum number of return / yield for function / method body.
489 | max-returns=6
490 |
491 | # Maximum number of statements in function / method body.
492 | max-statements=50
493 |
494 | # Minimum number of public methods for a class (see R0903).
495 | min-public-methods=2
496 |
497 |
498 | [CLASSES]
499 |
500 | # List of method names used to declare (i.e. assign) instance attributes.
501 | defining-attr-methods=__init__,
502 | __new__,
503 | setUp,
504 | __post_init__
505 |
506 | # List of member names, which should be excluded from the protected access
507 | # warning.
508 | exclude-protected=_asdict,
509 | _fields,
510 | _replace,
511 | _source,
512 | _make
513 |
514 | # List of valid names for the first argument in a class method.
515 | valid-classmethod-first-arg=cls
516 |
517 | # List of valid names for the first argument in a metaclass class method.
518 | valid-metaclass-classmethod-first-arg=cls
519 |
520 |
521 | [EXCEPTIONS]
522 |
523 | # Exceptions that will emit a warning when being caught. Defaults to
524 | # "BaseException, Exception".
525 | overgeneral-exceptions=builtins.BaseException,
526 | builtins.Exception
527 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.exclude": {
3 | "**/__pycache__": true
4 | },
5 | "blender.addon.loadDirectory": "addon",
6 | "blender.addon.moduleName": "servo_animation"
7 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Blender Servo Animation Add-on
2 |
3 | Export your Blender animation to servo position values. They can be used with an Arduino compatible micro controller to move PWM-driven servos according to your animation.
4 |
5 | Animate your robot or animatronic project and take advantage of Blender's animation tools!
6 |
7 | Also check out the [Blender Servo Animation Arduino Library](https://github.com/timhendriks93/blender-servo-animation-arduino) which is specifically designed to work with this add-on.
8 |
9 | [](https://github.com/timhendriks93/blender-servo-animation/actions/workflows/ci.yml)
10 |
11 | ## Features
12 |
13 | - Represent servos through armature bones
14 | - Provide individual `Servo Settings` per bone
15 | - Export an animation as servo position values
16 | - Send position values via a live mode connection in real-time
17 | - Supporting Inverse Kinematics (IK)
18 |
19 | ## Installation
20 |
21 | > Note: the latest version of this Add-on is compatible with Blender **4.2 or higher**.
22 |
23 | The Add-on can be installed as a regular [Blender Extension](https://docs.blender.org/manual/en/latest/editors/preferences/extensions.html).
24 |
25 | ## Providing Servo Settings
26 |
27 | After enabling this Add-on, you should see a `Servo Settings` panel within the `Bone Properties` tab. This tab will be available once you select a bone while being in `Edit` or `Pose` mode.
28 |
29 | The underlying principle is that each bone represents a servo motor in the real world. To treat a bone as a servo and activate the `Servo Settings`, enable the checkbox in the panel header.
30 |
31 | 
32 |
33 | ### Servo Setting Properties
34 |
35 | | Property | Description |
36 | | -------- | ----------- |
37 | | Servo ID | Unique number between `0` and `255` to identify this servo (used to send live commands) |
38 | | Position Min | The minimum position value to identify this servo physically stops moving |
39 | | Position Max | Same as `Position Min`, but for the maximum value |
40 | | Threshold | The maximum value change between frames which is also used for frame jump handling in live mode |
41 | | Neutral Angle | The assumed neutral angle of the servo in degrees (typically half the rotation range) which should be adjusted carefully, since the servo will first move to its 'natural' neutral angle when powered |
42 | | Rotation Range | The manufactured rotation range of the servo in degrees (typically `180`) |
43 | | Euler Rotation Axis | The Euler rotation axis (`X`, `Y` or `Z`) of the bone rotation representing the servo movement |
44 | | Multiplier | Multiplier to increase or decrease the rotation to adjust the intensity within a specific build |
45 | | Reverse Direction | Whether the applied rotation should be reversed when converting to position value which might be necessary to reflect the servo's positioning within a specific build |
46 |
47 | ### Choosing a Position Value Range
48 |
49 | The default position min and max values are based on servo pulse lengths as they are required when using a library to control a servo driver module, like the `PCA9685`.
50 |
51 | It is also possible to use a different kind of value range. For example, to use the default Arduino Servo library, you can use a degrees value range by setting min to `0` and max to `180`.
52 |
53 | > Note: the correct settings vary between different servo brands and models. Be careful not to damage the servo when finding the min and max position values.
54 |
55 | ### Limiting the value range
56 |
57 | You can take advantage of Blender's functionality and use [bone constraints](https://docs.blender.org/manual/en/latest/animation/constraints/transform/limit_rotation.html) to already limit the bone rotation according to your build. The more precise your 3D model, the easier it will be to apply constraints and get an accurate preview of the real-world setup.
58 |
59 | ## Animating the Armature
60 |
61 | When animating your armature you can benefit from all the exciting animation features Blender has to offer. Apart from animating every bone/servo separately, you can also use IK ([Inverse Kinematics](https://www.youtube.com/watch?v=S-2v_CKmVE8)) to let the Add-On calculate the positions of multiple servos automatically.
62 |
63 | When thinking of animatronic or robotic projects, you could animate a head or arm without having to worry about the individual bones/servos that make up the neck mechanism or arm segments. To further illustrate this, you can also find an [example of a neck mechanism](examples/IK/ik.blend) to learn about the armature and constraints setup.
64 |
65 | ## Exporting
66 |
67 | Once all servo settings are provided and your animation is ready, you can calculate and export the servo position values.
68 |
69 | Make sure to select the armature containing the bones/servos you want to export and choose the desired format in the `File > Export` menu:
70 |
71 | 
72 |
73 | Alternatively, you can also trigger the export via the timeline menu which is shown in the live mode section below:
74 |
75 | 
76 |
77 | ### Export Formats
78 |
79 | There are 3 different formats to choose from:
80 |
81 | 1. `Animation Servo Positions (.h)`: An Arduino/C/C++ style header file which can be easily included in an Arduino project.
82 | 2. `Animation Servo Positions (.json)`: A simple (non-formatted) JSON file which can be used in a more generic way.
83 | 3. `Animation Servo Positions (.bin)`: A binary file which can be used to store the animation data on an SD card.
84 |
85 | ### Using the Exported Data
86 |
87 | For projects which involve an Arduino compatible microcontroller, the easiest way to work with the exported data is by using the dedicated [Blender Servo Animation Arduino Library](https://github.com/timhendriks93/blender-servo-animation-arduino). This library allows you to map the exported positions to a servo representation and add custom logic to actually send servo control signals. Check out the library's repository for more details and some read-to-use examples.
88 |
89 | Apart from using the library, it is also possible to write use the exported data in any other kind of program. Especially the JSON format simply represents a list of position values which can be easily parsed via code.
90 |
91 | ## Live Mode
92 |
93 | To make the animation process even more intuitive, you can enable the `Live mode` to send position commands via one of the following connection types:
94 |
95 | - Serial (UART/USB)
96 | - Web socket (TCP)
97 |
98 | This will allow you to control your servos in real-time from within Blender.
99 |
100 | ### Setup a connection
101 |
102 | To use the `Live Mode`, you will need to prepare a receiver which will interpret the received commands and use them to control the servo motors accordingly.
103 |
104 | In most cases, the receiver can be considered an Arduino compatible micro controller. As a first step, a connection method should be selected via the `Method` dropdown menu.
105 |
106 | 
107 |
108 | > Note: starting the `Live Mode` will immediately send the position values for all servos based on the current frame. Make sure that this will not break anything, as the servos will try to move to their new position as fast as possible.
109 |
110 | #### Serial connection
111 |
112 | Once the micro controller is connected via USB to your PC, the add-on will try to find and list the respective `Serial Port`. If there are multiple ports and you are unsure which one belongs to your controller, simply compare the list of ports after removing and re-connecting the device.
113 |
114 | The `Baud Rate` specifies at which rate or speed the data will be transferred. It might need to be adjusted according to the limitations and configurations of your receiver. Keep in mind that a high frame rate combined with a multitude of servos requires a faster data transmission to achieve a smooth movement. As a reference, it was possible to smoothly control `16 servos` at `60 fps` with a baud rate of `115200`.
115 |
116 | Once the `Serial Port` and `Baud Rate` have been set, you can click the `Connect` button to establish the serial connection and start the `Live Mode`.
117 |
118 | #### Web socket connection
119 |
120 | It is also possible to send the position values via a TCP-based web socket connection. For example, one could use a WiFi-capable micro controller like the `ESP32` and set up a server to receive commands from Blender. The server should be in the same network as the machine which is running Blender.
121 |
122 | After starting such a server, we can enter the respective IP address and port into the `Host` and `Port` input fields.
123 |
124 | Clicking the `Connect` button will then establish a tcp connection and start the `Live Mode`.
125 |
126 | ### Position Jump Handling
127 |
128 | Once the connection is established, you can use the timeline to control your servos in a synchronized way. This opens up the possibility to jump to a different frame or position within your animation. To prevent damage due to the servos moving too quickly, you can use `Position Jump Handling`. This option is enabled by default.
129 |
130 | When clicking somewhere in the timeline and therefore jumping to a different frame, the add-on will first calculate all position value differences. If one of those differences exceeds the `Threshold` value of the respective servos, they will be slowly moved to their new target position. This is done by sending multiple position values in small increments. During this process, the user interface will show a progress indicator.
131 |
132 | The speed of this process is also relative to the configured `Threshold` values. A slower and safer movement can be achieved by setting the threshold values as low as possible with the actual animation still able to run properly.
133 |
134 | ### Servo Calibration
135 |
136 | While having an active live mode connection, it is possible to use a servo calibration feature. This will allow you to find the minimum and maximum position value of a servo similar to what you would normally do with a servo tester.
137 |
138 | The calibration process can be started by clicking the `Calibrate servo` button within the servo settings panel:
139 |
140 | 
141 |
142 | > Note: the button will only be clickable when there is an active live mode connection.
143 |
144 | Clicking this button will bring up a dialog containing a drop down menu to switch between the minimum and maximum position. You can then carefully adjust the position value until the servo stops moving. After doing so for both directions or position types, you can click on `OK` to apply these values as the new min and max position values.
145 |
146 | 
147 |
148 | > Note: Be careful when changing the position value and toggling the position type as the servo will move at full speed and position jump handling is not being considered.
149 |
150 | To cancel this process you can either press `ESC` or click outside the dialog box. While position jump handling is not considered during the calibration process it is again considered when cancelling or applying the calibration.
151 |
152 | ### Command Protocol
153 |
154 | The position values are sent based on a specific binary protocol. The receiver has to know about it and be able to interpret the received data in order to successfully trigger the correct servo movement.
155 |
156 | The protocol defines in which order and pattern individual bytes are transferred. The following table shows the protocol structure based on an example where the servo with the ID `0` should receive the position value `375`:
157 |
158 | | | Start | Servo ID | High Pos | Low Pos | End |
159 | | --- | --- | --- | --- | --- | --- |
160 | | ASCII | < | 0 | 1 | 119 | > |
161 | | Decimal | 60 | 0 | 1 | 119 | 62 |
162 | | Hexadecimal | 0x3C | 0x00 | 0x01 | 0x77 | 0x3E |
163 |
164 | The position value is split into 2 bytes (high and low), while the first byte is the most significant one.
165 |
166 | ### Reading Commands on an Arduino
167 |
168 | Instead of writing your own logic to read and interpret the live mode commands, you can also use the [Blender Servo Animation Arduino Library](https://github.com/timhendriks93/blender-servo-animation-arduino) which has a built-in support for the live mode. Check out the library's repository for more details and some ready-to-use examples.
169 |
--------------------------------------------------------------------------------
/addon/__init__.py:
--------------------------------------------------------------------------------
1 | import bpy
2 |
3 | from .props.bone_property_group import BonePropertyGroup
4 | from .props.wm_property_group import WindowManagerPropertyGroup
5 | from .ui.bone_panel import BonePanel
6 | from .ui.menu_panel import MenuPanel
7 | from .ops.json_export import JsonExport
8 | from .ops.arduino_export import ArduinoExport
9 | from .ops.binary_export import BinaryExport
10 | from .ops.stop_live_mode import StopLiveMode
11 | from .ops.start_live_mode import StartLiveMode
12 | from .ops.calibrate_servo import CalibrateServo
13 |
14 |
15 | classes = (
16 | BonePropertyGroup,
17 | WindowManagerPropertyGroup,
18 | BonePanel,
19 | MenuPanel,
20 | ArduinoExport,
21 | JsonExport,
22 | BinaryExport,
23 | StopLiveMode,
24 | StartLiveMode,
25 | CalibrateServo
26 | )
27 |
28 |
29 | def menu_func_export(self, _):
30 | self.layout.operator(ArduinoExport.bl_idname)
31 | self.layout.operator(JsonExport.bl_idname)
32 | self.layout.operator(BinaryExport.bl_idname)
33 |
34 |
35 | def menu_func_timeline(self, _):
36 | self.layout.popover(MenuPanel.bl_idname)
37 |
38 |
39 | def register():
40 | for cls in classes:
41 | bpy.utils.register_class(cls)
42 |
43 | bpy.types.Bone.servo_settings = bpy.props.PointerProperty(
44 | type=BonePropertyGroup)
45 | bpy.types.EditBone.servo_settings = bpy.props.PointerProperty(
46 | type=BonePropertyGroup)
47 | bpy.types.WindowManager.servo_animation = bpy.props.PointerProperty(
48 | type=WindowManagerPropertyGroup)
49 | bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
50 | bpy.types.TIME_MT_editor_menus.append(menu_func_timeline)
51 |
52 |
53 | def unregister():
54 | for cls in classes:
55 | bpy.utils.unregister_class(cls)
56 |
57 | del bpy.types.Bone.servo_settings
58 | del bpy.types.EditBone.servo_settings
59 | del bpy.types.WindowManager.servo_animation
60 | bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
61 | bpy.types.TIME_MT_editor_menus.remove(menu_func_timeline)
62 |
--------------------------------------------------------------------------------
/addon/blender_manifest.toml:
--------------------------------------------------------------------------------
1 | schema_version = "1.0.0"
2 |
3 | id = "servo_animation"
4 | version = "2.0.0"
5 | name = "Servo Animation"
6 | tagline = "Export your Blender animation to servo position values"
7 | maintainer = "Tim Hendriks "
8 | type = "add-on"
9 |
10 | website = "https://github.com/timhendriks93/blender-servo-animation"
11 |
12 | tags = ["Animation", "Import-Export", "Rigging"]
13 |
14 | blender_version_min = "4.2.0"
15 |
16 | license = [
17 | "SPDX:GPL-3.0-or-later",
18 | ]
19 |
20 | wheels = [
21 | "./wheels/pyserial-3.5-py2.py3-none-any.whl",
22 | "./wheels/websocket_client-1.5.1-py3-none-any.whl",
23 | ]
24 |
25 | files = "Export animation servo position values to disk"
26 |
--------------------------------------------------------------------------------
/addon/ops/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/addon/ops/__init__.py
--------------------------------------------------------------------------------
/addon/ops/arduino_export.py:
--------------------------------------------------------------------------------
1 | import bpy
2 |
3 | from bpy.types import Operator
4 | from bpy_extras.io_utils import ExportHelper
5 | from .base_export import BaseExport
6 |
7 |
8 | class ArduinoExport(Operator, BaseExport, ExportHelper):
9 | bl_idname = "export_anim.servo_animation_arduino"
10 | bl_label = "Servo Animation (.h)"
11 | bl_description = "Save an Arduino header file with servo position values of the active armature"
12 |
13 | filename_ext = ".h"
14 | chunk_size = 12
15 |
16 | filter_glob: bpy.props.StringProperty(
17 | default="*.h",
18 | options={'HIDDEN'},
19 | maxlen=255
20 | )
21 |
22 | namespace: bpy.props.BoolProperty(
23 | name="Add scene namespace",
24 | description=(
25 | "Use the current scene name to wrap the position arrays and "
26 | "variables in a namespace"
27 | )
28 | )
29 |
30 | def export(self, positions, filepath, context):
31 | fps, frames, seconds = self.get_time_meta(context.scene)
32 | filename = self.get_blend_filename()
33 |
34 | content = (
35 | "/*\n Blender Servo Animation Positions\n\n "
36 | f"FPS: {fps}\n Frames: {frames}\n Seconds: {seconds}\n "
37 | f"Bones: {len(positions[0])}\n Armature: {context.object.name}\n "
38 | f"Scene: {context.scene.name}\n File: {filename}\n*/\n\n"
39 | "#include \n"
40 | )
41 |
42 | commands = self.get_commands(positions)
43 | length = len(commands)
44 | lines = self.join_by_chunk_size(commands, self.chunk_size)
45 |
46 | if self.namespace:
47 | scene_name = self.format_scene_name()
48 | content += f"\nnamespace {scene_name} {{\n"
49 |
50 | content += (
51 | f"\nconst byte FPS = {fps};"
52 | f"\nconst int FRAMES = {frames};"
53 | f"\nconst int LENGTH = {length};\n\n"
54 | )
55 |
56 | content += f'const byte PROGMEM ANIMATION_DATA[LENGTH] = {{\n{lines}}};\n'
57 |
58 | if self.namespace:
59 | content += f"\n}} // namespace {scene_name}\n"
60 |
61 | with open(filepath, 'w', encoding='utf-8') as file:
62 | file.write(content)
63 |
64 | @classmethod
65 | def join_by_chunk_size(cls, iterable, chunk_size):
66 | output = ''
67 | str_iterable = list(map(cls.format_hex, iterable))
68 |
69 | for i in range(0, len(str_iterable), chunk_size):
70 | output += ' ' + ', '.join(str_iterable[i:i + chunk_size]) + ',\n'
71 |
72 | return output
73 |
74 | @classmethod
75 | def format_hex(cls, byte):
76 | return f'{byte:#04x}'
77 |
78 | @classmethod
79 | def format_scene_name(cls):
80 | valid_chars = set('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_')
81 | scene_name = ''.join(c if c in valid_chars else '_' for c in bpy.context.scene.name)
82 |
83 | if scene_name[0].isdigit():
84 | scene_name = '_' + scene_name
85 |
86 | return scene_name
87 |
--------------------------------------------------------------------------------
/addon/ops/base_export.py:
--------------------------------------------------------------------------------
1 | import time
2 | import bpy
3 |
4 | from ..utils.converter import calculate_positions
5 | from ..utils.live_mode import LiveMode
6 |
7 |
8 | class BaseExport:
9 | COMMAND_START = 0x3C
10 | COMMAND_END = 0x3E
11 | LINE_BREAK = 10
12 |
13 | skip_duplicates: bpy.props.BoolProperty(
14 | name="Skip unchanged positions",
15 | description="Skip positions which haven't changed since the last frame",
16 | default=True
17 | )
18 |
19 | @classmethod
20 | def poll(cls, context):
21 | if not context.object or context.object.type != 'ARMATURE':
22 | return False
23 | for pose_bone in context.object.pose.bones:
24 | if pose_bone.bone.servo_settings.active:
25 | return True
26 | return False
27 |
28 | def execute(self, context):
29 | start = time.time()
30 | original_frame = context.scene.frame_current
31 | original_live_mode = LiveMode.is_connected()
32 |
33 | if original_live_mode is True:
34 | bpy.ops.servo_animation.stop_live_mode()
35 |
36 | try:
37 | positions = calculate_positions(context, self.skip_duplicates)
38 | self.export(positions, self.filepath, context)
39 | except RuntimeError as error:
40 | self.report({'ERROR'}, str(error))
41 |
42 | return {'CANCELLED'}
43 | finally:
44 | context.scene.frame_set(original_frame)
45 |
46 | if original_live_mode is True:
47 | bpy.ops.servo_animation.start_live_mode('INVOKE_DEFAULT')
48 |
49 | end = time.time()
50 | duration = round(end - start)
51 | unit = "second" if duration == 1 else "seconds"
52 | self.report(
53 | {'INFO'}, f"Animation servo positions exported after {duration} {unit}")
54 |
55 | return {'FINISHED'}
56 |
57 | def get_commands(self, positions):
58 | commands = []
59 |
60 | for frame_positions in positions:
61 | for servo_id in frame_positions:
62 | position = frame_positions[servo_id]
63 | commands += self.get_command(servo_id, position)
64 |
65 | commands.append(self.LINE_BREAK)
66 |
67 | return commands
68 |
69 | def get_command(self, servo_id, position):
70 | command = [self.COMMAND_START, servo_id]
71 | command += position.to_bytes(2, 'big')
72 | command += [self.COMMAND_END]
73 |
74 | return command
75 |
76 | @staticmethod
77 | def get_time_meta(scene):
78 | fps = scene.render.fps
79 | frames = scene.frame_end - scene.frame_start + 1
80 | seconds = round(frames / scene.render.fps)
81 |
82 | return fps, frames, seconds
83 |
84 | @staticmethod
85 | def get_blend_filename():
86 | return bpy.path.basename(bpy.context.blend_data.filepath)
87 |
--------------------------------------------------------------------------------
/addon/ops/binary_export.py:
--------------------------------------------------------------------------------
1 | import bpy
2 |
3 | from bpy.types import Operator
4 | from bpy_extras.io_utils import ExportHelper
5 | from .base_export import BaseExport
6 |
7 |
8 | class BinaryExport(Operator, BaseExport, ExportHelper):
9 | bl_idname = "export_anim.servo_animation_binary"
10 | bl_label = "Servo Animation (.bin)"
11 | bl_description = "Save a binary file with servo position values of the active armature"
12 |
13 | filename_ext = ".bin"
14 |
15 | filter_glob: bpy.props.StringProperty(
16 | default="*.bin",
17 | options={'HIDDEN'},
18 | maxlen=255
19 | )
20 |
21 | def export(self, positions, filepath, _context):
22 | commands = self.get_commands(positions)
23 |
24 | with open(filepath, 'wb') as file:
25 | file.write(bytes(commands))
26 |
--------------------------------------------------------------------------------
/addon/ops/calibrate_servo.py:
--------------------------------------------------------------------------------
1 | import bpy
2 |
3 | from bpy.types import Operator
4 | from ..utils.live_mode import LiveMode
5 |
6 |
7 | def send_position_min(self, context):
8 | LiveMode.send_position(
9 | context.active_bone.servo_settings.servo_id,
10 | self.position_min
11 | )
12 |
13 | def send_position_max(self, context):
14 | LiveMode.send_position(
15 | context.active_bone.servo_settings.servo_id,
16 | self.position_max
17 | )
18 |
19 | def toggle_position(self, context):
20 | if self.toggle == 'MIN':
21 | send_position_min(self, context)
22 | else:
23 | send_position_max(self, context)
24 |
25 |
26 | class CalibrateServo(Operator):
27 | bl_idname = "servo_animation.calibrate"
28 | bl_label = "Calibrate servo"
29 | bl_description = "Calibrate servo during live mode by setting the min and max position values"
30 | bl_options = {'INTERNAL', 'BLOCKING'}
31 |
32 | toggle: bpy.props.EnumProperty(
33 | name="Position type",
34 | items=[
35 | ('MIN', 'Min position', ''),
36 | ('MAX', 'Max position', '')
37 | ],
38 | default='MIN',
39 | options={'SKIP_SAVE'},
40 | update=toggle_position
41 | )
42 | position_min: bpy.props.IntProperty(
43 | name="Position value",
44 | min=0,
45 | max=10000,
46 | description="The minimum position value before the servo physically stops moving",
47 | update=send_position_min
48 | )
49 | position_max: bpy.props.IntProperty(
50 | name="Position value",
51 | min=0,
52 | max=10000,
53 | description="The maximum position value before the servo physically stops moving",
54 | update=send_position_max
55 | )
56 |
57 | @classmethod
58 | def poll(cls, context):
59 | return context.active_bone and LiveMode.is_connected()
60 |
61 | def execute(self, context):
62 | servo_settings = context.active_bone.servo_settings
63 | servo_settings.position_min = self.position_min
64 | servo_settings.position_max = self.position_max
65 |
66 | self.stop()
67 |
68 | return {'FINISHED'}
69 |
70 | def __del__(self):
71 | self.stop()
72 |
73 | @classmethod
74 | def stop(cls):
75 | if not LiveMode.is_handler_enabled():
76 | LiveMode.enable_handler()
77 | LiveMode.handler(None, None)
78 |
79 | def invoke(self, context, _event):
80 | servo_id = context.active_bone.servo_settings.servo_id
81 | last_position = LiveMode.get_last_position(servo_id)
82 |
83 | if last_position is None:
84 | self.report({'ERROR'}, f"Could not find last position for servo with ID {servo_id}")
85 |
86 | return {'CANCELLED'}
87 |
88 | self.position_min = last_position
89 | self.position_max = last_position
90 |
91 | LiveMode.disable_handler()
92 |
93 | return context.window_manager.invoke_props_dialog(self)
94 |
95 | def draw(self, _context):
96 | layout = self.layout
97 | layout.use_property_split = True
98 |
99 | box = layout.box()
100 | box.label(text="Changes move servo immediately", icon="ERROR")
101 |
102 | layout.separator()
103 |
104 | col = self.layout.column(align=True)
105 | col.prop(self, "toggle")
106 |
107 | if self.toggle == 'MIN':
108 | col.prop(self, "position_min")
109 | else:
110 | col.prop(self, "position_max")
111 |
112 | layout.separator()
113 |
--------------------------------------------------------------------------------
/addon/ops/json_export.py:
--------------------------------------------------------------------------------
1 | import json
2 | import bpy
3 |
4 | from bpy.types import Operator
5 | from bpy_extras.io_utils import ExportHelper
6 | from .base_export import BaseExport
7 |
8 |
9 | class JsonExport(Operator, BaseExport, ExportHelper):
10 | bl_idname = "export_anim.servo_animation_json"
11 | bl_label = "Servo Animation (.json)"
12 | bl_description = "Save a JSON file with servo position values of the active armature"
13 |
14 | filename_ext = ".json"
15 |
16 | filter_glob: bpy.props.StringProperty(
17 | default="*.json",
18 | options={'HIDDEN'},
19 | maxlen=255
20 | )
21 |
22 | indent: bpy.props.EnumProperty(
23 | name="Indent",
24 | items=[
25 | ('None', 'No indent', ''),
26 | ('1', '1 Space', ''),
27 | ('2', '2 Spaces', ''),
28 | ('3', '3 Spaces', ''),
29 | ('4', '4 Spaces', ''),
30 | ],
31 | default='2',
32 | )
33 |
34 | def export(self, positions, filepath, context):
35 | fps, frames, seconds = self.get_time_meta(context.scene)
36 | filename = self.get_blend_filename()
37 |
38 | try:
39 | indent = int(self.indent)
40 | except ValueError:
41 | indent = None
42 |
43 | data = {
44 | "description": 'Blender Servo Animation Positions',
45 | "fps": fps,
46 | "frames": frames,
47 | "seconds": seconds,
48 | "bones": len(positions[0]),
49 | "armature": context.object.name,
50 | "file": filename,
51 | "scene": context.scene.name,
52 | "positions": positions
53 | }
54 |
55 | content = json.dumps(data, indent=indent)
56 |
57 | with open(filepath, 'w', encoding='utf-8') as file:
58 | file.write(content)
59 |
--------------------------------------------------------------------------------
/addon/ops/start_live_mode.py:
--------------------------------------------------------------------------------
1 | import bpy
2 | import serial
3 | import websocket
4 |
5 | from bpy.types import Operator
6 | from ..utils.live_mode import LiveMode
7 |
8 |
9 | class StartLiveMode(Operator):
10 | bl_idname = "servo_animation.start_live_mode"
11 | bl_label = "Live Mode"
12 | bl_description = "Start sending live position values via a live mode connection"
13 | bl_options = {'INTERNAL', 'BLOCKING'}
14 |
15 | METHOD_ITEMS = [
16 | (LiveMode.METHOD_SERIAL, "Serial", "Connect via USB"),
17 | (LiveMode.METHOD_SOCKET, "Web Socket", "Connect via a web socket"),
18 | ]
19 |
20 | method: bpy.props.EnumProperty(items=METHOD_ITEMS)
21 |
22 | serial_port: bpy.props.StringProperty()
23 | serial_baud: bpy.props.IntProperty()
24 |
25 | socket_host: bpy.props.StringProperty()
26 | socket_port: bpy.props.IntProperty()
27 | socket_path: bpy.props.StringProperty()
28 |
29 | @classmethod
30 | def poll(cls, context):
31 | servo_animation = context.window_manager.servo_animation
32 |
33 | return (
34 | not LiveMode.is_connected()
35 | and (
36 | (
37 | servo_animation.live_mode_method == LiveMode.METHOD_SERIAL
38 | and servo_animation.serial_port != "NONE"
39 | )
40 | or (
41 | servo_animation.live_mode_method == LiveMode.METHOD_SOCKET
42 | and servo_animation.socket_host != ""
43 | ) or bpy.app.background
44 | )
45 | )
46 |
47 | @classmethod
48 | def register_handler(cls):
49 | bpy.app.handlers.frame_change_post.append(LiveMode.handler)
50 | bpy.app.handlers.depsgraph_update_post.append(LiveMode.handler)
51 | LiveMode.handler(bpy.context.scene, None)
52 |
53 | def execute(self, context):
54 | servo_animation = context.window_manager.servo_animation
55 | servo_animation.live_mode_method = self.method
56 |
57 | if self.method == LiveMode.METHOD_SERIAL:
58 | return self.open_serial(context)
59 |
60 | if self.method == LiveMode.METHOD_SOCKET:
61 | return self.open_socket(context)
62 |
63 | self.report({'ERROR'}, "Unknown live mode method")
64 |
65 | return {'CANCELLED'}
66 |
67 | def open_serial(self, _context):
68 | try:
69 | serial_connection = serial.Serial(self.serial_port, self.serial_baud)
70 | except (serial.SerialException, ValueError):
71 | self.report(
72 | {'ERROR'},
73 | (
74 | f"Failed to open serial connection on port {self.serial_port} "
75 | f"with baud rate {self.serial_baud}"
76 | )
77 | )
78 |
79 | return {'CANCELLED'}
80 |
81 | LiveMode.set_connection(serial_connection)
82 |
83 | self.register_handler()
84 | self.report(
85 | {'INFO'},
86 | f"Opened serial connection on port {self.serial_port} with baud rate {self.serial_baud}"
87 | )
88 |
89 | return {'FINISHED'}
90 |
91 | def open_socket(self, _context):
92 | socket_url = f"ws://{self.socket_host}:{self.socket_port}{self.socket_path}"
93 | socket_connection = websocket.WebSocket()
94 | socket_connection.settimeout(1)
95 |
96 | try:
97 | socket_connection.connect(socket_url)
98 | except (websocket.WebSocketException, OSError):
99 | self.report({'ERROR'}, f"Failed to open web socket connection with {socket_url}")
100 |
101 | return {'CANCELLED'}
102 |
103 | LiveMode.set_connection(socket_connection)
104 |
105 | self.register_handler()
106 | self.report({'INFO'}, f"Opened web socket connection with {socket_url}")
107 |
108 | return {'FINISHED'}
109 |
110 | def invoke(self, context, _event):
111 | servo_animation = context.window_manager.servo_animation
112 |
113 | self.method = servo_animation.live_mode_method
114 |
115 | self.serial_port = servo_animation.serial_port
116 | self.serial_baud = int(servo_animation.serial_baud)
117 |
118 | self.socket_host = servo_animation.socket_host
119 | self.socket_port = servo_animation.socket_port
120 | self.socket_path = servo_animation.socket_path
121 |
122 | return self.execute(context)
123 |
--------------------------------------------------------------------------------
/addon/ops/stop_live_mode.py:
--------------------------------------------------------------------------------
1 | import bpy
2 |
3 | from bpy.types import Operator
4 | from ..utils.live_mode import LiveMode
5 |
6 |
7 | class StopLiveMode(Operator):
8 | bl_idname = "servo_animation.stop_live_mode"
9 | bl_label = "Stop Live Mode"
10 | bl_description = "Stop sending live position values via the current live mode connection"
11 | bl_options = {'INTERNAL', 'BLOCKING'}
12 |
13 | unexpected: bpy.props.BoolProperty()
14 |
15 | @staticmethod
16 | def display_warning(popup_self, _context):
17 | popup_self.layout.label(text="Please check your setup and start the live mode again.")
18 |
19 | @classmethod
20 | def unregister_handler(cls):
21 | if bpy.app.handlers.frame_change_post.count(LiveMode.handler):
22 | bpy.app.handlers.frame_change_post.remove(LiveMode.handler)
23 |
24 | if bpy.app.handlers.depsgraph_update_post.count(LiveMode.handler):
25 | bpy.app.handlers.depsgraph_update_post.remove(LiveMode.handler)
26 |
27 | def execute(self, context):
28 | method = context.window_manager.servo_animation.live_mode_method
29 |
30 | LiveMode.close_connection()
31 |
32 | self.unregister_handler()
33 |
34 | if method == LiveMode.METHOD_SERIAL:
35 | connection_type = "serial"
36 | elif method == LiveMode.METHOD_SOCKET:
37 | connection_type = "web socket"
38 | else:
39 | self.report({'ERROR'}, "Unknown live mode method")
40 |
41 | return {'CANCELLED'}
42 |
43 | if self.unexpected:
44 | report_type = {'WARNING'}
45 | message = f"{connection_type.capitalize()} connection closed unexpectedly"
46 | context.window_manager.popup_menu(self.display_warning, title=message, icon='ERROR')
47 | else:
48 | report_type = {'INFO'}
49 | message = f"Closed {connection_type} connection"
50 |
51 | self.report(report_type, message)
52 |
53 | return {'FINISHED'}
54 |
--------------------------------------------------------------------------------
/addon/props/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/addon/props/__init__.py
--------------------------------------------------------------------------------
/addon/props/bone_property_group.py:
--------------------------------------------------------------------------------
1 | import bpy
2 |
3 | from bpy.types import PropertyGroup
4 | from ..utils.servo_settings import range_limit_value
5 |
6 |
7 | def update_position_min(self, _context):
8 | self.position_min = range_limit_value(
9 | self.position_min, None, self.position_max)
10 |
11 |
12 | def update_position_max(self, _context):
13 | self.position_max = range_limit_value(
14 | self.position_max, self.position_min, None)
15 |
16 |
17 | def update_neutral_angle(self, _context):
18 | self.neutral_angle = range_limit_value(
19 | self.neutral_angle, None, self.rotation_range)
20 |
21 |
22 | class BonePropertyGroup(PropertyGroup):
23 | active: bpy.props.BoolProperty(
24 | name="Provide Servo Settings",
25 | description="Provide servo settings for this bone"
26 | )
27 | servo_id: bpy.props.IntProperty(
28 | name="Servo ID",
29 | default=0,
30 | min=0,
31 | max=255,
32 | description="The unique servo ID which is also used for sending live commands"
33 | )
34 | position_min: bpy.props.IntProperty(
35 | name="Min Position",
36 | default=150,
37 | min=0,
38 | max=10000,
39 | description="The minimum position value before the servo physically stops moving",
40 | update=update_position_min
41 | )
42 | position_max: bpy.props.IntProperty(
43 | name="Max Position",
44 | default=600,
45 | min=0,
46 | max=10000,
47 | description="The maximum position value before the servo physically stops moving",
48 | update=update_position_max
49 | )
50 | threshold: bpy.props.IntProperty(
51 | name="Threshold",
52 | default=20,
53 | min=0,
54 | max=10000,
55 | description=(
56 | "The maximum value change between frames which is also "
57 | "used for frame jump handling in live mode"
58 | )
59 | )
60 | neutral_angle: bpy.props.IntProperty(
61 | name="Neutral Angle",
62 | default=90,
63 | min=0,
64 | max=360,
65 | description=(
66 | "The neutral angle of the servo in degrees (typically half the rotation range) "
67 | "which resembles the bone's position in the first frame"
68 | ),
69 | update=update_neutral_angle
70 | )
71 | reverse_direction: bpy.props.BoolProperty(
72 | name="Reverse Direction",
73 | description=(
74 | "Whether the applied rotation should be reversed when converting to "
75 | "position value which might be necessary to reflect the servo's "
76 | "positioning within a specific build"
77 | )
78 | )
79 | multiplier: bpy.props.FloatProperty(
80 | name="Multiplier",
81 | default=1,
82 | min=0.1,
83 | max=100,
84 | precision=1,
85 | step=10,
86 | description=(
87 | "Multiplier to increase or decrease the rotation to adjust the "
88 | "intensity within a specific build"
89 | )
90 | )
91 | rotation_range: bpy.props.IntProperty(
92 | name="Rotation Range",
93 | default=180,
94 | min=0,
95 | max=360,
96 | description="The manufactured rotation range of the servo in degrees (typically 180)"
97 | )
98 | rotation_axis: bpy.props.EnumProperty(
99 | name="Euler Rotation Axis",
100 | default=0,
101 | items=[
102 | ('0', 'X', "X Euler rotation axis"),
103 | ('1', 'Y', "Y Euler rotation axis"),
104 | ('2', 'Z', "Z Euler rotation axis")
105 | ]
106 | )
107 |
--------------------------------------------------------------------------------
/addon/props/wm_property_group.py:
--------------------------------------------------------------------------------
1 | import bpy
2 |
3 | from bpy.types import PropertyGroup
4 | from ..ops.start_live_mode import StartLiveMode
5 | from ..utils.live_mode import LiveMode
6 |
7 |
8 | def get_serial_port_items(_self, _context):
9 | items = []
10 | ports = LiveMode.get_serial_ports()
11 |
12 | if len(ports) < 1:
13 | items.append(("NONE", "No port available", ""))
14 | else:
15 | for port in ports:
16 | items.append((port, port, ""))
17 |
18 | return items
19 |
20 |
21 | class WindowManagerPropertyGroup(PropertyGroup):
22 | live_mode_method: bpy.props.EnumProperty(
23 | name="Method",
24 | items=StartLiveMode.METHOD_ITEMS
25 | )
26 | serial_port: bpy.props.EnumProperty(
27 | name="Port",
28 | items=get_serial_port_items
29 | )
30 | serial_baud: bpy.props.EnumProperty(
31 | name="Baud Rate",
32 | default="115200",
33 | items=[
34 | ("19200", "19200", ""),
35 | ("115200", "115200", ""),
36 | ("192500", "192500", "")
37 | ]
38 | )
39 | socket_host: bpy.props.StringProperty(
40 | name="Host",
41 | default="127.0.0.1"
42 | )
43 | socket_port: bpy.props.IntProperty(
44 | name="Port",
45 | min=0,
46 | max=65535,
47 | default=80
48 | )
49 | socket_path: bpy.props.StringProperty(
50 | name="Path",
51 | default="/"
52 | )
53 | position_jump_handling: bpy.props.BoolProperty(
54 | name="Position Jump Handling",
55 | description=(
56 | "Slowly move the servos to their new position "
57 | "when the position difference exceeds the threshold"
58 | ),
59 | default=True
60 | )
61 |
--------------------------------------------------------------------------------
/addon/ui/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/addon/ui/__init__.py
--------------------------------------------------------------------------------
/addon/ui/bone_panel.py:
--------------------------------------------------------------------------------
1 |
2 | from bpy.types import Panel
3 | from ..ops.calibrate_servo import CalibrateServo
4 | from ..utils.converter import calculate_position
5 | from ..utils.servo_settings import has_unique_servo_id
6 |
7 |
8 | class BonePanel(Panel):
9 | bl_label = "Servo Settings"
10 | bl_idname = "BONE_PT_servo"
11 | bl_space_type = 'PROPERTIES'
12 | bl_region_type = 'WINDOW'
13 | bl_context = "bone"
14 |
15 | @classmethod
16 | def poll(cls, context):
17 | return context.active_bone is not None
18 |
19 | def draw_header(self, context):
20 | servo_settings = context.active_bone.servo_settings
21 | layout = self.layout
22 | layout.prop(servo_settings, "active", text="")
23 |
24 | def draw(self, context):
25 | layout = self.layout
26 | layout.use_property_split = True
27 | servo_settings = context.active_bone.servo_settings
28 |
29 | layout.operator(CalibrateServo.bl_idname)
30 | layout.separator()
31 |
32 | self.draw_servo_id(servo_settings, context)
33 |
34 | layout.separator()
35 |
36 | col = layout.column(align=True)
37 | col.active = servo_settings.active
38 | col.prop(servo_settings, "position_min")
39 | col.prop(servo_settings, "position_max")
40 |
41 | col = layout.column(align=True)
42 | col.active = servo_settings.active
43 | col.prop(servo_settings, "threshold")
44 |
45 | layout.separator()
46 |
47 | col = layout.column(align=True)
48 | col.active = servo_settings.active
49 | col.prop(servo_settings, "neutral_angle")
50 | col.prop(servo_settings, "rotation_range")
51 | col.prop(servo_settings, "rotation_axis")
52 |
53 | layout.separator()
54 |
55 | col = layout.column()
56 | col.active = servo_settings.active
57 | col.prop(servo_settings, "multiplier")
58 | col.prop(servo_settings, "reverse_direction")
59 |
60 | if servo_settings.active and context.active_pose_bone is not None:
61 | self.draw_current(context)
62 |
63 | def draw_servo_id(self, servo_settings, context):
64 | layout = self.layout
65 |
66 | if servo_settings.active and not has_unique_servo_id(context.active_bone, context.scene):
67 | box = layout.box()
68 | box.label(text="Servo ID is not unique", icon="ERROR")
69 |
70 | col = layout.column()
71 | col.active = servo_settings.active
72 | col.prop(servo_settings, "servo_id")
73 |
74 | def draw_current(self, context):
75 | layout = self.layout
76 | box = layout.box()
77 | position, angle, in_range = calculate_position(context.active_pose_bone)
78 |
79 | if not in_range:
80 | box.label(text="Position is out of range", icon="ERROR")
81 |
82 | row = box.row()
83 | col = row.column(align=True)
84 | col.alignment = 'RIGHT'
85 | col.label(text="Frame:")
86 | col.label(text="Position value:")
87 | col.label(text="Angle:")
88 | col = row.column(align=True)
89 | col.label(text=str(context.scene.frame_current))
90 | col.label(text=str(position))
91 | col.label(text=str(angle) + "°")
92 |
--------------------------------------------------------------------------------
/addon/ui/menu_panel.py:
--------------------------------------------------------------------------------
1 | from bpy.types import Panel
2 | from ..ops.json_export import JsonExport
3 | from ..ops.arduino_export import ArduinoExport
4 | from ..ops.binary_export import BinaryExport
5 | from ..ops.stop_live_mode import StopLiveMode
6 | from ..ops.start_live_mode import StartLiveMode
7 | from ..utils.live_mode import LiveMode
8 |
9 |
10 | class MenuPanel(Panel):
11 | bl_label = "Servo Animation"
12 | bl_idname = "TIMELINE_PT_servo"
13 | bl_space_type = 'SEQUENCE_EDITOR'
14 | bl_region_type = 'HEADER'
15 |
16 | def draw(self, context):
17 | layout = self.layout
18 | layout.use_property_split = True
19 | layout.use_property_decorate = False
20 |
21 | col = layout.column()
22 | col.label(text="Live Mode")
23 |
24 | self.draw_live_mode(context, layout, col)
25 |
26 | col = layout.column(align=True)
27 | col.label(text="Export")
28 | col.operator(ArduinoExport.bl_idname, text="Arduino (.h)")
29 | col.operator(JsonExport.bl_idname, text="JSON (.json)")
30 | col.operator(BinaryExport.bl_idname, text="Binary (.bin)")
31 |
32 | @classmethod
33 | def draw_live_mode(cls, context, layout, col):
34 | servo_animation = context.window_manager.servo_animation
35 | live_mode_is_connected = LiveMode.is_connected()
36 |
37 | if live_mode_is_connected:
38 | col.operator(StopLiveMode.bl_idname,
39 | text="Disconnect", depress=True)
40 | else:
41 | col.operator(StartLiveMode.bl_idname, text="Connect")
42 |
43 | col = layout.column(align=True)
44 | col.enabled = not live_mode_is_connected
45 | col.prop(servo_animation, "live_mode_method")
46 |
47 | if servo_animation.live_mode_method == LiveMode.METHOD_SERIAL:
48 | sub = col.column(align=True)
49 | sub.prop(servo_animation, "serial_port")
50 | col.prop(servo_animation, "serial_baud")
51 |
52 | if servo_animation.serial_port == 'NONE':
53 | sub.enabled = False
54 |
55 | elif servo_animation.live_mode_method == LiveMode.METHOD_SOCKET:
56 | col.prop(servo_animation, "socket_host")
57 | col.prop(servo_animation, "socket_port")
58 | col.prop(servo_animation, "socket_path")
59 |
60 | col = layout.column()
61 | col.prop(servo_animation, "position_jump_handling")
62 |
--------------------------------------------------------------------------------
/addon/utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/addon/utils/__init__.py
--------------------------------------------------------------------------------
/addon/utils/converter.py:
--------------------------------------------------------------------------------
1 | import math
2 | import mathutils
3 |
4 |
5 | def range_map(value, from_low, from_high, to_low, to_high):
6 | return (value - from_low) * (to_high - to_low) / (from_high - from_low) + to_low
7 |
8 |
9 | def matrix_visual(pose_bone):
10 | bone = pose_bone.bone
11 |
12 | matrix_pose_bone = pose_bone.matrix
13 | matrix_bone = bone.matrix_local
14 |
15 | if bone.parent:
16 | matrix_parent_bone = bone.parent.matrix_local.copy()
17 | matrix_parent_pose_bone = pose_bone.parent.matrix.copy()
18 | else:
19 | matrix_parent_bone = mathutils.Matrix()
20 | matrix_parent_pose_bone = mathutils.Matrix()
21 |
22 | matrix_bone_inverted = matrix_bone.copy().inverted()
23 | matrix_parent_pose_bone_inverted = matrix_parent_pose_bone.copy().inverted()
24 |
25 | return (
26 | matrix_bone_inverted
27 | @ matrix_parent_bone
28 | @ matrix_parent_pose_bone_inverted
29 | @ matrix_pose_bone
30 | )
31 |
32 |
33 | def calculate_position(pose_bone):
34 | servo_settings = pose_bone.bone.servo_settings
35 | rotation_euler = matrix_visual(pose_bone).to_euler()
36 | rotation_axis_index = int(servo_settings.rotation_axis)
37 | rotation_in_degrees = round(math.degrees(
38 | rotation_euler[rotation_axis_index]) * servo_settings.multiplier, 2)
39 |
40 | if servo_settings.reverse_direction:
41 | rotation_in_degrees = rotation_in_degrees * -1
42 |
43 | angle = servo_settings.neutral_angle - rotation_in_degrees
44 | position = round(range_map(angle, 0, servo_settings.rotation_range,
45 | servo_settings.position_min, servo_settings.position_max))
46 |
47 | in_range = servo_settings.position_min <= position <= servo_settings.position_max
48 |
49 | return position, round(angle, 2), in_range
50 |
51 |
52 | def calculate_positions(context, skip_duplicates):
53 | pose_bones = []
54 | positions = []
55 | last_positions = {}
56 | window_manager = context.window_manager
57 | start = context.scene.frame_start
58 | end = context.scene.frame_end + 1
59 |
60 | window_manager.progress_begin(min=start, max=end)
61 |
62 | for pose_bone in context.object.pose.bones:
63 | servo_settings = pose_bone.bone.servo_settings
64 | if servo_settings.active:
65 | pose_bones.append(pose_bone)
66 |
67 | for frame in range(start, end):
68 | frame_positions = calculate_frame_positions(
69 | context, pose_bones, last_positions, skip_duplicates, frame)
70 | positions.append(frame_positions)
71 | window_manager.progress_update(frame)
72 |
73 | window_manager.progress_end()
74 |
75 | return positions
76 |
77 |
78 | def calculate_frame_positions(context, pose_bones, last_positions, skip_duplicates, frame):
79 | frame_positions = {}
80 |
81 | context.scene.frame_set(frame)
82 |
83 | for pose_bone in pose_bones:
84 | bone = pose_bone.bone
85 | servo_id = bone.servo_settings.servo_id
86 | position, _angle, in_range = calculate_position(pose_bone)
87 |
88 | if servo_id not in last_positions:
89 | last_positions[servo_id] = None
90 |
91 | if not in_range:
92 | raise RuntimeError(
93 | f"Calculated position {position} for bone {bone.name} "
94 | + f"is out of range at frame {frame}."
95 | )
96 |
97 | if skip_duplicates and last_positions[servo_id] == position:
98 | continue
99 |
100 | frame_positions[servo_id] = position
101 | last_positions[servo_id] = position
102 |
103 | return frame_positions
104 |
--------------------------------------------------------------------------------
/addon/utils/live_mode.py:
--------------------------------------------------------------------------------
1 | # pylint: disable=broad-exception-caught
2 |
3 | import time
4 | import math
5 | import bpy
6 | import serial
7 | import websocket
8 |
9 | from serial.tools import list_ports
10 |
11 | from ..utils.servo_settings import get_active_pose_bones
12 | from ..utils.converter import calculate_position
13 |
14 | class LiveMode:
15 | COMMAND_START = 0x3C
16 | COMMAND_END = 0x3E
17 |
18 | METHOD_SERIAL = "SERIAL"
19 | METHOD_SOCKET = "SOCKET"
20 |
21 | STEP_DURATION_BASE = .3
22 |
23 | _last_positions = {}
24 | _connection = None
25 | _handler_enabled = True
26 |
27 | @classmethod
28 | def set_connection(cls, connection):
29 | cls._connection = connection
30 |
31 | @classmethod
32 | def is_connected(cls):
33 | method = bpy.context.window_manager.servo_animation.live_mode_method
34 |
35 | if method == LiveMode.METHOD_SERIAL:
36 | return (
37 | isinstance(cls._connection, serial.Serial)
38 | and cls._connection.is_open
39 | and (
40 | cls._connection.port in cls.get_serial_ports()
41 | or bpy.app.background
42 | )
43 | )
44 |
45 | if method == LiveMode.METHOD_SOCKET:
46 | return (
47 | isinstance(cls._connection, websocket.WebSocket)
48 | and cls._connection.connected
49 | )
50 |
51 | return False
52 |
53 | @classmethod
54 | def is_handler_enabled(cls):
55 | return cls._handler_enabled
56 |
57 | @classmethod
58 | def enable_handler(cls):
59 | cls._handler_enabled = True
60 |
61 | @classmethod
62 | def disable_handler(cls):
63 | cls._handler_enabled = False
64 |
65 | @classmethod
66 | def get_serial_ports(cls):
67 | ports = []
68 |
69 | for port in list_ports.comports():
70 | ports.append(port.device)
71 |
72 | return ports
73 |
74 | @classmethod
75 | def get_last_position(cls, servo_id):
76 | if servo_id in cls._last_positions:
77 | return cls._last_positions[servo_id]
78 |
79 | return None
80 |
81 | @classmethod
82 | def handler(cls, _scene, _depsgraph):
83 | if not cls.is_handler_enabled():
84 | return
85 |
86 | cls.disable_handler()
87 |
88 | threshold_exceeded = False
89 | target_positions = []
90 | servo_animation = bpy.context.window_manager.servo_animation
91 |
92 | for pose_bone in get_active_pose_bones(bpy.context.scene):
93 | position, _angle, in_range = calculate_position(pose_bone)
94 |
95 | if not in_range:
96 | continue
97 |
98 | servo_settings = pose_bone.bone.servo_settings
99 | servo_id = servo_settings.servo_id
100 | step = round(servo_settings.threshold / 10)
101 | target_positions.append((servo_id, position, step))
102 |
103 | if (
104 | servo_id in cls._last_positions
105 | and abs(position - cls._last_positions[servo_id]) > servo_settings.threshold
106 | ):
107 | threshold_exceeded = True
108 |
109 | if (servo_animation.position_jump_handling and threshold_exceeded):
110 | cls.handle_position_jump(target_positions)
111 | else:
112 | cls.handle_default(target_positions)
113 |
114 | cls.enable_handler()
115 |
116 | @classmethod
117 | def handle_default(cls, target_positions):
118 | for servo_id, position, _step in target_positions:
119 | cls.send_position(servo_id, position)
120 |
121 | @classmethod
122 | def handle_position_jump(cls, target_positions):
123 | if bpy.context.screen.is_animation_playing:
124 | bpy.ops.screen.animation_cancel(restore_frame=False)
125 |
126 | abs_steps = 0
127 |
128 | for servo_id, position, step in target_positions:
129 | diff = abs(position - cls._last_positions[servo_id])
130 | steps = math.ceil(diff / step)
131 | abs_steps = max(abs_steps, steps)
132 |
133 | window_manager = bpy.context.window_manager
134 | window_manager.progress_begin(0, abs_steps)
135 |
136 | for abs_step in range(abs_steps):
137 | window_manager.progress_update(abs_step)
138 |
139 | for servo_id, position, step in target_positions:
140 | new_position = cls._last_positions[servo_id]
141 |
142 | if position == new_position:
143 | continue
144 |
145 | if position > new_position:
146 | new_position += step
147 | else:
148 | new_position -= step
149 |
150 | if abs(position - new_position) < step:
151 | new_position = position
152 |
153 | cls.send_position(servo_id, new_position)
154 |
155 | time.sleep(.01)
156 |
157 | window_manager.progress_end()
158 |
159 | @classmethod
160 | def send_position(cls, servo_id, position):
161 | if position == cls._last_positions.get(servo_id):
162 | return
163 |
164 | command = [cls.COMMAND_START, servo_id]
165 | command += position.to_bytes(2, 'big')
166 | command += [cls.COMMAND_END]
167 |
168 | servo_animation = bpy.context.window_manager.servo_animation
169 |
170 | try:
171 | if servo_animation.live_mode_method == LiveMode.METHOD_SERIAL:
172 | cls._connection.write(command)
173 | elif servo_animation.live_mode_method == LiveMode.METHOD_SOCKET:
174 | cls._connection.send_binary(bytes(command))
175 |
176 | cls._last_positions[servo_id] = position
177 | except Exception:
178 | bpy.ops.servo_animation.stop_live_mode(unexpected=True)
179 |
180 | @classmethod
181 | def close_connection(cls):
182 | cls._last_positions = {}
183 |
184 | if cls._connection:
185 | cls._connection.close()
186 |
--------------------------------------------------------------------------------
/addon/utils/servo_settings.py:
--------------------------------------------------------------------------------
1 | def get_active_pose_bones(scene):
2 | pose_bones = []
3 |
4 | for obj in scene.objects:
5 | if obj.type != "ARMATURE":
6 | continue
7 |
8 | for pose_bone in obj.pose.bones:
9 | if pose_bone.bone.servo_settings.active:
10 | pose_bones.append(pose_bone)
11 |
12 | return pose_bones
13 |
14 |
15 | def get_pose_bone_by_servo_id(servo_id, scene):
16 | for pose_bone in get_active_pose_bones(scene):
17 | if pose_bone.bone.servo_settings.servo_id == servo_id:
18 | return pose_bone
19 |
20 | return None
21 |
22 |
23 | def range_limit_value(value, min_value, max_value):
24 | if min_value is not None and value < min_value:
25 | return min_value
26 | if max_value is not None and value > max_value:
27 | return max_value
28 | return value
29 |
30 |
31 | def has_unique_servo_id(bone, scene):
32 | for pose_bone in get_active_pose_bones(scene):
33 | if pose_bone.bone.name == bone.name:
34 | continue
35 | if pose_bone.bone.servo_settings.servo_id == bone.servo_settings.servo_id:
36 | return False
37 |
38 | return True
39 |
--------------------------------------------------------------------------------
/addon/wheels/pyserial-3.5-py2.py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/addon/wheels/pyserial-3.5-py2.py3-none-any.whl
--------------------------------------------------------------------------------
/addon/wheels/websocket_client-1.5.1-py3-none-any.whl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/addon/wheels/websocket_client-1.5.1-py3-none-any.whl
--------------------------------------------------------------------------------
/examples/IK/ik.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/examples/IK/ik.bin
--------------------------------------------------------------------------------
/examples/IK/ik.blend:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/examples/IK/ik.blend
--------------------------------------------------------------------------------
/examples/IK/ik.h:
--------------------------------------------------------------------------------
1 | /*
2 | Blender Servo Animation Positions
3 |
4 | FPS: 30
5 | Frames: 100
6 | Seconds: 3
7 | Bones: 2
8 | Armature: Armature
9 | Scene: Scene
10 | File: ik.blend
11 | */
12 |
13 | #include
14 |
15 | const byte FPS = 30;
16 | const int FRAMES = 100;
17 | const int LENGTH = 1040;
18 |
19 | const byte PROGMEM ANIMATION_DATA[LENGTH] = {
20 | 0x3c, 0x00, 0x01, 0x77, 0x3e, 0x3c, 0x01, 0x01, 0x77, 0x3e, 0x0a, 0x3c,
21 | 0x00, 0x01, 0x78, 0x3e, 0x3c, 0x01, 0x01, 0x78, 0x3e, 0x0a, 0x3c, 0x00,
22 | 0x01, 0x79, 0x3e, 0x3c, 0x01, 0x01, 0x7b, 0x3e, 0x0a, 0x3c, 0x00, 0x01,
23 | 0x7c, 0x3e, 0x3c, 0x01, 0x01, 0x7f, 0x3e, 0x0a, 0x3c, 0x00, 0x01, 0x80,
24 | 0x3e, 0x3c, 0x01, 0x01, 0x84, 0x3e, 0x0a, 0x3c, 0x00, 0x01, 0x83, 0x3e,
25 | 0x3c, 0x01, 0x01, 0x8a, 0x3e, 0x0a, 0x3c, 0x00, 0x01, 0x87, 0x3e, 0x3c,
26 | 0x01, 0x01, 0x91, 0x3e, 0x0a, 0x3c, 0x00, 0x01, 0x8c, 0x3e, 0x3c, 0x01,
27 | 0x01, 0x99, 0x3e, 0x0a, 0x3c, 0x00, 0x01, 0x90, 0x3e, 0x3c, 0x01, 0x01,
28 | 0xa1, 0x3e, 0x0a, 0x3c, 0x00, 0x01, 0x93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 0x3c, 0x00, 0x01, 0x7d, 0x3e, 0x3c, 0x01, 0x01, 0x71, 0x3e, 0x0a,
102 | 0x3c, 0x00, 0x01, 0x7c, 0x3e, 0x3c, 0x01, 0x01, 0x72, 0x3e, 0x0a, 0x3c,
103 | 0x00, 0x01, 0x7a, 0x3e, 0x3c, 0x01, 0x01, 0x74, 0x3e, 0x0a, 0x3c, 0x00,
104 | 0x01, 0x79, 0x3e, 0x3c, 0x01, 0x01, 0x75, 0x3e, 0x0a, 0x3c, 0x00, 0x01,
105 | 0x78, 0x3e, 0x3c, 0x01, 0x01, 0x76, 0x3e, 0x0a, 0x3c, 0x00, 0x01, 0x77,
106 | 0x3e, 0x3c, 0x01, 0x01, 0x77, 0x3e, 0x0a, 0x0a,
107 | };
108 |
--------------------------------------------------------------------------------
/examples/IK/ik.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Blender Servo Animation Positions",
3 | "fps": 30,
4 | "frames": 100,
5 | "seconds": 3,
6 | "bones": 2,
7 | "armature": "Armature",
8 | "file": "ik.blend",
9 | "scene": "Scene",
10 | "positions": [
11 | {
12 | "0": 375,
13 | "1": 375
14 | },
15 | {
16 | "0": 376,
17 | "1": 376
18 | },
19 | {
20 | "0": 377,
21 | "1": 379
22 | },
23 | {
24 | "0": 380,
25 | "1": 383
26 | },
27 | {
28 | "0": 384,
29 | "1": 388
30 | },
31 | {
32 | "0": 387,
33 | "1": 394
34 | },
35 | {
36 | "0": 391,
37 | "1": 401
38 | },
39 | {
40 | "0": 396,
41 | "1": 409
42 | },
43 | {
44 | "0": 400,
45 | "1": 417
46 | },
47 | {
48 | "0": 403,
49 | "1": 426
50 | },
51 | {
52 | "0": 406,
53 | "1": 434
54 | },
55 | {
56 | "0": 408,
57 | "1": 443
58 | },
59 | {
60 | "0": 410,
61 | "1": 450
62 | },
63 | {
64 | "1": 457
65 | },
66 | {
67 | "0": 409,
68 | "1": 463
69 | },
70 | {
71 | "0": 406,
72 | "1": 468
73 | },
74 | {
75 | "0": 402,
76 | "1": 471
77 | },
78 | {
79 | "0": 396,
80 | "1": 472
81 | },
82 | {
83 | "0": 390,
84 | "1": 471
85 | },
86 | {
87 | "0": 382,
88 | "1": 469
89 | },
90 | {
91 | "0": 373,
92 | "1": 466
93 | },
94 | {
95 | "0": 364,
96 | "1": 462
97 | },
98 | {
99 | "0": 355,
100 | "1": 457
101 | },
102 | {
103 | "0": 346,
104 | "1": 452
105 | },
106 | {
107 | "0": 338,
108 | "1": 447
109 | },
110 | {
111 | "0": 330,
112 | "1": 441
113 | },
114 | {
115 | "0": 323,
116 | "1": 437
117 | },
118 | {
119 | "0": 318,
120 | "1": 432
121 | },
122 | {
123 | "0": 314,
124 | "1": 428
125 | },
126 | {
127 | "0": 311,
128 | "1": 424
129 | },
130 | {
131 | "0": 309,
132 | "1": 420
133 | },
134 | {
135 | "0": 307,
136 | "1": 416
137 | },
138 | {
139 | "0": 305,
140 | "1": 411
141 | },
142 | {
143 | "1": 407
144 | },
145 | {
146 | "1": 402
147 | },
148 | {
149 | "1": 398
150 | },
151 | {
152 | "0": 306,
153 | "1": 394
154 | },
155 | {
156 | "0": 307,
157 | "1": 389
158 | },
159 | {
160 | "0": 309,
161 | "1": 384
162 | },
163 | {
164 | "0": 311,
165 | "1": 380
166 | },
167 | {
168 | "0": 314,
169 | "1": 375
170 | },
171 | {
172 | "0": 317,
173 | "1": 370
174 | },
175 | {
176 | "0": 320,
177 | "1": 366
178 | },
179 | {
180 | "0": 323,
181 | "1": 361
182 | },
183 | {
184 | "0": 327,
185 | "1": 356
186 | },
187 | {
188 | "0": 331,
189 | "1": 352
190 | },
191 | {
192 | "0": 335,
193 | "1": 347
194 | },
195 | {
196 | "0": 339,
197 | "1": 342
198 | },
199 | {
200 | "0": 343,
201 | "1": 337
202 | },
203 | {
204 | "0": 347,
205 | "1": 333
206 | },
207 | {
208 | "0": 351,
209 | "1": 328
210 | },
211 | {
212 | "0": 356,
213 | "1": 324
214 | },
215 | {
216 | "0": 360,
217 | "1": 319
218 | },
219 | {
220 | "0": 364,
221 | "1": 315
222 | },
223 | {
224 | "0": 369,
225 | "1": 312
226 | },
227 | {
228 | "0": 374,
229 | "1": 309
230 | },
231 | {
232 | "0": 380,
233 | "1": 308
234 | },
235 | {
236 | "0": 386,
237 | "1": 307
238 | },
239 | {
240 | "0": 392,
241 | "1": 306
242 | },
243 | {
244 | "0": 398
245 | },
246 | {
247 | "0": 404
248 | },
249 | {
250 | "0": 410,
251 | "1": 307
252 | },
253 | {
254 | "0": 415,
255 | "1": 308
256 | },
257 | {
258 | "0": 420,
259 | "1": 309
260 | },
261 | {
262 | "0": 425,
263 | "1": 310
264 | },
265 | {
266 | "0": 429,
267 | "1": 311
268 | },
269 | {
270 | "0": 432,
271 | "1": 312
272 | },
273 | {
274 | "0": 435,
275 | "1": 313
276 | },
277 | {
278 | "0": 436
279 | },
280 | {
281 | "0": 437
282 | },
283 | {},
284 | {
285 | "0": 436,
286 | "1": 314
287 | },
288 | {
289 | "0": 435,
290 | "1": 315
291 | },
292 | {
293 | "0": 434,
294 | "1": 316
295 | },
296 | {
297 | "0": 432,
298 | "1": 318
299 | },
300 | {
301 | "0": 430,
302 | "1": 320
303 | },
304 | {
305 | "0": 428,
306 | "1": 322
307 | },
308 | {
309 | "0": 426,
310 | "1": 324
311 | },
312 | {
313 | "0": 423,
314 | "1": 327
315 | },
316 | {
317 | "0": 421,
318 | "1": 329
319 | },
320 | {
321 | "0": 418,
322 | "1": 332
323 | },
324 | {
325 | "0": 415,
326 | "1": 335
327 | },
328 | {
329 | "0": 412,
330 | "1": 338
331 | },
332 | {
333 | "0": 409,
334 | "1": 341
335 | },
336 | {
337 | "0": 406,
338 | "1": 344
339 | },
340 | {
341 | "0": 403,
342 | "1": 347
343 | },
344 | {
345 | "0": 400,
346 | "1": 350
347 | },
348 | {
349 | "0": 397,
350 | "1": 353
351 | },
352 | {
353 | "0": 394,
354 | "1": 356
355 | },
356 | {
357 | "0": 391,
358 | "1": 359
359 | },
360 | {
361 | "0": 388,
362 | "1": 362
363 | },
364 | {
365 | "0": 386,
366 | "1": 364
367 | },
368 | {
369 | "0": 384,
370 | "1": 366
371 | },
372 | {
373 | "0": 381,
374 | "1": 369
375 | },
376 | {
377 | "0": 380,
378 | "1": 370
379 | },
380 | {
381 | "0": 378,
382 | "1": 372
383 | },
384 | {
385 | "0": 377,
386 | "1": 373
387 | },
388 | {
389 | "0": 376,
390 | "1": 374
391 | },
392 | {
393 | "0": 375,
394 | "1": 375
395 | },
396 | {}
397 | ]
398 | }
--------------------------------------------------------------------------------
/examples/Scenes/scene-a.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/examples/Scenes/scene-a.bin
--------------------------------------------------------------------------------
/examples/Scenes/scene-a.h:
--------------------------------------------------------------------------------
1 | /*
2 | Blender Servo Animation Positions
3 |
4 | FPS: 30
5 | Frames: 100
6 | Seconds: 3
7 | Bones: 1
8 | Armature: Armature
9 | Scene: SceneA
10 | File: scenes.blend
11 | */
12 |
13 | #include
14 |
15 | namespace SceneA {
16 |
17 | const byte FPS = 30;
18 | const int FRAMES = 100;
19 | const int LENGTH = 600;
20 |
21 | const byte PROGMEM ANIMATION_DATA[LENGTH] = {
22 | 0x3c, 0x00, 0x05, 0xc0, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc1, 0x3e, 0x0a,
23 | 0x3c, 0x00, 0x05, 0xc5, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xcb, 0x3e, 0x0a,
24 | 0x3c, 0x00, 0x05, 0xd4, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xde, 0x3e, 0x0a,
25 | 0x3c, 0x00, 0x05, 0xeb, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xf9, 0x3e, 0x0a,
26 | 0x3c, 0x00, 0x06, 0x08, 0x3e, 0x0a, 0x3c, 0x00, 0x06, 0x1a, 0x3e, 0x0a,
27 | 0x3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3e, 0x0a, 0x3c, 0x00, 0x05, 0xbb, 0x3e, 0x0a,
71 | 0x3c, 0x00, 0x05, 0xbf, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc0, 0x3e, 0x0a,
72 | };
73 |
74 | } // namespace SceneA
75 |
--------------------------------------------------------------------------------
/examples/Scenes/scene-a.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Blender Servo Animation Positions",
3 | "fps": 30,
4 | "frames": 100,
5 | "seconds": 3,
6 | "bones": 1,
7 | "armature": "Armature",
8 | "file": "scenes.blend",
9 | "scene": "SceneA",
10 | "positions": [
11 | {
12 | "0": 1472
13 | },
14 | {
15 | "0": 1473
16 | },
17 | {
18 | "0": 1477
19 | },
20 | {
21 | "0": 1483
22 | },
23 | {
24 | "0": 1492
25 | },
26 | {
27 | "0": 1502
28 | },
29 | {
30 | "0": 1515
31 | },
32 | {
33 | "0": 1529
34 | },
35 | {
36 | "0": 1544
37 | },
38 | {
39 | "0": 1562
40 | },
41 | {
42 | "0": 1580
43 | },
44 | {
45 | "0": 1599
46 | },
47 | {
48 | "0": 1619
49 | },
50 | {
51 | "0": 1640
52 | },
53 | {
54 | "0": 1661
55 | },
56 | {
57 | "0": 1682
58 | },
59 | {
60 | "0": 1704
61 | },
62 | {
63 | "0": 1726
64 | },
65 | {
66 | "0": 1747
67 | },
68 | {
69 | "0": 1768
70 | },
71 | {
72 | "0": 1789
73 | },
74 | {
75 | "0": 1809
76 | },
77 | {
78 | "0": 1828
79 | },
80 | {
81 | "0": 1846
82 | },
83 | {
84 | "0": 1864
85 | },
86 | {
87 | "0": 1879
88 | },
89 | {
90 | "0": 1893
91 | },
92 | {
93 | "0": 1906
94 | },
95 | {
96 | "0": 1916
97 | },
98 | {
99 | "0": 1925
100 | },
101 | {
102 | "0": 1931
103 | },
104 | {
105 | "0": 1935
106 | },
107 | {
108 | "0": 1936
109 | },
110 | {
111 | "0": 1934
112 | },
113 | {
114 | "0": 1926
115 | },
116 | {
117 | "0": 1914
118 | },
119 | {
120 | "0": 1898
121 | },
122 | {
123 | "0": 1879
124 | },
125 | {
126 | "0": 1855
127 | },
128 | {
129 | "0": 1828
130 | },
131 | {
132 | "0": 1799
133 | },
134 | {
135 | "0": 1767
136 | },
137 | {
138 | "0": 1732
139 | },
140 | {
141 | "0": 1695
142 | },
143 | {
144 | "0": 1657
145 | },
146 | {
147 | "0": 1617
148 | },
149 | {
150 | "0": 1577
151 | },
152 | {
153 | "0": 1535
154 | },
155 | {
156 | "0": 1493
157 | },
158 | {
159 | "0": 1451
160 | },
161 | {
162 | "0": 1409
163 | },
164 | {
165 | "0": 1367
166 | },
167 | {
168 | "0": 1327
169 | },
170 | {
171 | "0": 1287
172 | },
173 | {
174 | "0": 1249
175 | },
176 | {
177 | "0": 1212
178 | },
179 | {
180 | "0": 1177
181 | },
182 | {
183 | "0": 1145
184 | },
185 | {
186 | "0": 1116
187 | },
188 | {
189 | "0": 1089
190 | },
191 | {
192 | "0": 1065
193 | },
194 | {
195 | "0": 1046
196 | },
197 | {
198 | "0": 1030
199 | },
200 | {
201 | "0": 1018
202 | },
203 | {
204 | "0": 1010
205 | },
206 | {
207 | "0": 1008
208 | },
209 | {
210 | "0": 1009
211 | },
212 | {
213 | "0": 1013
214 | },
215 | {
216 | "0": 1018
217 | },
218 | {
219 | "0": 1026
220 | },
221 | {
222 | "0": 1035
223 | },
224 | {
225 | "0": 1046
226 | },
227 | {
228 | "0": 1059
229 | },
230 | {
231 | "0": 1073
232 | },
233 | {
234 | "0": 1088
235 | },
236 | {
237 | "0": 1105
238 | },
239 | {
240 | "0": 1122
241 | },
242 | {
243 | "0": 1141
244 | },
245 | {
246 | "0": 1160
247 | },
248 | {
249 | "0": 1179
250 | },
251 | {
252 | "0": 1199
253 | },
254 | {
255 | "0": 1220
256 | },
257 | {
258 | "0": 1240
259 | },
260 | {
261 | "0": 1260
262 | },
263 | {
264 | "0": 1281
265 | },
266 | {
267 | "0": 1301
268 | },
269 | {
270 | "0": 1320
271 | },
272 | {
273 | "0": 1339
274 | },
275 | {
276 | "0": 1358
277 | },
278 | {
279 | "0": 1375
280 | },
281 | {
282 | "0": 1392
283 | },
284 | {
285 | "0": 1407
286 | },
287 | {
288 | "0": 1421
289 | },
290 | {
291 | "0": 1434
292 | },
293 | {
294 | "0": 1445
295 | },
296 | {
297 | "0": 1454
298 | },
299 | {
300 | "0": 1462
301 | },
302 | {
303 | "0": 1467
304 | },
305 | {
306 | "0": 1471
307 | },
308 | {
309 | "0": 1472
310 | }
311 | ]
312 | }
--------------------------------------------------------------------------------
/examples/Scenes/scene-b.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/examples/Scenes/scene-b.bin
--------------------------------------------------------------------------------
/examples/Scenes/scene-b.h:
--------------------------------------------------------------------------------
1 | /*
2 | Blender Servo Animation Positions
3 |
4 | FPS: 60
5 | Frames: 200
6 | Seconds: 3
7 | Bones: 1
8 | Armature: Armature.001
9 | Scene: SceneB
10 | File: scenes.blend
11 | */
12 |
13 | #include
14 |
15 | namespace SceneB {
16 |
17 | const byte FPS = 60;
18 | const int FRAMES = 200;
19 | const int LENGTH = 1160;
20 |
21 | const byte PROGMEM ANIMATION_DATA[LENGTH] = {
22 | 0x3c, 0x00, 0x05, 0xc0, 0x3e, 0x0a, 0x0a, 0x3c, 0x00, 0x05, 0xc1, 0x3e,
23 | 0x0a, 0x0a, 0x3c, 0x00, 0x05, 0xc2, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc3,
24 | 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc5, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc7,
25 | 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc9, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xcb,
26 | 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xcd, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xd0,
27 |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x0a, 0x3c, 0x00, 0x05, 0xd0, 0x3e, 0x0a,
114 | 0x3c, 0x00, 0x05, 0xcd, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xcb, 0x3e, 0x0a,
115 | 0x3c, 0x00, 0x05, 0xc8, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc6, 0x3e, 0x0a,
116 | 0x3c, 0x00, 0x05, 0xc5, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc3, 0x3e, 0x0a,
117 | 0x3c, 0x00, 0x05, 0xc2, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc1, 0x3e, 0x0a,
118 | 0x0a, 0x3c, 0x00, 0x05, 0xc0, 0x3e, 0x0a, 0x0a,
119 | };
120 |
121 | } // namespace SceneB
122 |
--------------------------------------------------------------------------------
/examples/Scenes/scene-b.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Blender Servo Animation Positions",
3 | "fps": 60,
4 | "frames": 200,
5 | "seconds": 3,
6 | "bones": 0,
7 | "armature": "Armature.001",
8 | "file": "scenes.blend",
9 | "scene": "SceneB",
10 | "positions": [
11 | {
12 | "0": 1472
13 | },
14 | {},
15 | {
16 | "0": 1473
17 | },
18 | {},
19 | {
20 | "0": 1474
21 | },
22 | {
23 | "0": 1475
24 | },
25 | {
26 | "0": 1477
27 | },
28 | {
29 | "0": 1479
30 | },
31 | {
32 | "0": 1481
33 | },
34 | {
35 | "0": 1483
36 | },
37 | {
38 | "0": 1485
39 | },
40 | {
41 | "0": 1488
42 | },
43 | {
44 | "0": 1491
45 | },
46 | {
47 | "0": 1494
48 | },
49 | {
50 | "0": 1497
51 | },
52 | {
53 | "0": 1501
54 | },
55 | {
56 | "0": 1504
57 | },
58 | {
59 | "0": 1508
60 | },
61 | {
62 | "0": 1512
63 | },
64 | {
65 | "0": 1517
66 | },
67 | {
68 | "0": 1521
69 | },
70 | {
71 | "0": 1526
72 | },
73 | {
74 | "0": 1531
75 | },
76 | {
77 | "0": 1536
78 | },
79 | {
80 | "0": 1541
81 | },
82 | {
83 | "0": 1546
84 | },
85 | {
86 | "0": 1551
87 | },
88 | {
89 | "0": 1557
90 | },
91 | {
92 | "0": 1562
93 | },
94 | {
95 | "0": 1568
96 | },
97 | {
98 | "0": 1574
99 | },
100 | {
101 | "0": 1580
102 | },
103 | {
104 | "0": 1586
105 | },
106 | {
107 | "0": 1592
108 | },
109 | {
110 | "0": 1599
111 | },
112 | {
113 | "0": 1605
114 | },
115 | {
116 | "0": 1611
117 | },
118 | {
119 | "0": 1618
120 | },
121 | {
122 | "0": 1625
123 | },
124 | {
125 | "0": 1631
126 | },
127 | {
128 | "0": 1638
129 | },
130 | {
131 | "0": 1645
132 | },
133 | {
134 | "0": 1652
135 | },
136 | {
137 | "0": 1659
138 | },
139 | {
140 | "0": 1666
141 | },
142 | {
143 | "0": 1672
144 | },
145 | {
146 | "0": 1679
147 | },
148 | {
149 | "0": 1686
150 | },
151 | {
152 | "0": 1693
153 | },
154 | {
155 | "0": 1700
156 | },
157 | {
158 | "0": 1708
159 | },
160 | {
161 | "0": 1715
162 | },
163 | {
164 | "0": 1722
165 | },
166 | {
167 | "0": 1729
168 | },
169 | {
170 | "0": 1736
171 | },
172 | {
173 | "0": 1742
174 | },
175 | {
176 | "0": 1749
177 | },
178 | {
179 | "0": 1756
180 | },
181 | {
182 | "0": 1763
183 | },
184 | {
185 | "0": 1770
186 | },
187 | {
188 | "0": 1777
189 | },
190 | {
191 | "0": 1783
192 | },
193 | {
194 | "0": 1790
195 | },
196 | {
197 | "0": 1797
198 | },
199 | {
200 | "0": 1803
201 | },
202 | {
203 | "0": 1809
204 | },
205 | {
206 | "0": 1816
207 | },
208 | {
209 | "0": 1822
210 | },
211 | {
212 | "0": 1828
213 | },
214 | {
215 | "0": 1834
216 | },
217 | {
218 | "0": 1840
219 | },
220 | {
221 | "0": 1846
222 | },
223 | {
224 | "0": 1851
225 | },
226 | {
227 | "0": 1857
228 | },
229 | {
230 | "0": 1862
231 | },
232 | {
233 | "0": 1867
234 | },
235 | {
236 | "0": 1872
237 | },
238 | {
239 | "0": 1877
240 | },
241 | {
242 | "0": 1882
243 | },
244 | {
245 | "0": 1887
246 | },
247 | {
248 | "0": 1891
249 | },
250 | {
251 | "0": 1896
252 | },
253 | {
254 | "0": 1900
255 | },
256 | {
257 | "0": 1904
258 | },
259 | {
260 | "0": 1907
261 | },
262 | {
263 | "0": 1911
264 | },
265 | {
266 | "0": 1914
267 | },
268 | {
269 | "0": 1917
270 | },
271 | {
272 | "0": 1920
273 | },
274 | {
275 | "0": 1923
276 | },
277 | {
278 | "0": 1925
279 | },
280 | {
281 | "0": 1927
282 | },
283 | {
284 | "0": 1929
285 | },
286 | {
287 | "0": 1931
288 | },
289 | {
290 | "0": 1933
291 | },
292 | {
293 | "0": 1934
294 | },
295 | {
296 | "0": 1935
297 | },
298 | {},
299 | {
300 | "0": 1936
301 | },
302 | {},
303 | {},
304 | {
305 | "0": 1935
306 | },
307 | {},
308 | {
309 | "0": 1934
310 | },
311 | {
312 | "0": 1933
313 | },
314 | {
315 | "0": 1931
316 | },
317 | {
318 | "0": 1930
319 | },
320 | {
321 | "0": 1928
322 | },
323 | {
324 | "0": 1925
325 | },
326 | {
327 | "0": 1923
328 | },
329 | {
330 | "0": 1920
331 | },
332 | {
333 | "0": 1918
334 | },
335 | {
336 | "0": 1915
337 | },
338 | {
339 | "0": 1911
340 | },
341 | {
342 | "0": 1908
343 | },
344 | {
345 | "0": 1904
346 | },
347 | {
348 | "0": 1900
349 | },
350 | {
351 | "0": 1896
352 | },
353 | {
354 | "0": 1892
355 | },
356 | {
357 | "0": 1888
358 | },
359 | {
360 | "0": 1883
361 | },
362 | {
363 | "0": 1878
364 | },
365 | {
366 | "0": 1874
367 | },
368 | {
369 | "0": 1869
370 | },
371 | {
372 | "0": 1864
373 | },
374 | {
375 | "0": 1858
376 | },
377 | {
378 | "0": 1853
379 | },
380 | {
381 | "0": 1847
382 | },
383 | {
384 | "0": 1842
385 | },
386 | {
387 | "0": 1836
388 | },
389 | {
390 | "0": 1830
391 | },
392 | {
393 | "0": 1824
394 | },
395 | {
396 | "0": 1818
397 | },
398 | {
399 | "0": 1812
400 | },
401 | {
402 | "0": 1805
403 | },
404 | {
405 | "0": 1799
406 | },
407 | {
408 | "0": 1792
409 | },
410 | {
411 | "0": 1786
412 | },
413 | {
414 | "0": 1779
415 | },
416 | {
417 | "0": 1773
418 | },
419 | {
420 | "0": 1766
421 | },
422 | {
423 | "0": 1759
424 | },
425 | {
426 | "0": 1752
427 | },
428 | {
429 | "0": 1746
430 | },
431 | {
432 | "0": 1739
433 | },
434 | {
435 | "0": 1732
436 | },
437 | {
438 | "0": 1725
439 | },
440 | {
441 | "0": 1718
442 | },
443 | {
444 | "0": 1711
445 | },
446 | {
447 | "0": 1704
448 | },
449 | {
450 | "0": 1697
451 | },
452 | {
453 | "0": 1690
454 | },
455 | {
456 | "0": 1683
457 | },
458 | {
459 | "0": 1676
460 | },
461 | {
462 | "0": 1669
463 | },
464 | {
465 | "0": 1662
466 | },
467 | {
468 | "0": 1656
469 | },
470 | {
471 | "0": 1649
472 | },
473 | {
474 | "0": 1642
475 | },
476 | {
477 | "0": 1635
478 | },
479 | {
480 | "0": 1629
481 | },
482 | {
483 | "0": 1622
484 | },
485 | {
486 | "0": 1616
487 | },
488 | {
489 | "0": 1609
490 | },
491 | {
492 | "0": 1603
493 | },
494 | {
495 | "0": 1596
496 | },
497 | {
498 | "0": 1590
499 | },
500 | {
501 | "0": 1584
502 | },
503 | {
504 | "0": 1578
505 | },
506 | {
507 | "0": 1572
508 | },
509 | {
510 | "0": 1566
511 | },
512 | {
513 | "0": 1561
514 | },
515 | {
516 | "0": 1555
517 | },
518 | {
519 | "0": 1550
520 | },
521 | {
522 | "0": 1544
523 | },
524 | {
525 | "0": 1539
526 | },
527 | {
528 | "0": 1534
529 | },
530 | {
531 | "0": 1530
532 | },
533 | {
534 | "0": 1525
535 | },
536 | {
537 | "0": 1520
538 | },
539 | {
540 | "0": 1516
541 | },
542 | {
543 | "0": 1512
544 | },
545 | {
546 | "0": 1508
547 | },
548 | {
549 | "0": 1504
550 | },
551 | {
552 | "0": 1500
553 | },
554 | {
555 | "0": 1497
556 | },
557 | {
558 | "0": 1493
559 | },
560 | {
561 | "0": 1490
562 | },
563 | {
564 | "0": 1488
565 | },
566 | {
567 | "0": 1485
568 | },
569 | {
570 | "0": 1483
571 | },
572 | {
573 | "0": 1480
574 | },
575 | {
576 | "0": 1478
577 | },
578 | {
579 | "0": 1477
580 | },
581 | {
582 | "0": 1475
583 | },
584 | {
585 | "0": 1474
586 | },
587 | {
588 | "0": 1473
589 | },
590 | {},
591 | {
592 | "0": 1472
593 | },
594 | {}
595 | ]
596 | }
--------------------------------------------------------------------------------
/examples/Scenes/scenes.blend:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/examples/Scenes/scenes.blend
--------------------------------------------------------------------------------
/examples/Simple/simple.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/examples/Simple/simple.bin
--------------------------------------------------------------------------------
/examples/Simple/simple.blend:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/examples/Simple/simple.blend
--------------------------------------------------------------------------------
/examples/Simple/simple.h:
--------------------------------------------------------------------------------
1 | /*
2 | Blender Servo Animation Positions
3 |
4 | FPS: 30
5 | Frames: 100
6 | Seconds: 3
7 | Bones: 1
8 | Armature: Armature
9 | Scene: Scene
10 | File: simple.blend
11 | */
12 |
13 | #include
14 |
15 | const byte FPS = 30;
16 | const int FRAMES = 100;
17 | const int LENGTH = 600;
18 |
19 | const byte PROGMEM ANIMATION_DATA[LENGTH] = {
20 | 0x3c, 0x00, 0x05, 0xc0, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc5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 | 0x3c, 0x00, 0x04, 0x43, 0x3e, 0x0a, 0x3c, 0x00, 0x04, 0x79, 0x3e, 0x0a,
65 | 0x3c, 0x00, 0x04, 0xae, 0x3e, 0x0a, 0x3c, 0x00, 0x04, 0xe0, 0x3e, 0x0a,
66 | 0x3c, 0x00, 0x05, 0x0e, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0x39, 0x3e, 0x0a,
67 | 0x3c, 0x00, 0x05, 0x5f, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0x80, 0x3e, 0x0a,
68 | 0x3c, 0x00, 0x05, 0x9b, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xaf, 0x3e, 0x0a,
69 | 0x3c, 0x00, 0x05, 0xbc, 0x3e, 0x0a, 0x3c, 0x00, 0x05, 0xc0, 0x3e, 0x0a,
70 | };
71 |
--------------------------------------------------------------------------------
/examples/Simple/simple.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Blender Servo Animation Positions",
3 | "fps": 30,
4 | "frames": 100,
5 | "seconds": 3,
6 | "bones": 1,
7 | "armature": "Armature",
8 | "file": "simple.blend",
9 | "scene": "Scene",
10 | "positions": [
11 | {
12 | "0": 1472
13 | },
14 | {
15 | "0": 1477
16 | },
17 | {
18 | "0": 1490
19 | },
20 | {
21 | "0": 1512
22 | },
23 | {
24 | "0": 1541
25 | },
26 | {
27 | "0": 1576
28 | },
29 | {
30 | "0": 1617
31 | },
32 | {
33 | "0": 1663
34 | },
35 | {
36 | "0": 1713
37 | },
38 | {
39 | "0": 1766
40 | },
41 | {
42 | "0": 1821
43 | },
44 | {
45 | "0": 1878
46 | },
47 | {
48 | "0": 1936
49 | },
50 | {
51 | "0": 1994
52 | },
53 | {
54 | "0": 2051
55 | },
56 | {
57 | "0": 2106
58 | },
59 | {
60 | "0": 2159
61 | },
62 | {
63 | "0": 2209
64 | },
65 | {
66 | "0": 2255
67 | },
68 | {
69 | "0": 2296
70 | },
71 | {
72 | "0": 2331
73 | },
74 | {
75 | "0": 2360
76 | },
77 | {
78 | "0": 2382
79 | },
80 | {
81 | "0": 2395
82 | },
83 | {
84 | "0": 2400
85 | },
86 | {
87 | "0": 2398
88 | },
89 | {
90 | "0": 2391
91 | },
92 | {
93 | "0": 2381
94 | },
95 | {
96 | "0": 2366
97 | },
98 | {
99 | "0": 2348
100 | },
101 | {
102 | "0": 2326
103 | },
104 | {
105 | "0": 2301
106 | },
107 | {
108 | "0": 2273
109 | },
110 | {
111 | "0": 2241
112 | },
113 | {
114 | "0": 2207
115 | },
116 | {
117 | "0": 2170
118 | },
119 | {
120 | "0": 2131
121 | },
122 | {
123 | "0": 2089
124 | },
125 | {
126 | "0": 2045
127 | },
128 | {
129 | "0": 1999
130 | },
131 | {
132 | "0": 1951
133 | },
134 | {
135 | "0": 1902
136 | },
137 | {
138 | "0": 1852
139 | },
140 | {
141 | "0": 1800
142 | },
143 | {
144 | "0": 1747
145 | },
146 | {
147 | "0": 1693
148 | },
149 | {
150 | "0": 1638
151 | },
152 | {
153 | "0": 1583
154 | },
155 | {
156 | "0": 1528
157 | },
158 | {
159 | "0": 1472
160 | },
161 | {
162 | "0": 1416
163 | },
164 | {
165 | "0": 1361
166 | },
167 | {
168 | "0": 1306
169 | },
170 | {
171 | "0": 1251
172 | },
173 | {
174 | "0": 1197
175 | },
176 | {
177 | "0": 1144
178 | },
179 | {
180 | "0": 1092
181 | },
182 | {
183 | "0": 1042
184 | },
185 | {
186 | "0": 993
187 | },
188 | {
189 | "0": 945
190 | },
191 | {
192 | "0": 899
193 | },
194 | {
195 | "0": 855
196 | },
197 | {
198 | "0": 813
199 | },
200 | {
201 | "0": 774
202 | },
203 | {
204 | "0": 737
205 | },
206 | {
207 | "0": 703
208 | },
209 | {
210 | "0": 671
211 | },
212 | {
213 | "0": 643
214 | },
215 | {
216 | "0": 618
217 | },
218 | {
219 | "0": 596
220 | },
221 | {
222 | "0": 578
223 | },
224 | {
225 | "0": 563
226 | },
227 | {
228 | "0": 553
229 | },
230 | {
231 | "0": 546
232 | },
233 | {
234 | "0": 544
235 | },
236 | {
237 | "0": 548
238 | },
239 | {
240 | "0": 561
241 | },
242 | {
243 | "0": 581
244 | },
245 | {
246 | "0": 608
247 | },
248 | {
249 | "0": 641
250 | },
251 | {
252 | "0": 679
253 | },
254 | {
255 | "0": 722
256 | },
257 | {
258 | "0": 768
259 | },
260 | {
261 | "0": 818
262 | },
263 | {
264 | "0": 871
265 | },
266 | {
267 | "0": 925
268 | },
269 | {
270 | "0": 980
271 | },
272 | {
273 | "0": 1036
274 | },
275 | {
276 | "0": 1091
277 | },
278 | {
279 | "0": 1145
280 | },
281 | {
282 | "0": 1198
283 | },
284 | {
285 | "0": 1248
286 | },
287 | {
288 | "0": 1294
289 | },
290 | {
291 | "0": 1337
292 | },
293 | {
294 | "0": 1375
295 | },
296 | {
297 | "0": 1408
298 | },
299 | {
300 | "0": 1435
301 | },
302 | {
303 | "0": 1455
304 | },
305 | {
306 | "0": 1468
307 | },
308 | {
309 | "0": 1472
310 | }
311 | ]
312 | }
--------------------------------------------------------------------------------
/images/calibrate_servo_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/images/calibrate_servo_button.png
--------------------------------------------------------------------------------
/images/calibrate_servo_dialog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/images/calibrate_servo_dialog.png
--------------------------------------------------------------------------------
/images/export_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/images/export_menu.png
--------------------------------------------------------------------------------
/images/servo_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/images/servo_settings.png
--------------------------------------------------------------------------------
/images/timeline_menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/images/timeline_menu.png
--------------------------------------------------------------------------------
/requirements-dev.txt:
--------------------------------------------------------------------------------
1 | parameterized
2 | websockets
3 |
--------------------------------------------------------------------------------
/scripts/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | blender --command extension build --source-dir addon --output-filepath blender_servo_animation_addon.zip
4 |
--------------------------------------------------------------------------------
/scripts/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | blender --command extension install-file -r user_default -e blender_servo_animation_addon.zip
4 |
--------------------------------------------------------------------------------
/scripts/prepare.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | PARENTDIR=$(dirname "$current_dir")
4 | TESTSDIR="$PARENTDIR/tests"
5 |
6 | blender \
7 | -noaudio \
8 | --background \
9 | --python-use-system-env \
10 | --python-exit-code 1 \
11 | --python $TESTSDIR/prepare.py
12 |
13 | exit $?
14 |
--------------------------------------------------------------------------------
/scripts/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | PARENTDIR=$(dirname "$current_dir")
4 | TESTSDIR="$PARENTDIR/tests"
5 | TESTFILE="$TESTSDIR/results.txt"
6 |
7 | blender \
8 | -noaudio \
9 | --background $TESTSDIR/integration/test.blend \
10 | --addons servo_animation \
11 | --python-use-system-env \
12 | --python-exit-code 1 \
13 | --python $TESTSDIR/test.py \
14 | > /dev/null 2>&1
15 |
16 | cat $TESTFILE
17 |
18 | last_line=$(tail -n 1 "$TESTFILE")
19 |
20 | if [ "$last_line" == "OK" ]; then
21 | exit 0
22 | else
23 | exit 1
24 | fi
25 |
--------------------------------------------------------------------------------
/tests/integration/test.blend:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/timhendriks93/blender-servo-animation/ef5a1491100f4b89ea759c227bb828d735c7a773/tests/integration/test.blend
--------------------------------------------------------------------------------
/tests/integration/test_export.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os
3 | import shutil
4 | import hashlib
5 |
6 | from parameterized import parameterized
7 |
8 | import bpy
9 |
10 |
11 | def assert_file_hash(file_path, expected):
12 | assert os.path.exists(
13 | file_path), "expected export file to be present"
14 |
15 | hash_object = hashlib.sha256()
16 |
17 | with open(file_path, "rb") as file:
18 | hash_object.update(file.read())
19 |
20 | file_hash = hash_object.hexdigest()
21 |
22 | assert file_hash == expected, f"expected file has to be {expected}, got {file_hash} instead"
23 |
24 |
25 | class TestExport(unittest.TestCase):
26 | def setUp(self):
27 | test_dir = os.path.dirname(__file__)
28 | self.output_dir = test_dir + "/output"
29 | shutil.rmtree(self.output_dir, ignore_errors=True)
30 | os.mkdir(self.output_dir)
31 |
32 | def tearDown(self):
33 | shutil.rmtree(self.output_dir, ignore_errors=True)
34 | bpy.data.armatures['Armature'].bones['Bone'].servo_settings.active = True
35 |
36 | @parameterized.expand([
37 | ("with skipping and indent of 2", True, "2",
38 | "7576d368e9680a35a67a62df0200f08fd310e0f830e1497f8f12a3138e5ff24b"),
39 | ("without skipping and indent of 2", False, "2",
40 | "f96d14717222b184740f4258842f766eee341f0768eac42c44a4efd8e45f5814"),
41 | ("with skipping and no indent", True, "None",
42 | "88b4da9ceee71fbbe75f1f0f73727b69bc8b6ba21358a86932efb41ab5b1a1e6"),
43 | ("with skipping and indent of 4", True, "4",
44 | "87f25f8fab6a8996393a0e277d6e2891c70194d24c8283bf937097970c5033c8")
45 | ])
46 | def test_json_export(self, _name, skip_duplicates, indent, expected):
47 | export_file = self.output_dir + "/export.json"
48 |
49 | bpy.ops.export_anim.servo_animation_json(
50 | filepath=export_file, skip_duplicates=skip_duplicates, indent=indent)
51 |
52 | assert_file_hash(export_file, expected)
53 |
54 | @parameterized.expand([
55 | ("with skipping and no namespace", True, False,
56 | "5b8b6abd5ae925a394020dcfe2341705c74a3b1f2dd3a2a5230d73e56b85b4c5"),
57 | ("without skipping and no namespace", False, False,
58 | "38d458c7061ca3d252da01995199e7f23e646e9889d5b4a6609328fa57b9a237"),
59 | ("with skipping and namespace", True, True,
60 | "fc3e0c39b24bc2147c56d6cc3f65181839478e0df54b0b580328f50b0587a6d1"),
61 | ("without skipping and namespace", False, True,
62 | "e1abc66c2dc73bb13828c83bbd30c8967a1a0bb346a01ad542d5e74321b68e2a")
63 | ])
64 | def test_arduino_export(self, _name, skip_duplicates, namespace, expected):
65 | export_file = self.output_dir + "/export.h"
66 |
67 | bpy.ops.export_anim.servo_animation_arduino(
68 | filepath=export_file,
69 | skip_duplicates=skip_duplicates,
70 | namespace=namespace
71 | )
72 |
73 | assert_file_hash(export_file, expected)
74 |
75 | @parameterized.expand([
76 | ("with skipping", True,
77 | "f6d5d5b3e0012e63e28b51bfe7416ffebf9517b67e4a873f947ff1c998a4a512"),
78 | ("without skipping", False,
79 | "11f06c27463865d5e6a4f014c515a01c1c0212c413d0434698908a562c13237f")
80 | ])
81 | def test_binary_export(self, _name, skip_duplicates, expected):
82 | export_file = self.output_dir + "/export.bin"
83 |
84 | bpy.ops.export_anim.servo_animation_binary(
85 | filepath=export_file,
86 | skip_duplicates=skip_duplicates
87 | )
88 |
89 | assert_file_hash(export_file, expected)
90 |
91 | @parameterized.expand([
92 | ("arduino", ".h"),
93 | ("json", ".json"),
94 | ("binary", ".bin")
95 | ])
96 | def test_no_servo_settings(self, export_type, extension):
97 | export_file = self.output_dir + "/export" + extension
98 |
99 | bpy.data.armatures['Armature'].bones['Bone'].servo_settings.active = False
100 |
101 | error_msg = ""
102 |
103 | try:
104 | if export_type == "arduino":
105 | bpy.ops.export_anim.servo_animation_arduino(
106 | filepath=export_file)
107 | elif export_type == "json":
108 | bpy.ops.export_anim.servo_animation_json(filepath=export_file)
109 | elif export_type == "binary":
110 | bpy.ops.export_anim.servo_animation_binary(
111 | filepath=export_file)
112 | except RuntimeError as error:
113 | error_msg = str(error)
114 |
115 | assert not os.path.exists(
116 | export_file), "did not expect export file to be present"
117 |
118 | exp = (
119 | f"Operator bpy.ops.export_anim.servo_animation_{export_type}.poll() failed, "
120 | "context is incorrect"
121 | )
122 | got = error_msg
123 | assert got == exp, f"expected error message '{exp}', got '{got}' instead"
124 |
125 |
126 | if __name__ == '__main__':
127 | unittest.main()
128 |
--------------------------------------------------------------------------------
/tests/integration/test_serial_live_mode.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os
3 |
4 | from parameterized import parameterized
5 |
6 | import bpy
7 |
8 | COMMAND_LENGTH = 5
9 | COMMAND_START = b"<"
10 | COMMAND_END = b">"
11 |
12 |
13 | class TestSerialLiveMode(unittest.TestCase):
14 | def setUp(self):
15 | self.receiver, self.sender = os.openpty()
16 | self.ttyname = os.ttyname(self.sender)
17 |
18 | def tearDown(self):
19 | try:
20 | os.close(self.sender)
21 | os.close(self.receiver)
22 | except OSError:
23 | pass
24 |
25 | bpy.context.window_manager.servo_animation.position_jump_handling = False
26 | bpy.context.object.data.bones['Bone'].servo_settings.servo_id = 0
27 | bpy.context.object.data.bones['Bone'].servo_settings.threshold = 20
28 | bpy.context.scene.frame_set(1)
29 |
30 | def read_bytes(self):
31 | read_bytes = []
32 |
33 | try:
34 | os.close(self.sender)
35 | with os.fdopen(self.receiver, "rb") as reader:
36 | while len(reader.peek()) > 0:
37 | byte = reader.read(1)
38 | read_bytes.append(byte)
39 | except OSError:
40 | pass
41 |
42 | return read_bytes
43 |
44 | @parameterized.expand([
45 | ("115200 baud rate", 115200, 1, 90, 0),
46 | ("19200 baud rate", 19200, 33, 45, 1),
47 | ("192500 baud rate", 192500, 66, 135, 12),
48 | ])
49 | def test_start_stop(self, _name, baud_rate, frame, position, servo_id):
50 | bpy.context.scene.frame_set(frame)
51 | bpy.context.object.data.bones['Bone'].servo_settings.servo_id = servo_id
52 |
53 | bpy.ops.servo_animation.start_live_mode(
54 | 'EXEC_DEFAULT',
55 | method='SERIAL',
56 | serial_port=self.ttyname,
57 | serial_baud=baud_rate
58 | )
59 | bpy.ops.servo_animation.stop_live_mode('EXEC_DEFAULT')
60 | bpy.context.scene.frame_set(33)
61 |
62 | read_bytes = self.read_bytes()
63 |
64 | assert len(read_bytes) == COMMAND_LENGTH
65 | assert read_bytes[0] == COMMAND_START
66 | assert int.from_bytes(read_bytes[1], 'big') == servo_id
67 | assert int.from_bytes(read_bytes[2]+read_bytes[3], 'big') == position
68 | assert read_bytes[4] == COMMAND_END
69 |
70 | @parameterized.expand([
71 | ('without handling', False, 10, 33, [90, 45]),
72 | ('threshold reached', True, 10, 33, range(90, 44, -1)),
73 | ('threshold not reached - small frame jump', True, 10, 10, [90, 81]),
74 | ('threshold not reached - increased threshold', True, 50, 33, [90, 45]),
75 | ])
76 | def test_position_jump(self, _name, handling, threshold, frame, positions):
77 | bpy.ops.servo_animation.start_live_mode(
78 | 'EXEC_DEFAULT',
79 | method='SERIAL',
80 | serial_port=self.ttyname,
81 | serial_baud=115200
82 | )
83 | bpy.context.window_manager.servo_animation.position_jump_handling = handling
84 | bpy.context.object.data.bones['Bone'].servo_settings.threshold = threshold
85 | bpy.context.scene.frame_set(frame)
86 | bpy.ops.servo_animation.stop_live_mode('EXEC_DEFAULT')
87 |
88 | read_bytes = self.read_bytes()
89 |
90 | exp = len(positions) * COMMAND_LENGTH
91 | got = len(read_bytes)
92 | assert exp == got, f"expected {exp} bytes, got {got} instead"
93 |
94 | for i, position in enumerate(positions):
95 | offset = i * COMMAND_LENGTH
96 | position_byte_a = read_bytes[offset + 2]
97 | position_byte_b = read_bytes[offset + 3]
98 |
99 | assert read_bytes[offset] == COMMAND_START
100 | assert int.from_bytes(read_bytes[offset + 1], 'big') == 0
101 | assert int.from_bytes(position_byte_a+position_byte_b, 'big') == position
102 | assert read_bytes[offset + 4] == COMMAND_END
103 |
104 | @parameterized.expand([
105 | ("invalid serial port", "/dev/ttyInvalid", 115200),
106 | ("invalid baud rate", None, -1),
107 | ])
108 | def test_invalid_serial_port(self, _name, serial_port, baud_rate):
109 | if serial_port is None:
110 | serial_port = self.ttyname
111 |
112 | raised_exception = False
113 |
114 | try:
115 | bpy.ops.servo_animation.start_live_mode(
116 | 'EXEC_DEFAULT',
117 | method='SERIAL',
118 | serial_port=serial_port,
119 | serial_baud=baud_rate
120 | )
121 | except RuntimeError:
122 | raised_exception = True
123 |
124 | assert raised_exception is True
125 | assert len(self.read_bytes()) == 0
126 |
--------------------------------------------------------------------------------
/tests/integration/test_servo_calibration.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os
3 |
4 | from parameterized import parameterized
5 |
6 | import bpy
7 |
8 | COMMAND_LENGTH = 5
9 |
10 |
11 | class TestServoCalibration(unittest.TestCase):
12 | def setUp(self):
13 | self.receiver, self.sender = os.openpty()
14 | self.ttyname = os.ttyname(self.sender)
15 |
16 | def tearDown(self):
17 | try:
18 | os.close(self.sender)
19 | os.close(self.receiver)
20 | except OSError:
21 | pass
22 |
23 | bpy.context.window_manager.servo_animation.position_jump_handling = False
24 | bpy.context.object.data.bones['Bone'].servo_settings.position_min = 0
25 | bpy.context.object.data.bones['Bone'].servo_settings.position_max = 180
26 |
27 | def read_bytes(self):
28 | read_bytes = []
29 |
30 | try:
31 | os.close(self.sender)
32 | with os.fdopen(self.receiver, "rb") as reader:
33 | while len(reader.peek()) > 0:
34 | byte = reader.read(1)
35 | read_bytes.append(byte)
36 | except OSError:
37 | pass
38 |
39 | return read_bytes
40 |
41 | @parameterized.expand([
42 | ("without handling", False, 45, 135, 4),
43 | ("threshold reached", True, 45, 135, 25),
44 | ("threshold not reached", True, 80, 110, 4),
45 | ])
46 | def test_calibration(self, _name, handling, position_min, position_max, commands):
47 | servo_settings = bpy.context.object.data.bones['Bone'].servo_settings
48 |
49 | bpy.context.window_manager.servo_animation.position_jump_handling = handling
50 |
51 | assert servo_settings.position_min == 0
52 | assert servo_settings.position_max == 180
53 |
54 | bpy.ops.servo_animation.start_live_mode(
55 | 'EXEC_DEFAULT',
56 | method='SERIAL',
57 | serial_port=self.ttyname,
58 | serial_baud=115200
59 | )
60 | bpy.ops.servo_animation.calibrate(
61 | 'EXEC_DEFAULT',
62 | position_min=position_min,
63 | position_max=position_max
64 | )
65 | bpy.ops.servo_animation.stop_live_mode('EXEC_DEFAULT')
66 |
67 | assert servo_settings.position_min == position_min
68 | assert servo_settings.position_max == position_max
69 |
70 | read_bytes = self.read_bytes()
71 |
72 | assert len(read_bytes) == commands * COMMAND_LENGTH
73 |
--------------------------------------------------------------------------------
/tests/integration/test_socket_live_mode.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import threading
3 |
4 | from websocket import WebSocket
5 | from parameterized import parameterized
6 | from websockets.sync.server import serve
7 |
8 | import bpy
9 |
10 | COMMAND_LENGTH = 5
11 | COMMAND_START = b"<"
12 | COMMAND_END = b">"
13 |
14 |
15 | class TestSocketLiveMode(unittest.TestCase):
16 | def setUp(self):
17 | self.received_data = []
18 | self.server = serve(self.handler, "localhost", 0)
19 | self.host, self.port = self.server.socket.getsockname()
20 | self.server_thread = threading.Thread(target=self.run_server)
21 | self.server_thread.start()
22 |
23 | def tearDown(self):
24 | self.stop_server()
25 |
26 | bpy.context.window_manager.servo_animation.position_jump_handling = False
27 | bpy.context.object.data.bones['Bone'].servo_settings.servo_id = 0
28 | bpy.context.object.data.bones['Bone'].servo_settings.threshold = 20
29 | bpy.context.scene.frame_set(1)
30 |
31 | def run_server(self):
32 | self.server.serve_forever()
33 |
34 | def stop_server(self):
35 | self.server.shutdown()
36 | self.server_thread.join()
37 |
38 | def handler(self, socket):
39 | for message in socket:
40 | if message == "stop":
41 | self.stop_server()
42 | break
43 |
44 | for integer in message:
45 | byte = integer.to_bytes(length=1, byteorder='big')
46 | self.received_data.append(byte)
47 |
48 | def read_bytes(self):
49 | con = WebSocket()
50 | con.connect(f"ws://{self.host}:{self.port}")
51 | con.send("stop")
52 | con.close()
53 |
54 | while self.server_thread.is_alive():
55 | pass
56 |
57 | return self.received_data
58 |
59 | @parameterized.expand([
60 | ("frame 1", 1, 90, 0),
61 | ("frame 33", 33, 45, 1),
62 | ("frame 66", 66, 135, 12),
63 | ])
64 | def test_start_stop(self, _name, frame, position, servo_id):
65 | bpy.context.scene.frame_set(frame)
66 | bpy.context.object.data.bones['Bone'].servo_settings.servo_id = servo_id
67 |
68 | bpy.ops.servo_animation.start_live_mode(
69 | 'EXEC_DEFAULT',
70 | method='SOCKET',
71 | socket_host=self.host,
72 | socket_port=self.port
73 | )
74 | bpy.ops.servo_animation.stop_live_mode('EXEC_DEFAULT')
75 | bpy.context.scene.frame_set(33)
76 |
77 | read_bytes = self.read_bytes()
78 |
79 | assert len(read_bytes) == COMMAND_LENGTH, f"got {len(read_bytes)}"
80 | assert read_bytes[0] == COMMAND_START
81 | assert int.from_bytes(read_bytes[1], 'big') == servo_id
82 | assert int.from_bytes(read_bytes[2]+read_bytes[3], 'big') == position
83 | assert read_bytes[4] == COMMAND_END
84 |
85 | @parameterized.expand([
86 | ('without handling', False, 10, 33, [90, 45]),
87 | ('threshold reached', True, 10, 33, range(90, 44, -1)),
88 | ('threshold not reached - small frame jump', True, 10, 10, [90, 81]),
89 | ('threshold not reached - increased threshold', True, 50, 33, [90, 45]),
90 | ])
91 | def test_position_jump(self, _name, handling, threshold, frame, positions):
92 | bpy.ops.servo_animation.start_live_mode(
93 | 'EXEC_DEFAULT',
94 | method='SOCKET',
95 | socket_host=self.host,
96 | socket_port=self.port
97 | )
98 | bpy.context.window_manager.servo_animation.position_jump_handling = handling
99 | bpy.context.object.data.bones['Bone'].servo_settings.threshold = threshold
100 | bpy.context.scene.frame_set(frame)
101 | bpy.ops.servo_animation.stop_live_mode('EXEC_DEFAULT')
102 |
103 | read_bytes = self.read_bytes()
104 |
105 | exp = len(positions) * COMMAND_LENGTH
106 | got = len(read_bytes)
107 | assert exp == got, f"expected {exp} bytes, got {got} instead"
108 |
109 | for i, position in enumerate(positions):
110 | offset = i * COMMAND_LENGTH
111 | position_byte_a = read_bytes[offset + 2]
112 | position_byte_b = read_bytes[offset + 3]
113 |
114 | assert read_bytes[offset] == COMMAND_START
115 | assert int.from_bytes(read_bytes[offset + 1], 'big') == 0
116 | assert int.from_bytes(position_byte_a+position_byte_b, 'big') == position
117 | assert read_bytes[offset + 4] == COMMAND_END
118 |
119 | @parameterized.expand([
120 | ("invalid IP", "127.0.0.1234", 80),
121 | ("invalid port", "127.0.0.1", 1234)
122 | ])
123 | def test_invalid_connection(self, _name, socket_host, socket_port):
124 | raised_exception = False
125 |
126 | try:
127 | bpy.ops.servo_animation.start_live_mode(
128 | 'EXEC_DEFAULT',
129 | method='SOCKET',
130 | socket_host=socket_host,
131 | socket_port=socket_port
132 | )
133 | except RuntimeError:
134 | raised_exception = True
135 |
136 | assert raised_exception is True
137 | assert len(self.read_bytes()) == 0
138 |
--------------------------------------------------------------------------------
/tests/prepare.py:
--------------------------------------------------------------------------------
1 | import os
2 | import pathlib
3 | import sys
4 | import ensurepip
5 | import subprocess
6 |
7 | import bpy
8 |
9 |
10 | main_dir = pathlib.Path(os.path.dirname(__file__)).resolve()
11 | sys.path.append(str(main_dir))
12 |
13 | def ensure_pip():
14 | ensurepip.bootstrap()
15 | os.environ.pop("PIP_REQ_TRACKER", None)
16 |
17 | def install_dependencies():
18 | try:
19 | python = bpy.app.binary_path_python
20 | except AttributeError:
21 | python = sys.executable
22 |
23 | dir_path = os.path.dirname(__file__)
24 | req_file = dir_path + "/../requirements-dev.txt"
25 |
26 | subprocess.run([python, "-m", "pip", "install", "--upgrade", "pip"], check=True)
27 | subprocess.run([python, "-m", "pip", "install", "-r", req_file], check=True)
28 |
29 | if __name__ == "__main__":
30 | ensure_pip()
31 | install_dependencies()
32 |
--------------------------------------------------------------------------------
/tests/test.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | if __name__ == '__main__':
4 | integration_suite = unittest.TestLoader().discover('tests/integration')
5 |
6 | with open('tests/results.txt', 'w', encoding="utf-8") as f:
7 | runner = unittest.TextTestRunner(stream=f, verbosity=2)
8 | runner.run(integration_suite)
9 |
--------------------------------------------------------------------------------