[x3d-public] SOLVED by building x3d.py: Re: stiffness, waiting for upload. [was Re: HAnim, X3dToPython.xslt X3dToJson.xslt Upgrade X3DUOM? HAnimHumanoid explained, problem identified, corrections applied
John Carlson
yottzumm at gmail.com
Fri Dec 24 00:11:39 PST 2021
Well, there's available, and then there's available.
Rebuilt x3d.py from sources.
Woohoo, no errors!
$ pip3 install xmlschema
Collecting xmlschema
Downloading xmlschema-1.9.2-py3-none-any.whl (273 kB)
|████████████████████████████████| 273 kB 2.0 MB/s
Collecting elementpath<3.0.0,>=2.4.0
Downloading elementpath-2.4.0-py3-none-any.whl (163 kB)
|████████████████████████████████| 163 kB 20.6 MB/s
Installing collected packages: elementpath, xmlschema
Successfully installed elementpath-2.4.0 xmlschema-1.9.2
(venv) coderextreme at coderextreme-Kubuntu20:~/X3DJSONLD/src/main/python$
python3 net/x3djsonld/data/JinLOA4.py
x3d.py package loaded, have fun with X3D Graphics!
Python-to-XML well-formed XML document test of XML output successful
Python-to-XML X3D 4.0 schema validation test of XML output successful
Python-to-VRML export of VRML output successful (still testing)
Python-to-JSON export of JSON output successful (still testing)
python x3d.py load and self-test complete for JinLOA4.py
On 12/24/21 01:49, John Carlson wrote:
>
> Generated 10 mintues ago:
>
> HAnimJoint(DEF='hanim_l_knee',center=(4.116,18.170,-0.863900),name='l_knee',stiffness=[0,0,0],
>
> Not seeing MFFloat in:
>
> $ python3 net/x3djsonld/data/JinLOA4.py
> x3d.py package loaded, have fun with X3D Graphics!
> Traceback (most recent call last):
> File
> "/home/coderextreme/X3DJSONLD/src/main/python/net/x3djsonld/data/JinLOA4.py",
> line 177, in <module>
> HAnimJoint(DEF='hanim_l_tarsal_distal_interphalangeal_1',center=(2.761,0.539400,5.125),name='l_tarsal_distal_interphalangeal_1',stiffness=[0,0,0],
> File
> "/home/coderextreme/X3DJSONLD/src/main/python/net/x3djsonld/data/x3d.py",
> line 43724, in __init__
> self.stiffness = stiffness
> File
> "/home/coderextreme/X3DJSONLD/src/main/python/net/x3djsonld/data/x3d.py",
> line 43873, in stiffness
> assertValidSFVec3f(stiffness)
> File
> "/home/coderextreme/X3DJSONLD/src/main/python/net/x3djsonld/data/x3d.py",
> line 3953, in assertValidSFVec3f
> raise X3DTypeError(str(value)[:100] + ', type=' + str(type(value))
> + ' is not a valid Python tuple for SFVec3f')
> x3d.X3DTypeError: [0, 0, 0], type=<class 'list'> is not a valid Python
> tuple for SFVec3f
>
>
> Spotted stiffness as MFFloat in X3DUOM.
>
>
> Will rebuild once there's a new python x3d.py package available.
>
> John
>
>
>> but then got a self-validation error by the JinLOA4.py python program,
>>
>> create python:
>>
>> C:\x3d-code\www.web3d.org\x3d\content\examples\HumanoidAnimation/Characters//JinLOA4.x3d
>> processing with X3dToPython stylesheet...
>>
>> C:\x3d-code\www.web3d.org\x3d\content\examples\HumanoidAnimation/Characters//JinLOA4.py
>> self-validation tests...
>>
>> validate python:
>>
>> x3d.py package loaded, have fun with X3D Graphics!
>>
>> Traceback (most recent call last):
>>
>> File
>> "C:\x3d-code\www.web3d.org\x3d\content\examples\HumanoidAnimation\Characters\JinLOA4.py",
>> line 169, in <module>
>>
>> HAnimJoint(DEF='hanim_l_tarsal_distal_interphalangeal_1',center=(2.761,0.539400,5.125),name='l_tarsal_distal_interphalangeal_1',stiffness=[0,0,0],
>>
>> File "C:\x3d-code\www.web3d.org\x3d\stylesheets\python\x3d\x3d.py",
>> line 43724, in __init__
>>
>> self.stiffness = stiffness
>>
>> File "C:\x3d-code\www.web3d.org\x3d\stylesheets\python\x3d\x3d.py",
>> line 43873, in stiffness
>>
>> assertValidSFVec3f(stiffness)
>>
>> File "C:\x3d-code\www.web3d.org\x3d\stylesheets\python\x3d\x3d.py",
>> line 3953, in assertValidSFVec3f
>>
>> raise X3DTypeError(str(value)[:100] + ', type=' +
>> str(type(value)) + ' is not a valid Python tuple for SFVec3f')
>>
>> x3d.X3DTypeError: [0, 0, 0], type=<class 'list'> is not a valid
>> Python tuple for SFVec3f
>>
>> Result: 1
>>
>> Note how stiffness=[0,0,0]was given as a list in brackets, rather
>> than a tuple value in parentheses stiffness=(0,0,0) as might be
>> expected for SFVec3f, and so this is a useful diagnostic.
>>
>> However the actual specification type for stiffness is MFFloat.
>> (This was a mantis issue, might we tighten it to SFVec3f, but decided
>> to keep it MFFloat in case more-advanced kinematics engines were
>> someday of interest.
>>
>> *
>> https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-CD1/Part01/components/hanim.html#HAnimJoint
>>
>> 26.3.3 HAnimJoint
>>
>> HAnimJoint : X3DGroupingNode {
>>
>> […]
>>
>> MFFloat [in,out] stiffness [0 0 0] [0,1]
>>
>> Applied change to X3D DTD, X3D XML Schema and again autogenerated
>> X3DUOM and x3d.py and X3D Ontology to match.
>>
>> 23 DEC 2021, carlson brutzman
>>
>> - restore type of HAnimJoint stiffness field as MFFloat (vice
>> SFVec3f) to match
>>
>> specification, since more-advanced kinematics engines might someday
>> hold interest.
>>
>> This fixed the stiffness error.
>>
>> However, next got a surprising conversion error (which might have
>> been what you experienced originally):
>>
>> =====================
>>
>> create python:
>>
>> C:\x3d-code\www.web3d.org\x3d\content\examples\HumanoidAnimation/Characters//JinLOA4.x3d
>> processing with X3dToPython stylesheet...
>>
>> C:\x3d-code\www.web3d.org\x3d\content\examples\HumanoidAnimation/Characters//JinLOA4.py
>> self-validation tests...
>>
>> validate python:
>>
>> x3d.py package loaded, have fun with X3D Graphics!Traceback (most
>> recent call last):
>>
>> File
>> "C:\x3d-code\www.web3d.org\x3d\content\examples\HumanoidAnimation\Characters\JinLOA4.py",
>> line 50, in <module>
>>
>> HAnimHumanoid(DEF='hanim_JinLOA4',loa=4,name='JinLOA4',scale=(0.0225,0.0225,0.0225),version='2.0',
>>
>> TypeError: HAnimHumanoid.__init__() got an unexpected keyword
>> argument 'value'
>>
>> Result: 1
>>
>> =====================
>>
>> Which apparently was on line 1950,
>>
>> value=MetadataSet(name='HAnimHumanoid.info',reference='https://www.web3d.org/documents/specifications/19774/V2.0/Architecture/ObjectInterfaces.html#Humanoid',etc.
>>
>> This conversion should have been metadata=MetadataSet etc. Looks like
>> the field name for the HAnimHumanoid MetadataSet was not specified
>> incorrectly, the automatic conversion by X3dTidy did not apply
>> correct containerField value.
>>
>> I have added a rule to X3dTidy.xslt that looks for this case (for
>> either representation, X3D3 or X3D4) and corrects it. I have added a
>> similar diagnostic rule to X3dSchematron checks.
>>
>> All affected HAnimHumanoid scenes have been updated and are now
>> getting compiled correctly by Python.
>>
>> All changes checked into subversion. Further regression testing
>> continuing, website uploads to follow.
>>
>> So again thanks for exposing this issue. Pretty complex but
>> resolvable. Once again the strict nature of Python aided us in
>> achieving high Quality Assurance (QA) for X3D.
>>
>> Happy holidays with X3D! 8)
>>
>> all the best, Don
>>
>> --
>>
>> Don Brutzman Naval Postgraduate School, Code USW/Br brutzman at nps.edu
>>
>> Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA
>> +1.831.656.2149
>>
>> X3D graphics, virtual worlds, navy robotics https://
>> faculty.nps.edu/brutzman
>>
>> *From:* John Carlson <yottzumm at gmail.com>
>> *Sent:* Wednesday, December 22, 2021 12:44 PM
>> *To:* Brutzman, Donald (Don) (CIV) <brutzman at nps.edu>; X3D Graphics
>> public mailing list <x3d-public at web3d.org>
>> *Subject:* Re: HAnim, X3dToPython.xslt X3dToJson.xslt Upgrade X3DUOM?
>>
>> I believe I checked the right standard, here:
>>
>> https://www.web3d.org/documents/specifications/19774-1/V2.0/index.html
>>
>> And neither value or metadata is a field????
>>
>> Seems a bit strange.
>>
>> On Wed, Dec 22, 2021 at 2:20 PM John Carlson <yottzumm at gmail.com> wrote:
>>
>> hoping to see value field added to HAnimHumanoid in X3DUOM, or
>> some notice that the package generating stylesheets are not
>> up-to-date.
>>
>> Also, check to make sure stiffness is assigned the right data
>> structure (between list and tuple). And no, iOS, I do not want
>> “Tupperware” for the second time. We need more women
>> mathematicians (sorry for any stereotyping). On that subject, I
>> wonder what coordinate system crocheted hats use?
>>
>> On Mon, Dec 20, 2021 at 3:17 AM John Carlson <yottzumm at gmail.com>
>> wrote:
>>
>> Okay, now I seem to be having a similar problem between my
>> python serializer, X3dToPython.xslt, and probably other
>> serialized stuff. I couldn't figure out how to fix the
>> stiffness issue in X3dToPython.xslt, but hand-editing saved
>> that on this particular python file
>> (python/net/x3djsonld/data/JinLOA4.py). Other JinLOA's still
>> have lists with Don's generator.
>>
>> I believe the main change I am dealing with is metadata vs
>> value containerFields. See JSON diff below. I'm not seeing
>> relevant changes to X3D JSON schema 4.0. Does something need
>> to be upgraded in X3DUOM or X3D JSON schema? I'm not seeing
>> a value field in HAnimHumanoid.
>>
>> *~/X3DJSONLD/src/main/python/net/coderextreme/data*$ python
>> JinLOA4.py
>> Traceback (most recent call last):
>> File
>> "/home/coderextreme/X3DJSONLD/src/main/python/net/coderextreme/data/JinLOA4.py",
>> line 148, in <module>
>> HAnimHumanoid23.setValue(MetadataSet24)
>> AttributeError: 'org.web3d.x3d.jsail.HAnim.HAnimHumanoid'
>> object has no attribute 'setValue'. Did you mean: 'setName'?
>> *~/X3DJSONLD/src/main/python/net/x3djsonld/data*$ python
>> JinLOA4.py
>> x3d.py package loaded, have fun with X3D Graphics!
>> Traceback (most recent call last):
>> File
>> "/home/coderextreme/X3DJSONLD/src/main/python/net/x3djsonld/data/JinLOA4.py",
>> line 50, in <module>
>> HAnimHumanoid(DEF='hanim_JinLOA4',loa=4,name='JinLOA4',scale=(0.0225,0.0225,0.0225),version='2.0',
>>
>> TypeError: HAnimHumanoid.__init__() got an unexpected keyword
>> argument 'value'
>>
>>
>> *~/X3DJSONLD/src/main/data*$ git diff JinLOA4.json
>> *diff --git a/src/main/data/JinLOA4.json
>> b/src/main/data/JinLOA4.json*
>> *index c970a652a..e1930f4cf 100644*
>> *--- a/src/main/data/JinLOA4.json*
>> *+++ b/src/main/data/JinLOA4.json*
>> @@ -78,7 +78,7 @@
>> },
>> {
>> "@name":"translated",
>> - "@content":"14 October 2021"
>> + "@content":"20 December 2021"
>> },
>> {
>> "@name":"generator",
>> @@ -116,7 +116,7 @@
>> "@loa":4,
>> "@scale":[0.0225,0.0225,0.0225],
>> "@version":"2.0",
>> - "-metadata":
>> + "-value":[
>> { "MetadataSet":
>> {
>> "@name":"HAnimHumanoid.info",
>> @@ -160,7 +160,8 @@
>> }
>> ]
>> }
>> - },
>> + }
>> + ],
>> "-skeleton":[
>> { "HAnimJoint":
>> {
>>
>> ===================
>>
>> Validating JSON against schema:
>>
>> *~/X3DJSONLD/src/main/schema*$ node
>> ~/x3dvalidate/x3dvalidate.js ../data/JinLOA4.json
>> Loading schema
>> Parsing schema
>> Adding schema
>> Schema 4.0 added
>> Schema 4.0 compiled
>> ================================================================================
>>
>> File: ../data/JinLOA4.json
>> Error reading ../data/JinLOA4.json
>> keyword: required
>> instancePath: /X3D/Scene/-children/3/HAnimHumanoid
>> message: must have required property @USE
>> params: {"missingProperty":"@USE"}
>> file: ../data/JinLOA4.json
>> version: 4.0
>>
>> keyword: additionalProperties
>> instancePath: /X3D/Scene/-children/3/HAnimHumanoid
>> message: must NOT have additional properties
>> params: {"additionalProperty":"-value"}
>> file: ../data/JinLOA4.json
>> version: 4.0
>>
>> keyword: oneOf
>> instancePath: /X3D/Scene/-children/3/HAnimHumanoid
>> message: must match exactly one schema in "oneOf"
>> params: {"passingSchemas":null}
>> file: ../data/JinLOA4.json
>> version: 4.0
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20211224/6b4d76d6/attachment-0001.html>
More information about the x3d-public
mailing list