Skip to content

Instantly share code, notes, and snippets.

@pestefo
Last active August 29, 2015 14:05
Show Gist options
  • Save pestefo/84647ee76677722f55c8 to your computer and use it in GitHub Desktop.
Save pestefo/84647ee76677722f55c8 to your computer and use it in GitHub Desktop.
Debugging scriptTF
PhaROSPacket>>dump
| anEncoder stream |
type check: value.
stream := WriteStream on: (ByteArray new: (type dataTypeSizeFor: value ) + 4). "<<<<<"
anEncoder := PhaROSEncoder on: stream.
self encodePacketSize: (type dataTypeSizeFor: value) into: anEncoder.
type serialize: value into: anEncoder.
anEncoder flush.
^ stream contents.
" ... luego se ejecuta ..."
PhaROSCompositeType>>dataTypeSizeFor: aValue "VALUE 1"
"beware of recursive structures!"
| acc |
acc := 0.
typeDefinition keysAndValuesDo:[ :attributeName :type |
acc := acc + (type dataTypeSizeFor: (aValue perform: attributeName asSymbol)). "<<<"
].
^ acc.
" se entra al bloque keyAndValuesDo: y se vuelve a dataTypeSizeFor: pero en VALUE 2 "
PhaROSArrayType>>dataTypeSizeFor: aValue "VALUE 2"
self flag: #cambiarEstooo. " "
(self isAPossibleValue: aValue ) ifFalse: [
PhaROSUnexpextedValue signal: 'Unexpected value'.
].
^(aValue inject: 0 into:[
:acc :val |
acc + (self relatedType dataTypeSizeFor: val ).
]).
" ... hasta que paf! "
PhaROSArrayType>>isAPossibleValue: aValue
^( aValue isKindOf: Collection ) and: [ "<<< acá se cae ya que no es una colección, sino que es una instancia de Geometry_msgsTransformStamped"
aValue allSatisfy: [
:val |
self relatedType isAPossibleValue: val.
]
].
---
"VALUE 1"
TftfMessage>>
transforms:Geometry_msgsTransformStamped>>
transform:Geometry_msgsTransform>>
translation:Geometry_msgsVector3>>
x:0.0 | y:0.0 | z:0.0 |
| rotation:Geometry_msgsQuaternion>>
x:0.0 | y:0.0 | z:0.0 | w:1.0 |
|
| child_frame_id:/base_link | header:Std_msgsHeader>>
seq:270909 | frame_id:/odom | stamp:now |
|
|
------------
"VALUE 2 - Obtenido luego de la primera recursión de dataTypeSizeFor:"
Geometry_msgsTransformStamped>>
transform:Geometry_msgsTransform>>
translation:Geometry_msgsVector3>>
x:0.0 | y:0.0 | z:0.0 |
| rotation:Geometry_msgsQuaternion>>
x:0.0 | y:0.0 | z:0.0 | w:1.0 |
|
| child_frame_id:/base_link | header:Std_msgsHeader>>
seq:270907 | frame_id:/odom | stamp:now |
|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment