Skip to content

Commit 46445b0

Browse files
authored
Merge pull request #16 from mleegwt/master
Preparing for MPU9250 and improving Nav2 configuration. Never been so close to waypoint navigation.
2 parents 9c8e803 + ff6d79d commit 46445b0

File tree

24 files changed

+273
-414
lines changed

24 files changed

+273
-414
lines changed

.github/workflows/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ jobs:
1212
required-ros-distributions: jazzy
1313
- uses: ros-tooling/action-ros-ci@v0.3
1414
with:
15-
package-name: boat_interfaces boatcontrol navigation tempreader sensorfusion
15+
package-name: boat_interfaces boatcontrol navigation tempreader
1616
target-ros2-distro: jazzy
1717

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.*
21
ros_ws/log/*
32
ros_ws/src/log/*
43
ros_ws/build/*

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Load ROS 2:
66
Navigate to ROS workspace:
77
`cd ros_ws`
88

9+
# Temerature sensor
910
Build and run temperature sensor node (my SensorID):
1011
`colcon build && source ./install/setup.bash && ros2 run tempreader tempreaderNode --ros-args -p sensorId:=28.C23646D48524 &`
1112

@@ -19,3 +20,26 @@ Read fixes from GPS:
1920

2021
Read temperature:
2122
`ros2 topic echo /temperature`
23+
24+
# Boat total setup launch file
25+
26+
This currently works on My Machine TM (use the generic instructions at the top first):
27+
`colcon build && source install/setup.bash && ros2 launch navigation boat.launch.py`
28+
29+
## Installation of ROS2 packages
30+
31+
Currently the following packages have been installed (these will introduce many dependencies, list generated with `apt-mark showmanual > ~/manual-packages.txt`:
32+
ros-dev-tools
33+
ros-jazzy-gps-tools
34+
ros-jazzy-gpsd-client
35+
ros-jazzy-mapviz-interfaces
36+
ros-jazzy-nav2-bringup
37+
ros-jazzy-nav2-waypoint-follower
38+
ros-jazzy-navigation2
39+
ros-jazzy-robot-localization
40+
ros-jazzy-ros-base
41+
ros-jazzy-ros2-control
42+
ros-jazzy-ros2-controllers
43+
ros-jazzy-tf-transformations
44+
ros2-apt-source
45+

ros_ws/src/boatcontrol/boatcontrol/boatcontrolnode.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self):
1919
self.heading_sub = self.create_subscription(Float64, '/desired_heading', self.heading_callback, 10)
2020
self.speed_sub = self.create_subscription(Float64, '/desired_speed', self.speed_callback, 10)
2121
self.current_heading = None
22-
timer_period = 1 # Seconds
22+
timer_period = 0.05 # Seconds
2323
self.timer = self.create_timer(timer_period, self.timer_callback)
2424

2525
def start(self):
@@ -29,8 +29,7 @@ def start(self):
2929
response = ser.readline().decode().strip() # Read response from the actuator
3030
self.get_logger().info(f"Received: {response}")
3131
self.send_enable_command()
32-
time.sleep(1)
33-
self.send_calib_command()
32+
time.sleep(0.1)
3433
self.send_speed_command(30)
3534

3635
def timer_callback(self):
@@ -51,11 +50,11 @@ def speed_callback(self, speed):
5150
def send_command(self, command):
5251
if ser.is_open:
5352
ser.write(command.encode())
54-
time.sleep(1)
53+
time.sleep(0.01)
5554
response=""
5655
while "OK" not in response:
5756
response = ser.readline().decode().strip() # Read response from the actuator
58-
time.sleep(0.2)
57+
time.sleep(0.01)
5958
self.get_logger().debug(f"Sent: {command}, Received: {response}")
6059
return response
6160

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,29 @@
1-
controller_server:
1+
/controller_server:
22
ros__parameters:
3-
use_sim_time: true
4-
controller_plugins: ["FollowPath"]
5-
6-
FollowPath:
7-
plugin: "dwb_core::DWBLocalPlanner"
8-
9-
debug_trajectory_details: true
10-
min_vel_x: 0.0
11-
max_vel_x: 0.26
12-
min_vel_y: 0.0
13-
max_vel_y: 0.0
14-
max_vel_theta: 1.0
15-
min_speed_xy: 0.0
16-
max_speed_xy: 0.26
17-
min_speed_theta: 0.0
18-
19-
acc_lim_x: 2.5
20-
acc_lim_y: 0.0
21-
acc_lim_theta: 3.2
22-
23-
decel_lim_x: -1.0
24-
decel_lim_y: 0.0
25-
decel_lim_theta: -1.0
26-
27-
vx_samples: 20
28-
vtheta_samples: 40
29-
30-
sim_time: 1.7
31-
linear_granularity: 0.05
32-
angular_granularity: 0.025
33-
transform_tolerance: 0.2
34-
35-
critics: [
36-
"RotateToGoal",
37-
# "ObstacleFootprint",
38-
"GoalAlign",
39-
"PathAlign",
40-
"PathDist",
41-
"GoalDist",
42-
"PreferForward"
43-
]
3+
use_sim_time: false
4+
controller_plugins: ["FollowWaypoints"]
5+
6+
local_costmap:
7+
global_frame: local_enu
8+
robot_base_frame: base_link
9+
update_frequency: 5.0
10+
publish_frequency: 2.0
11+
rolling_window: true
12+
width: 1000.0
13+
height: 1000.0
14+
resolution: 5.0
15+
transform_tolerance: 1.0
16+
inflation_radius: 0.5
17+
cost_scaling_factor: 10.0
18+
19+
plugins:
20+
- name: obstacle_layer
21+
type: "nav2_costmap_2d::ObstacleLayer"
22+
- name: inflation_layer
23+
type: "nav2_costmap_2d::InflationLayer"
24+
25+
FollowWaypoints:
26+
plugin: "nav2_controller::FollowWaypoints"
27+
allow_in_place_goal: true
28+
controller_frequency: 10.0
4429

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/ekf_filter_node:
2+
ros__parameters:
3+
frequency: 5.0
4+
sensor_timeout: 5.0
5+
initial_state_timeout: 10.0
6+
two_d_mode: true
7+
publish_tf: true
8+
map_frame: map
9+
odom_frame: odom
10+
base_link_frame: base_link
11+
world_frame: map
12+
imu0: /imu/data
13+
imu0_config: [false, false, false,
14+
true, true, true,
15+
false, false, false,
16+
false, false, false,
17+
true, true, true]
18+
imu0_differential: false
19+
imu0_remove_gravitational_acceleration: true
20+
imu0_covariance: [
21+
0.02, 0.0, 0.0,
22+
0.0, 0.02, 0.0,
23+
0.0, 0.0, 0.02
24+
]
25+
imu0_queue_size: 10
26+
27+
gps0: /fix/valid
28+
gps0_config: [true, true, false,
29+
false, false, false,
30+
false, false, false]
31+
gps0_queue_size: 10
32+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
navsat_transform_node:
2+
ros__parameters:
3+
frequency: 2.5
4+
delay: 1.0
5+
magnetic_declination_radians: 0.0
6+
yaw_offset: 0.0
7+
zero_altitude: true
8+
broadcast_cartesian_transform: true
9+
publish_filtered_gps: true
10+
11+
use_odometry_yaw: false # We hebben een IMU!
12+
use_local_cartesian: true # Handig voor testgebieden
13+
wait_for_datum: false # Gebruik eerste fix als referentie
14+
world_frame: map
15+
map_frame: map
16+
child_frame_id: local_enu
17+
18+
gps_topic: /fix/valid
19+
imu_topic: /imu/data
20+
odometry_topic: /odometry/gps
21+
22+
imu_queue_size: 50
23+
gps_queue_size: 10
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/planner_server:
2+
ros__parameters:
3+
use_sim_time: false
4+
planner_frequency: 0.5
5+
expected_planner_frequency: 0.5
6+
7+
planner_plugins: ["GridBased"]
8+
GridBased:
9+
plugin: "nav2_smac_planner::SmacPlanner2D"
10+
11+
expected_planner_frequency: 20.0
12+
13+
global_costmap:
14+
static_layer:
15+
enabled: false

ros_ws/src/navigation/launch/boat.launch.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ def generate_launch_description():
2020
)
2121
)
2222

23-
sensorfusion_dir = get_package_share_directory('sensorfusion')
24-
sensorfusion = IncludeLaunchDescription(
23+
imu_dir = get_package_share_directory('mpu9250')
24+
imu = IncludeLaunchDescription(
2525
PythonLaunchDescriptionSource(
26-
os.path.join(sensorfusion_dir, 'launch', 'sensorfusion.launch.py')
26+
os.path.join(imu_dir, 'launch', 'mpu9250.launch.py')
2727
)
2828
)
2929

30+
3031
nav_dir = get_package_share_directory('navigation')
3132
nav_launch = IncludeLaunchDescription(
3233
PythonLaunchDescriptionSource(
@@ -37,6 +38,6 @@ def generate_launch_description():
3738
return LaunchDescription([
3839
gpsd_launch,
3940
boatcontrol,
40-
sensorfusion,
41+
imu,
4142
nav_launch
4243
])

0 commit comments

Comments
 (0)