Skip to content

Migrate sailing-robot from ROS 1 to ROS 2 - #276

Open
tsaoyu with Copilot wants to merge 7 commits into
masterfrom
copilot/rewrite-project-in-ros2
Open

Migrate sailing-robot from ROS 1 to ROS 2#276
tsaoyu with Copilot wants to merge 7 commits into
masterfrom
copilot/rewrite-project-in-ros2

Conversation

Copilot AI commented Mar 17, 2026

Copy link
Copy Markdown

Full port of the sailing-robot stack from ROS 1 (Indigo/catkin/rospy) to ROS 2 (Humble/ament/rclpy). All nodes, launch files, build system, CI, and tests updated.

Build system

  • package.xml → format 3, ament_cmake / ament_python
  • CMakeLists.txtament_cmake with rosidl_generate_interfaces
  • setup.py / setup.cfgament_python entry-point style
  • LatLonLatLon23 (Python 3 compatible) throughout

Node scripts (~30 nodes)

All scripts converted from procedural rospy.init_node pattern to class-based rclpy.node.Node:

# Before (ROS 1)
rospy.init_node('helming')
rate = rospy.Rate(rospy.get_param('config/rate'))
pub = rospy.Publisher('rudder_angle', Float32, queue_size=10)

# After (ROS 2)
class Helming(Node):
    def __init__(self):
        super().__init__('helming')
        self.declare_parameter('config.rate', 10)
        self.pub = self.create_publisher(Float32, 'rudder_angle', 10)
        rate = self.get_parameter('config.rate').value
        self.create_timer(1.0 / rate, self.timer_callback)

tasks_ros.py library

RosTasksRunner now accepts a node= kwarg instead of calling rospy.Publisher at module level. A _NullPublisher stub allows the class to be instantiated in tests without a live ROS 2 daemon.

xsens_driver/nodes/mtnode.py

Full rewrite: XSensDriver(Node), all publishers created upfront in __init__, device polling moved to a create_timer callback, tf.transformationstf_transformations with pure-math fallback, Python 3 q_mult tuple-arg syntax fixed, Header.seq removed (dropped in ROS 2).

Launch files

All XML .launch files replaced with Python .launch.py equivalents using launch_ros.actions.Node and IncludeLaunchDescription.

CI

.travis.yml rewritten for ROS 2 Humble on Ubuntu 22.04, using colcon build and pytest instead of catkin_make and catkin_make run_tests.

Tests

  • nose.tools.assert_equal / assert_almost_equal → plain assert + pytest.approx
  • rostests/test_1.py converted from rostest/rospy to a pytest unittest.TestCase using rclpy directly, with @unittest.skipUnless(ROS2_AVAILABLE, ...) guard
  • All 27 pure-Python unit tests pass

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits March 17, 2026 10:27
- Update sailing_robot/package.xml to format 3 with ament_cmake deps
- Replace sailing_robot/CMakeLists.txt with ament_cmake + rosidl_generate_interfaces
- Replace sailing_robot/setup.py with standard setuptools for ROS 2
- Add sailing_robot/setup.cfg and resource/sailing_robot marker file
- Update xsens_driver/package.xml to format 3 with ament_cmake deps
- Replace xsens_driver/CMakeLists.txt with ament_cmake build
- Add xsens_driver/resource/xsens_driver marker file

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace rospy with rclpy + Node subclass pattern
- Move module-level rospy.get_param() calls into __init__
- Replace Publisher/Subscriber with create_publisher/create_subscription
- Replace Rate+while loop with create_timer callbacks
- Replace rospy.log* with self.get_logger().*
- Replace rospy.ROSInterruptException with KeyboardInterrupt
- Add main() entry-point function with rclpy.init/shutdown
- Downgrade high-frequency timer logs to debug level
- Wrap hardware imports (pigpio, ina219) in try/except for sim mode

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- simulation_position: class-based Node, rclpy pub/sub/timer/params
- simulation_velocity: class-based Node, rclpy pub/sub/timer/params
- simulation_heading: class-based Node, rclpy pub/sub/timer/params
- simulation_wind_apparent: class-based Node, rclpy pub/sub/timer/params
- simulation_gps_fix: class-based Node, rclpy pub/sub/timer
- sensor_service_imu: use tf_transformations (with scipy/manual fallback)
- debugging_gps_log: class-based Node, rclpy sub/param, proper file close
- wave_period: class-based Node, rclpy sub/timer
- wave_position: class-based Node, rclpy sub/timer/params
- sensor_driver_imu_fusion: class-based Node, rclpy pub/timer, RTIMU guard

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tring in debugging_gps_log

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace rospy with rclpy + Node subclass pattern
- Move module-level rospy.get_param() calls into Node constructors
- Replace dynamic_reconfigure with declare_parameter/get_parameter
- Replace rospy.Publisher/Subscriber with create_publisher/create_subscription
- Replace rospy.Rate loops with create_timer callbacks
- Replace rospy.logXXX with self.get_logger().XXX
- Replace rospy.ROSInterruptException with KeyboardInterrupt
- Add proper main() functions with rclpy.init/spin/shutdown

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor project codebase to ROS2 Migrate project from ROS 1 (Indigo/catkin) to ROS 2 (rclpy/ament) Mar 17, 2026
Copilot AI requested a review from tsaoyu March 17, 2026 11:09
…r, tests

Co-authored-by: tsaoyu <6488896+tsaoyu@users.noreply.github.com>
Copilot AI changed the title Migrate project from ROS 1 (Indigo/catkin) to ROS 2 (rclpy/ament) Migrate sailing-robot from ROS 1 to ROS 2 Mar 17, 2026
@tsaoyu
tsaoyu marked this pull request as ready for review March 18, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants