Skip to content

Commit 90755ea

Browse files
authored
Merge pull request #13 from mleegwt/feature/workaround
Testing of navigation
2 parents 7458d91 + 096bb08 commit 90755ea

File tree

22 files changed

+314
-33
lines changed

22 files changed

+314
-33
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Load ROS 2:
44
`source /opt/ros/jazzy/setup.bash`
55

6+
Navigate to ROS workspace:
7+
`cd ros_ws`
8+
69
Build and run temperature sensor node (my SensorID):
710
`colcon build && source ./install/setup.bash && ros2 run tempreader tempreaderNode --ros-args -p sensorId:=28.C23646D48524 &`
811

ros_ws/src/boat_interfaces/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ find_package(ament_cmake REQUIRED)
1010
find_package(rosidl_default_generators REQUIRED)
1111
# uncomment the following section in order to fill in
1212
# further dependencies manually.
13-
# find_package(<dependency> REQUIRED)
13+
find_package(geometry_msgs REQUIRED)
1414

1515
rosidl_generate_interfaces(${PROJECT_NAME}
16-
"msg/BoatHeading.msg"
16+
"msg/Waypoints.msg"
17+
DEPENDENCIES geometry_msgs
1718
)
1819

1920
if(BUILD_TESTING)

ros_ws/src/boat_interfaces/msg/BoatHeading.msg

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Inspired by: https://docs.ros.org/en/iron/p/nav2_msgs/interfaces/action/FollowGPSWaypoints.html
2+
geometry_msgs/PoseStamped[] gps_poses

ros_ws/src/boat_interfaces/package.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
<maintainer email="mleegwt@users.noreply.github.com">pi</maintainer>
88
<license>TODO: License declaration</license>
99

10+
<build_depend>geometry_msgs</build_depend>
11+
<exec_depend>geometry_msgs</exec_depend>
12+
<build_export_depend>geometry_msgs</build_export_depend>
13+
1014
<buildtool_depend>ament_cmake</buildtool_depend>
1115

1216
<buildtool_depend>rosidl_default_generators</buildtool_depend>
1317
<exec_depend>rosidl_default_runtime</exec_depend>
1418
<member_of_group>rosidl_interface_packages</member_of_group>
1519

16-
<!-- <test_depend>ament_lint_auto</test_depend>
17-
<test_depend>ament_lint_common</test_depend>-->
18-
1920
<export>
2021
<build_type>ament_cmake</build_type>
2122
</export>

ros_ws/src/boatcontrol/boatcontrol/boatcontrolnode.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import math
55
import rclpy
66
from rclpy.node import Node
7+
from std_msgs.msg import Float64
78

89
# Initialize serial communication for actuator control
910
serial_port = "/dev/ttyUSB0" # Update with your port
@@ -60,9 +61,9 @@ class BoatControlNode(Node):
6061

6162
def __init__(self):
6263
super().__init__('boat_control_node')
63-
self.compass_pub = self.create_publisher(BoatHeading, '/compass', 10)
64-
self.heading_sub = self.create_subscriber(Float64, '/desired_heading', self.heading_callback, 10)
65-
self.speed_sub = self.create_subscriber(Float64, '/desired_speed', self.speed_callback, 10)
64+
self.compass_pub = self.create_publisher(Float64, '/compass', 10)
65+
self.heading_sub = self.create_subscription(Float64, '/desired_heading', self.heading_callback, 10)
66+
self.speed_sub = self.create_subscription(Float64, '/desired_speed', self.speed_callback, 10)
6667
self.current_heading = None
6768
timer_period = 1 # Seconds
6869
self.timer = self.create_timer(timer_period, self.timer_callback)
@@ -72,8 +73,8 @@ def timer_callback(self):
7273
current_heading = get_heading_command()
7374
current_heading = get_heading_command()# dual reading to flush !
7475

75-
msg = BoatHeading()
76-
msg.heading = current_heading
76+
msg = Float64()
77+
msg.data = current_heading
7778
self.compass_pub.publish(msg)
7879

7980
def heading_callback(self, heading):
@@ -94,9 +95,9 @@ def main():
9495
try:
9596
time.sleep(0.5)
9697
response = ser.readline().decode().strip() # Read response from the actuator
97-
print(f"Received: {response}")
98+
print(f"Received: {response}\n")
9899
response = ser.readline().decode().strip() # Read response from the actuator
99-
print(f"Received: {response}")
100+
print(f"Received: {response}\n")
100101
send_enable_command()
101102
time.sleep(1)
102103
send_calib_command()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from launch import LaunchDescription
2+
from launch_ros.actions import Node
3+
import launch_testing.actions
4+
5+
def generate_launch_description():
6+
nodes = [
7+
Node(
8+
package='boatcontrol',
9+
executable='boatcontrol_node',
10+
name='boatcontrol_node',
11+
output='screen',
12+
parameters=[{'use_sim_time': False}]
13+
)
14+
]
15+
16+
return LaunchDescription(nodes + [
17+
launch_testing.actions.ReadyToTest()
18+
])

ros_ws/src/boatcontrol/package.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
<depend>rclpy</depend>
1212
<depend>serial</depend>
1313
<depend>time</depend>
14+
<depend>std_msgs</depend>
15+
16+
<exec_depend>boat_interfaces</exec_depend>
17+
<exec_depend>launch</exec_depend>
18+
<exec_depend>launch_testing</exec_depend>
19+
<exec_depend>launch_ros</exec_depend>
1420

1521
<test_depend>ament_copyright</test_depend>
1622
<test_depend>ament_pep257</test_depend>

ros_ws/src/boatcontrol/setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
version='0.0.0',
88
packages=find_packages(exclude=['test']),
99
data_files=[
10-
('share/ament_index/resource_index/packages',
11-
['resource/' + package_name]),
10+
('share/ament_index/resource_index/packages', ['resource/' + package_name]),
11+
('share/' + package_name + '/launch', ['launch/boatcontrol.launch.py']),
1212
('share/' + package_name, ['package.xml']),
1313
],
1414
install_requires=['setuptools'],
@@ -20,6 +20,7 @@
2020
tests_require=['pytest'],
2121
entry_points={
2222
'console_scripts': [
23+
'boatcontrol_node = boatcontrol.boatcontrolnode:main'
2324
],
2425
},
2526
)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from launch import LaunchDescription
2+
from launch.launch_description_sources import PythonLaunchDescriptionSource
3+
from launch.actions import IncludeLaunchDescription
4+
from launch_ros.actions import Node
5+
from ament_index_python.packages import get_package_share_directory
6+
import os
7+
8+
def generate_launch_description():
9+
gpsd_client_dir = get_package_share_directory('gpsd_client')
10+
gpsd_launch = IncludeLaunchDescription(
11+
PythonLaunchDescriptionSource(
12+
os.path.join(gpsd_client_dir, 'launch', 'gpsd_client-launch.py')
13+
)
14+
)
15+
16+
boatcontrol_dir = get_package_share_directory('boatcontrol')
17+
boatcontrol = IncludeLaunchDescription(
18+
PythonLaunchDescriptionSource(
19+
os.path.join(boatcontrol_dir, 'launch', 'boatcontrol.launch.py')
20+
)
21+
)
22+
23+
sensorfusion_dir = get_package_share_directory('sensorfusion')
24+
sensorfusion = IncludeLaunchDescription(
25+
PythonLaunchDescriptionSource(
26+
os.path.join(sensorfusion_dir, 'launch', 'sensorfusion.launch.py')
27+
)
28+
)
29+
30+
nav_dir = get_package_share_directory('navigation')
31+
nav_launch = IncludeLaunchDescription(
32+
PythonLaunchDescriptionSource(
33+
os.path.join(nav_dir, 'launch', 'nav2_stack.launch.py')
34+
)
35+
)
36+
37+
return LaunchDescription([
38+
gpsd_launch,
39+
boatcontrol,
40+
sensorfusion,
41+
nav_launch
42+
])

0 commit comments

Comments
 (0)