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

Portuguese Ledge world #172

Merged
merged 11 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,27 @@ for example:
1. `~/lrauv_ws/src/lrauv-application-2/bin/LRAUV`
1. Start more `bin/LRAUV` as needed

## Levels

Some worlds support [levels](https://ignitionrobotics.org/api/gazebo/6.7/levels.html).
Levels are turned off by default, which means that all heightmap tiles will
be loaded at all times. When levels are enabled, only the tiles containing
vehicles (performers) spawned with `WorldCommPlugin` with an
[lrauv_init](https://github.com/osrf/lrauv/blob/main/lrauv_ignition_plugins/proto/lrauv_init.proto)
message will be loaded.

For example, loading without levels:

`ign gazebo -v 4 portuguese_ledge.sdf`

![portuguese_ledge_no_levels](https://user-images.githubusercontent.com/5751272/159629754-9206a9fe-eeed-4afc-a516-5c25a9fbdaf6.png)

And with levels:

`ign gazebo -v 4 portuguese_ledge.sdf --levels`

![portuguese_ledge_no_levels](https://user-images.githubusercontent.com/5751272/159813230-809d1cad-b3f5-457a-af19-3752bec0710f.gif)

### Troubleshoot

After issuing control commands, for example, rudder and thrust, if you then
Expand Down
3 changes: 2 additions & 1 deletion docker/debug_integration/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ RUN apt-get update \
lsb-release \
tzdata \
wget \
python3-empy \
python3-numpy

# Add Ignition's latest packages, which may be more up-to-date than the ones from the MBARI image
Expand All @@ -47,7 +48,7 @@ RUN /bin/sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable

# Install the latest Ignition binaries
RUN apt-get -qq update && apt-get -q -y install \
ignition-garden python3-numpy
ignition-garden

# Install PCL
RUN apt-get update \
Expand Down
1 change: 0 additions & 1 deletion docker/empty_world/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ RUN apt-get update \
software-properties-common \
sudo \
vim \
python3-numpy \
chapulina marked this conversation as resolved.
Show resolved Hide resolved
&& apt-get clean

# setup timezone
Expand Down
1 change: 1 addition & 0 deletions docker/tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ RUN apt-get update \
lsb-release \
tzdata \
wget \
python3-empy \
python3-numpy

# Add Ignition's latest packages, which may be more up-to-date than the ones from the MBARI image
Expand Down
14 changes: 14 additions & 0 deletions lrauv_ignition_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,20 @@ configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/hooks/hook.dsv" @ONLY
)

#============================================================================
# World generation
set(WORLD_NAME "portuguese_ledge")
add_custom_command(
OUTPUT world_gen_cmd
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/worlds/empy_expander.py
${CMAKE_CURRENT_SOURCE_DIR}/worlds/${WORLD_NAME}.sdf.em
${CMAKE_CURRENT_BINARY_DIR}/worlds/${WORLD_NAME}.sdf
)

add_custom_target(world_gen_target ALL
DEPENDS world_gen_cmd
)

#============================================================================
# Tests
if(BUILD_TESTING)
Expand Down
13 changes: 13 additions & 0 deletions lrauv_ignition_plugins/src/WorldCommPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void WorldCommPlugin::Configure(

// Services
this->createService = "/world/" + topicWorldName + "/create";
this->performerService = "/world/" + topicWorldName + "/level/set_performer";
this->setSphericalCoordsService = "/world/" + topicWorldName
+ "/set_spherical_coordinates";

Expand Down Expand Up @@ -213,6 +214,18 @@ void WorldCommPlugin::SpawnCallback(
ignerr << "Failed to request service [" << this->createService
<< "]" << std::endl;
}
else
{
// Make spawned model a performer
ignition::msgs::StringMsg performerReq;
performerReq.set_data(_msg.id_().data());
if (!this->node.Request(this->performerService, performerReq,
&WorldCommPlugin::ServiceResponse, this))
{
ignerr << "Failed to request service [" << this->performerService
<< "]" << std::endl;
}
}
}

/////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions lrauv_ignition_plugins/src/WorldCommPlugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ namespace tethys
/// Service to create entities
private: std::string createService;

/// Service to make spawned entities performers (for levels)
private: std::string performerService;

/// Whether the world origin's latitude and longitude have already been set.
private: bool hasWorldLatLon{false};
};
Expand Down
22 changes: 22 additions & 0 deletions lrauv_ignition_plugins/worlds/empy_expander.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Takes in a template and generates a file.

import argparse
import em
import os
import sys

def main(argv=sys.argv[1:]):
parser = argparse.ArgumentParser()
parser.add_argument('infile', help='Full path to input template.')
parser.add_argument('outfile', help='Full path to output file.')
args = parser.parse_args()

with open(args.infile) as infile:
template = infile.read()
result = em.expand(template, {})
os.makedirs(os.path.dirname(args.outfile), exist_ok=True)
with open(args.outfile, 'w') as outfile:
outfile.write(result)

if __name__ == '__main__':
sys.exit(main())
Loading