Skip to content

Commit

Permalink
Merge pull request #206 from mavlink/fix-201
Browse files Browse the repository at this point in the history
Handle repeated non-primitive types in translate_from_rpc
  • Loading branch information
julianoes authored Jun 3, 2020
2 parents e46f75d + b5a6b53 commit 0265233
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mavsdk/generated/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,7 +1386,7 @@ def translate_from_rpc(rpcSettingOptions):
rpcSettingOptions.setting_description,


Option.translate_from_rpc(rpcSettingOptions.options),
map(lambda elem: Option.translate_from_rpc(elem), rpcSettingOptions.options),


rpcSettingOptions.is_range
Expand Down
2 changes: 1 addition & 1 deletion mavsdk/generated/geofence.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def translate_from_rpc(rpcPolygon):
""" Translates a gRPC struct to the SDK equivalent """
return Polygon(

Point.translate_from_rpc(rpcPolygon.points),
map(lambda elem: Point.translate_from_rpc(elem), rpcPolygon.points),


Polygon.Type.translate_from_rpc(rpcPolygon.type)
Expand Down
2 changes: 1 addition & 1 deletion mavsdk/generated/mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def translate_from_rpc(rpcMissionPlan):
""" Translates a gRPC struct to the SDK equivalent """
return MissionPlan(

MissionItem.translate_from_rpc(rpcMissionPlan.mission_items)
map(lambda elem: MissionItem.translate_from_rpc(elem), rpcMissionPlan.mission_items)
)

def translate_to_rpc(self, rpcMissionPlan):
Expand Down
2 changes: 1 addition & 1 deletion mavsdk/generated/offboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def translate_from_rpc(rpcActuatorControl):
""" Translates a gRPC struct to the SDK equivalent """
return ActuatorControl(

ActuatorControlGroup.translate_from_rpc(rpcActuatorControl.groups)
map(lambda elem: ActuatorControlGroup.translate_from_rpc(elem), rpcActuatorControl.groups)
)

def translate_to_rpc(self, rpcActuatorControl):
Expand Down
2 changes: 1 addition & 1 deletion mavsdk/generated/tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def translate_from_rpc(rpcTuneDescription):
""" Translates a gRPC struct to the SDK equivalent """
return TuneDescription(

SongElement.translate_from_rpc(rpcTuneDescription.song_elements),
map(lambda elem: SongElement.translate_from_rpc(elem), rpcTuneDescription.song_elements),


rpcTuneDescription.tempo
Expand Down
4 changes: 4 additions & 0 deletions other/templates/py/struct.j2
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ class {{ name.upper_camel_case }}:
{% if field.type_info.is_primitive %}
rpc{{ name.upper_camel_case }}.{{ field.name.lower_snake_case }}{{ "," if not loop.last }}
{% else %}
{%- if field.type_info.is_repeated %}
map(lambda elem: {{ field.type_info.inner_name }}.translate_from_rpc(elem), rpc{{ name.upper_camel_case }}.{{ field.name.lower_snake_case }}){{ "," if not loop.last }}
{%- else %}
{% if field.type_info.parent_type is not none %}{{ field.type_info.parent_type }}.{% endif %}{{ field.type_info.inner_name }}.translate_from_rpc(rpc{{ name.upper_camel_case }}.{{ field.name.lower_snake_case }}){{ "," if not loop.last }}
{%- endif %}
{% endif %}
{%- endfor %})

Expand Down

0 comments on commit 0265233

Please sign in to comment.