Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extends python interface of some maliput.api entities. #23

Merged
merged 2 commits into from
Nov 10, 2021

Conversation

francocipollone
Copy link
Collaborator

@francocipollone francocipollone commented Nov 9, 2021

Related to #21 and #20

Provides more coverage for maliput::api:

  • Extends InertialPosition
  • Fixes RoadPosition
  • Adds RoadPositionResult
  • Extends RoadGeometry to include ToRoadPosition, ToRoadPositionByHint and FindRoadPositions
  • Extends RoadGeometry.ByIndex to include GetLanes, GetSegment, GetJunction.
  • Extends Lane to include to_left, to_right
  • Adds missing ids: SegmentId, JunctionId

Note1: Tests were added, however some tests involving the RoadGeometry weren't added as they need an implementation of maliput. We probably should create some mocks to fully test the python interface.

Note2: As a reference of use of some of the here added features, the following script could be used:

Click to see py script
#!/usr/bin/env python3

import maliput

manager = maliput.plugin.MaliputPluginManager()
print(manager.ListPlugins())

road_network_configuration = {"opendrive_file":"TShapeRoad.xodr"}
road_network = maliput.plugin.create_road_network_from_plugin("maliput_malidrive", road_network_configuration)
rg = road_network.road_geometry()

for i in range(rg.num_junctions()):
 junction = rg.junction(i)


road_position_result = rg.ToRoadPosition(maliput.api.InertialPosition(0,0,0))
print(road_position_result.distance)
print(road_position_result.road_position.lane.id().string())
print(road_position_result.road_position.pos.srh())

road_position_hint = maliput.api.RoadPosition(road_position_result.road_position.lane, road_position_result.road_position.pos)
road_position_result_by_hint = rg.ToRoadPositionByHint(maliput.api.InertialPosition(0,0,0), road_position_hint)
print(road_position_result_by_hint.distance)
print(road_position_result_by_hint.road_position.lane.id().string())
print(road_position_result_by_hint.road_position.pos.srh())

road_positions_result = rg.FindRoadPositions(maliput.api.InertialPosition(0,0,0), 20)
print(road_positions_result[1].distance)
print(road_positions_result[1].road_position.lane.id().string())
print(road_positions_result[1].road_position.pos.srh())

id_index = rg.ById()
lanes = id_index.GetLanes()
for lane_id in lanes:
 print(lane_id.string())

lane = id_index.GetLane(maliput.api.LaneId("1_0_-1"))
assert(lane.id().string() == "1_0_-1")

segment_id = lane.segment().id()
assert(segment_id.string() == id_index.GetSegment(segment_id).id().string())

left_lane = lane.to_left()
assert(left_lane.id().string() == "1_0_1")

assert(left_lane.to_right() == lane)

Copy link
Collaborator

@agalbachicar agalbachicar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@agalbachicar
Copy link
Collaborator

Note1: Tests were added, however some tests involving the RoadGeometry weren't added as they need an implementation of maliput. We probably should create some mocks to fully test the python interface.

Let's create a ticket and consider using gmock for that.

@francocipollone
Copy link
Collaborator Author

Note1: Tests were added, however some tests involving the RoadGeometry weren't added as they need an implementation of maliput. We probably should create some mocks to fully test the python interface.

Let's create a ticket and consider using gmock for that.

Added here as a bullet

@francocipollone francocipollone merged commit 2c88515 into main Nov 10, 2021
@francocipollone francocipollone deleted the francocipollone/extend_python_interface branch November 10, 2021 14:22
francocipollone pushed a commit that referenced this pull request Jul 1, 2022
…p configurations. (#23)

- Restores xodr integration tests.
- Creates a dictionary with maps and their geometry configurations
  to easily tweak parameters when including a new xodr map.
- Fixes bug introduced while testing the plugin system. It avoids a
  double free error.
- Adds static to dictionary with xodr map information.
- Extends to 280s the timeout of the extensive integration tests.
- Sets extensive tests timeout to 300s because CI needs more time
  than development computers to run.
- Alphasort dependency list.
- Fixes the timeout in the regression tests and increases the timeout to 300s for the integration tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants