Skip to content

Commit

Permalink
Merge pull request #1 from srmainwaring/feature/wrsc-devel
Browse files Browse the repository at this point in the history
Feature/wrsc devel
  • Loading branch information
srmainwaring authored Jun 24, 2020
2 parents 0d3283e + 6317646 commit 728d530
Show file tree
Hide file tree
Showing 85 changed files with 2,910 additions and 2,769 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
129 changes: 104 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,140 @@
# ASV Simulator

This package contains plugins and models that support the
simulation of surface vessels in Gazebo.
This package contains plugins and models for the simulation of surface vessels in Gazebo.

## Installation
## Dependencies

You will need a working installation of ROS and Gazebo in order to use this package.

The package was built and tested with:
It has been tested with:

- Gazebo version 9.4.1
- ROS Melodic Morenia
- OSX 10.11.6

## Installation

Source your ROS installation:
Source your ROS installation and update the Gazebo plugin path:

```bash
source /opt/ros/melodic/setup.bash
# Source the ROS and Gazebo environment (add this to ~/.bash_profile)
$ source /opt/ros/melodic/setup.bash
$ source /usr/local/share/gazebo/setup.sh
```

Create a catkin workspace:
Create and configure a catkin workspace, clone and build the repo:

```bash
mkdir asv_ws
cd asv_ws
mkdir src
catkin init
```
# Create a catkin workspace
$ mkdir -p <catkin_ws>/src

Clone the ASV Simulator repository:
# Clone dependencies
$ cd <catkin_ws>/src
$ git clone https://github.com/srmainwaring/asv_wave_sim.git

```bash
cd src
git clone ssh://[email protected]:/volume1/git/asv_sim.git
# Clone this repo
$ git clone https://github.com/srmainwaring/asv_sim.git

# Configure and build
$ cd <catkin_ws>
$ catkin config --extend /opt/ros/melodic \
--cmake-args -DCMAKE_CXX_STANDARD=14 -DCMAKE_BUILD_TYPE=RelWithDebInfo
$ catkin build

# Source the workspace
$ source devel/setup.bash

# Update the Gazebo plugin path
$ export GAZEBO_PLUGIN_PATH=$(pwd)/devel/lib:$GAZEBO_PLUGIN_PATH

# Check the Gazebo environment variables
$ printenv |grep GAZEBO
```

Compile the packages:
## Anemometer Sensor

```bash
catkin build
AnemometerSensor to measure wind speed and direction.

### Usage

Add the SDF for the sensor to a `<link>` element of your model.

```xml
<sensor name="anemometer_sensor" type="anemometer">
<always_on>true</always_on>
<update_rate>50</update_rate>
<topic>anemometer</topic>
</sensor>
```

## Usage
### Published Topics

1. `~/anemometer` (`gazebo::msgs::Param_V`)

- `time` (`gazebo::msgs::Time`) \
The simulation time of the observation.

Launch a Gazebo session with `roslaunch`:
- `true_wind` (`gazebo::msgs::Vector3d`) \
The true wind at the link origin.

- `apparent_wind` (`gazebo::msgs::Vector3d`) \
The apparent wind at the link origin
(i.e. true wind adjusted for the link velocity).

### Parameters

1. `<always_on>` (`bool`, default: `false`) \
Standard `<sensor>` parameter.
See [SDF documentation](http://sdformat.org/spec?ver=1.6&elem=sensor) for details.

2. `<update_rate>` (`double`, default: `0`) \
Standard `<sensor>` parameter.
See [SDF documentation](http://sdformat.org/spec?ver=1.6&elem=sensor) for details.

3. `<topic>` (`string`, default: `~/anemometer`) \
Standard `<sensor>` parameter.
See [SDF documentation](http://sdformat.org/spec?ver=1.6&elem=sensor) for details.

## Anemometer Example

To run the example:

```bash
roslaunch asv_sim_gazebo milford_haven_world.launch verbose:=true
roslaunch asv_sim_gazebo anemometer_demo_world.launch verbose:=true
```

The launch file loads the `RegisterSensorsPlugin` system plugin using
the parameter:

```xml
<arg name="extra_gazebo_args" default="--server-plugin libRegisterSensorsPlugin.so" />
```

You should see a world containing a single block at the origin.
The figure below shows the block falling to demonstate the effect
of motion on apparent wind:

![Anemometer World](https://github.com/srmainwaring/asv_sim/wiki/images/anemometer_world_falling.jpg)

Open the Topic Visualization window and select the `anemometer` topic:

![Anemometer Topic](https://github.com/srmainwaring/asv_sim/wiki/images/anemometer_topic.jpg)

When the block is at rest with axis aligned with the world frame,
the true and apparent wind should be the same. When the block is in motion,
for instance by setting the `z` pose to `100` and letting it fall, the
apparent wind will be adjusted for the object's motion.

![Anemometer Rest](https://github.com/srmainwaring/asv_sim/wiki/images/anemometer_topic_view_rest.jpg)
![Anemometer Falling](https://github.com/srmainwaring/asv_sim/wiki/images/anemometer_topic_view_falling.jpg)

## License

ASV Simulator is free software: you can redistribute it and/or modify
This is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

ASV Simulator is distributed in the hope that it will be useful,
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[GNU General Public License](LICENSE) for more details.
12 changes: 5 additions & 7 deletions asv_sim/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
<name>asv_sim</name>
<version>0.1.0</version>
<description>
This package contains plugins and models for simulating
surface vessels.
This package contains plugins and models for simulating surface vessels.
</description>

<maintainer email="[email protected]">Rhys Mainwaring</maintainer>
<license>GPLv3</license>
<url type="website">https://github.com/srmainwaring/asv_sim</url>
<url type="repository">https://github.com/srmainwaring/asv_sim</url>
<url type="bugtracker">https://github.com/srmainwaring/asv_sim/issues</url>
<author email="[email protected]">Rhys Mainwaring</author>

<buildtool_depend>catkin</buildtool_depend>
<exec_depend>asv_sim_gazebo</exec_depend>
<exec_depend>gazebo</exec_depend>
<exec_depend>gazebo_ros</exec_depend>

<exec_depend>asv_sim_gazebo_plugins</exec_depend>
<export>
<metapackage />
</export>
Expand Down
9 changes: 8 additions & 1 deletion asv_sim_gazebo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
cmake_minimum_required(VERSION 2.8.3)
project(asv_sim_gazebo)
find_package(catkin REQUIRED)

find_package(catkin REQUIRED COMPONENTS)

catkin_package()

install(DIRECTORY launch worlds
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
28 changes: 28 additions & 0 deletions asv_sim_gazebo/launch/anemometer_demo_world.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<launch>
<!--
These are the arguments you can pass this launch file.
See: gazebo_ros/launch/empty_world.launch for details.
-->
<arg name="paused" default="false" />
<arg name="use_sim_time" default="true" />
<arg name="extra_gazebo_args"
default="--server-plugin libRegisterSensorsPlugin.so
--gui-plugin libRegisterSensorsPlugin.so"
/>
<arg name="gui" default="true" />
<arg name="recording" default="false" />
<arg name="debug" default="false" />
<arg name="verbose" default="false" />

<!-- Resume the logic in empty_world.launch, over-riding a number of arguments -->
<include file="$(find asv_sim_gazebo)/launch/empty_world.launch">
<arg name="world_name" value="$(find asv_sim_gazebo)/worlds/anemometer_demo.world" />
<arg name="paused" value="$(arg paused)" />
<arg name="use_sim_time" value="$(arg use_sim_time)" />
<arg name="extra_gazebo_args" value="$(arg extra_gazebo_args)" />
<arg name="gui" value="$(arg gui)" />
<arg name="recording" value="$(arg recording)" />
<arg name="debug" value="$(arg debug)" />
<arg name="verbose" value="$(arg verbose)" />
</include>
</launch>
25 changes: 0 additions & 25 deletions asv_sim_gazebo/launch/arran_lamlash_world.launch

This file was deleted.

52 changes: 52 additions & 0 deletions asv_sim_gazebo/launch/empty_world.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0"?>
<launch>

<!-- these are the arguments you can pass this launch file, for example paused:=true -->
<arg name="paused" default="false"/>
<arg name="use_sim_time" default="true"/>
<arg name="extra_gazebo_args" default=""/>
<arg name="gui" default="true"/>
<arg name="recording" default="false"/>
<!-- Note that 'headless' is currently non-functional. See gazebo_ros_pkgs issue #491 (-r arg does not disable
rendering, but instead enables recording). The arg definition has been left here to prevent breaking downstream
launch files, but it does nothing. -->
<arg name="headless" default="false"/>
<arg name="debug" default="false"/>
<arg name="physics" default="ode"/>
<arg name="verbose" default="false"/>
<arg name="output" default="screen"/>
<arg name="world_name" default="worlds/empty.world"/> <!-- Note: the world_name is with respect to GAZEBO_RESOURCE_PATH environmental variable -->
<arg name="respawn_gazebo" default="false"/>
<arg name="use_clock_frequency" default="false"/>
<arg name="pub_clock_frequency" default="100"/>
<arg name="enable_ros_network" default="true" />

<!-- set use_sim_time flag -->
<param name="/use_sim_time" value="$(arg use_sim_time)"/>

<!-- set command arguments -->
<arg unless="$(arg paused)" name="command_arg1" value=""/>
<arg if="$(arg paused)" name="command_arg1" value="-u"/>
<arg unless="$(arg recording)" name="command_arg2" value=""/>
<arg if="$(arg recording)" name="command_arg2" value="-r"/>
<arg unless="$(arg verbose)" name="command_arg3" value=""/>
<arg if="$(arg verbose)" name="command_arg3" value="--verbose"/>
<arg unless="$(arg debug)" name="script_type" value="gzserver"/>
<arg if="$(arg debug)" name="script_type" value="debug"/>

<!-- start gazebo server-->
<group if="$(arg use_clock_frequency)">
<param name="gazebo/pub_clock_frequency" value="$(arg pub_clock_frequency)" />
</group>
<group>
<param name="gazebo/enable_ros_network" value="$(arg enable_ros_network)" />
</group>
<node name="gazebo" pkg="gazebo_ros" type="$(arg script_type)" respawn="$(arg respawn_gazebo)" output="$(arg output)"
args="$(arg command_arg1) $(arg command_arg2) $(arg command_arg3) -e $(arg physics) $(arg extra_gazebo_args) $(arg world_name)" />

<!-- start gazebo client -->
<group if="$(arg gui)">
<node name="gazebo_gui" pkg="gazebo_ros" type="gzclient" respawn="false" output="$(arg output)" args="$(arg command_arg3) $(arg extra_gazebo_args)"/>
</group>

</launch>
25 changes: 0 additions & 25 deletions asv_sim_gazebo/launch/luing_sound_world.launch

This file was deleted.

25 changes: 0 additions & 25 deletions asv_sim_gazebo/launch/milford_haven_world.launch

This file was deleted.

25 changes: 0 additions & 25 deletions asv_sim_gazebo/launch/swansea_bay_world.launch

This file was deleted.

Loading

0 comments on commit 728d530

Please sign in to comment.