diff --git a/.catkin_workspace b/.catkin_workspace new file mode 100644 index 0000000000000000000000000000000000000000..52fd97e7ea4bd421af3f7dacb539d241bcee6583 --- /dev/null +++ b/.catkin_workspace @@ -0,0 +1 @@ +# This file currently only serves to mark the location of a catkin workspace for tool integration diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..ef5e8767442185827e79a2589059e12029361224 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build +devel + diff --git a/fre_matchfield/README.md b/fre_matchfield/README.md deleted file mode 100755 index 699d9b03349a604a0e1eca01021a13c7529a045a..0000000000000000000000000000000000000000 --- a/fre_matchfield/README.md +++ /dev/null @@ -1,6 +0,0 @@ -1. Clone in your home directory. -2. Place this line in your bashrc: "export GAZEBO_MODEL_PATH=~/<path_to_this_directory>/sub_models:${GAZEBO_MODEL_PATH}" -3. Open a new terminal and start an empty world using gazebo ros(e.g.: "roslaunch gazebo_ros empty_world.launch") -4. Run 'create_task1.sh' or 'create_task2.sh' to spawn your world. -5. spawn your robot in the world - diff --git a/fre_matchfield/create_long_row.sh b/fre_matchfield/create_long_row.sh deleted file mode 100755 index 2b4cad63be5b8d3a8ea07ebe861b2fb1dfbe506d..0000000000000000000000000000000000000000 --- a/fre_matchfield/create_long_row.sh +++ /dev/null @@ -1,11 +0,0 @@ -# add new ground plane -rosrun gazebo_ros spawn_model -file sub_models/my_ground_plane/model.sdf -sdf -x 5 -y 5 -model real_soil - -cd src - - - -# create maize field -python plant_factory.py --obj_in_row 100 --nr_of_rows 2 --obj_dist 0.15 --row_width_var 0.05 --row_dir_var 0.05 - - diff --git a/fre_matchfield/create_screen_recording.md b/fre_matchfield/create_screen_recording.md deleted file mode 100755 index d7ecd68f12ace05de3d2bc4ebf8f50a35fb49b82..0000000000000000000000000000000000000000 --- a/fre_matchfield/create_screen_recording.md +++ /dev/null @@ -1,8 +0,0 @@ - -# create recording -ffmpeg -video_size 1920x1080 -framerate 7 -f x11grab -i :0.0+0,0 output.mp4 - - -# speed up the recording -ffmpeg -i output.mp4 -filter:v "setpts=0.2*PTS" output_ffmpegx5.mp4 - diff --git a/fre_matchfield/create_task1.sh b/fre_matchfield/create_task1.sh deleted file mode 100755 index 012694e30dd1f65eea3ac12c511b3811d2cc1268..0000000000000000000000000000000000000000 --- a/fre_matchfield/create_task1.sh +++ /dev/null @@ -1,12 +0,0 @@ -# add new ground plane -rosrun gazebo_ros spawn_model -file sub_models/my_ground_plane/model.sdf -sdf -x 5 -y 5 -model real_soil - -cd src - -# spawn pebbles -python random_field.py --nr_of_rows 3 --obj_in_row 75 --obj_dist 0.1 --random_color --rand_placement --models pebble.urdf --base_color 0.2 0.2 0.2 --row_width_var 0.375 --row_dir_var 0.5 --y0 3.375 --x0 -1.5 - - -# create maize field -python plant_factory.py --obj_in_row 30 --nr_of_rows 8 --obj_dist 0.15 --row_width_var 0.07 --row_dir_var 0.05 --amplitude 1 --row_shape sine - diff --git a/fre_matchfield/create_task2.sh b/fre_matchfield/create_task2.sh deleted file mode 100755 index 73e7d77c2bba3e58d5c8625172a45df2e7d01cff..0000000000000000000000000000000000000000 --- a/fre_matchfield/create_task2.sh +++ /dev/null @@ -1,13 +0,0 @@ -# add new ground plane -rosrun gazebo_ros spawn_model -file sub_models/my_ground_plane/model.sdf -sdf -x 5 -y 5 -model real_soil - -cd src - -# spawn pebbles -python random_field.py --nr_of_rows 3 --obj_in_row 75 --obj_dist 0.1 --random_color --rand_placement --models pebble.urdf --base_color 0.2 0.2 0.2 --row_width_var 0.375 --row_dir_var 0.5 --y0 3.375 --x0 -1.5 - - -# create maize field -python plant_factory.py --obj_in_row 30 --nr_of_rows 8 --obj_dist 0.15 --row_width_var 0.07 --row_dir_var 0.05 --row_holes 3 4 5 6 7 - - diff --git a/fre_matchfield/create_task3.sh b/fre_matchfield/create_task3.sh deleted file mode 100755 index 2f26a59efdfdc7d24c9b761a6a0eef889d2b654d..0000000000000000000000000000000000000000 --- a/fre_matchfield/create_task3.sh +++ /dev/null @@ -1,25 +0,0 @@ -# add new ground plane -rosrun gazebo_ros spawn_model -file sub_models/my_ground_plane/model.sdf -sdf -x 5 -y 5 -model real_soil - -# 8 balls - -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_01 -x 2.2 -y 0.7 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_02 -x 3.5 -y 1.5 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_03 -x 1 -y 1.5 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_04 -x 2.8 -y 2.9 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_05 -x 0.5 -y 3.5 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_06 -x 3.6 -y 4.4 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_07 -x 2.1 -y 4.6 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_08 -x 1.3 -y 5.2 - -cd src - -# spawn pebbles -python random_field.py --nr_of_rows 5 --obj_in_row 19 --obj_dist 0.4 --random_color --rand_placement --models pebble.urdf --base_color 0.2 0.2 0.2 --row_width_var 0.375 --row_dir_var 0.5 --y0 1.875 --x0 -1.5 - - -# create maize field -python plant_factory.py --obj_in_row 30 --nr_of_rows 8 --obj_dist 0.15 --row_width_var 0.03 --row_dir_var 0.05 --amplitude 0.35 --row_shape sine - - - diff --git a/fre_matchfield/create_task4.sh b/fre_matchfield/create_task4.sh deleted file mode 100755 index 49db8f85459c174a33dea0f50b8bc3b0e57935c5..0000000000000000000000000000000000000000 --- a/fre_matchfield/create_task4.sh +++ /dev/null @@ -1,25 +0,0 @@ -# add new ground plane -rosrun gazebo_ros spawn_model -file sub_models/my_ground_plane/model.sdf -sdf -x 5 -y 5 -model real_soil - -# 8 balls - -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_01 -x 2.2 -y 0.0 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_02 -x 3.7 -y 0.8 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_03 -x 1.0 -y 0.9 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_04 -x 2.8 -y 2.2 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_05 -x 0.5 -y 3.5 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_06 -x 3.6 -y 4.5 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_07 -x 2.1 -y 3.8 -rosrun gazebo_ros spawn_model -file sub_models/pink_ball/model.sdf -sdf -model pink_ball_08 -x 1.3 -y 4.5 - -cd src - -# spawn pebbles -python random_field.py --nr_of_rows 5 --obj_in_row 19 --obj_dist 0.4 --random_color --rand_placement --models pebble.urdf --base_color 0.2 0.2 0.2 --row_width_var 0.375 --row_dir_var 0.5 --y0 1.875 --x0 -1.5 - - -# create maize field -python plant_factory.py --obj_in_row 30 --nr_of_rows 8 --obj_dist 0.15 --row_width_var 0.03 --row_dir_var 0.05 --amplitude -0.35 --row_shape sine - - - diff --git a/fre_matchfield/src/plant_factory.py b/fre_matchfield/src/plant_factory.py deleted file mode 100755 index 2e36476ddb491bd602de562d657a0a7494542d16..0000000000000000000000000000000000000000 --- a/fre_matchfield/src/plant_factory.py +++ /dev/null @@ -1,331 +0,0 @@ -#! /usr/bin/env python -# This creats urdf plants -# see --help for more info -# -# Author: -# author: Thijs Ruigrok -# email: thijs.ruigrok@wur.nl - - -# import tf -# from gazebo_msgs.srv import SpawnModel, DeleteModel -# from geometry_msgs.msg import Pose, Point, Quaternion -from random import random, randint -# import os -# import re -# import argparse -# import sys -import math - -class Plant(object): - def __init__(self, plant_nr): - # init colors - self.base_color = [0.4, 0.9, 0.6] - self.base_ambient = 0.8 - self.rand_ambient = 0.3 - self.base_diffuse = 0.8 - self.rand_diffuse = 0.4 - self.base_specular = 0.4 - self.rand_specular = 1.0 - - self.ambient = self.scale_color(self.base_ambient, self.rand_ambient) - self.diffuse = self.scale_color(self.base_diffuse, self.rand_diffuse) - self.specular = self.scale_color(self.base_specular, self.rand_specular) - - # init kinematics - self.branch_length = 0.2 - self.rand_branch = 0.1 - - # create stem - self.cont = '' - self.stem_name = "cylinder_%03d" %plant_nr - self.create_cylinder(self.stem_name) - self.add_color(self.stem_name) - - # create leafs - leafs = 2 - for leaf_nr in range(leafs): - leaf_name = "leaf_%03d_%02d" %(plant_nr, leaf_nr) - self.create_leaf(leaf_name) - self.add_color(leaf_name) - self.create_joint(self.stem_name, leaf_name) - - - def create_cylinder(self, name): - # params - mass = 1 - r = 0.03 - l = 0.7 - - - #link name - self.cont += '\t<link name="%s"> \n' %name - - # inertia - self.cont += '\t\t<inertial> \n' - self.cont += '\t\t\t<mass value="%f"/> \n' % mass - - ixx = (mass/12)*(3*r*r + l*l) - iyy = ixx - izz = (mass/2)*r*r - - self.cont += '\t\t\t<inertia ixx="%f" ixy="0.0" ixz="0.0" iyy="%f" iyz="0.0" izz="%f" /> \n' % (ixx, iyy, izz) - self.cont += '\t\t\t<origin xyz="0 0 0"/> \n' - self.cont += '\t\t</inertial> \n' - - # visual - self.cont += '\t\t<visual> \n' - self.cont += '\t\t\t<geometry> \n' - self.cont += '\t\t\t\t<cylinder length="%f" radius="%f"/> \n' % (l, r) - self.cont += '\t\t\t</geometry> \n' - self.cont += '\t\t</visual> \n' - - # collision - self.cont += '\t\t<collision> \n' - self.cont += '\t\t\t<geometry> \n' - self.cont += '\t\t\t\t<cylinder length="%f" radius="%f"/> \n' % (l, r) - self.cont += '\t\t\t</geometry> \n' - self.cont += '\t\t</collision> \n' - - # link end - self.cont += '\t</link> \n \n' - - - def create_leaf(self, name): - - #link name - self.cont += '\t<link name="%s"> \n' %name - - # inertia - self.cont += '\t\t<inertial> \n' - self.cont += '\t\t\t<mass value="0.01" /> \n' - self.cont += '\t\t\t<inertia ixx="0.000075" ixy="0.0" ixz="0.0" iyy="0.0000084" iyz="0.0" izz="0.000083" /> \n' - self.cont += '\t\t\t<origin rpy="0 0 0" xyz="0 0 -0.8"/> \n' - self.cont += '\t\t</inertial> \n' - - # visual - self.cont += '\t\t<visual> \n' - self.cont += '\t\t\t<origin rpy="0 0 0" xyz="0 0 -0.8"/> \n' - self.cont += '\t\t\t<geometry> \n' - self.cont += '\t\t\t\t<box size="0.01 0.05 0.3" /> \n' - self.cont += '\t\t\t</geometry> \n' - self.cont += '\t\t</visual> \n' - - # collision - self.cont += '\t\t<collision> \n' - self.cont += '\t\t\t<origin rpy="0 0 0" xyz="0 0 -0.8"/> \n' - self.cont += '\t\t\t<geometry> \n' - self.cont += '\t\t\t\t<box size="0.01 0.05 0.3" /> \n' - self.cont += '\t\t\t</geometry> \n' - self.cont += '\t\t</collision> \n' - - # link end - self.cont += '\t</link> \n \n' - - - def create_joint(self, link1, link2): - - # use a dummy link for creating multiple dofs - dummy_name = "dummy_%s" % link2 - self.create_dummy(dummy_name) - - # calculate position of the leaf - leaf_angle = 2*random()*math.pi - math.pi - cur_branch_length = self.branch_length + random() * self.rand_branch * 2 - self.rand_branch - x = math.cos(leaf_angle) * cur_branch_length - y = math.sin(leaf_angle) * cur_branch_length - - # dof 1 - joint_name = "%s_to_%s" % (link1, dummy_name) - self.cont += '\t<joint name="%s" type="revolute"> \n' %joint_name - self.cont += '\t\t<parent link="%s" />\n' %link1 - self.cont += '\t\t<child link="%s" />\n' %dummy_name - - self.cont += '\t\t<origin xyz="%f %f 0.7" rpy="0 0 %f" />\n' % (x, y, leaf_angle + math.pi/2) - self.cont += '\t\t<axis xyz="0 1 0" /> \n' - self.cont += '\t\t<limit upper="99999" lower="-99999" effort="9999" velocity="9999" />\n' - self.cont += '\t\t<dynamics damping="0.001" friction="0.003"/> \n' - self.cont += '\t</joint> \n \n' - - - # dof 2 - joint_name = "%s_to_%s" % (dummy_name, link2) - self.cont += '\t<joint name="%s" type="revolute"> \n' %joint_name - self.cont += '\t\t<parent link="%s" />\n' %dummy_name - self.cont += '\t\t<child link="%s" />\n' %link2 - - - self.cont += '\t\t<origin xyz="0 0 0" rpy="0 0 0" />\n' - self.cont += '\t\t<axis xyz="1 0 0" /> \n' - self.cont += '\t\t<limit upper="99999" lower="-99999" effort="9999" velocity="9999" />\n' - self.cont += '\t\t<dynamics damping="0.001" friction="0.003"/> \n' - self.cont += '\t</joint> \n \n' - - - def create_dummy(self, name): - # creates a dummy link for makin multiple dof joints - - #link name - self.cont += '\t<link name="%s"> \n' %name - - # inertia - self.cont += '\t\t<inertial> \n' - self.cont += '\t\t\t<mass value="0.01" /> \n' - self.cont += '\t\t\t<inertia ixx="0.000075" ixy="0.0" ixz="0.0" iyy="0.0000084" iyz="0.0" izz="0.000083" /> \n' - self.cont += '\t\t\t<origin rpy="0 0 0" xyz="0 0 0"/> \n' - self.cont += '\t\t</inertial> \n' - - # link end - self.cont += '\t</link> \n \n' - - - def add_color(self, link_name): - self.cont += '\t<gazebo reference="%s">\n' %link_name - self.cont += '\t\t<visual>\n' - self.cont += '\t\t\t<material>\n' - self.cont += '\t\t\t\t<ambient>%f %f %f 1.0</ambient>\n' % tuple(self.ambient) - self.cont += '\t\t\t\t<diffuse>%f %f %f 1.0</diffuse>\n' % tuple(self.diffuse) - self.cont += '\t\t\t\t<specular>%f %f %f 1.0</specular>\n' % tuple(self.specular) - self.cont += '\t\t\t\t<emissive>0.0 0.0 0.0 0.0</emissive>\n' - self.cont += '\t\t\t</material>\n' - self.cont += '\t\t</visual>\n' - self.cont += '\t</gazebo>\n \n' - - - def scale_color(self, base_val, at_rand): - # Scale atribute values for different visual properties - - # compute disturbance - at_scale = base_val + random() * at_rand * 2 - at_rand - - # scale original value to the disturbance scale - at_val = [color_val * at_scale for color_val in self.base_color] - - # clip between 0 and 1 - at_val = [max(min(x, 1.0), 0.0) for x in at_val] - - return at_val - - -class CropRow(object): - def __init__(self, row_nr, opt): - self.row_name = "crop_row_%03d" % row_nr - - # init row obj - self.cont = '' - self.create_header(self.row_name) - plant0 = Plant(0) - self.cont += plant0.cont - - # init row hole params - if row_nr in opt.row_holes: - create_hole = True - else: - create_hole = False - self.hole_size = 0 - self.hole_loc = randint(opt.hole_elm_from_end, opt.obj_in_row - opt.hole_elm_from_end - opt.hole_size) - - # sin params - self.row_length = (opt.obj_in_row-1) * opt.obj_dist - - # create more plants - for plant_nr in range(1,opt.obj_in_row): - x_base = plant_nr * opt.obj_dist - - # noise in the spawning location of the object - x = x_base + (2 * random() -1) * opt.row_dir_var - y = (2 * random() -1) * opt.row_width_var + opt.y0 - - if opt.row_shape == "sine": - cur_dist = (plant_nr -1) * opt.obj_dist - rel_dist = cur_dist/self.row_length - y_pert = math.sin(rel_dist*math.pi) * opt.amplitude - y += y_pert - - # create a hole if needed - if create_hole and plant_nr >=self.hole_loc and self.hole_size <= opt.hole_size: - self.hole_size += 1 - - else: # plant plants - new_plant = Plant(plant_nr) - self.cont += new_plant.cont - self.join_plants(plant0.stem_name, new_plant.stem_name, x, y) - - # create the end of the row object - self.create_end() - - def create_header(self, name='my_name'): - self.cont += '<?xml version="1.0"?> \n' - self.cont += '<robot name="%s"> \n \n' %name - - def join_plants(self, link1, link2, x, y): - # joint the plants to the first plant using a floating joint - joint_name = "%s_to_%s" % (link1, link2) - # change the joint type to allow plants to fall over, or to be fixed ot the rest of the row. - self.cont += '\t<joint name="%s" type="floating"> \n' %joint_name - # self.cont += '\t<joint name="%s" type="fixed"> \n' %joint_name - self.cont += '\t\t<parent link="%s" />\n' %link1 - self.cont += '\t\t<child link="%s" />\n' %link2 - - self.cont += '\t\t<origin xyz="%f %f 0" rpy="0 0 0" />\n' % (x, y) - self.cont += '\t\t<axis xyz="0 1 0" /> \n' - self.cont += '\t\t<limit upper="3.14" lower="-3.14" effort="9999" velocity="9999" />\n' - self.cont += '\t\t<dynamics damping="0.001" friction="0.003"/> \n' - self.cont += '\t</joint> \n \n' - - - def create_end(self): - self.cont += '</robot> \n' - - -if __name__ =="__main__": - # remove the ros arguments from the argument list - import argparse - - parser = argparse.ArgumentParser() - - # row parameters - parser.add_argument('--obj_in_row', type=int, default=20, help='number of object rows to spawn') - parser.add_argument('--obj_dist', type=float, default=0.15, help='') - parser.add_argument('--row_width_var', type=float, default=0.07, help='') - parser.add_argument('--row_dir_var', type=float, default=0.05, help='') - - # hole params - parser.add_argument('--row_holes', nargs='*', default=-999, type=int, help='rows with holes') - parser.add_argument('--hole_elm_from_end', type=int, default=2, help='min plants at the end of the row') - parser.add_argument('--hole_size', type=int, default=4, help='number of missing plants in a hole') - - # curve params - parser.add_argument('--amplitude', type=float, default=1, help='amplitude of the sine row') - parser.add_argument('--row_shape', type=str, default='straight', help='shape of row, sine or straight') - - # field parameters - parser.add_argument('--x0', type=float, default=0, help='') - parser.add_argument('--y0', type=float, default=0, help='') - parser.add_argument('--nr_of_rows', type=int, default=6, help='number of rows') - parser.add_argument('--row_width', type=float, default=0.75, help='') - - opt = parser.parse_args() - if type(opt.row_holes) == type(0): - opt.row_holes = [opt.row_holes] - print(opt) - - import rospy - from gazebo_msgs.srv import SpawnModel, DeleteModel - from geometry_msgs.msg import Pose, Point, Quaternion - # initialize service handlers - rospy.wait_for_service("/gazebo/spawn_urdf_model") - spawn_model = rospy.ServiceProxy('/gazebo/spawn_urdf_model', SpawnModel) - delete_model = rospy.ServiceProxy('/gazebo/delete_model', DeleteModel) - - line_count = 0 - - for row_nr in range(opt.nr_of_rows): - y = opt.row_width * row_nr + opt.y0 - - row = CropRow(row_nr, opt) - line_count += row.cont.count('\n') - # spawn model - spawn_model(row.row_name, row.cont, "/row_object", Pose(position= Point(opt.x0,y,0),orientation=Quaternion(0,0,0,0)),"world") - - print("%d lines of urdf created" % line_count) diff --git a/fre_matchfield/src/random_field.py b/fre_matchfield/src/random_field.py deleted file mode 100755 index 33ebc58e41983b3204d01a03f208e57e578fc272..0000000000000000000000000000000000000000 --- a/fre_matchfield/src/random_field.py +++ /dev/null @@ -1,175 +0,0 @@ -#! /usr/bin/env python -# This node spawns a field with randoms disturbances in the objects -# see --help for more info -# -# Author: -# author: Thijs Ruigrok -# email: thijs.ruigrok@wur.nl -import rospy -import tf -from gazebo_msgs.srv import SpawnModel, DeleteModel -from geometry_msgs.msg import Pose, Point, Quaternion -from random import random, randint -import os -import re -import argparse -import sys -import math - -def spawn_field(opt): - - - script_dir = os.path.dirname(__file__) #<-- absolute dir the script is in - - # read allt he model xml files - model_list = [] - for file_name in opt.models: - model_path = os.path.join(script_dir, '../sub_models/', file_name) - model_list.append(open(model_path,'r').read()) - - # initialize service handlers - rospy.wait_for_service("/gazebo/spawn_urdf_model") - spawn_model = rospy.ServiceProxy('/gazebo/spawn_urdf_model', SpawnModel) - delete_model = rospy.ServiceProxy('/gazebo/delete_model', DeleteModel) - - # spawning function - for row_nr in range(opt.nr_of_rows): - y_base = row_nr * opt.row_width + opt.y0 - for plant_nr in range(opt.obj_in_row): - x_base = plant_nr * opt.obj_dist + opt.x0 - - # select random model form the list - model_nr = randint(0, len(model_list)-1) - model = model_list[model_nr] - file_name = opt.models[model_nr] - - model_name = file_name + "_" + str(row_nr) + "_" + str(plant_nr) - - # delete model if already exists - if opt.delete_models: - delete_model(model_name) - - - if opt.rand_placement: - # chance for a model to not be spawned - spawn_prob = random() - - # noise in the spawning location of the object - x = x_base + (2 * random() -1) * opt.row_dir_var - y = y_base + (2 * random() -1) * opt.row_width_var - - angle = random() * 2 * math.pi - orient = tf.transformations.quaternion_from_euler(0, 0, angle) - else: - x = x_base - y = y_base - spawn_prob = 2 # spawn all models - - orient = tf.transformations.quaternion_from_euler(0, 0, 0) - - if spawn_prob > opt.missing_prob: - # print("spawning: " + model_name) - - # apply color transformations - model = scale_color(model, 'ambient', opt.base_color, opt.base_ambient, opt.rand_ambient) - model = scale_color(model, 'diffuse', opt.base_color, opt.base_diffuse, opt.rand_diffuse) - model = scale_color(model, 'specular', opt.base_color, opt.base_specular, opt.rand_specular) - - if opt.random_size: - if opt.models == 'sphere.urdf' or opt.models == 'pebble.urdf': - model = scale_sphere(model, opt.base_rad, opt.rand_rad) - else: - print('no scaling function availeble from model') - - - # spawn model - spawn_model(model_name, model, "/row_object", Pose(position= Point(x,y,0),orientation=Quaternion(orient[0],orient[1],orient[2],orient[3])),"world") - - print("succesfully spawned " + str(opt.nr_of_rows) + " rows, with " + str(opt.obj_in_row) + " objects in each row") - - -def scale_sphere(model, base_rad, rand_rad): - # model: urdf model in string format - # base_rad: base radius - # at_rand: random scaling for the radius - - rad = base_rad + random() * rand_rad * 2 - rand_rad - sphere_str = '<sphere radius=' + str(rad) + '/>' - model = re.sub('<sphere.*/>', sphere_str, model) - - return model - - -def scale_color(model, at_name, base_color, base_val, at_rand): - # model: urdf model in string format containgin the field for the specified atribute - # at_name: string of the atribute name you want to change (e.g.) 'ambient' for the ambient reflectance - # base_color: base value for this atribute (assumes 3 values) - # base_val: base ratio of the base_color for this atribute - # at_rand: random scaling for the base_val - - # compute disturbance - at_scale = base_val + random() * at_rand * 2 - at_rand - - # scale original value to the disturbance scale - at_val = [color_val * at_scale for color_val in base_color] - - # clip between 0 and 1 - at_val = [max(min(x, 1.0), 0.0) for x in at_val] - - # apply new value to the model string - ambient_string = '<' + at_name +'> ' + str(at_val[0]) + ' ' + str(at_val[1]) + ' ' + str(at_val[2]) + ' 1.0 </' + at_name + '>' - model = re.sub('<' + at_name + '>.*</' + at_name +'>', ambient_string, model) - - return model - - -if __name__ == "__main__": - - # remove the ros arguments from the argument list - sys.argv = rospy.myargv(argv=sys.argv) - - rospy.init_node('spawn_random_field', anonymous=True) - - parser = argparse.ArgumentParser() - parser.add_argument('--models', default='sphere.urdf', nargs='+', help='file of the urdf models to spawn') - parser.add_argument('--nr_of_rows', type=int, default=5, help='number of object rows to spawn') - parser.add_argument('--obj_in_row', type=int, default=15, help='number of objects in one (crop) row') - parser.add_argument('--row_width', type=float, default=0.75, help='distance between the rows') - parser.add_argument('--obj_dist', type=float, default=0.3, help='distance within the row') - - parser.add_argument('--rand_placement', action='store_true', help='add random disturbances to the placement of the objects') - parser.add_argument('--missing_prob', type=float, default=0.2, help='probability a row object is missing in the row') - parser.add_argument('--row_dir_var', type=float, default=0.1, help='variation in the spawn location in the row direction') - parser.add_argument('--row_width_var', type=float, default=0.05, help='variation in the spawn location in the width of the row direction') - parser.add_argument('--y0', type=float, default=999, help='y location of object 0') - parser.add_argument('--x0', type=float, default=0, help='x location of object 0') - parser.add_argument('--delete_models', action='store_true', help='delete row objects that already exist') - - parser.add_argument('--random_color', action='store_true', help='create random colors') - parser.add_argument('--base_color', type=float, default=[1.0, 0.4627450980392157, 0.09803921568627451], nargs=3, help='rgb values of the color of the object') - parser.add_argument('--base_ambient', type=float, default=0.4, help='base ratio for ambient reflection') - parser.add_argument('--rand_ambient', type=float, default=0.3, help='disturbance in the ambient reflection') - parser.add_argument('--base_diffuse', type=float, default=0.7, help='base ratio for diffuse reflection') - parser.add_argument('--rand_diffuse', type=float, default=0.4, help='disturbance in the diffuse reflection') - parser.add_argument('--base_specular', type=float, default=0.4, help='base ratio for specular reflection') - parser.add_argument('--rand_specular', type=float, default=1.0, help='disturbance on specular reflection') - - parser.add_argument('--random_size', action='store_true', help='rescale the size of the models') - parser.add_argument('--base_rad', type=float, default=0.075, help='base radius of the sphere') - parser.add_argument('--rand_rad', type=float, default=0.02, help='disturbance in radius of the sphere') - - opt = parser.parse_args() - - if opt.y0 == 999: - opt.y0 = -opt.row_width / 2 # y location of object 0 - - if not type(opt.models) == type([]): - opt.models = [opt.models] - - if not opt.random_color: # remove color disturbance if color disturbance is disabled - opt.rand_ambient = 0 - opt.rand_diffuse = 0 - opt.rand_specular = 0 - - print(opt) - spawn_field(opt) \ No newline at end of file diff --git a/fre_matchfield/sub_models/box.urdf b/fre_matchfield/sub_models/box.urdf deleted file mode 100755 index a463c88fb5882f489d1dec6a1d28d352f86b82d3..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/box.urdf +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0"?> -<robot name="simple_box"> - - - <link name="my_box"> - <inertial> - <origin xyz="0 0 0"/> - <mass value="0.01" /> - <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="100.0" iyz="0.0" izz="1.0" /> - </inertial> - <visual> - <origin xyz="0 0 0"/> - <geometry> - <box size="0.1 0.1 0.2" /> - </geometry> - </visual> - <collision> - <origin xyz="0 0 0"/> - <geometry> - <box size="0.1 0.1 0.2" /> - </geometry> - </collision> - </link> - - - <gazebo reference="my_box"> - <visual> - <material> - <ambient>0.0 0.0 0.0 1.0</ambient> - <diffuse>0.0 0.0 0.0 1.0</diffuse> - <specular>0.0 0.0 0.0 1.0</specular> - <emissive>0.0 0.0 0.0 0.0</emissive> - </material> - </visual> - </gazebo> -</robot> diff --git a/fre_matchfield/sub_models/box_with_picture/box_with_texture.urdf b/fre_matchfield/sub_models/box_with_picture/box_with_texture.urdf deleted file mode 100755 index 08b8b0b524868d11baf4d0c362ad32d032df607d..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/box_with_picture/box_with_texture.urdf +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0"?> -<robot name="box_with_picture"> - - <link name="my_box"> - <inertial> - <origin xyz="0 0 0"/> - <mass value="0.01" /> - <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="100.0" iyz="0.0" izz="1.0" /> - </inertial> - <visual> - <origin xyz="0 0 0"/> - <geometry> - <box size="0.1 0.1 0.2" /> - </geometry> - </visual> - <collision> - <origin xyz="0 0 0"/> - <geometry> - <box size="0.1 0.1 0.2" /> - </geometry> - </collision> - </link> - - <gazebo reference="my_box"> - <visual> - <material> - <script> - <uri>model://box_with_picture/materials/scripts</uri> - <uri>model://box_with_picture/materials/textures</uri> - <name>sofaMat/Diffuse</name> - </script> - </material> - </visual> - </gazebo> - -</robot> diff --git a/fre_matchfield/sub_models/box_with_picture/materials/scripts/example.material b/fre_matchfield/sub_models/box_with_picture/materials/scripts/example.material deleted file mode 100755 index 8c4eaba0b9541de455ee20cb248889358d1e07bc..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/box_with_picture/materials/scripts/example.material +++ /dev/null @@ -1,14 +0,0 @@ -material sofaMat/Diffuse -{ - receive_shadows off - technique - { - pass - { - texture_unit - { - texture sofa1.png - } - } - } -} diff --git a/fre_matchfield/sub_models/box_with_picture/materials/textures/sofa1.png b/fre_matchfield/sub_models/box_with_picture/materials/textures/sofa1.png deleted file mode 100755 index c16abb2ceca3694138e7097f2b42f6a58853a5af..0000000000000000000000000000000000000000 Binary files a/fre_matchfield/sub_models/box_with_picture/materials/textures/sofa1.png and /dev/null differ diff --git a/fre_matchfield/sub_models/cylinder.urdf b/fre_matchfield/sub_models/cylinder.urdf deleted file mode 100755 index 4963251da143e863e7cd76e1a5df497b1c8280fc..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/cylinder.urdf +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0"?> -<robot name="simple_box"> - <link name="my_cylinder"> - <inertial> - <origin xyz="0 0 0" rpy="0 0 0"/> - <mass value="0.01"/> - <inertia ixx="0.0004106" ixy="0.0" ixz="0.0" iyy="0.0004106" iyz="0.0" izz="0.0000045" /> - </inertial> - - <visual> - <origin xyz="0 0 0" rpy="0 0 0" /> - <geometry> - <cylinder length="0.7" radius="0.03"/> - </geometry> - </visual> - - <collision> - <origin xyz="0 0 0" rpy="0 0 0"/> - <geometry> - <cylinder length="0.7" radius="0.03"/> - </geometry> - </collision> - - </link> - <gazebo reference="my_cylinder"> - <visual> - <material> - <ambient>0.0 0.0 0.0 1.0</ambient> - <diffuse>0.0 0.0 0.0 1.0</diffuse> - <specular>0.0 0.0 0.0 1.0</specular> - <emissive>0.0 0.0 0.0 0.0</emissive> - </material> - </visual> - </gazebo> -</robot> - - diff --git a/fre_matchfield/sub_models/cylinder_with_leafs.urdf b/fre_matchfield/sub_models/cylinder_with_leafs.urdf deleted file mode 100755 index 9f14fdd0e6e77233f6f5cebb73d39a728cdcc43e..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/cylinder_with_leafs.urdf +++ /dev/null @@ -1,121 +0,0 @@ -<?xml version="1.0"?> -<robot name="cylinder_with_leafs"> - - - <link name="cylinder"> - <static>true</static> - <inertial> - <!-- <mass value="1"/> --> - <!-- <inertia ixx="0.04106" ixy="0.0" ixz="0.0" iyy="0.04106" iyz="0.0" izz="0.00045" /> --> - <!-- the inertia is super high, to make the object unmovable --> - <mass value="999"/> - <inertia ixx="999" ixy="0.0" ixz="0.0" iyy="999" iyz="0.0" izz="999" /> - <origin xyz="0 0 0"/> - </inertial> - <visual> - <geometry> - <cylinder length="0.7" radius="0.03"/> - </geometry> - </visual> - <collision> - <geometry> - <cylinder length="0.7" radius="0.03"/> - </geometry> - </collision> - </link> - - <link name="leaf1"> - <inertial> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <mass value="0.01" /> - <inertia ixx="0.000075" ixy="0.0" ixz="0.0" iyy="0.0000084" iyz="0.0" izz="0.000083" /> - </inertial> - <visual> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <geometry> - <box size="0.01 0.05 0.3" /> - </geometry> - </visual> - <collision> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <geometry> - <box size="0.01 0.05 0.3" /> - </geometry> - </collision> - </link> - - <link name="leaf2"> - <inertial> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <mass value="0.01" /> - <inertia ixx="0.000075" ixy="0.0" ixz="0.0" iyy="0.0000084" iyz="0.0" izz="0.000083" /> - </inertial> - <visual> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <geometry> - <box size="0.01 0.05 0.3" /> - </geometry> - </visual> - <collision> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <geometry> - <box size="0.01 0.05 0.3" /> - </geometry> - </collision> - </link> - - <joint name="cylinder_to_leaf1" type="revolute"> - <parent link="cylinder" /> - <child link="leaf1" /> - <origin xyz="0 0.2 0.7" /> - <axis xyz="0 1 0" /> - <limit upper="3.14" lower="-3.14" effort="9999" velocity="9999" /> - <dynamics damping="0.001" friction="0.003"/> - </joint> - - <joint name="cylinder_to_leaf2" type="revolute"> - <parent link="cylinder" /> - <child link="leaf2" /> - <origin xyz="0 -0.2 0.7" /> - <axis xyz="0 1 0" /> - <limit upper="3.14" lower="-3.14" effort="9999" velocity="9999" /> - <dynamics damping="0.001" friction="0.003"/> - </joint> - - - <gazebo reference="cylinder"> - <visual> - <material> - <ambient>0.0 0.0 0.0 1.0</ambient> - <diffuse>0.0 0.0 0.0 1.0</diffuse> - <specular>0.0 0.0 0.0 1.0</specular> - <emissive>0.0 0.0 0.0 0.0</emissive> - </material> - </visual> - </gazebo> - - <gazebo reference="leaf1"> - <visual> - <material> - <ambient>0.0 0.0 0.0 1.0</ambient> - <diffuse>0.0 0.0 0.0 1.0</diffuse> - <specular>0.0 0.0 0.0 1.0</specular> - <emissive>0.0 0.0 0.0 0.0</emissive> - </material> - </visual> - </gazebo> - - <gazebo reference="leaf2"> - <visual> - <material> - <ambient>0.0 0.0 0.0 1.0</ambient> - <diffuse>0.0 0.0 0.0 1.0</diffuse> - <specular>0.0 0.0 0.0 1.0</specular> - <emissive>0.0 0.0 0.0 0.0</emissive> - </material> - </visual> - </gazebo> - -</robot> - - diff --git a/fre_matchfield/sub_models/cylinders_with_leafs.urdf b/fre_matchfield/sub_models/cylinders_with_leafs.urdf deleted file mode 100755 index bdec0a15d202dabe974ff5acf2a56038db27eb00..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/cylinders_with_leafs.urdf +++ /dev/null @@ -1,121 +0,0 @@ -<?xml version="1.0"?> -<robot name="cylinder_with_leafs"> - - - <link name="cylinder"> - <static>true</static> - <inertial> - <!-- <mass value="1"/> --> - <!-- <inertia ixx="0.04106" ixy="0.0" ixz="0.0" iyy="0.04106" iyz="0.0" izz="0.00045" /> --> - <!-- the inertia is super high, to make the object unmovable --> - <mass value="999"/> - <inertia ixx="999" ixy="0.0" ixz="0.0" iyy="999" iyz="0.0" izz="999" /> - <origin xyz="0 0 0"/> - </inertial> - <visual> - <geometry> - <cylinder length="0.7" radius="0.03"/> - </geometry> - </visual> - <collision> - <geometry> - <cylinder length="0.7" radius="0.03"/> - </geometry> - </collision> - </link> - - <link name="leaf1"> - <inertial> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <mass value="0.01" /> - <inertia ixx="0.000075" ixy="0.0" ixz="0.0" iyy="0.0000084" iyz="0.0" izz="0.000083" /> - </inertial> - <visual> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <geometry> - <box size="0.01 0.05 0.3" /> - </geometry> - </visual> - <collision> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <geometry> - <box size="0.01 0.05 0.3" /> - </geometry> - </collision> - </link> - - <link name="leaf2"> - <inertial> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <mass value="0.01" /> - <inertia ixx="0.000075" ixy="0.0" ixz="0.0" iyy="0.0000084" iyz="0.0" izz="0.000083" /> - </inertial> - <visual> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <geometry> - <box size="0.01 0.05 0.3" /> - </geometry> - </visual> - <collision> - <origin rpy="0 0 0" xyz="0 0 -0.8"/> - <geometry> - <box size="0.01 0.05 0.3" /> - </geometry> - </collision> - </link> - - <joint name="cylinder_to_leaf1" type="revolute"> - <parent link="cylinder" /> - <child link="leaf1" /> - <origin xyz="0 0.2 0.7" /> - <axis xyz="0 1 0" /> - <limit upper="3.14" lower="-3.14" effort="9999" velocity="9999" /> - <dynamics damping="0.001" friction="0.003"/> - </joint> - - <joint name="cylinder_to_leaf2" type="revolute"> - <parent link="cylinder" /> - <child link="leaf2" /> - <origin xyz="0 -0.2 0.7" /> - <axis xyz="1 0 0" /> - <limit upper="3.14" lower="-3.14" effort="9999" velocity="9999" /> - <dynamics damping="0.001" friction="0.003"/> - </joint> - - - <gazebo reference="cylinder"> - <visual> - <material> - <ambient>0.0 0.0 0.0 1.0</ambient> - <diffuse>0.0 0.0 0.0 1.0</diffuse> - <specular>0.0 0.0 0.0 1.0</specular> - <emissive>0.0 0.0 0.0 0.0</emissive> - </material> - </visual> - </gazebo> - - <gazebo reference="leaf1"> - <visual> - <material> - <ambient>0.0 0.0 0.0 1.0</ambient> - <diffuse>0.0 0.0 0.0 1.0</diffuse> - <specular>0.0 0.0 0.0 1.0</specular> - <emissive>0.0 0.0 0.0 0.0</emissive> - </material> - </visual> - </gazebo> - - <gazebo reference="leaf2"> - <visual> - <material> - <ambient>0.0 0.0 0.0 1.0</ambient> - <diffuse>0.0 0.0 0.0 1.0</diffuse> - <specular>0.0 0.0 0.0 1.0</specular> - <emissive>0.0 0.0 0.0 0.0</emissive> - </material> - </visual> - </gazebo> - -</robot> - - diff --git a/fre_matchfield/sub_models/golf_ball/golf_ball.urdf b/fre_matchfield/sub_models/golf_ball/golf_ball.urdf deleted file mode 100755 index f77fc9dcba8d1b215ab972c71e40572ab31a9009..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/golf_ball/golf_ball.urdf +++ /dev/null @@ -1,39 +0,0 @@ -<?xml version="1.0"?> -<robot name="golfball"> - - <link name="my_sphere"> - <inertial> - <origin xyz="0 0 0"/> - <mass value="999" /> - - <inertia ixx="999" ixy="0.0" ixz="0.0" iyy="999" iyz="0.0" izz="999" /> - </inertial> - - <visual> - <origin xyz="0 0 0"/> - <geometry> - <sphere radius="0.025"/> - </geometry> - </visual> - - <collision> - <origin xyz="0 0 0"/> - <geometry> - <sphere radius="0.025"/> - </geometry> - </collision> - </link> - - <gazebo reference="my_sphere"> - <visual> - <material> - <script> - <uri>model://golf_ball/materials/scripts</uri> - <uri>model://golf_ball/materials/textures</uri> - <name>golfball/Diffuse</name> - </script> - </material> - </visual> - </gazebo> - -</robot> diff --git a/fre_matchfield/sub_models/golf_ball/materials/scripts/example.material b/fre_matchfield/sub_models/golf_ball/materials/scripts/example.material deleted file mode 100755 index 8a6c747c8f7890905654bd4588ad6cda4eed69ae..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/golf_ball/materials/scripts/example.material +++ /dev/null @@ -1,14 +0,0 @@ -material golfball/Diffuse -{ - receive_shadows off - technique - { - pass - { - texture_unit - { - texture golfball.png - } - } - } -} diff --git a/fre_matchfield/sub_models/golf_ball/materials/textures/golfball.png b/fre_matchfield/sub_models/golf_ball/materials/textures/golfball.png deleted file mode 100755 index db6902bfea6df47be5a0391851d2bfcd521338f3..0000000000000000000000000000000000000000 Binary files a/fre_matchfield/sub_models/golf_ball/materials/textures/golfball.png and /dev/null differ diff --git a/fre_matchfield/sub_models/golf_ball/materials/textures/golfball1.png b/fre_matchfield/sub_models/golf_ball/materials/textures/golfball1.png deleted file mode 100755 index d6109b141a76d6b3e720d152de228add96e8be20..0000000000000000000000000000000000000000 Binary files a/fre_matchfield/sub_models/golf_ball/materials/textures/golfball1.png and /dev/null differ diff --git a/fre_matchfield/sub_models/how to add textures b/fre_matchfield/sub_models/how to add textures deleted file mode 100755 index 510fb8c0170275079b6ce23349f5fcd0b4ee7eff..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/how to add textures +++ /dev/null @@ -1,8 +0,0 @@ -Add groundplane -https://answers.gazebosim.org//question/4761/how-to-build-a-world-with-real-image-as-ground-plane/ - -use textures, eg textures from -https://opengameart.org/content/arid-ground-textures - -Apply textures to SDF see -https://www.theconstructsim.com/gazebo-5-minutes-006-use-image-file-texture-gazebo-model-2/ diff --git a/fre_matchfield/sub_models/my_ground_plane/materials/scripts/my_ground_plane.material b/fre_matchfield/sub_models/my_ground_plane/materials/scripts/my_ground_plane.material deleted file mode 100755 index cc2313bc0eaa8fce7da5d0a7acb72f582ba318be..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/my_ground_plane/materials/scripts/my_ground_plane.material +++ /dev/null @@ -1,18 +0,0 @@ - material MyGroundPlane/Image - { - technique - { - pass - { - ambient 0.5 0.5 0.5 1.0 - diffuse 1.0 1.0 1.0 1.0 - specular 0.0 0.0 0.0 1.0 0.5 - - texture_unit - { - texture soil.jpg - filtering trilinear - } - } - } - } diff --git a/fre_matchfield/sub_models/my_ground_plane/materials/textures/soil.jpg b/fre_matchfield/sub_models/my_ground_plane/materials/textures/soil.jpg deleted file mode 100755 index 4fbc94c9bc01a09b9db71312429c770c4b200e9a..0000000000000000000000000000000000000000 Binary files a/fre_matchfield/sub_models/my_ground_plane/materials/textures/soil.jpg and /dev/null differ diff --git a/fre_matchfield/sub_models/my_ground_plane/model.config b/fre_matchfield/sub_models/my_ground_plane/model.config deleted file mode 100755 index 6ec19ce69ed63d6efa6e6cb696db2dbe5634bd9d..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/my_ground_plane/model.config +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0"?> -<model> - <name>My Ground Plane</name> - <version>1.0</version> - <sdf version="1.6">model.sdf</sdf> - - <description> - groundplane. - </description> -</model> diff --git a/fre_matchfield/sub_models/my_ground_plane/model.sdf b/fre_matchfield/sub_models/my_ground_plane/model.sdf deleted file mode 100755 index 9fc269cf627d455b2b0923db66519eff397348fc..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/my_ground_plane/model.sdf +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0"?> -<sdf version="1.4"> -<model name="my_ground_plane"> - <static>true</static> - <link name="link"> - <collision name="collision"> - <geometry> - <plane> - <normal>0 0 1</normal> - <size>100 100</size> - </plane> - </geometry> - <surface> - <friction> - <ode> - <mu>100</mu> - <mu2>50</mu2> - </ode> - </friction> - </surface> - </collision> - <visual name="visual"> - <cast_shadows>false</cast_shadows> - <geometry> - <plane> - <normal>0 0 1</normal> - <size>20 20</size> - </plane> - </geometry> - <material> - <script> - <uri>model://my_ground_plane/materials/scripts</uri> - <uri>model://my_ground_plane/materials/textures</uri> - <name>MyGroundPlane/Image</name> - </script> - </material> - </visual> - </link> - </model> -</sdf> diff --git a/fre_matchfield/sub_models/pebble.urdf b/fre_matchfield/sub_models/pebble.urdf deleted file mode 100755 index d5d27b29df38408790dba6ad0a8b5fb98750394a..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/pebble.urdf +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0"?> -<robot name="simple_box"> - <link name="my_sphere"> - <inertial> - <origin xyz="0 0 0"/> - <mass value="99" /> - <!-- the inertia is super high, to make the object unmovable --> - <inertia ixx="999" ixy="0.0" ixz="0.0" iyy="999" iyz="0.0" izz="999" /> - </inertial> - - <visual> - <origin xyz="0 0 0"/> - <geometry> - <sphere radius=0.025/> - </geometry> - </visual> - - <collision> - <origin xyz="0 0 0"/> - <geometry> - <sphere radius=0.0125/> - </geometry> - </collision> - - </link> - <gazebo reference="my_sphere"> - <visual> - <material> - <ambient>0.0 0.0 0.0 1.0</ambient> - <diffuse>0.0 0.0 0.0 1.0</diffuse> - <specular>0.0 0.0 0.0 1.0</specular> - <emissive>0.0 0.0 0.0 0.0</emissive> - </material> - </visual> - </gazebo> - - <!-- make the entire model static - <gazebo> - <static>true</static> - </gazebo> - --> -</robot> diff --git a/fre_matchfield/sub_models/pink_ball/model.config b/fre_matchfield/sub_models/pink_ball/model.config deleted file mode 100755 index 19dd9eac7cdfa826a6de4c12eea814bf1b5595ce..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/pink_ball/model.config +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<model> - <name>pink_ball</name> - <version>0.1.0</version> - <author> - <name>Jetze</name> - <email>jetze.vanheelsum@wur.nl</email> - </author> - <sdf>model.sdf</sdf> - <description> - spawn pink ball for mapping and detection of task 3 - </description> -</model> \ No newline at end of file diff --git a/fre_matchfield/sub_models/pink_ball/model.sdf b/fre_matchfield/sub_models/pink_ball/model.sdf deleted file mode 100755 index 1a92c13b0bf3e42b82e11d9f43bf05f59e5e1a71..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/pink_ball/model.sdf +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" ?> -<sdf version="1.4"> - <model name="maize"> - <static>false</static> - <link name="link"> - <inertial> - <pose>0 0 0 0 0 0</pose> - <mass>0.050</mass> - <inertia> - <ixx>1.25e-5</ixx> - <ixy>0.0</ixy> - <ixz>0.0</ixz> - <iyy>1.25e-5</iyy> - <iyz>0.0</iyz> - <izz>1.25e-5</izz> - </inertia> - </inertial> - <collision name="collision"> - <pose>0 0 0 0 0 0</pose> - <geometry> - <sphere> - <radius>0.025</radius> - </sphere> - </geometry> - </collision> - <visual name="visual"> - <pose>0 0 0 0 0 0</pose> - <geometry> - <sphere> - <radius>0.025</radius> - </sphere> - </geometry> - <material> - <ambient>1 0 0.5 1</ambient> - <diffuse>1 0 0.5 1</diffuse> - <specular>1 1 1 1</specular> - </material> - </visual> - </link> - </model> -</sdf> diff --git a/fre_matchfield/sub_models/sphere.urdf b/fre_matchfield/sub_models/sphere.urdf deleted file mode 100755 index 893bd52e7cef14831a8550123f0167b4d91ce844..0000000000000000000000000000000000000000 --- a/fre_matchfield/sub_models/sphere.urdf +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> -<robot name="simple_box"> - <link name="my_sphere"> - <inertial> - <origin xyz="0 0 0"/> - <mass value="0.01" /> - <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="100.0" iyz="0.0" izz="1.0" /> - </inertial> - - <visual> - <origin xyz="0 0 0"/> - <geometry> - <sphere radius=0.075/> - </geometry> - </visual> - - <collision> - <origin xyz="0 0 0"/> - <geometry> - <sphere radius=0.075/> - </geometry> - </collision> - - </link> - <gazebo reference="my_sphere"> - <visual> - <material> - <ambient>0.0 0.0 0.0 1.0</ambient> - <diffuse>0.0 0.0 0.0 1.0</diffuse> - <specular>0.0 0.0 0.0 1.0</specular> - <emissive>0.0 0.0 0.0 0.0</emissive> - </material> - </visual> - </gazebo> -</robot> diff --git a/install_requirements.sh b/install_requirements.sh index c3bab04ea9d43c8bcdc27aa695e67a1c830c9955..ca87c6ea11d60c22aa953ab684f378c247525317 100755 --- a/install_requirements.sh +++ b/install_requirements.sh @@ -11,18 +11,21 @@ echo "Please wait while your working environment is setup" # install git and configure git apt-get -y install git -git clone https://git.wur.nl/ruigr004/fre_virtual_event.git +# git clone https://git.wur.nl/ruigr004/fre_virtual_event.git # install ROS melodic # ======================================= # your computer must accept packages from ros sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 -#apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 apt-get update + # install ros melodic apt-get -y install ros-melodic-desktop-full +# install the jackal software +sudo apt-get -y install ros-melodic-jackal-simulator ros-melodic-jackal-desktop ros-melodic-jackal-navigation + apt-get update apt-get -y upgrade @@ -30,7 +33,7 @@ apt-get -y upgrade grep -q -F "source /opt/ros/melodic/setup.bash" ~/.bashrc || echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc # add gazebo model path to the bashrc -grep -q -F "export GAZEBO_MODEL_PATH=~/fre_virtual_event/simple_world/:$GAZEBO_MODEL_PATH" ~/.bashrc || echo "export GAZEBO_MODEL_PATH=~/fre_virtual_event/simple_world/:$GAZEBO_MODEL_PATH" >> ~/.bashrc +grep -q -F "export GAZEBO_MODEL_PATH=~/fre_virtual_event/simple_world/:\$GAZEBO_MODEL_PATH" ~/.bashrc || echo "export GAZEBO_MODEL_PATH=~/fre_virtual_event/simple_world/:\$GAZEBO_MODEL_PATH" >> ~/.bashrc # update the current terminal with the newly added settings source ~/.bashrc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 120000 index 0000000000000000000000000000000000000000..66dd650aca8bc895ebfd0001a46559de60baee2c --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1 @@ +/opt/ros/melodic/share/catkin/cmake/toplevel.cmake \ No newline at end of file diff --git a/src/simple_world/CMakeLists.txt b/src/simple_world/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..cdd699e4bd28a920224ae096c745e5610c254a3f --- /dev/null +++ b/src/simple_world/CMakeLists.txt @@ -0,0 +1,202 @@ +cmake_minimum_required(VERSION 3.0.2) +project(simple_world) + +## Compile as C++11, supported in ROS Kinetic and newer +# add_compile_options(-std=c++11) + +## Find catkin macros and libraries +## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) +## is used, also find other catkin packages +find_package(catkin REQUIRED) + +## System dependencies are found with CMake's conventions +# find_package(Boost REQUIRED COMPONENTS system) + + +## Uncomment this if the package has a setup.py. This macro ensures +## modules and global scripts declared therein get installed +## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html +# catkin_python_setup() + +################################################ +## Declare ROS messages, services and actions ## +################################################ + +## To declare and build messages, services or actions from within this +## package, follow these steps: +## * Let MSG_DEP_SET be the set of packages whose message types you use in +## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). +## * In the file package.xml: +## * add a build_depend tag for "message_generation" +## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET +## * If MSG_DEP_SET isn't empty the following dependency has been pulled in +## but can be declared for certainty nonetheless: +## * add a exec_depend tag for "message_runtime" +## * In this file (CMakeLists.txt): +## * add "message_generation" and every package in MSG_DEP_SET to +## find_package(catkin REQUIRED COMPONENTS ...) +## * add "message_runtime" and every package in MSG_DEP_SET to +## catkin_package(CATKIN_DEPENDS ...) +## * uncomment the add_*_files sections below as needed +## and list every .msg/.srv/.action file to be processed +## * uncomment the generate_messages entry below +## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) + +## Generate messages in the 'msg' folder +# add_message_files( +# FILES +# Message1.msg +# Message2.msg +# ) + +## Generate services in the 'srv' folder +# add_service_files( +# FILES +# Service1.srv +# Service2.srv +# ) + +## Generate actions in the 'action' folder +# add_action_files( +# FILES +# Action1.action +# Action2.action +# ) + +## Generate added messages and services with any dependencies listed here +# generate_messages( +# DEPENDENCIES +# std_msgs # Or other packages containing msgs +# ) + +################################################ +## Declare ROS dynamic reconfigure parameters ## +################################################ + +## To declare and build dynamic reconfigure parameters within this +## package, follow these steps: +## * In the file package.xml: +## * add a build_depend and a exec_depend tag for "dynamic_reconfigure" +## * In this file (CMakeLists.txt): +## * add "dynamic_reconfigure" to +## find_package(catkin REQUIRED COMPONENTS ...) +## * uncomment the "generate_dynamic_reconfigure_options" section below +## and list every .cfg file to be processed + +## Generate dynamic reconfigure parameters in the 'cfg' folder +# generate_dynamic_reconfigure_options( +# cfg/DynReconf1.cfg +# cfg/DynReconf2.cfg +# ) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if your package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( +# INCLUDE_DIRS include +# LIBRARIES simple_world +# CATKIN_DEPENDS other_catkin_pkg +# DEPENDS system_lib +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +include_directories( +# include +# ${catkin_INCLUDE_DIRS} +) + +## Declare a C++ library +# add_library(${PROJECT_NAME} +# src/${PROJECT_NAME}/simple_world.cpp +# ) + +## Add cmake target dependencies of the library +## as an example, code may need to be generated before libraries +## either from message generation or dynamic reconfigure +# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Declare a C++ executable +## With catkin_make all packages are built within a single CMake context +## The recommended prefix ensures that target names across packages don't collide +# add_executable(${PROJECT_NAME}_node src/simple_world_node.cpp) + +## Rename C++ executable without prefix +## The above recommended prefix causes long target names, the following renames the +## target back to the shorter version for ease of user use +## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" +# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "") + +## Add cmake target dependencies of the executable +## same as for the library above +# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Specify libraries to link a library or executable target against +# target_link_libraries(${PROJECT_NAME}_node +# ${catkin_LIBRARIES} +# ) + +############# +## Install ## +############# + +# all install targets should use catkin DESTINATION variables +# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html + +## Mark executable scripts (Python etc.) for installation +## in contrast to setup.py, you can choose the destination +# catkin_install_python(PROGRAMS +# scripts/my_python_script +# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark executables for installation +## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html +# install(TARGETS ${PROJECT_NAME}_node +# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark libraries for installation +## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html +# install(TARGETS ${PROJECT_NAME} +# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} +# ) + +## Mark cpp header files for installation +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +# FILES_MATCHING PATTERN "*.h" +# PATTERN ".svn" EXCLUDE +# ) + +## Mark other files for installation (e.g. launch and bag files, etc.) +# install(FILES +# # myfile1 +# # myfile2 +# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +# ) + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test_simple_world.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) diff --git a/src/simple_world/launch/mais_world.launch b/src/simple_world/launch/mais_world.launch new file mode 100644 index 0000000000000000000000000000000000000000..1ba81457d5e6ac0e6d8e5091d05dfb817cfd59b2 --- /dev/null +++ b/src/simple_world/launch/mais_world.launch @@ -0,0 +1,12 @@ +<?xml version='1.0'?> +<launch> +<!-- Launch Gazebo with the specified world --> + <include file="$(find gazebo_ros)/launch/empty_world.launch"> + <!-- <arg name="world_name" value="~/fre_virtual_event/simple_world/simple_world.world"/> --> + <arg name="use_sim_time" value="true"/> + <arg name="gui" value="true"/> + <arg name="paused" value="false"/> + <arg name="headless" value="false"/> + <arg name="recording" value="false"/> + </include> +</launch> diff --git a/src/simple_world/launch/simple_world.launch b/src/simple_world/launch/simple_world.launch new file mode 100644 index 0000000000000000000000000000000000000000..9c6fb7af569f2de289e29b5a37d302e4f44e0f3a --- /dev/null +++ b/src/simple_world/launch/simple_world.launch @@ -0,0 +1,40 @@ +<?xml version='1.0'?> +<launch> + <arg name="use_sim_time" default="true" /> + <arg name="gui" default="true" /> + <arg name="headless" default="false" /> + <arg name="world_name" default="~/fre_virtual_event/simple_world/simple_world.world" /> + + <!-- Short-term hack to support the original front_laser:=true argument for spawning + the simulator. This will be removed in favour of using the config:=x arg instead. --> + <arg name="front_laser" default="false" /> + <arg name="default_config" value="front_laser" if="$(arg front_laser)" /> + <arg name="default_config" value="base" unless="$(arg front_laser)" /> + <!-- end of hack --> + + <!-- Configuration of Jackal which you would like to simulate. + See jackal_description for details. --> + <arg name="config" default="$(arg default_config)" /> + + <!-- Optionally enable teleop for the simulation --> + <arg name="joystick" default="true" /> + + <!-- Launch Gazebo with the specified world --> + <include file="$(find gazebo_ros)/launch/empty_world.launch"> + <arg name="debug" value="0" /> + <arg name="gui" value="$(arg gui)" /> + <arg name="use_sim_time" value="$(arg use_sim_time)" /> + <arg name="headless" value="$(arg headless)" /> + <arg name="world_name" value="$(arg world_name)" /> + </include> + + <!-- Spawn Jackal --> + <include file="$(find jackal_gazebo)/launch/spawn_jackal.launch"> + <arg name="x" value="-0.75" /> + <arg name="y" value="0.35" /> + <arg name="z" value="1.0" /> + <arg name="yaw" value="0" /> + <arg name="config" value="$(arg config)" /> + <arg name="joystick" value="$(arg joystick)" /> + </include> +</launch> diff --git a/simple_world/maize_cylinder/model.config b/src/simple_world/maize_cylinder/model.config similarity index 86% rename from simple_world/maize_cylinder/model.config rename to src/simple_world/maize_cylinder/model.config index c2783d44427786d1d43564cdb00553490c8f699d..e3af232e9f24e89e0342a8f289ef497e03816a00 100644 --- a/simple_world/maize_cylinder/model.config +++ b/src/simple_world/maize_cylinder/model.config @@ -3,7 +3,7 @@ <model> <name>maize_cylinder</name> <version>1.0</version> - <sdf version="1.5">model.sdf</sdf> + <sdf version="1.6">model.sdf</sdf> <author> <name>Thijs Ruigrok</name> diff --git a/simple_world/maize_cylinder/model.sdf b/src/simple_world/maize_cylinder/model.sdf similarity index 98% rename from simple_world/maize_cylinder/model.sdf rename to src/simple_world/maize_cylinder/model.sdf index 323055b13b03cf023f33a41900ff60759ca8c461..73b145408a64609f48fda1470437a5d9b76c99c8 100644 --- a/simple_world/maize_cylinder/model.sdf +++ b/src/simple_world/maize_cylinder/model.sdf @@ -1,5 +1,5 @@ <?xml version='1.0'?> -<sdf version="1.5"> +<sdf version="1.6"> <model name="maize_cylinder"> <pose>0 0 0.5 0 0 0</pose> <static>true</static> diff --git a/src/simple_world/package.xml b/src/simple_world/package.xml new file mode 100644 index 0000000000000000000000000000000000000000..28e41be4c25c47f48863de6929d9debe4c338b96 --- /dev/null +++ b/src/simple_world/package.xml @@ -0,0 +1,59 @@ +<?xml version="1.0"?> +<package format="2"> + <name>simple_world</name> + <version>0.0.0</version> + <description>The simple_world package</description> + + <!-- One maintainer tag required, multiple allowed, one person per tag --> + <!-- Example: --> + <!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> --> + <maintainer email="fre@todo.todo">fre</maintainer> + + + <!-- One license tag required, multiple allowed, one license per tag --> + <!-- Commonly used license strings: --> + <!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 --> + <license>TODO</license> + + + <!-- Url tags are optional, but multiple are allowed, one per tag --> + <!-- Optional attribute type can be: website, bugtracker, or repository --> + <!-- Example: --> + <!-- <url type="website">http://wiki.ros.org/simple_world</url> --> + + + <!-- Author tags are optional, multiple are allowed, one per tag --> + <!-- Authors do not have to be maintainers, but could be --> + <!-- Example: --> + <!-- <author email="jane.doe@example.com">Jane Doe</author> --> + + + <!-- The *depend tags are used to specify dependencies --> + <!-- Dependencies can be catkin packages or system dependencies --> + <!-- Examples: --> + <!-- Use depend as a shortcut for packages that are both build and exec dependencies --> + <!-- <depend>roscpp</depend> --> + <!-- Note that this is equivalent to the following: --> + <!-- <build_depend>roscpp</build_depend> --> + <!-- <exec_depend>roscpp</exec_depend> --> + <!-- Use build_depend for packages you need at compile time: --> + <!-- <build_depend>message_generation</build_depend> --> + <!-- Use build_export_depend for packages you need in order to build against this package: --> + <!-- <build_export_depend>message_generation</build_export_depend> --> + <!-- Use buildtool_depend for build tool packages: --> + <!-- <buildtool_depend>catkin</buildtool_depend> --> + <!-- Use exec_depend for packages you need at runtime: --> + <!-- <exec_depend>message_runtime</exec_depend> --> + <!-- Use test_depend for packages you need only for testing: --> + <!-- <test_depend>gtest</test_depend> --> + <!-- Use doc_depend for packages you need only for building documentation: --> + <!-- <doc_depend>doxygen</doc_depend> --> + <buildtool_depend>catkin</buildtool_depend> + + + <!-- The export tag contains other, unspecified, tags --> + <export> + <!-- Other tools can request additional information be placed here --> + + </export> +</package> diff --git a/simple_world/simple_world.world b/src/simple_world/simple_world.world similarity index 97% rename from simple_world/simple_world.world rename to src/simple_world/simple_world.world index eb3ea6e3d89e6e3856efa2a3be158ee216537d32..81cfd6ad510da17c3a5f19d0cda82546034b6f4f 100644 --- a/simple_world/simple_world.world +++ b/src/simple_world/simple_world.world @@ -1,5 +1,5 @@ <?xml version="1.0" ?> -<sdf version="1.5"> +<sdf version="1.6"> <world name="default"> <!-- A global light source -->