Skip to content

Commit

Permalink
Update ign branch (FieldRobotEvent#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick-v-E authored Jan 19, 2024
1 parent 067dd46 commit 4b0a13f
Show file tree
Hide file tree
Showing 26 changed files with 253 additions and 905 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ros-noetic-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: ros-noetic

on:
workflow_dispatch:
branches:
- main
pull_request:
branches:
- main
Expand All @@ -16,7 +14,7 @@ jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: ros-tooling/setup-ros@v0.6
- uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: noetic
- uses: ros-tooling/action-ros-ci@v0.3
Expand Down
14 changes: 0 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,5 @@ CATKIN_IGNORE
*.ipynb
.vscode

# Ignore generated files
worlds/generated.world
Media/models/virtual_maize_field_heightmap.png
map/*
gt/*
launch/robot_spawner.launch.py

# Ignore generated models
models/*_day_*

# Ignore models that may not be published on Github
models/dandelion_*

# Keep specific files
!map/.gitkeep
!gt/.gitkeep
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## Virtual Maize Field (ROS 2)

### Version 5.0.0 (2024-01-20)
* Change location of generated files ([#56](https://github.com/FieldRobotEvent/virtual_maize_field/pull/56))
* Remove outdated script that checks for updates ([#56](https://github.com/FieldRobotEvent/virtual_maize_field/pull/56))

> [!IMPORTANT]
> Since the location of the robot spawner launch file is also changed, update your launch file. See the [readme](README.md) for an example.
### Version 4.7.3 (2023-05-10)
* Add warning for non-public models ([#54](https://github.com/FieldRobotEvent/virtual_maize_field/pull/54))
* Fix GitHub actions for ROS 2 ([#51](https://github.com/FieldRobotEvent/virtual_maize_field/pull/51))
* Fix world generation in ROS 2 ([#46](https://github.com/FieldRobotEvent/virtual_maize_field/pull/46))
* Fix `TypeError` when creating worlds ([#44](https://github.com/FieldRobotEvent/virtual_maize_field/pull/44))
* Fix setuptools warning ([#36](https://github.com/FieldRobotEvent/virtual_maize_field/pull/36))
* Fix GitHub actions ([#35](https://github.com/FieldRobotEvent/virtual_maize_field/pull/35))

### Version 4.7.2 (2022-06-10)
* Fix row width to be consistent ([#32](https://github.com/FieldRobotEvent/virtual_maize_field/pull/32))

### Version 4.7.1 (2022-06-10)
* Change sigmoid function to sinus ([#31](https://github.com/FieldRobotEvent/virtual_maize_field/pull/31))

### Version 4.7.0 (2022-06-09)
* Add litter to the mapping task ([#28](https://github.com/FieldRobotEvent/virtual_maize_field/pull/28))

### Version 4.6.1 (2022-06-08)
* Fix `TypeError` when generating world ([#27](https://github.com/FieldRobotEvent/virtual_maize_field/pull/27))

### Version 4.6.0 (2022-06-03)
* Fix length of the field to match the competition description ([#25](https://github.com/FieldRobotEvent/virtual_maize_field/pull/25))

### Version 4.5.0 (2022-06-02)
* Add sigmoid function to create fields ([#24](https://github.com/FieldRobotEvent/virtual_maize_field/pull/24))

### Version 4.4.1 (2022-05-30)
* Lower the spawn height of the robot ([#23](https://github.com/FieldRobotEvent/virtual_maize_field/pull/23))

### Version 4.4.0 (2022-05-25)
* Move `map.csv` and `map.png` to a seperate folder to disable access during competition ([#21](https://github.com/FieldRobotEvent/virtual_maize_field/pull/21))
* Remove the `bin` folder ([#22](https://github.com/FieldRobotEvent/virtual_maize_field/pull/22))

### Version 4.3.1 (2022-05-04)
* Fix import ([#17](https://github.com/FieldRobotEvent/virtual_maize_field/pull/17))
* Add initial joint pose argument ([#20](https://github.com/FieldRobotEvent/virtual_maize_field/pull/20))

### Version 4.3.0 (2022-05-3)
* Add dandelion models ([#14](https://github.com/FieldRobotEvent/virtual_maize_field/pull/14))

75 changes: 63 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
This is a package to procedurally generate randomized fields with rows of plants for Gazebo.
</p>

![Screenshot of a generated map with maize plants](./misc/screenshot_v4.7.jpg)
![Screenshot of a generated map with maize plants](./misc/screenshot_v5.0_classic.png)

ROS Distro | Branch | Build status
:---------: | :----: | :----------:
**Rolling** | [`ros2`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/ros2) | [![ros-rolling](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-rolling-test.yaml/badge.svg?branch=ros2)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-rolling-test.yaml)
**Iron** | [`ros2`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/ros2) | [![ros-iron](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-iron-test.yaml/badge.svg?branch=ros2)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-iron-test.yaml)
**Humble** | [`ros2`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/ros2) | [![ros-humble](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-humble-test.yaml/badge.svg?branch=ros2)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-humble-test.yaml)
**Noetic** | [`main`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/main) | [![ros-noetic](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-noetic-test.yaml/badge.svg?branch=main)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-noetic-test.yaml?branch=main)
ROS Distro | Gazebo version | Branch | Build status
:---------: | :----: | :----: | :----------:
**Rolling** | **Gazebo** | [`ros2-gz`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/ros2-gz) | [![ros-rolling-gz](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-rolling-gz-test.yaml/badge.svg?branch=ros2-gz)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-rolling-gz-test.yaml)
**Rolling** | **Gazebo Classic** | [`ros2`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/ros2) | [![ros-rolling](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-rolling-test.yaml/badge.svg?branch=ros2)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-rolling-test.yaml)
**Iron** | **Gazebo** | [`ros2-gz`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/ros2-gz) | [![ros-iron-gz](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-iron-gz-test.yaml/badge.svg?branch=ros2-gz)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-iron-gz-test.yaml)
**Iron** | **Gazebo Classic** | [`ros2`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/ros2) | [![ros-iron](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-iron-test.yaml/badge.svg?branch=ros2)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-iron-test.yaml)
**Humble** | **Ignition Gazebo** | [`ros2-ign`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/ros2-ign) | [![ros-humble-ign](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-humble-ign-test.yaml/badge.svg?branch=ros2-ign)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-humble-ign-test.yaml)
**Humble** | **Gazebo Classic** | [`ros2`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/ros2) | [![ros-humble](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-humble-test.yaml/badge.svg?branch=ros2)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-humble-test.yaml)
**Noetic** | **Gazebo Classic** | [`main`](https://github.com/FieldRobotEvent/virtual_maize_field/tree/main) | [![ros-noetic](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-noetic-test.yaml/badge.svg?branch=main)](https://github.com/FieldRobotEvent/virtual_maize_field/actions/workflows/ros-noetic-test.yaml?branch=main)


## Installation
Expand All @@ -35,7 +38,7 @@ Clone this repository and build the workspace. Additional you'll need the follow
rosdep install virtual_maize_field
```

This package has been tested on ROS 2 Foxy, Humble and Rolling.
This package has been tested on ROS 2 Humble, Iron and Rolling.

## Generating new maize field worlds
This package includes a script (`virtual_maize_field/generate_world.py`) that can generate randomized agricultural worlds. All parameters are optional and have default values. All comma separated arguments can be scaler as well.
Expand All @@ -44,7 +47,9 @@ You can call the script using
```bash
ros2 run virtual_maize_field generate_world
```
The resulting file will be placed in `<workspace folder>/install/virtual_maize_field/share/virtual_maize_field/worlds/generated.world`. You can use this script by one of the defined config files or specifying the parameters below:
The resulting file will be placed in `$ROS_HOME/virtual_maize_field/generated.world`.

You can use this script by one of the defined config files or specifying the parameters below:
<details>
<summary>Click to show all possible arguments</summary>

Expand Down Expand Up @@ -189,7 +194,7 @@ Worlds for the Field Robot Event 2022:
| *fre22_task_navigation* | Task navigation, curved rows that get more difficult (eg. have more and larger holes) to the left |
| *fre22_task_mapping* | Task mapping, field with random holes, bottles and weeds spread throughout the field. The cans, bottles and weeds have no collision box and are static. <br /><sub>This world needs dandelion models which were only distributed among competitors of the Field Robot Event 2022. They are not uploaded to Github because they cannot be open-sourced. If you don't have access to these models, check out the `fre21_task_3` worlds.</sub>|

Other sample Worlds:
Worlds for the Field Robot Event 2021:
| Name | Description |
|:---- |:----------- |
| *fre21_task_1* | Task 1, curved rows without holes |
Expand All @@ -202,8 +207,54 @@ You can use these config files when generating worlds, e.g.:
ros2 run virtual_maize_field generate_world fre22_task_navigation_mini
```

## Launching worlds
The launch file to launch the worlds is called `simulation.launch`. You can launch the launch file by running `ros2 launch virtual_maize_field simulation.launch.py`. By default the launch file will launch `generated_world.world`. You can launch any world by using the `world_name` arg. e.g. `ros2 launch virtual_maize_field simulation.launch.py world_name:=simple_row_level_1.world`.
## Launching and using generated worlds
The launch file to launch the worlds is called `simulation.launch`. You can launch the launch file by running `ros2 launch virtual_maize_field simulation.launch.py`. By default the launch file will launch `generated_world.world`. You can launch any world by using the `world_name` arg. e.g. `ros2 launch virtual_maize_field simulation.launch.py world_name:=simple_row_level_1.world`. The generated world will be saved in `$ROS_HOME/virtual_maize_field` (usually, this will be `~/.ros/virtual_maize_field`).

To add your own robot in the world, use the generated `robot_spawner.launch.py`. This launches your robot at the correct position in the generated world. Your launch file to launch your robot should look like (replace `<<robot_name>>` with your robot name):

```python
from __future__ import annotations

from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource

from virtual_maize_field import get_spawner_launch_file


def generate_launch_description() -> LaunchDescription:
robot_spawner_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([get_spawner_launch_file()]),
launch_arguments={"robot_name": "<<robot_name>>"}.items(),
)

return LaunchDescription([robot_spawner_launch])
```

Use the function `get_driving_pattern_file()` to get the path of the generated driving pattern and `get_markers_file` to get the path of the generated markers:

```python
from __future__ import annotations

from csv import reader
from pathlib import Path

from virtual_maize_field import get_driving_pattern_file, get_markers_file

def read_driving_pattern() -> None:
driving_pattern = Path(get_driving_pattern_file()).read_text("utf-8")
print(f"The driving pattern is {driving_pattern}")

def read_markers_file() -> None:
with open(get_markers_file(), "r") as f:
reader = csv.reader(f)

# Skip header
next(reader)

for row in reader:
print(f"Position {row[2]}: x={float(row[0]):.3f} y={float(row[1]):.3f}")
```

## License
Virtual Maize Field is copyright (C) 2021 *Farm Technology Group of Wageningen University & Research* and *Kamaro Engineering e.V.* and licensed under [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0).
Expand Down
Empty file removed gt/.gitkeep
Empty file.
25 changes: 0 additions & 25 deletions launch/rviz.launch.py

This file was deleted.

89 changes: 32 additions & 57 deletions launch/simulation.launch.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
from __future__ import annotations

from os import environ, path

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription
from launch.conditions import IfCondition
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch.substitutions import LaunchConfiguration, PythonExpression
from launch_ros.actions import Node


def generate_launch_description() -> LaunchDescription:
use_sim_time = LaunchConfiguration("use_sim_time")
gui = LaunchConfiguration("gui")
paused = LaunchConfiguration("paused")
headless = LaunchConfiguration("headless")
world_path = LaunchConfiguration("world_path")
world_name = LaunchConfiguration("world_name")
check_for_updates = LaunchConfiguration("check_for_updates")

# Create launch arguments
declare_use_sim_time_cmd = DeclareLaunchArgument(
name="use_sim_time", default_value="True"
)
declare_gui_cmd = DeclareLaunchArgument(name="gui", default_value="True")
declare_paused_cmd = DeclareLaunchArgument(name="paused", default_value="False")
declare_headless_cmd = DeclareLaunchArgument(name="headless", default_value="False")
declare_world_path_cmd = DeclareLaunchArgument(
name="world_path",
default_value=get_package_share_directory("virtual_maize_field") + "/worlds/",
)
declare_world_name_cmd = DeclareLaunchArgument(
name="world_name", default_value="generated.world"
_ros_home_path = environ.get("ROS_HOME", path.join(path.expanduser("~"), ".ros"))
cache_dir = path.join(_ros_home_path, "virtual_maize_field/")

use_sim_time = LaunchConfiguration("use_sim_time", default=True)
gui = LaunchConfiguration("gui", default=True)
paused = LaunchConfiguration("paused", default=False)
headless = LaunchConfiguration("headless", default=False)
world_path = LaunchConfiguration("world_path", default=cache_dir)
world_name = LaunchConfiguration("world_name", default="generated.world")

gz_server_launch_file = path.join(
get_package_share_directory("gazebo_ros"), "launch", "gzserver.launch.py"
)
declare_check_for_updates_cmd = DeclareLaunchArgument(
name="check_for_updates", default_value="True"
gz_client_launch_file = path.join(
get_package_share_directory("gazebo_ros"), "launch", "gzclient.launch.py"
)

# Create nodes
start_gazebo_server_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
get_package_share_directory("gazebo_ros") + "/launch/gzserver.launch.py"
),
gz_server_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([gz_server_launch_file]),
launch_arguments={
"world": [world_path, world_name],
"pause": paused,
Expand All @@ -49,36 +39,21 @@ def generate_launch_description() -> LaunchDescription:
}.items(),
)

start_gazebo_client_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
get_package_share_directory("gazebo_ros") + "/launch/gzclient.launch.py"
),
gz_client_launch = IncludeLaunchDescription(
PythonLaunchDescriptionSource([gz_client_launch_file]),
condition=IfCondition(PythonExpression([gui, " and not ", headless])),
launch_arguments={"use_sim_time": use_sim_time}.items(),
)

start_check_updates_node_cmd = Node(
package="virtual_maize_field",
executable="check_for_updates",
name="check_virtual_maize_field_updates",
condition=IfCondition(check_for_updates),
arguments={"use_sim_time": use_sim_time}.items(),
return LaunchDescription(
[
DeclareLaunchArgument(name="use_sim_time", default_value=use_sim_time),
DeclareLaunchArgument(name="gui", default_value=gui),
DeclareLaunchArgument(name="paused", default_value=paused),
DeclareLaunchArgument(name="headless", default_value=headless),
DeclareLaunchArgument(name="world_path", default_value=world_path),
DeclareLaunchArgument(name="world_name", default_value=world_name),
gz_server_launch,
gz_client_launch,
]
)

ld = LaunchDescription()

# Declare the launch options
ld.add_action(declare_use_sim_time_cmd)
ld.add_action(declare_gui_cmd)
ld.add_action(declare_paused_cmd)
ld.add_action(declare_headless_cmd)
ld.add_action(declare_world_path_cmd)
ld.add_action(declare_world_name_cmd)
ld.add_action(declare_check_for_updates_cmd)

# Add nodes
ld.add_action(start_gazebo_server_cmd)
ld.add_action(start_gazebo_client_cmd)
ld.add_action(start_check_updates_node_cmd)

return ld
Empty file removed map/.gitkeep
Empty file.
1 change: 0 additions & 1 deletion map/driving_pattern.txt

This file was deleted.

Binary file added misc/screenshot_v5.0_classic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added misc/screenshot_v5.0_ign.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>virtual_maize_field</name>
<version>4.7.4</version>
<version>5.0.0</version>
<description>A virtual maize field for agricultural robot simulation in Gazebo.</description>

<maintainer email="info@fieldrobot.com">Field Robot Event Organization</maintainer>
Expand Down
Loading

0 comments on commit 4b0a13f

Please sign in to comment.