Skip to content

Commit 4346427

Browse files
authored
Merge pull request #10 from aerostack2/9-dji-m30t-cannot-obtain-control-authority-but-dji-example-works
9 dji m30t cannot obtain control authority but dji example works
2 parents 087bc60 + 910451f commit 4346427

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/as2_platform_dji_psdk.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,11 @@ bool DJIMatricePSDKPlatform::ownSetOffboardControl(bool offboard)
172172
{
173173
if (!offboard) {
174174
// Release control authority
175+
RCLCPP_INFO(this->get_logger(), "Releasing control authority");
175176
return setControlAuthority(false);
176177
}
177-
return true;
178+
RCLCPP_INFO(this->get_logger(), "Obtain control authority");
179+
return setControlAuthority(true);
178180
}
179181

180182
bool DJIMatricePSDKPlatform::ownSetPlatformControlMode(const as2_msgs::msg::ControlMode & msg)
@@ -196,7 +198,7 @@ bool DJIMatricePSDKPlatform::ownSetPlatformControlMode(const as2_msgs::msg::Cont
196198
{
197199
// Obtain control authority
198200
RCLCPP_INFO(this->get_logger(), "HOVER || SPEED MODE: Obtain control authority");
199-
success = setControlAuthority(true);
201+
success = ctl_authority_;
200202
break;
201203
}
202204
default:
@@ -275,6 +277,9 @@ bool DJIMatricePSDKPlatform::ownTakeoff()
275277
bool success = result && response->success;
276278
if (!success) {
277279
RCLCPP_INFO(this->get_logger(), "Could not takeoff due to '%s'", response->message.data());
280+
} else {
281+
// sleep 10 seconds to wait for the takeoff
282+
rclcpp::sleep_for(std::chrono::seconds(10));
278283
}
279284
return success;
280285
}
@@ -289,6 +294,9 @@ bool DJIMatricePSDKPlatform::ownLand()
289294
bool success = result && response->success;
290295
if (!success) {
291296
RCLCPP_INFO(this->get_logger(), "Could not land due to '%s'", response->message.data());
297+
} else {
298+
// sleep 10 seconds to wait for the land
299+
rclcpp::sleep_for(std::chrono::seconds(10));
292300
}
293301
return success;
294302
}

0 commit comments

Comments
 (0)