Skip to content

Commit

Permalink
Merge pull request #346 from FlaSpaceInst/staging
Browse files Browse the repository at this point in the history
Staging -> Master: GitHub Actions and PEP8 changes
  • Loading branch information
CSharpRon authored Jul 24, 2020
2 parents 7204305 + 4a68fca commit 6ef8eaa
Show file tree
Hide file tree
Showing 62 changed files with 1,901 additions and 1,589 deletions.
7 changes: 7 additions & 0 deletions .github/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ros:melodic

# Copy code repository and script that specifies test procedure
COPY . /ez-rassor
COPY .github/build/entrypoint.sh /entrypoint.sh

CMD ["/bin/sh", "/entrypoint.sh"]
11 changes: 11 additions & 0 deletions .github/build/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh -l

cd /ez-rassor

# Go through the setup commands
sh develop.sh setup
sh develop.sh link
sh develop.sh build

# Run the test function (uses catkin_make run_tests)
sh develop.sh test
36 changes: 36 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: dev

on:
push:
branches:
- dev
- staging
pull_request:
branches:
- dev
- staging

jobs:

rostest:

runs-on: ubuntu-latest

# Builds a docker image with the repository inside. The executable for the container installs all packages and runs rostest.
steps:
- uses: actions/checkout@v2
- name: Run rostest on repository
run: |
docker build -t ez-rassor_rostest -f .github/build/Dockerfile .
docker run ez-rassor_rostest
flake8:

runs-on: ubuntu-latest

# Runs flake8 linter on all Python code. Saves changes as annotations to a PR.
steps:
- uses: actions/checkout@v2
- uses: TrueBrain/actions-flake8@master
with:
ignore: E501,W503
54 changes: 29 additions & 25 deletions dem_scripts/auto_gen_wrld/model_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
from lxml import etree
import sys

""" Given a uri tag, modify model_name and dem_name parts of the path """

def replace_ref(tag, model_name, dem_name):
"""Given a uri tag, modify model_name and dem_name parts of the path."""
first = True
tag_text = tag.text
tag_text = tag_text.split("/")
Expand All @@ -19,8 +20,9 @@ def replace_ref(tag, model_name, dem_name):

tag.text = new_tag_text

""" Given a uri tag, modify model_name part of the path """

def replace_diff_mod(tag, model_name):
"""Given a uri tag, modify model_name part of the path."""
first = True
tag_text = tag.text
tag_text = tag_text.split("/")
Expand All @@ -36,38 +38,35 @@ def replace_diff_mod(tag, model_name):

tag.text = new_tag_text

""" Update a tag's name attribute with model_name """

def replace_top_model_name(tag, model_name):
tag.attrib['name'] = model_name
"""Update a tag's name attribute with model_name."""
tag.attrib["name"] = model_name


""" Update a tag's text field with string """
def replace_text_field(tag, string):
"""Update a tag's text field with string."""
tag.text = string

""" Fill in model.sdf template """

def model_trav(path_to_file, model_name, dem_name, w, h, squish_factor):
"""Fill in model.sdf template."""

tree = etree.parse(path_to_file)

top_tag = tree.xpath(
"//sdf/model"
)[0]
top_tag = tree.xpath("//sdf/model")[0]

collision_uri_tag = tree.xpath(
"//sdf/model/link/collision/geometry/heightmap/uri"
)[0]
visual_uri_tag = tree.xpath(
"//sdf/model/link/visual/geometry/heightmap/uri"
)[0]
collision_uri_tag = tree.xpath("//sdf/model/link/collision/geometry/heightmap/uri")[
0
]
visual_uri_tag = tree.xpath("//sdf/model/link/visual/geometry/heightmap/uri")[0]
visual_tex_tag = tree.xpath(
"//sdf/model/link/visual/geometry/heightmap/texture/diffuse"
)[0]
"//sdf/model/link/visual/geometry/heightmap/texture/diffuse"
)[0]
collision_size_tag = tree.xpath(
"//sdf/model/link/collision/geometry/heightmap/size"
)[0]
visual_size_tag = tree.xpath(
"//sdf/model/link/visual/geometry/heightmap/size"
)[0]
"//sdf/model/link/collision/geometry/heightmap/size"
)[0]
visual_size_tag = tree.xpath("//sdf/model/link/visual/geometry/heightmap/size")[0]

replace_ref(collision_uri_tag, model_name, dem_name)

Expand All @@ -83,6 +82,7 @@ def model_trav(path_to_file, model_name, dem_name, w, h, squish_factor):

tree.write(path_to_file, xml_declaration=True)


def main():

if len(sys.argv) < 6:
Expand All @@ -100,10 +100,14 @@ def main():
squish_factor = sys.argv[6]

model_trav(
path_to_model, model_name, dem_img_file,
dimmensions_w, dimmensions_h,
squish_factor
path_to_model,
model_name,
dem_img_file,
dimmensions_w,
dimmensions_h,
squish_factor,
)


if __name__ == "__main__":
main()
44 changes: 22 additions & 22 deletions dem_scripts/auto_gen_wrld/world_file_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,39 @@
import model_create as mc

""" Fill in world template """


def world_trav(path_to_file, model_name, dem_name, w, h, squish_factor):

tree = etree.parse(path_to_file)
tree.xpath("//sdf/world/state")[0].attrib['world_name'] = model_name \
+ "_world"
tree.xpath("//sdf/world/state/model")[0].attrib['name'] = model_name
tree.xpath("//sdf/world/state")[0].attrib["world_name"] = model_name + "_world"
tree.xpath("//sdf/world/state/model")[0].attrib["name"] = model_name

include_tag = tree.xpath(
"//sdf/world/include"
)[1].getchildren()[0]
include_tag = tree.xpath("//sdf/world/include")[1].getchildren()[0]

top_tag = tree.xpath(
"//sdf/world/model"
)[0]
top_tag = tree.xpath("//sdf/world/model")[0]

world_tag = tree.xpath(
"//sdf/world"
)[0]
world_tag = tree.xpath("//sdf/world")[0]

collision_uri_tag = tree.xpath(
"//sdf/world/model/link/collision/geometry/heightmap/uri"
)[0]
)[0]

visual_uri_tag = tree.xpath(
"//sdf/world/model/link/visual/geometry/heightmap/uri"
)[0]
visual_uri_tag = tree.xpath("//sdf/world/model/link/visual/geometry/heightmap/uri")[
0
]

visual_tex_tag = tree.xpath(
"//sdf/world/model/link/visual/geometry/heightmap/texture/diffuse"
)[0]
)[0]

collision_size_tag = tree.xpath(
"//sdf/world/model/link/collision/geometry/heightmap/size"
)[0]
)[0]

visual_size_tag = tree.xpath(
"//sdf/world/model/link/visual/geometry/heightmap/size"
)[0]
)[0]

mc.replace_ref(collision_uri_tag, model_name, dem_name)

Expand All @@ -61,6 +56,7 @@ def world_trav(path_to_file, model_name, dem_name, w, h, squish_factor):

tree.write(path_to_file, xml_declaration=True)


def main():

if len(sys.argv) < 6:
Expand All @@ -78,10 +74,14 @@ def main():
squish_factor = sys.argv[6]

world_trav(
path_to_world, model_name, dem_img_file,
dimmensions_w, dimmensions_h,
squish_factor
path_to_world,
model_name,
dem_img_file,
dimmensions_w,
dimmensions_h,
squish_factor,
)


if __name__ == "__main__":
main()
101 changes: 52 additions & 49 deletions dem_scripts/auto_move/move_model_world.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
#!/usr/bin/env python
import os
import sys


def main():

world_ext = ""
choice = "queue_packs/"

l = os.listdir("./" + choice)

for i in l:

print("Processing {}".format(i))

folder_name = ""
cool = i.split("_")
num = len(cool)
new_str = ""
for p in range(num - 1):
if p < num - 2:
new_str += cool[p] + "_"
else:
new_str += cool[p]

world_file = ""
folder_name = new_str
lister = os.listdir("./" + choice + i)
for file in lister:
if ".world" in file:
world_file = file
tester = os.listdir("./" + choice + i + "/" + folder_name
+ "/materials/textures/"
)
cache = ""
for file in tester:
if file != "AS16-110-18026HR-512x512.jpg":
temp = file.split(".")
cache = temp[0]
print("Remove cache for {}".format(cache))
os.system("rm -rf $HOME/.gazebo/paging/" + cache)

print("Copying model and world to appropriate folders")
os.system(
"cp -r ./" + choice + i + "/" + folder_name
+ " $HOME/.gazebo/models/"
)
os.system(
"cp ./" + choice + i + "/" + world_file
+ " ../../packages/simulation/ezrassor_sim_gazebo/worlds"
)

if __name__ == '__main__':
main()
choice = "queue_packs/"

packs = os.listdir("./" + choice)

for i in packs:

print("Processing {}".format(i))

folder_name = ""
cool = i.split("_")
num = len(cool)
new_str = ""
for p in range(num - 1):
if p < num - 2:
new_str += cool[p] + "_"
else:
new_str += cool[p]

world_file = ""
folder_name = new_str
lister = os.listdir("./" + choice + i)
for file in lister:
if ".world" in file:
world_file = file
tester = os.listdir(
"./" + choice + i + "/" + folder_name + "/materials/textures/"
)
cache = ""
for file in tester:
if file != "AS16-110-18026HR-512x512.jpg":
temp = file.split(".")
cache = temp[0]
print("Remove cache for {}".format(cache))
os.system("rm -rf $HOME/.gazebo/paging/" + cache)

print("Copying model and world to appropriate folders")
os.system(
"cp -r ./" + choice + i + "/" + folder_name + " $HOME/.gazebo/models/"
)
os.system(
"cp ./"
+ choice
+ i
+ "/"
+ world_file
+ " ../../packages/simulation/ezrassor_sim_gazebo/worlds"
)


if __name__ == "__main__":
main()
Loading

0 comments on commit 6ef8eaa

Please sign in to comment.