-
Notifications
You must be signed in to change notification settings - Fork 17.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AP_DDS: Split external control to its own file
* Improves encapsulation, separates concerns Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
- Loading branch information
Showing
3 changed files
with
37 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#if AP_DDS_ENABLED | ||
|
||
#include "AP_DDS_ExternalControl.h" | ||
|
||
#include <AP_ExternalControl/AP_ExternalControl.h> | ||
|
||
bool AP_DDS_External_Control::handle_velocity_control(geometry_msgs_msg_TwistStamped& cmd_vel) | ||
{ | ||
auto *external_control = AP::externalcontrol(); | ||
if (external_control == nullptr) { | ||
return false; | ||
} | ||
|
||
// Convert commands from ENU to NED frame | ||
Vector3f linear_velocity { | ||
float(cmd_vel.twist.linear.y), | ||
float(cmd_vel.twist.linear.x), | ||
float(-cmd_vel.twist.linear.z) }; | ||
const float yaw_rate = -cmd_vel.twist.angular.z; | ||
return external_control->set_linear_velocity_and_yaw_rate(linear_velocity, yaw_rate); | ||
} | ||
|
||
|
||
#endif // AP_DDS_ENABLED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#if AP_DDS_ENABLED | ||
#include "geometry_msgs/msg/TwistStamped.h" | ||
|
||
class AP_DDS_External_Control | ||
{ | ||
public: | ||
static bool handle_velocity_control(geometry_msgs_msg_TwistStamped& cmd_vel); | ||
}; | ||
#endif // AP_DDS_ENABLED |