Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Mock AIS #46

Merged
merged 8 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ endforeach()

# Boost
find_package(Boost 1.74.0 COMPONENTS REQUIRED
# Insert desired libraries below (see /usr/include/boost/ for available options)
serialization
system
thread
Expand Down
10 changes: 5 additions & 5 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ description at the top describing its purpose.

To run with pure default defined in the code, run:

```
```shell
ros2 launch network_systems main_launch.py
```

To run with config files in this folder:

```
```shell
ros2 launch network_systems main_launch.py config:=<comma separated list of config files>
```

For example:

```
```shell
ros2 launch network_systems main_launch.py config:=default_prod_en.yaml
```

launches network_systems with the parameters specified in `default_prod_en.yaml`.

```
```shell
ros2 launch network_systems main_launch.py config:=default.yaml,example/example_en.yaml
```

Expand All @@ -34,7 +34,7 @@ launches network_systems with the parameters specified in `default_prod_en.yaml`

**NOTE**: Instead of defining a `mode` parameter for each node, a global ROS launch argument is used.

```
```shell
ros2 launch network_systems main_launch.py config:=<...> mode:=production
ros2 launch network_systems main_launch.py config:=<...> mode:=development
```
Expand Down
4 changes: 4 additions & 0 deletions config/default_prod_en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ network_systems:
ros__parameters:
enabled: true

mock_ais_node:
ros__parameters:
enabled: false

remote_transceiver_node:
ros__parameters:
enabled: true
5 changes: 5 additions & 0 deletions config/mock_ais/mock_ais_en_default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Enable Mock AIS with default settings
network_systems:
mock_ais_node:
ros__parameters:
enabled: true
11 changes: 11 additions & 0 deletions config/mock_ais/mock_ais_template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Template for the Mock AIS module
network_systems:
mock_ais_node:
ros__parameters:
enabled: true
# The following parameters are optional. Defaults are set in mock_ais_ros_intf.cpp
publish_rate_ms: # Integer: How frequently the Mock AIS publishes data in milliseconds (ex. 500)
seed: # Integer: Random seed used for random data generation
num_sim_ships: # Integer: Total number of AIS ships to simulate (does not include Polaris)
polaris_start_pos: # Integer Array (size 2): Initial latitude and longitude of Polaris for simulation
# (ex. [49.283, -123.652])
38 changes: 36 additions & 2 deletions launch/main_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def setup_launch(context: LaunchContext) -> List[Node]:
"""
launch_description_entities = list()
launch_description_entities.append(get_cached_fib_description(context))
launch_description_entities.append(get_mock_ais_description(context))
launch_description_entities.append(get_remote_transceiver_description(context))
return launch_description_entities

Expand All @@ -88,6 +89,7 @@ def get_cached_fib_description(context: LaunchContext) -> Node:
node_name = "cached_fib_subscriber"
ros_parameters = [
global_launch_config,
{"mode": LaunchConfiguration("mode")},
*LaunchConfiguration("config").perform(context).split(","),
]
ros_arguments: List[SomeSubstitutionsType] = [
Expand All @@ -107,20 +109,52 @@ def get_cached_fib_description(context: LaunchContext) -> Node:
return node


def get_mock_ais_description(context: LaunchContext) -> Node:
"""Gets the launch description for the mock_ais node.

Args:
context (LaunchContext): The current launch context.

Returns:
Node: The node object that launches the mock_ais node.
"""
node_name = "mock_ais_node"
ros_parameters = [
global_launch_config,
{"mode": LaunchConfiguration("mode")},
*LaunchConfiguration("config").perform(context).split(","),
]
ros_arguments: List[SomeSubstitutionsType] = [
"--log-level",
[f"{node_name}:=", LaunchConfiguration("log_level")],
]

node = Node(
package=PACKAGE_NAME,
namespace=NAMESPACE,
executable="mock_ais",
name=node_name,
parameters=ros_parameters,
ros_arguments=ros_arguments,
)

return node


def get_remote_transceiver_description(context: LaunchContext) -> Node:
"""Gets the launch description for the remote_transceiver node.

Args:
context (LaunchContext): The current launch context.

Returns:
Node: The node object that launches the cached_fib node.
Node: The node object that launches the remote_transceiver node.
"""
node_name = "remote_transceiver_node"
ros_parameters = [
global_launch_config,
*LaunchConfiguration("config").perform(context).split(","),
{"mode": LaunchConfiguration("mode")},
*LaunchConfiguration("config").perform(context).split(","),
]
ros_arguments: List[SomeSubstitutionsType] = [
"--log-level",
Expand Down
22 changes: 12 additions & 10 deletions lib/cmn_hdrs/shared_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@ constexpr float HEADING_LBND = 0.0;
constexpr float HEADING_UBND = 360.0;

// boat rotation
constexpr float ROT_LBND = -360.0;
constexpr float ROT_UBND = 360;
// See https://documentation.spire.com/ais-fundamentals/rate-of-turn-rot/ for how ROT works
constexpr int8_t ROT_LBND = -126;
constexpr int8_t ROT_UBND = 126;

// boat dimension
constexpr float DIMENSION_LBND = 0;
constexpr float DIMENSION_UBND = 650.0;
constexpr float SHIP_DIMENSION_LBND = 1; // arbitrary number
constexpr float SHIP_DIMENSION_UBND = 650.0; // arbitrary number

/***** Bounds for Battery ******/
constexpr float VOLT_LBND = 0.5; // Placeholder number
constexpr float VOLT_UBND = 250.0; // Placeholder number
constexpr float CURRENT_LBND = -200.0; // Placeholder number
constexpr float CURRENT_UBND = 200.0; // Placeholder number
constexpr float BATT_VOLT_LBND = 0.5; // Placeholder number
constexpr float BATT_VOLT_UBND = 250.0; // Placeholder number
constexpr float BATT_CURR_LBND = -200.0; // Placeholder number
constexpr float BATT_CURR_UBND = 200.0; // Placeholder number

/***** Bounds for Wind Sensor ******/
constexpr int DIRECTION_LBND = -180;
constexpr int DIRECTION_UBND = 179;
constexpr int WIND_DIRECTION_LBND = -180;
constexpr int WIND_DIRECTION_UBND = 179;
1 change: 1 addition & 0 deletions projects/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(mock_ais)
add_subdirectory(can_transceiver)
add_subdirectory(example)
add_subdirectory(local_transceiver)
Expand Down
31 changes: 31 additions & 0 deletions projects/mock_ais/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
set(module mock_ais)

# define external dependencies with link_libs and inc_dirs variables
set(link_libs
)

set(inc_dirs
)

set(compile_defs
)

# Create module library
set(srcs
${CMAKE_CURRENT_LIST_DIR}/src/mock_ais.cpp
)
make_lib(${module} "${srcs}" "${link_libs}" "${inc_dirs}" "${compile_defs}")

# Create module ROS executable
set(bin_srcs
${srcs}
${CMAKE_CURRENT_LIST_DIR}/src/mock_ais_ros_intf.cpp
)
make_exe(${module} "${bin_srcs}" "${link_libs}" "${inc_dirs}" "${compile_defs}")

# Create unit test
set(test_srcs
${srcs}
${CMAKE_CURRENT_LIST_DIR}/test/test_mock_ais.cpp
)
make_unit_test(${module} "${test_srcs}" "${link_libs}" "${inc_dirs}" "${compile_defs}")
Loading