Skip to content

Commit

Permalink
Added plotting method choice
Browse files Browse the repository at this point in the history
  • Loading branch information
Mokaz committed Apr 7, 2024
1 parent f99a935 commit 573263b
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 0 deletions.
27 changes: 27 additions & 0 deletions simulation/asv_simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.8)
project(asv_simulator)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake_python REQUIRED)
find_package(rclpy REQUIRED)
find_package(vortex_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)

ament_python_install_package(${PROJECT_NAME})

install(DIRECTORY
launch
config
DESTINATION share/${PROJECT_NAME}
)

install(PROGRAMS
asv_simulator/asv_simulator_node.py
DESTINATION lib/${PROJECT_NAME}
)

ament_package()
Empty file.
30 changes: 30 additions & 0 deletions simulation/asv_simulator/asv_simulator/asv_simulator_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from asv_simulator.plotting_matplotlib import plot_matplotlib
from asv_simulator.realtime_plotting_foxglove import plot_foxglove

class PlottingNode(Node):
def __init__(self):
super().__init__('asv_simulator_node')

self.declare_parameter('plotting_method', 'matplotlib')
plotting_library = self.get_parameter('plotting_method').value

logger = self.get_logger()

if plotting_library == 'matplotlib':
plot_matplotlib(logger)
elif plotting_library == 'foxglove':
plot_foxglove(logger)
else:
self.get_logger().error("Invalid plotting method choice!")

def main(args=None):
rclpy.init(args=args)
node = PlottingNode()
rclpy.spin(node)
rclpy.shutdown()

if __name__ == '__main__':
main()
2 changes: 2 additions & 0 deletions simulation/asv_simulator/asv_simulator/plotting_matplotlib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def plot_matplotlib(logger):
logger.info("U chose matplotlib XD")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def plot_foxglove(logger):
logger.info("U chose foxglove lol")
20 changes: 20 additions & 0 deletions simulation/asv_simulator/launch/asv_simulator.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument, LogInfo
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node

def generate_launch_description():
return LaunchDescription([
DeclareLaunchArgument(
'plotting_method',
default_value='matplotlib',
description='Choose the plotting library: matplotlib or foxglove'
),
Node(
package='asv_simulator',
executable='asv_simulator_node.py',
name='asv_simulator_node',
output='screen',
parameters=[{'plotting_method': LaunchConfiguration('plotting_method')}]
)
])
23 changes: 23 additions & 0 deletions simulation/asv_simulator/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>asv_simulator</name>
<version>0.0.0</version>
<description>This package provides the implementation of the asv_simulator for the Vortex ASV.</description>
<maintainer email="[email protected]">vortex</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake_python</buildtool_depend>

<depend>rclpy</depend>
<depend>python-transforms3d-pip</depend>
<depend>geometry_msgs</depend>
<depend>vortex_msgs</depend>

<test_depend>python3-pytest</test_depend>


<export>
<build_type>ament_cmake</build_type>
</export>
</package>

0 comments on commit 573263b

Please sign in to comment.