diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..3901c53 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,72 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Install_Dependencies", + "type": "shell", + "command": "source /opt/ros/humble/setup.sh && source install/setup.sh && sudo apt-get update && rosdep install --from-path src", + "group": { + "kind": "build", + "isDefault": true + }, + "options": { + "shell": { + "executable": "/bin/bash", + "args": ["--login", "-i", "-c"] // --login loads your ~/.bashrc + } + }, + "problemMatcher": [] + }, + { + "label": "Build", + "type": "shell", + "command": "echo '---- building -----' && source /opt/ros/humble/setup.sh && source install/setup.sh && colcon build", + "group": { + "kind": "build", + "isDefault": true + }, + "options": { + "shell": { + "executable": "/bin/bash", + "args": ["--login", "-i", "-c"] // --login loads your ~/.bashrc + } + }, + "problemMatcher": [] + }, + { + "label": "Run_Simulation", + "type": "shell", + "command": "echo '----- running simulation -----' source ~/.bashrc && source /opt/ros/humble/setup.sh && source install/setup.sh && ros2 launch simulation simulation.launch.py", + "group": { + "kind": "build", + "isDefault": true + }, + "dependsOn": ["Build"], + "options": { + "shell": { + "executable": "/bin/bash", + "args": ["--login", "-i", "-c"] // --login loads your ~/.bashrc + } + }, + "problemMatcher": [] + }, + { + "label": "Run_Raw_Gazebo", + "type": "shell", + "command": "echo '----- running simulation -----' source ~/.bashrc && source /opt/ros/humble/setup.sh && source install/setup.sh && ign gazebo worlds/test.world", + "group": { + "kind": "build", + "isDefault": true + }, + "dependsOn": ["Build"], + "options": { + "shell": { + "executable": "/bin/bash", + "args": ["--login", "-i", "-c"] // --login loads your ~/.bashrc + } + }, + "problemMatcher": [] + } + + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6e0a232 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Wisconsin Robotics + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..881a1dc --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +inst_dep: + sudo apt-get update + rosdep install --from-path src +build_env: + colcon build + echo "DONT FORGET TO SOURCE!" +run: + ros2 launch simulation simulation.launch.py + +clean: + rm -rf build/ install/ log/ + +run_and_build: install_dependencies build run + +fast_build: clean build_env run diff --git a/README.md b/README.md index 0102931..98bb843 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,11 @@ This is the official repository for WRover Software Simulation. ## Tools and Lanugages +- Rosviz +- Gazebo for simulation. + - ROS2GZ bridge + - Xacro udrf +- Custom VSCode build scripts Currently using Rosviz with Gazebo for simulation. @@ -36,4 +41,57 @@ Currently using Rosviz with Gazebo for simulation. - Code that is free of syntax errors and basic bugs should be merged into the test branch by opening a pull request. -- The test branch will be periodically merged into main after thorough testing. +## Notes +Documentation about the software being used, resources for development, things that need to be done, can all be found in [/docs/](./docs/) + + +# Simulation Setup +starting from the root of the WiscRobo directory (where this readme is). +- NOTE: for development purposes, it is recommended to use VScode seeing as there are custom build commands and compile tasks in VSCode +- WSL has varying support for different graphics card. If there is trouble running the software, please refer to [/docs/graphics.md](./docs/graphics.md) and contribute to such file. + +### Prereqs +These are required to be installed on the system in order for the simulation to work. +``` +sudo apt install python3-colcon-common-extensions +sudo apt-get install python3-rosdep2 +sudo apt install ros-humble-joint-state-publisher-gui +``` + +### Raw Build and Run Commands + +``` +# Install package dependencies +source /opt/ros/humble/setup.sh +sudo apt-get update +rosdep install --from-path src + +# Build projcet +colcon build + +# Run Sim +source install/setup.sh +ros2 launch simulation simulation.launch.py +``` + +### Shortcuts +``` bash +# For fast builds use fast_build script at the top level +# This will do the entire build, source, and run routine for you +# make sure to chmod the script +./fast_build + +# clean repo +make clean + +# install ros dependencies +make inst_dep + +# build project +make build_env + +# run after source +make run +``` + + diff --git a/docs/.gitkeep b/docs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/TODO.md b/docs/TODO.md new file mode 100644 index 0000000..25924d1 --- /dev/null +++ b/docs/TODO.md @@ -0,0 +1,5 @@ +# TODO + +- [ ] Run test vs real rover to see how similar the simulation is to the real rover + - [ ] Calibrate the inertial values of the rover to be similar to the real thing + - [ ] Calibrate sensors to be similar to the sensors on the real rover \ No newline at end of file diff --git a/docs/documents.md b/docs/documents.md new file mode 100644 index 0000000..d8ef4ac --- /dev/null +++ b/docs/documents.md @@ -0,0 +1,5 @@ +# Docs +These files all outline design decisions, software stack, and resources for other developers + +1. [development resources](./Resources.md) - a list of documents related to ROS, gazebo, and simulation development +2. [todo](./TODO.md) - lists all things that need to get done on the rover \ No newline at end of file diff --git a/docs/graphics.md b/docs/graphics.md new file mode 100644 index 0000000..7fe039d --- /dev/null +++ b/docs/graphics.md @@ -0,0 +1,13 @@ +# Graphics information +WSL is supper funky when it comes to graphics. You might need to make some changes in order to get this to render on your computer + + +## INTEL Arc Graphics cards +Intel Arc graphics cards have proven problematic, you need to use software rendering if +possible by your computer. + +```bash +# Run the following in your shell instance +export LIBGL_ALWAYS_SOFTWARE=1 +export GALLIUM_DRIVER=llvmpipe +``` diff --git a/docs/resources.md b/docs/resources.md new file mode 100644 index 0000000..03eab47 --- /dev/null +++ b/docs/resources.md @@ -0,0 +1,42 @@ + +# Resources and Notes +These all serve as notes and general resources aimed at helping other developers. If you find anything useful please put it here + +## Gazebo Plugins +Gazebo plugins are scarce and not very common, here are some that are found regarding plugin development. + +Gazebo Plugin Development +1) [Gazebo Plugin Tutorial Website by Hrithik Verma](https://sites.google.com/view/gazebo-plugin-tutorials/3-write-a-world-plugin?authuser=0) +2) [Gazebo Plugin Tutorial Youtube Series by Hrithik Verma](https://www.youtube.com/watch?v=UNZMce9z5Fc&list=PLOQhCaBjYnseDMTpd-b52spLSq7hg0ar1&index=1) + +Gazebo Documentations +1) [Defualt Gazeo Plugins Github](https://github.com/gazebosim/gz-sim/tree/main/src/systems) +2) [Default Gazebo Plugins Docs](https://gazebosim.org/api/gazebo/6/namespaceignition_1_1gazebo_1_1systems.html) +3) [Gazebo API Docs](https://osrf-distributions.s3.amazonaws.com/gazebo/api/dev/index.html) +4) [Ignition Math Docs](https://osrf-distributions.s3.amazonaws.com/ign-math/api/1.0.0/namespaceignition_1_1math.html) + +Gazebo ROS intigration +1) [Example Gazebo/ROS2 project](https://github.com/gazebosim/ros_gz_project_template/tree/main) + + + +## Inertials +This is a note about inertials. Intertials are what tell the simulation how the links interact with the world. +A great wiki artical about this is [Moment of Inertia Wiki Page](https://en.wikipedia.org/wiki/Moment_of_inertia#Inertia_tensor), specifically the inertia tensors since that is what URDF uses. + +### Approximation Methods +There are two main methods for estimating inertial values: getting it from CAD and estimating it with general shapes. +#### CAD +in Onshape, you can take the moment of inertia from the shapes themselves + +### URDF Reference frames +Take the exampple: +``` xml + + + + + + +``` +In the case of URDF, the intertials of the child will be relative to the origin axis, the origin axis being based off the parent's frame of reference diff --git a/fast_build.sh b/fast_build.sh new file mode 100755 index 0000000..8dc17ad --- /dev/null +++ b/fast_build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Exit on error +set -e + +# clearing +clear + +# Source ROS2 +source /opt/ros/humble/setup.bash + +# clean project and build +make clean +make build_env + +# Source workspace +source install/setup.bash + +# Launch simulation +make run diff --git a/src/.gitkeep b/src/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/simulation/LICENSE b/src/simulation/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/src/simulation/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. diff --git a/src/simulation/config/ROS_gazebo_bridge_config.yaml b/src/simulation/config/ROS_gazebo_bridge_config.yaml new file mode 100644 index 0000000..1ef3333 --- /dev/null +++ b/src/simulation/config/ROS_gazebo_bridge_config.yaml @@ -0,0 +1,19 @@ +--- +# Test +- ros_topic_name: "cmd_wheel_velocity" + gazebo_topic_name: "cmd_wheel_velocity" + ros_type_name: "std_msgs/msg/Float64" + gz_type_name: "ignition.msgs.Double" + direction: ROS_TO_GZ +# Front Drive Train Wheel +- ros_topic_name: "rover/drive/TR_wheel_swivel" + gazebo_topic_name: "rover/drive/TR_wheel_swivel" + ros_type_name: "std_msgs/msg/Float64" + gz_type_name: "ignition.msgs.Double" + direction: ROS_TO_GZ +# Front Swivel to Chasis +- ros_topic_name: "rover/drive/TR_swivel_chasis" + gazebo_topic_name: "rover/drive/TR_swivel_chasis" + ros_type_name: "std_msgs/msg/Float64" + gz_type_name: "ignition.msgs.Double" + direction: ROS_TO_GZ \ No newline at end of file diff --git a/src/simulation/config/rviz_config.rviz b/src/simulation/config/rviz_config.rviz new file mode 100644 index 0000000..55036c1 --- /dev/null +++ b/src/simulation/config/rviz_config.rviz @@ -0,0 +1,45 @@ +Panels: + - Class: rviz_common/Displays + Name: Displays + - Class: rviz_common/Views + Name: Views + +Visualization Manager: + Class: "" + Displays: + - Class: rviz_default_plugins/Grid + Enabled: true + Name: Grid + Value: true + - Class: rviz_default_plugins/RobotModel + Description Source: Topic + Description Topic: /robot_description + Enabled: true + Name: Rover_Model + Value: true + Visual Enabled: true + Collision Enabled: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Fixed Frame: base_link + Frame Rate: 30 + Name: root + Tools: + - Class: rviz_default_plugins/MoveCamera + - Class: rviz_default_plugins/Select + Value: true + Views: + Current: + Class: rviz_default_plugins/Orbit + Distance: 2 + Pitch: 0.5 + Target Frame: base_link + Yaw: 0.8 + Saved: ~ + +Window Geometry: + Height: 900 + Width: 1200 + X: 0 + Y: 0 \ No newline at end of file diff --git a/src/simulation/launch/simulation.launch.py b/src/simulation/launch/simulation.launch.py new file mode 100644 index 0000000..7d96a29 --- /dev/null +++ b/src/simulation/launch/simulation.launch.py @@ -0,0 +1,75 @@ +from launch import LaunchDescription +from launch_ros.actions import Node +from launch.actions import ExecuteProcess, TimerAction,SetEnvironmentVariable +from ament_index_python.packages import get_package_share_directory +import xacro +import os +from pathlib import Path + + +def generate_launch_description(): + + # Gazebo Resource folders look one directory above the package folder + pkg = get_package_share_directory("simulation") + + # Process xacro and write urdf to install dir + xacro_file = os.path.join(pkg, "urdf", "rover.urdf.xacro") + doc = xacro.process_file(xacro_file).toxml() + + + return LaunchDescription([ + # Start Gazebo with the world + ExecuteProcess( + cmd=['ros2', 'launch', "ros_gz_sim", "gz_sim.launch.py", f'gz_args:=-r {os.path.join(pkg, "worlds", "test.world")}'], + additional_env={ + 'GZ_SIM_RESOURCE_PATH': str(Path(pkg).parent), + }, + output='screen' + ), + + # Spawn Robot and start ROS Bridge to transfer ros messages to gazebo messages after a delay + TimerAction( + period=3.0, + actions=[ + # Start the robot state publisher to publish the robot's TF frames + Node( + package='robot_state_publisher', + executable='robot_state_publisher', + parameters=[{'robot_description': doc}], + output='screen' + ), + Node( + package='joint_state_publisher_gui', + executable='joint_state_publisher_gui', + name='joint_state_publisher_gui', + ), + # Start RViz to visualize the robot + Node( + package='rviz2', + executable='rviz2', + output='screen', + arguments=['-d', os.path.join(pkg, "config", "rviz_config.rviz")] + ), + # Spawn the robot in Gazebo + Node( + package='ros_gz_sim', + executable='create', + arguments=[ + '-string', doc, + '-name', 'rover', + '-x', '0', '-y', '0', '-z', '0.25' + ], + output='screen' + ), + # Start the ROS-Gazebo bridge + Node( + package='ros_gz_bridge', + executable='parameter_bridge', + parameters = [{ + "config_file" : os.path.join(pkg, "config", "ROS_gazebo_bridge_config.yaml") + }], + output='screen' + ) + ] + ) + ]) diff --git a/src/simulation/meshes/main_chassis.stl b/src/simulation/meshes/main_chassis.stl new file mode 100644 index 0000000..888e940 Binary files /dev/null and b/src/simulation/meshes/main_chassis.stl differ diff --git a/src/simulation/meshes/rd_back_swivel.stl b/src/simulation/meshes/rd_back_swivel.stl new file mode 100644 index 0000000..b542327 Binary files /dev/null and b/src/simulation/meshes/rd_back_swivel.stl differ diff --git a/src/simulation/meshes/rd_back_wheel.stl b/src/simulation/meshes/rd_back_wheel.stl new file mode 100644 index 0000000..a9d6b1a Binary files /dev/null and b/src/simulation/meshes/rd_back_wheel.stl differ diff --git a/src/simulation/meshes/rd_chasis.stl b/src/simulation/meshes/rd_chasis.stl new file mode 100644 index 0000000..648b2d7 Binary files /dev/null and b/src/simulation/meshes/rd_chasis.stl differ diff --git a/src/simulation/meshes/rd_front_swivel.stl b/src/simulation/meshes/rd_front_swivel.stl new file mode 100644 index 0000000..3d99e77 Binary files /dev/null and b/src/simulation/meshes/rd_front_swivel.stl differ diff --git a/src/simulation/meshes/rd_front_wheel.stl b/src/simulation/meshes/rd_front_wheel.stl new file mode 100644 index 0000000..56200fa Binary files /dev/null and b/src/simulation/meshes/rd_front_wheel.stl differ diff --git a/src/simulation/package.xml b/src/simulation/package.xml new file mode 100644 index 0000000..23835a3 --- /dev/null +++ b/src/simulation/package.xml @@ -0,0 +1,24 @@ + + + + simulation + 0.0.0 + A ROS2/Gazebo Robot simulation environment for Wisconsin Robotics + teggatz + Apache-2.0 + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + ros_gz_bridge + ros_gz_sim + ros2launch + xacro + + + + ament_python + + diff --git a/src/simulation/resource/simulation b/src/simulation/resource/simulation new file mode 100644 index 0000000..e69de29 diff --git a/src/simulation/setup.cfg b/src/simulation/setup.cfg new file mode 100644 index 0000000..c2bfec0 --- /dev/null +++ b/src/simulation/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/simulation +[install] +install_scripts=$base/lib/simulation diff --git a/src/simulation/setup.py b/src/simulation/setup.py new file mode 100644 index 0000000..db2a289 --- /dev/null +++ b/src/simulation/setup.py @@ -0,0 +1,48 @@ +from glob import glob +import os +from setuptools import find_packages, setup + +package_name = 'simulation' + +def get_data_files(dir): + data_files = [] + for root, dirs, files in os.walk(dir): + if files: + install_dir = os.path.join("share", package_name, root) + file_paths = [os.path.join(root, f) for f in files] + data_files.append((install_dir, file_paths)) + return data_files + + + +setup( + name=package_name, + version='0.0.0', + packages=find_packages(exclude=['test']), + data_files=[ + ('share/ament_index/resource_index/packages', + ['resource/' + package_name]), + ('share/' + package_name, ['package.xml']), + (os.path.join('share', package_name, 'launch'), glob('launch/*.py')), + *get_data_files("models"), + *get_data_files("config"), + *get_data_files("worlds"), + *get_data_files("urdf"), + *get_data_files("meshes"), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='Christopher Teggatz Jr.', + maintainer_email='categgatzjr@gmail.com', + description='A ROS2/Gazebo Robot simulation environment for Wisconsin Robotics', + license='Apache-2.0', + extras_require={ + 'test': [ + 'pytest', + ], + }, + entry_points={ + 'console_scripts': [ + ], + }, +) diff --git a/src/simulation/simulation/__init__.py b/src/simulation/simulation/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/simulation/test/test_copyright.py b/src/simulation/test/test_copyright.py new file mode 100644 index 0000000..97a3919 --- /dev/null +++ b/src/simulation/test/test_copyright.py @@ -0,0 +1,25 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# 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. + +from ament_copyright.main import main +import pytest + + +# Remove the `skip` decorator once the source file(s) have a copyright header +@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/src/simulation/test/test_flake8.py b/src/simulation/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/src/simulation/test/test_flake8.py @@ -0,0 +1,25 @@ +# Copyright 2017 Open Source Robotics Foundation, Inc. +# +# 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. + +from ament_flake8.main import main_with_errors +import pytest + + +@pytest.mark.flake8 +@pytest.mark.linter +def test_flake8(): + rc, errors = main_with_errors(argv=[]) + assert rc == 0, \ + 'Found %d code style errors / warnings:\n' % len(errors) + \ + '\n'.join(errors) diff --git a/src/simulation/test/test_pep257.py b/src/simulation/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/src/simulation/test/test_pep257.py @@ -0,0 +1,23 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# 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. + +from ament_pep257.main import main +import pytest + + +@pytest.mark.linter +@pytest.mark.pep257 +def test_pep257(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found code style errors / warnings' diff --git a/src/simulation/urdf/components/left_drive.xacro b/src/simulation/urdf/components/left_drive.xacro new file mode 100644 index 0000000..b3f1928 --- /dev/null +++ b/src/simulation/urdf/components/left_drive.xacro @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/simulation/urdf/components/main_body.xacro b/src/simulation/urdf/components/main_body.xacro new file mode 100644 index 0000000..1bf6cc5 --- /dev/null +++ b/src/simulation/urdf/components/main_body.xacro @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/simulation/urdf/components/right_drive.xacro b/src/simulation/urdf/components/right_drive.xacro new file mode 100644 index 0000000..9a1c096 --- /dev/null +++ b/src/simulation/urdf/components/right_drive.xacro @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/simulation/urdf/components/text.urdf.xacro b/src/simulation/urdf/components/text.urdf.xacro new file mode 100644 index 0000000..0cfa3ad --- /dev/null +++ b/src/simulation/urdf/components/text.urdf.xacro @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/simulation/urdf/rover.urdf.xacro b/src/simulation/urdf/rover.urdf.xacro new file mode 100644 index 0000000..0459d74 --- /dev/null +++ b/src/simulation/urdf/rover.urdf.xacro @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/simulation/urdf/util/materials.xacro b/src/simulation/urdf/util/materials.xacro new file mode 100644 index 0000000..201bef6 --- /dev/null +++ b/src/simulation/urdf/util/materials.xacro @@ -0,0 +1,61 @@ + + + + + + + ${r} ${g} ${b} ${a} + ${r} ${g} ${b} ${a} + 0.1 0.1 0.1 ${a} + 0 0 0 ${a} + + + + + + + + + + + + ${r} ${g} ${b} ${a} + ${r} ${g} ${b} ${a} + 0.1 0.1 0.1 ${a} + 0 0 0 ${a} + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/simulation/worlds/test.world b/src/simulation/worlds/test.world new file mode 100644 index 0000000..c7793c0 --- /dev/null +++ b/src/simulation/worlds/test.world @@ -0,0 +1,76 @@ + + + + + 0.001 + 1.0 + + + + + + + + + + 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 + + + + + + + 0 0 1 + 100 100 + + + + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + 0.8 0.8 0.8 1 + + + + + + 2.0 + 2.0 + + + + + + + + \ No newline at end of file