diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 11e7ef7e00..448b0f7572 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -63,7 +63,33 @@ configure_file( install(FILES ${model_configured} DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/ignition/) +#=============================================================================== +# Used for the installed model command version. +# Generate the ruby script that gets installed. +# Note that the major version of the library is included in the name. +set(cmd_model_script_generated "${CMAKE_CURRENT_BINARY_DIR}/cmdpkg_create${PROJECT_VERSION_MAJOR}.rb") +set(cmd_model_script_configured "${cmd_model_script_generated}.configured") +configure_file( + "cmdpkg_create.rb.in" + "${cmd_model_script_configured}" + @ONLY) +file(GENERATE + OUTPUT "${cmd_model_script_generated}" + INPUT "${cmd_model_script_configured}") + +install(FILES ${cmd_model_script_generated} DESTINATION lib/ruby/ignition) +install(DIRECTORY resources + DESTINATION lib/ruby/ignition) +# Used for the installed version. +set(ign_model_ruby_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmdpkg_create${PROJECT_VERSION_MAJOR}") + +set(model_configured "${CMAKE_CURRENT_BINARY_DIR}/pkg_create{PROJECT_VERSION_MAJOR}.yaml") +configure_file( + "pkg_create.yaml.in" + ${model_configured}) + +install(FILES ${model_configured} DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/ignition/) #=============================================================================== # Generate the ruby script for internal testing. # Note that the major version of the library is included in the name. diff --git a/src/cmd/cmdpkg_create.rb.in b/src/cmd/cmdpkg_create.rb.in new file mode 100644 index 0000000000..df28889611 --- /dev/null +++ b/src/cmd/cmdpkg_create.rb.in @@ -0,0 +1,248 @@ +#!/usr/bin/ruby +require 'erb' +require 'open-uri' +require 'yaml' +require 'ostruct' + +# Copyright (C) 2022 Open Source Robotics Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# We use 'dl' for Ruby <= 1.9.x and 'fiddle' for Ruby >= 2.0.x +if RUBY_VERSION.split('.')[0] < '2' + require 'dl' + require 'dl/import' + include DL +else + require 'fiddle' + require 'fiddle/import' + include Fiddle +end + +require 'optparse' + +# Constants. +LIBRARY_NAME = '@library_location@' +LIBRARY_VERSION = '@PROJECT_VERSION_FULL@' + +COMMON_OPTIONS = + " -h [--help] Print this help message.\n"\ + " \n" + + " --force-version Use a specific library version.\n"\ + " \n" + + ' --versions Show the available versions.' + +COMMANDS = { 'pkg_create' => + "Create a new ignition package.\n"+ + " \n"\ + " ign pkg_create [options] \n\n"\ + " \n"\ + "Available Options: \n\n"\ + " -n [--name] arg Name of new package [Required] \n\n"\ + " -i [--init-with-example-system] Package with various example resources \n\n"+ + " -b [--built_type] arg Build type between ament_cmake or cmake \n\n"+ + " -e [--export_type] arg Export type between colcon or plain-camke] \n\n"+ + " -d [--ign_dependecies] Package depends on common ign packages \n\n"+ + " -g [--gazebo_version] arg Gazebo version name for dependencies \n\n"+ + + COMMON_OPTIONS +} + +# +# Class for the Gazebo pkg_create command line tools. +# +class Cmd + + # + # Return a structure describing the options. + # + def parse(args) + options = { + } + usage = COMMANDS[args[0]] + + opt_parser = OptionParser.new do |opts| + opts.banner = usage + + opts.on('-h', '--help') do + puts usage + exit + end + opts.on('-n [arg]', '--name [arg]', String, 'Name of new package') do |n| + options['name'] = n + end + opts.on('-i','--init-with-example-system', String, 'Package with various example resources') do + options['init-with-example-system'] = 1 + end + opts.on('-b [arg]', '--built_type [arg]', String, 'Build type between ament_cmake or cmake') do |b| + options['built_type'] = b + end + opts.on('-e [arg]', '--export_type [arg]', String, 'Export type between colcon or plain-camke') do |e| + options['export_type'] = e + end + opts.on('-d','--ign_dependecies', String, 'Package depends on common ign packages') do + options['ign_dependecies'] = 1 + end + opts.on('-g [arg]', '--gazebo_version [arg]',String, 'Gazebo version name for dependencies') do |g| + options['gazebo_version'] = g + end + + end # opt_parser do + begin + opt_parser.parse!(args) + rescue + puts usage + exit(-1) + end + + # Check if all options are correct + + if !(options.key?('name') && options['name'].class()==String) + puts "ERROR: Please provide proper package name.\n" + puts usage + exit(-1) + end + if (options.key?('built_type') && !(['ament_cmake','cmake'].include? options["built_type"])) + puts "WARNING: Invalid Built-type,defaulting to cmake\n" + options['built_type'] = "cmake" + end + if (options.key?('export_type') && !(['plain_cmake','colcon'].include? options["export_type"])) + puts "WARNING: Invalid Export-type,defaulting to colcon\n" + options['export_type'] = "colcon" + end + if (options.key?('gazebo_version') && !(['acropolis','blueprint','citadel','dome','edifice','fortress','garden'].include? options["gazebo_version"])) + puts "WARNING: Invalid Gazebo Version,defaulting to fortress\n" + options['gazebo_version'] = "fortress" + end + #Giving default values + + if !options.key?('init-with-example-system') + options['init-with-example-system'] = 0 + end + if !options.key?('built_type') + options['built_type'] = "cmake" + end + if !options.key?('export_type') + options['export_type'] = "colcon" + end + if !options.key?('ign_dependecies') + options['ign_dependecies'] = 0 + end + if !options.key?('gazebo_version') + options['gazebo_version'] = "fortress" + end + + options['command'] = args[0] + + options + end # parse() + + def execute(args) + options = parse(args) + + # Read the plugin that handles the command. + if LIBRARY_NAME[0] == '/' + # If the first character is a slash, we'll assume that we've been given an + # absolute path to the library. This is only used during test mode. + plugin = LIBRARY_NAME + else + # We're assuming that the library path is relative to the current + # location of this script. + plugin = File.expand_path(File.join(File.dirname(__FILE__), LIBRARY_NAME)) + end + conf_version = LIBRARY_VERSION + + begin + Importer.dlload plugin + rescue DLError => e + puts "Library error for [#{plugin}]: #{e.to_s}" + exit(-1) + end + + ##Code for package generation + if Dir.exists?(options['name']) + puts "ERROR:Folder with this name already exists." + exit(-1) + end + + #Creates Package folder + Dir.mkdir(options['name']) + + #Fetching dependencies versions for common dependencies + if options['ign_dependecies']==1 + dependencies = URI.open('https://raw.githubusercontent.com/ignition-tooling/gazebodistro/master/collection-%s.yaml'% options['gazebo_version']){|f| f.read} + dependencies_yaml = YAML.load(dependencies) + dependencies_dict={} + for dependency in dependencies_yaml.fetch('repositories').keys + dependencies_dict[dependency]=dependencies_yaml['repositories'][dependency]['version'].scan( /\d+$/ ).first + end + end + + resources_dir=__dir__+"/resources" + + #Creates CMakeLists.txt using erb + cmakelists_render = ERB.new(File.read(resources_dir+"/CMakeLists.erb"),trim_mode: ">") + cmakelists_file = File.new(options['name']+"/CMakeLists.txt", "w") + cmakelists_file.puts(cmakelists_render.result(OpenStruct.new(options).instance_eval { binding })) + cmakelists_file.close + + #Creates package.xml for ament dependent + if options['built_type']=='ament_cmake' + package_xml_render = ERB.new(File.read(resources_dir+"/package_xml.erb"),trim_mode: ">") + package_xml_file = File.new(options['name']+"/package.xml", "w") + package_xml_file.puts(package_xml_render.result(OpenStruct.new(options).instance_eval { binding })) + package_xml_file.close + end + + #Creates example resources for advance package + if options['init-with-example-system']==1 + Dir.mkdir(options['name']+"/worlds") + Dir.mkdir(options['name']+"/models") + Dir.mkdir(options['name']+"/models/elevator") + Dir.mkdir(options['name']+"/plugins") + Dir.mkdir(options['name']+"/src") + + executable_txt=File.read(resources_dir+"/executables/random_points.cc") + executable_file = File.new(options['name']+"/src/random_points.cc", "w") + executable_file.puts(executable_txt) + executable_file.close + + plugin_txt=File.read(resources_dir+"/plugins/HelloWorld.cc") + plugin_file = File.new(options['name']+"/plugins/HelloWorld.cc", "w") + plugin_file.puts(plugin_txt) + plugin_file.close + + plugin_header_txt=File.read(resources_dir+"/plugins/HelloWorld.hh") + plugin_header_file = File.new(options['name']+"/plugins/HelloWorld.hh", "w") + plugin_header_file.puts(plugin_header_txt) + plugin_header_file.close + + world_txt=File.read(resources_dir+"/worlds/empty_platform_with_elevator.sdf") + world_file = File.new(options['name']+"/worlds/empty_platform_with_elevator.sdf", "w") + world_file.puts(world_txt) + world_file.close + + model_config_txt=File.read(resources_dir+"/models/elevator/model.config") + model_config_file = File.new(options['name']+"/models/elevator/model.config", "w") + model_config_file.puts(model_config_txt) + model_config_file.close + + model_sdf_txt=File.read(resources_dir+"/models/elevator/model.sdf") + model_sdf_file = File.new(options['name']+"/models/elevator/model.sdf", "w") + model_sdf_file.puts(model_sdf_txt) + model_sdf_file.close + end + # # execute + end +# class +end diff --git a/src/cmd/pkg_create.yaml.in b/src/cmd/pkg_create.yaml.in new file mode 100644 index 0000000000..ed572c053e --- /dev/null +++ b/src/cmd/pkg_create.yaml.in @@ -0,0 +1,8 @@ +--- # Model subcommand available inside ignition gazebo. +format: 1.0.0 +library_name: ignition-gazebo-ign +library_version: @PROJECT_VERSION_FULL@ +library_path: @ign_model_ruby_path@ +commands: + - pkg_create : Create a new ignition package +--- diff --git a/src/cmd/resources/CMakeLists.erb b/src/cmd/resources/CMakeLists.erb new file mode 100644 index 0000000000..92cc91ea47 --- /dev/null +++ b/src/cmd/resources/CMakeLists.erb @@ -0,0 +1,80 @@ +#These lines will set minimum required version of cmake and declare the name of the project. +cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) +project(<%= options['name'] %>) +<% if options['ign_dependecies']==1 %> + +#This is a list of general packages on which your ignition package will depend,find_package function will find and source theses packages. +#You can add or delete dependencies based on your requirement. +<% if options['built_type']=='ament_cmake' %> +#Since,the package is amnet dependent we will find and call ament_cmake. + +find_package(ament_cmake REQUIRED) +<% end %> + +find_package(ignition-cmake<%= dependencies_dict["ign-cmake"]%> REQUIRED) + +find_package(ignition-gazebo<%= dependencies_dict["ign-gazebo"]%> REQUIRED COMPONENTS gui) +set(IGN_GAZEBO_VER ${ignition-gazebo<%= dependencies_dict["ign-gazebo"]%>_VERSION_MAJOR}) + +find_package(ignition-gui<%= dependencies_dict["ign-gui"]%> REQUIRED) +set(IGN_GUI_VER ${ignition-gui<%= dependencies_dict["ign-gui"]%>_VERSION_MAJOR}) + +find_package(ignition-rendering<%= dependencies_dict["ign-rendering"]%> REQUIRED) +set(IGN_RENDERING_VER ${ignition-rendering<%= dependencies_dict["ign-rendering"]%>_VERSION_MAJOR}) + +find_package(ignition-sensors<%= dependencies_dict["ign-sensors"]%> REQUIRED) +set(IGN_SENSORS_VER ${ignition-sensors<%= dependencies_dict["ign-sensors"]%>_VERSION_MAJOR}) + +find_package(ignition-msgs<%= dependencies_dict["ign-msgs"]%> REQUIRED) +set(IGN_MSGS_VER ${ignition-msgs<%= dependencies_dict["ign-msgs"]%>_VERSION_MAJOR}) + +find_package(ignition-plugin<%= dependencies_dict["ign-plugin"]%> REQUIRED COMPONENTS register) +set(IGN_PLUGIN_VER ${ignition-plugin<%= dependencies_dict["ign-plugin"]%>_VERSION_MAJOR}) + +find_package(ignition-utils<%= dependencies_dict["ign-utils"]%> REQUIRED) +set(IGN_UTILS_VER ${ignition-utils<%= dependencies_dict["ign-utils"]%>_VERSION_MAJOR}) + +find_package(ignition-common<%= dependencies_dict["ign-common"]%> REQUIRED COMPONENTS profiler) +set(IGN_COMMON_VER ${ignition-common<%= dependencies_dict["ign-common"]%>_VERSION_MAJOR}) +<% end %> +<% if options['init-with-example-system']==1 %> + +#These will install directories with various resources like worlds,plugins etc. +ign_add_resources(worlds) +ign_add_resources(models) +ign_export_variable(LD_LIBRARY_PATH @CMAKE_INSTALL_PREFIX@/lib) +ign_add_plugins(plugins COMMON_PUBLIC_LIBRARIES + ignition-gazebo${IGN_GAZEBO_VER}::ignition-gazebo${IGN_GAZEBO_VER} + ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER} + ignition-plugin${IGN_PLUGIN_VER}::ignition-plugin${IGN_PLUGIN_VER}) +ign_add_executables(src COMMON_PUBLIC_LIBRARIES +ignition-msgs${IGN_MSGS_VER}::ignition-msgs${IGN_MSGS_VER}) + +#This line will export paths of all the above mentioned resources. +<% if options['export_type']=="colcon"%> +ign_environment_hook(colcon) +<% end %> +<% if options['export_type']=="plain_cmake"%> +ign_environment_hook(plain-cmake) +<% end %> +<% end %> + +#These line will run tests for the package, if build testing is set to be TRUE +#You can add your tests here + +if(BUILD_TESTING) + +<% if options['built_type']=='ament_cmake' %> +find_package(ament_cmake_gtest REQUIRED) +<% end %> +set("PROJECT_BINARY_PATH" ${CMAKE_CURRENT_BINARY_DIR}) +set("PROJECT_SOURCE_PATH" ${CMAKE_CURRENT_SOURCE_DIR}) + +endif() +<% if options['built_type']=='ament_cmake' %> + +#The project setup is done by ament_package(). +#It installs the package.xml, registers the package with the ament index, and installs config (and possibly target) files +#for CMake so that it can be found by other packages using find_package. +ament_package() +<% end %> diff --git a/src/cmd/resources/executables/random_points.cc b/src/cmd/resources/executables/random_points.cc new file mode 100644 index 0000000000..1bdf3e0ece --- /dev/null +++ b/src/cmd/resources/executables/random_points.cc @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +//This is a sample code showing how an Gazebo simulator executable works +#include +#include +int main() +{ + ignition::msgs::Vector3d point1; + point1.set_x(std::rand()); + point1.set_y(std::rand()); + point1.set_z(std::rand()); + ignition::msgs::Vector3d point2; + point2.set_x(std::rand()); + point2.set_y(std::rand()); + point2.set_z(std::rand()); + std::cout << "Random_point1:\n" << point1.DebugString() << std::endl; + std::cout << "Random_point2:\n" << point2.DebugString() << std::endl; + return 0; +} \ No newline at end of file diff --git a/src/cmd/resources/models/elevator/model.config b/src/cmd/resources/models/elevator/model.config new file mode 100644 index 0000000000..03d08b5b9b --- /dev/null +++ b/src/cmd/resources/models/elevator/model.config @@ -0,0 +1,11 @@ + + + Elevator + 1.0 + model.sdf + + Nick Lamprianidis + nlamprian@gmail.com + + An elevator with configurable number of floors. + diff --git a/src/cmd/resources/models/elevator/model.sdf b/src/cmd/resources/models/elevator/model.sdf new file mode 100644 index 0000000000..7ec8b2e2d2 --- /dev/null +++ b/src/cmd/resources/models/elevator/model.sdf @@ -0,0 +1,1258 @@ + + + + 0 0 0.2 0 0 0 + + + true + 0.0 0.0 0.0 0 0 0 + + 1000 + + 10974.166666666666 + 0 + 0 + 10854.166666666666 + 0 + 546.6666666666667 + + 0 0 3.2 0 0 0 + + + 0.875 0.0 -0.1 0 0 0 + + + 0.15 2.3 0.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.0 -0.1 0 0 0 + + + 0.15 2.3 0.2 + + + + + 0.875 0.0 2.5 0 0 0 + + + 0.15 2.3 1.0 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.0 2.5 0 0 0 + + + 0.15 2.3 1.0 + + + + + 0.875 -0.925 1.0 0 0 0 + + + 0.15 0.45 2.0 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 -0.925 1.0 0 0 0 + + + 0.15 0.45 2.0 + + + + + 0.875 0.925 1.0 0 0 0 + + + 0.15 0.45 2.0 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.925 1.0 0 0 0 + + + 0.15 0.45 2.0 + + + + + 0.0 -1.225 1.4 0 0 0 + + + 1.9 0.15 3.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.0 -1.225 1.4 0 0 0 + + + 1.9 0.15 3.2 + + + + + 0.0 1.225 1.4 0 0 0 + + + 1.9 0.15 3.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.0 1.225 1.4 0 0 0 + + + 1.9 0.15 3.2 + + + + + -1.025 0.0 1.4 0 0 0 + + + 0.15 2.6 3.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + -1.025 0.0 1.4 0 0 0 + + + 0.15 2.6 3.2 + + + + + 1.95 0.0 -0.1 0 0 0 + + + 2.0 4.0 0.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 1.95 0.0 -0.1 0 0 0 + + + 2.0 4.0 0.2 + + + + + 0.875 0.0 3.1 0 0 0 + + + 0.15 2.3 0.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.0 3.1 0 0 0 + + + 0.15 2.3 0.2 + + + + + 0.875 0.0 5.45 0 0 0 + + + 0.15 2.3 0.5 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.0 5.45 0 0 0 + + + 0.15 2.3 0.5 + + + + + 0.875 -0.925 4.2 0 0 0 + + + 0.15 0.45 2.0 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 -0.925 4.2 0 0 0 + + + 0.15 0.45 2.0 + + + + + 0.875 0.925 4.2 0 0 0 + + + 0.15 0.45 2.0 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.925 4.2 0 0 0 + + + 0.15 0.45 2.0 + + + + + 0.0 -1.225 4.35 0 0 0 + + + 1.9 0.15 2.7 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.0 -1.225 4.35 0 0 0 + + + 1.9 0.15 2.7 + + + + + 0.0 1.225 4.35 0 0 0 + + + 1.9 0.15 2.7 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.0 1.225 4.35 0 0 0 + + + 1.9 0.15 2.7 + + + + + -1.025 0.0 4.35 0 0 0 + + + 0.15 2.6 2.7 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + -1.025 0.0 4.35 0 0 0 + + + 0.15 2.6 2.7 + + + + + 1.95 0.0 3.1 0 0 0 + + + 2.0 4.0 0.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 1.95 0.0 3.1 0 0 0 + + + 2.0 4.0 0.2 + + + + + 0.875 0.0 5.8 0 0 0 + + + 0.15 2.3 0.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.0 5.8 0 0 0 + + + 0.15 2.3 0.2 + + + + + 0.875 0.0 8.15 0 0 0 + + + 0.15 2.3 0.5 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.0 8.15 0 0 0 + + + 0.15 2.3 0.5 + + + + + 0.875 -0.925 6.9 0 0 0 + + + 0.15 0.45 2.0 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 -0.925 6.9 0 0 0 + + + 0.15 0.45 2.0 + + + + + 0.875 0.925 6.9 0 0 0 + + + 0.15 0.45 2.0 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.925 6.9 0 0 0 + + + 0.15 0.45 2.0 + + + + + 0.0 -1.225 7.05 0 0 0 + + + 1.9 0.15 2.7 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.0 -1.225 7.05 0 0 0 + + + 1.9 0.15 2.7 + + + + + 0.0 1.225 7.05 0 0 0 + + + 1.9 0.15 2.7 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.0 1.225 7.05 0 0 0 + + + 1.9 0.15 2.7 + + + + + -1.025 0.0 7.05 0 0 0 + + + 0.15 2.6 2.7 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + -1.025 0.0 7.05 0 0 0 + + + 0.15 2.6 2.7 + + + + + 1.95 0.0 5.8 0 0 0 + + + 2.0 4.0 0.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 1.95 0.0 5.8 0 0 0 + + + 2.0 4.0 0.2 + + + + + 0.875 0.0 8.5 0 0 0 + + + 0.15 2.3 0.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.0 8.5 0 0 0 + + + 0.15 2.3 0.2 + + + + + 0.875 0.0 10.85 0 0 0 + + + 0.15 2.3 0.5 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.0 10.85 0 0 0 + + + 0.15 2.3 0.5 + + + + + 0.875 -0.925 9.6 0 0 0 + + + 0.15 0.45 2.0 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 -0.925 9.6 0 0 0 + + + 0.15 0.45 2.0 + + + + + 0.875 0.925 9.6 0 0 0 + + + 0.15 0.45 2.0 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.875 0.925 9.6 0 0 0 + + + 0.15 0.45 2.0 + + + + + 0.0 -1.225 9.75 0 0 0 + + + 1.9 0.15 2.7 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.0 -1.225 9.75 0 0 0 + + + 1.9 0.15 2.7 + + + + + 0.0 1.225 9.75 0 0 0 + + + 1.9 0.15 2.7 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 0.0 1.225 9.75 0 0 0 + + + 1.9 0.15 2.7 + + + + + -1.025 0.0 9.75 0 0 0 + + + 0.15 2.6 2.7 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + -1.025 0.0 9.75 0 0 0 + + + 0.15 2.6 2.7 + + + + + 1.95 0.0 8.5 0 0 0 + + + 2.0 4.0 0.2 + + + + 1.0 1.0 1.0 1 + 1.0 1.0 1.0 1 + 0.1 0.1 0.1 1 + + + + 1.95 0.0 8.5 0 0 0 + + + 2.0 4.0 0.2 + + + + + + world + structure + + + + + 0.85 0.0 1.0 0 0 0 + + 20 + + 9.933333333333334 + 0 + 0 + 6.683333333333333 + 0 + 3.2833333333333328 + + 0 0 0 0 0 0 + + + + + 0.1 1.4 2.0 + + + + 1.0 0.0 0.0 1 + 1.0 0.0 0.0 1 + 0.1 0.1 0.1 1 + + + + + + 0.1 1.4 2.0 + + + + + + structure + door_panel_0 + + 0 1 0 + + 0 + 1.4 + 5000 + 0.1 + + + 30 + + + + + door_0 + 60 + 0 + 40 + -20 + 20 + + + 0.85 0.0 4.2 0 0 0 + + 20 + + 9.933333333333334 + 0 + 0 + 6.683333333333333 + 0 + 3.2833333333333328 + + 0 0 0 0 0 0 + + + + + 0.1 1.4 2.0 + + + + 1.0 0.0 0.0 1 + 1.0 0.0 0.0 1 + 0.1 0.1 0.1 1 + + + + + + 0.1 1.4 2.0 + + + + + + structure + door_panel_1 + + 0 1 0 + + 0 + 1.4 + 5000 + 0.1 + + + 30 + + + + + door_1 + 60 + 0 + 40 + -20 + 20 + + + 0.85 0.0 6.9 0 0 0 + + 20 + + 9.933333333333334 + 0 + 0 + 6.683333333333333 + 0 + 3.2833333333333328 + + 0 0 0 0 0 0 + + + + + 0.1 1.4 2.0 + + + + 1.0 0.0 0.0 1 + 1.0 0.0 0.0 1 + 0.1 0.1 0.1 1 + + + + + + 0.1 1.4 2.0 + + + + + + structure + door_panel_2 + + 0 1 0 + + 0 + 1.4 + 5000 + 0.1 + + + 30 + + + + + door_2 + 60 + 0 + 40 + -20 + 20 + + + 0.85 0.0 9.6 0 0 0 + + 20 + + 9.933333333333334 + 0 + 0 + 6.683333333333333 + 0 + 3.2833333333333328 + + 0 0 0 0 0 0 + + + + + 0.1 1.4 2.0 + + + + 1.0 0.0 0.0 1 + 1.0 0.0 0.0 1 + 0.1 0.1 0.1 1 + + + + + + 0.1 1.4 2.0 + + + + + + structure + door_panel_3 + + 0 1 0 + + 0 + 1.4 + 5000 + 0.1 + + + 30 + + + + + door_3 + 60 + 0 + 40 + -20 + 20 + + + + + 0.0 0.0 0.0 0 0 0 + + 200 + + 147.33333333333334 + 0 + 0 + 123.33333333333336 + 0 + 109.33333333333333 + + 0 0 1.1 0 0 0 + + + 0 -0.5 2.09 0 0 0 + 1 1 1 1 + .2 .2 .2 1 + + 2.2 + 0.2 + 0.05 + 0.01 + + 0 0 1 + + 0.1 + 1.0 + 0.8 + + true + + + 0 0.5 2.09 0 0 0 + 1 1 1 1 + .2 .2 .2 1 + + 2.2 + 0.2 + 0.05 + 0.01 + + 0 0 1 + + 0.1 + 1.0 + 0.8 + + true + + + 0 0 -0.05 0 0 0 + + + 1.6 2.0 0.1 + + + + 0.175 0.175 0.175 1 + 0.175 0.175 0.175 1 + 0.1 0.1 0.1 1 + + + + 0 0 -0.05 0 0 0 + + + 1.6 2.0 0.1 + + + + + 0 0 2.25 0 0 0 + + + 1.6 2.0 0.1 + + + + 0.175 0.175 0.175 1 + 0.175 0.175 0.175 1 + 0.1 0.1 0.1 1 + + + + 0 0 2.25 0 0 0 + + + 1.6 2.0 0.1 + + + + + 0 -1.05 1.1 0 0 0 + + + 1.6 0.1 2.4 + + + + 0.175 0.175 0.175 1 + 0.175 0.175 0.175 1 + 0.1 0.1 0.1 1 + + + + 0 -1.05 1.1 0 0 0 + + + 1.6 0.1 2.4 + + + + + 0 1.05 1.1 0 0 0 + + + 1.6 0.1 2.4 + + + + 0.175 0.175 0.175 1 + 0.175 0.175 0.175 1 + 0.1 0.1 0.1 1 + + + + 0 1.05 1.1 0 0 0 + + + 1.6 0.1 2.4 + + + + + -0.85 0 1.1 0 0 0 + + + 0.1 2.2 2.4 + + + + 0.175 0.175 0.175 1 + 0.175 0.175 0.175 1 + 0.1 0.1 0.1 1 + + + + -0.85 0 1.1 0 0 0 + + + 0.1 2.2 2.4 + + + + + + structure + cabin + + 0 0 1 + + 0 + 8.600000000000001 + 50000000 + 0.5 + + + 180000 + + + + + lift + 4000000 + 2000 + 5000 + -2000 + 2000 + -80000 + 120000 + + + + + 0.0 0.0 0.0 0 0 0 + + + structure + floor_0 + + + 0.0 0.0 3.2 0 0 0 + + + structure + floor_1 + + + 0.0 0.0 5.9 0 0 0 + + + structure + floor_2 + + + 0.0 0.0 8.6 0 0 0 + + + structure + floor_3 + + + + + 0.875 -0.7 0.2 1.5707963267948966 0 1.5707963267948966 + + model/elevator/door_0/lidar + 10 + + + + 1 + 1 + 0 + 0 + + + + 0.001 + 1.395 + 0.01 + + + + + + structure + door_lidar_0 + + + 0.875 -0.7 3.4 1.5707963267948966 0 1.5707963267948966 + + model/elevator/door_1/lidar + 10 + + + + 1 + 1 + 0 + 0 + + + + 0.001 + 1.395 + 0.01 + + + + + + structure + door_lidar_1 + + + 0.875 -0.7 6.1 1.5707963267948966 0 1.5707963267948966 + + model/elevator/door_2/lidar + 10 + + + + 1 + 1 + 0 + 0 + + + + 0.001 + 1.395 + 0.01 + + + + + + structure + door_lidar_2 + + + 0.875 -0.7 8.8 1.5707963267948966 0 1.5707963267948966 + + model/elevator/door_3/lidar + 10 + + + + 1 + 1 + 0 + 0 + + + + 0.001 + 1.395 + 0.01 + + + + + + structure + door_lidar_3 + + + + + + + + diff --git a/src/cmd/resources/package_xml.erb b/src/cmd/resources/package_xml.erb new file mode 100644 index 0000000000..75a6600362 --- /dev/null +++ b/src/cmd/resources/package_xml.erb @@ -0,0 +1,20 @@ + + + <%= options['name'] %> +0.0.0 +Add a short description of your project +Your Name +Apache License 2.0 +Your Name +ament_cmake +ament_index_python +launch +launch_ros +xacro +ament_cmake_gtest +ament_lint_auto +ament_lint_common + + ament_cmake + + diff --git a/src/cmd/resources/plugins/HelloWorld.cc b/src/cmd/resources/plugins/HelloWorld.cc new file mode 100644 index 0000000000..6d260437bc --- /dev/null +++ b/src/cmd/resources/plugins/HelloWorld.cc @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +//This is a sample code showing how an Gazebo simulator plugins works +// We'll use a string and the ignmsg command below for a brief example. +// Remove these includes if your plugin doesn't need them. +#include +#include + +// This header is required to register plugins. It's good practice to place it +// in the cc file, like it's done here. +#include + +// Don't forget to include the plugin's header. +#include "HelloWorld.hh" + +// This is required to register the plugin. Make sure the interfaces match +// what's in the header. +IGNITION_ADD_PLUGIN( + hello_world::HelloWorld, + ignition::gazebo::System, + hello_world::HelloWorld::ISystemPostUpdate) + +using namespace hello_world; + +// Here we implement the PostUpdate function, which is called at every +// iteration. +void HelloWorld::PostUpdate(const ignition::gazebo::UpdateInfo &_info, + const ignition::gazebo::EntityComponentManager &/*_ecm*/) +{ + // This is a simple example of how to get information from UpdateInfo. + std::string msg = "Hello, world! Simulation is "; + if (!_info.paused) + msg += "not "; + msg += "paused."; + + // Messages printed with ignmsg only show when running with verbosity 3 or + // higher (i.e. ign gazebo -v 3) + ignmsg << msg << std::endl; +} + + diff --git a/src/cmd/resources/plugins/HelloWorld.hh b/src/cmd/resources/plugins/HelloWorld.hh new file mode 100644 index 0000000000..ee93c28207 --- /dev/null +++ b/src/cmd/resources/plugins/HelloWorld.hh @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2022 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#ifndef SYSTEM_PLUGIN_HELLOWORLD_HH_ +#define SYSTEM_PLUGIN_HELLOWORLD_HH_ + +// The only required include in the header is this one. +// All others will depend on what your plugin does. +#include + +// It's good practice to use a custom namespace for your project. +namespace hello_world +{ + // This is the main plugin's class. It must inherit from System and at least + // one other interface. + // Here we use `ISystemPostUpdate`, which is used to get results after + // physics runs. The opposite of that, `ISystemPreUpdate`, would be used by + // plugins that want to send commands. + class HelloWorld: + public ignition::gazebo::System, + public ignition::gazebo::ISystemPostUpdate + { + // Plugins inheriting ISystemPostUpdate must implement the PostUpdate + // callback. This is called at every simulation iteration after the physics + // updates the world. The _info variable provides information such as time, + // while the _ecm provides an interface to all entities and components in + // simulation. + public: void PostUpdate(const ignition::gazebo::UpdateInfo &_info, + const ignition::gazebo::EntityComponentManager &_ecm) override; + }; +} +#endif diff --git a/src/cmd/resources/worlds/empty_platform_with_elevator.sdf b/src/cmd/resources/worlds/empty_platform_with_elevator.sdf new file mode 100644 index 0000000000..abd487508b --- /dev/null +++ b/src/cmd/resources/worlds/empty_platform_with_elevator.sdf @@ -0,0 +1,102 @@ + + + + + + + 0.004 + 1.0 + + + + + + + + ogre2 + + + + + + + + + + + + + + + + false + 1.0 1.0 1.0 + 0.8 0.8 0.8 + + + + true + 0 0 10 0 0 0 + 0.8 0.8 0.8 1 + 0.2 0.2 0.2 1 + + 1000 + 0.9 + 0.01 + 0.001 + + -0.5 0.1 -0.9 + + + + true + 0 0 -1.5 0 0 0 + + + + + 20 20 3 + + + + + + + 20 20 3 + + + + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + + + + + + + model://elevator + + + + + + diff --git a/test/integration/log_system.cc b/test/integration/log_system.cc index 233ae638fa..9e2fa7c49f 100644 --- a/test/integration/log_system.cc +++ b/test/integration/log_system.cc @@ -1642,4 +1642,4 @@ TEST_F(LogSystemTest, IGN_UTILS_TEST_DISABLED_ON_WIN32(LogTopics)) this->RemoveLogsDir(); this->CreateLogsDir(); #endif -} +} \ No newline at end of file