Skip to content

Commit ace9609

Browse files
authored
Merge pull request #2 from aerostack2/psdk_ros2_v1.3.0
[as2_platform_dji_psdk] Update changes in launcher and params to psdk_ros2 v1.3.0
2 parents d39d88b + 18bf203 commit ace9609

7 files changed

+88
-36
lines changed

config/platform_config_file.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/**:
22
ros__parameters:
3-
cmd_freq: 30.0 # Hz (default: 100.0)
4-
info_freq: 10.0 # Hz (default: 10.0)
5-
enable_camera: false # (default: false)
6-
enable_gimbal: false # (default: false)
7-
gimbal_base_frame_id: "gimbal_base" # (default: "gimbal_base")
8-
tf_timeout_threshold: 0.05 # Default tf timeout (50ms)
3+
cmd_freq: 30.0 # Command send frequency to the platform (default: 30.0 Hz)
4+
info_freq: 10.0 # Info send frequency to ROS 2 (default: 10.0 Hz)
5+
enable_camera: false # Enable camera image publishing (default: false)
6+
enable_gimbal: false # Enable gimbal control (default: false)
7+
tf_timeout_threshold: 0.05 # tf timeout (default: 0.05 s)

config/psdk_authentication.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**:
2+
ros__parameters:
3+
app_name: "YourPSDK"
4+
app_id: "YourID"
5+
app_key: "YourAppKey"
6+
app_license: "YourAppLicense"
7+
developer_account: "YourDeveloperAccount"
8+
baudrate: "921600"

config/psdk_params.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**:
2+
ros__parameters:
3+
num_of_initialization_retries: 3
4+
5+
imu_frame: "imu_link"
6+
body_frame: "base_link"
7+
map_frame: "psdk_map_enu"
8+
gimbal_base_frame: "gimbal_base"
9+
gimbal_frame: "gimbal"
10+
camera_frame: "camera_link"
11+
publish_transforms: true
12+
13+
file_path: "/tmp/"
14+
15+
# Mandatory modules to be initialized. Mark with a true those which you
16+
# consider mandatory for your application, false otherwise. Be aware that
17+
# some modules might have inter-dependencies. Non mandatory modules will
18+
# still be initialized but if case of failure, the node will continue to run.
19+
mandatory_modules:
20+
telemetry: true
21+
flight_control: true
22+
camera: false
23+
gimbal: false
24+
liveview: false
25+
hms: false
26+
27+
data_frequency: # Options are: 1, 5, 10, 50, 100, 200, 400 Hz
28+
imu: 1
29+
attitude: 10
30+
acceleration: 10
31+
velocity: 50
32+
angular_velocity: 10
33+
position: 50
34+
altitude: 50
35+
gps_fused_position: 50
36+
gps_data: 1
37+
rtk_data: 50
38+
magnetometer: 1
39+
rc_channels_data: 1
40+
gimbal_data: 10
41+
flight_status: 1
42+
battery_level: 1
43+
control_information: 1
44+
esc_data_frequency: 1
45+

include/as2_platform_dji_psdk/as2_platform_dji_psdk.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class DJIMatricePSDKPlatform : public as2::AerialPlatform
9292
as2::tf::TfHandler tf_handler_;
9393
std::chrono::nanoseconds tf_timeout_;
9494
bool enable_gimbal_;
95-
std::string gimbal_base_frame_id_;
9695
psdk_interfaces::msg::GimbalRotation gimbal_command_msg_;
9796
rclcpp::Time last_gimbal_command_time_;
9897

launch/as2_platform_dji_psdk.launch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@
3939
from as2_core.launch_configuration_from_config_file import LaunchConfigurationFromConfigFile
4040
from launch import LaunchDescription
4141
from launch.actions import DeclareLaunchArgument
42-
from launch.substitutions import EnvironmentVariable, LaunchConfiguration, PathJoinSubstitution
42+
from launch.substitutions import EnvironmentVariable, LaunchConfiguration
4343
from launch_ros.actions import Node
44-
from launch_ros.substitutions import FindPackageShare
4544

4645

4746
def generate_launch_description() -> LaunchDescription:
@@ -53,8 +52,10 @@ def generate_launch_description() -> LaunchDescription:
5352
"""
5453
# Get default platform configuration file
5554
package_folder = get_package_share_directory('as2_platform_dji_psdk')
55+
5656
platform_config_file = os.path.join(package_folder,
5757
'config/platform_config_file.yaml')
58+
5859
control_modes = PathJoinSubstitution([
5960
FindPackageShare('as2_platform_dji_psdk'),
6061
'config', 'control_modes.yaml'

launch/wrapper.launch.py renamed to launch/psdk_wrapper.launch.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@
3535
__license__ = 'BSD-3-Clause'
3636
__version__ = '0.1.0'
3737

38+
import os
39+
40+
from ament_index_python.packages import get_package_share_directory
41+
import as2_core.launch_param_utils as as2_utils
3842
import launch
3943
from launch import LaunchDescription
4044
from launch.actions import DeclareLaunchArgument, EmitEvent
41-
from launch.substitutions import EnvironmentVariable, LaunchConfiguration, PathJoinSubstitution
45+
from launch.substitutions import EnvironmentVariable, LaunchConfiguration
4246
from launch_ros.actions import LifecycleNode
4347
from launch_ros.events.lifecycle import ChangeState
44-
from launch_ros.substitutions import FindPackageShare
4548
import lifecycle_msgs.msg
4649

4750

@@ -52,21 +55,20 @@ def generate_launch_description() -> LaunchDescription:
5255
:return: Launch description
5356
:rtype: LaunchDescription
5457
"""
55-
# Declare the namespace launch argument
56-
psdk_params_file = PathJoinSubstitution([
57-
FindPackageShare('as2_platform_dji_psdk'),
58-
'config', 'psdk_params.yaml'
59-
])
58+
package_folder = get_package_share_directory(
59+
'as2_platform_dji_psdk')
6060

61-
link_config_file = PathJoinSubstitution([
62-
FindPackageShare('as2_platform_dji_psdk'),
63-
'config', 'link_config.json'
64-
])
61+
psdk_params_file = os.path.join(package_folder,
62+
'config/psdk_params.yaml')
6563

66-
hms_return_codes_file = PathJoinSubstitution([
67-
FindPackageShare('as2_platform_dji_psdk'),
68-
'config', 'hms_2023_08_22.json'
69-
])
64+
psdk_authentication_params_file = os.path.join(package_folder,
65+
'config/psdk_authentication_params.yaml')
66+
67+
link_config_file = os.path.join(package_folder,
68+
'config/link_config.json')
69+
70+
hms_return_codes_file = os.path.join(package_folder,
71+
'config/hms_2023_08_22.json')
7072

7173
# Prepare the wrapper node
7274
wrapper_node = LifecycleNode(
@@ -77,12 +79,13 @@ def generate_launch_description() -> LaunchDescription:
7779
output='screen',
7880
emulate_tty=True,
7981
parameters=[
82+
*as2_utils.launch_configuration('psdk_params_file',
83+
default_value=psdk_params_file),
8084
{
8185
'link_config_file_path': LaunchConfiguration('link_config_file_path'),
8286
'hms_return_codes_path': LaunchConfiguration('hms_return_codes_path'),
83-
'tf_frame_prefix': LaunchConfiguration('tf_frame_prefix'),
8487
},
85-
LaunchConfiguration('psdk_params_file_path'),
88+
LaunchConfiguration('psdk_authentication_params_file'),
8689
],
8790
remappings=[
8891
('psdk_ros2/gps_position_fused', 'sensor_measurements/gps'),
@@ -114,18 +117,19 @@ def generate_launch_description() -> LaunchDescription:
114117
default_value=EnvironmentVariable(
115118
'AEROSTACK2_SIMULATION_DRONE_ID'),
116119
description='Drone namespace'),
117-
DeclareLaunchArgument('psdk_params_file_path',
118-
default_value=psdk_params_file,
119-
description='DJI PSDK configuration file'),
120+
DeclareLaunchArgument('psdk_authentication_params_file',
121+
default_value=psdk_authentication_params_file,
122+
description='DJI PSDK authentication file'),
120123
DeclareLaunchArgument('link_config_file_path',
121124
default_value=link_config_file,
122125
description='DJI PSDK link configuration file'),
123126
DeclareLaunchArgument('hms_return_codes_path',
124127
default_value=hms_return_codes_file,
125128
description='Path to JSON file with known DJI return codes'),
126-
DeclareLaunchArgument('tf_frame_prefix',
127-
default_value='',
128-
description='TF frame prefix'),
129+
*as2_utils.declare_launch_arguments(
130+
'psdk_params_file',
131+
default_value=psdk_params_file,
132+
description='Paremeters for DJI PSDK authentication'),
129133
])
130134

131135
# Declare Launch options

src/as2_platform_dji_psdk.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ void DJIMatricePSDKPlatform::configureSensors()
156156
if (!success) {
157157
RCLCPP_INFO(this->get_logger(), "Could not reset gimbal");
158158
enable_gimbal_ = false;
159-
} else {
160-
this->declare_parameter<std::string>("gimbal_base_frame_id", "gimbal_base");
161-
this->get_parameter("gimbal_base_frame_id", gimbal_base_frame_id_);
162-
gimbal_base_frame_id_ = as2::tf::generateTfName(this->get_namespace(), gimbal_base_frame_id_);
163159
}
164160
}
165161
last_gimbal_command_time_ = this->now();

0 commit comments

Comments
 (0)