Skip to content

Commit

Permalink
core: added ComponentType::RemoteId, added missiong ComponentType::Gi…
Browse files Browse the repository at this point in the history
…mbal in places, consistent ordering of enums
  • Loading branch information
dakejahl committed Oct 7, 2024
1 parent 2362072 commit 41d3f18
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/mavsdk/core/include/mavsdk/component_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ enum class ComponentType {
CompanionComputer, /**< @brief SDK is used as a companion computer on board the MAV. */
Camera, /** < @brief SDK is used as a camera. */
Gimbal, /** < @brief SDK is used as a gimbal. */
RemoteId, /** < @brief SDK is used as a RemoteId system. */
Custom /**< @brief the SDK is used in a custom configuration, no automatic ID will be
provided */
};

} // namespace mavsdk
} // namespace mavsdk
8 changes: 6 additions & 2 deletions src/mavsdk/core/include/mavsdk/mavsdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,18 @@ class Mavsdk {
void intercept_outgoing_messages_async(std::function<bool(mavlink_message_t&)> callback);

private:
static constexpr int DEFAULT_SYSTEM_ID_AUTOPILOT = 1;
static constexpr int DEFAULT_COMPONENT_ID_AUTOPILOT = MAV_COMP_ID_AUTOPILOT1;
static constexpr int DEFAULT_SYSTEM_ID_GCS = 245;
static constexpr int DEFAULT_COMPONENT_ID_GCS = MAV_COMP_ID_MISSIONPLANNER;
static constexpr int DEFAULT_SYSTEM_ID_CC = 1;
static constexpr int DEFAULT_COMPONENT_ID_CC = MAV_COMP_ID_PATHPLANNER;
static constexpr int DEFAULT_SYSTEM_ID_AUTOPILOT = 1;
static constexpr int DEFAULT_COMPONENT_ID_AUTOPILOT = MAV_COMP_ID_AUTOPILOT1;
static constexpr int DEFAULT_SYSTEM_ID_CAMERA = 1;
static constexpr int DEFAULT_COMPONENT_ID_CAMERA = MAV_COMP_ID_CAMERA;
static constexpr int DEFAULT_SYSTEM_ID_GIMBAL = 1;
static constexpr int DEFAULT_COMPONENT_ID_GIMBAL = MAV_COMP_ID_GIMBAL;
static constexpr int DEFAULT_SYSTEM_ID_REMOTEID = 1;
static constexpr int DEFAULT_COMPONENT_ID_REMOTEID = MAV_COMP_ID_ODID_TXRX_1;

/* @private. */
std::shared_ptr<MavsdkImpl> _impl{};
Expand Down
18 changes: 16 additions & 2 deletions src/mavsdk/core/mavsdk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@ Mavsdk::Configuration::Configuration(
ComponentType Mavsdk::Configuration::component_type_for_component_id(uint8_t component_id)
{
switch (component_id) {
case Mavsdk::DEFAULT_COMPONENT_ID_AUTOPILOT:
return ComponentType::Autopilot;
case Mavsdk::DEFAULT_COMPONENT_ID_GCS:
return ComponentType::GroundStation;
case Mavsdk::DEFAULT_COMPONENT_ID_CC:
return ComponentType::CompanionComputer;
case Mavsdk::DEFAULT_COMPONENT_ID_AUTOPILOT:
return ComponentType::Autopilot;
case Mavsdk::DEFAULT_COMPONENT_ID_CAMERA:
return ComponentType::Camera;
case Mavsdk::DEFAULT_COMPONENT_ID_GIMBAL:
return ComponentType::Gimbal;
case Mavsdk::DEFAULT_COMPONENT_ID_REMOTEID:
return ComponentType::RemoteId;
default:
return ComponentType::Custom;
}
Expand Down Expand Up @@ -131,6 +135,16 @@ Mavsdk::Configuration::Configuration(ComponentType component_type) :
_component_id = Mavsdk::DEFAULT_COMPONENT_ID_CAMERA;
_always_send_heartbeats = true;
break;
case ComponentType::Gimbal:
_system_id = Mavsdk::DEFAULT_SYSTEM_ID_GIMBAL;
_component_id = Mavsdk::DEFAULT_COMPONENT_ID_GIMBAL;
_always_send_heartbeats = true;
break;
case ComponentType::RemoteId:
_system_id = Mavsdk::DEFAULT_SYSTEM_ID_REMOTEID;
_component_id = Mavsdk::DEFAULT_COMPONENT_ID_REMOTEID;
_always_send_heartbeats = true;
break;
default:
break;
}
Expand Down
8 changes: 8 additions & 0 deletions src/mavsdk/core/mavsdk_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ std::shared_ptr<ServerComponent> MavsdkImpl::server_component(unsigned instance)
case ComponentType::GroundStation:
case ComponentType::CompanionComputer:
case ComponentType::Camera:
case ComponentType::Gimbal:
case ComponentType::RemoteId:
case ComponentType::Custom:
return server_component_by_type(component_type, instance);
default:
Expand Down Expand Up @@ -704,6 +706,12 @@ uint8_t MavsdkImpl::get_mav_type() const
case ComponentType::Camera:
return MAV_TYPE_CAMERA;

case ComponentType::Gimbal:
return MAV_TYPE_GIMBAL;

case ComponentType::RemoteId:
return MAV_TYPE_ODID;

case ComponentType::Custom:
return MAV_TYPE_GENERIC;

Expand Down
18 changes: 11 additions & 7 deletions src/mavsdk/core/system_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,13 @@ ComponentType SystemImpl::component_type(uint8_t component_id)
switch (component_id) {
case MAV_COMP_ID_AUTOPILOT1:
return ComponentType::Autopilot;
case MAV_COMP_ID_MISSIONPLANNER:
return ComponentType::GroundStation;
case MAV_COMP_ID_ONBOARD_COMPUTER:
case MAV_COMP_ID_ONBOARD_COMPUTER2:
case MAV_COMP_ID_ONBOARD_COMPUTER3:
case MAV_COMP_ID_ONBOARD_COMPUTER4:
return ComponentType::CompanionComputer;
case MAV_COMP_ID_CAMERA:
case MAV_COMP_ID_CAMERA2:
case MAV_COMP_ID_CAMERA3:
Expand All @@ -343,13 +350,10 @@ ComponentType SystemImpl::component_type(uint8_t component_id)
return ComponentType::Camera;
case MAV_COMP_ID_GIMBAL:
return ComponentType::Gimbal;
case MAV_COMP_ID_ONBOARD_COMPUTER:
case MAV_COMP_ID_ONBOARD_COMPUTER2:
case MAV_COMP_ID_ONBOARD_COMPUTER3:
case MAV_COMP_ID_ONBOARD_COMPUTER4:
return ComponentType::CompanionComputer;
case MAV_COMP_ID_MISSIONPLANNER:
return ComponentType::GroundStation;
case MAV_COMP_ID_ODID_TXRX_1:
case MAV_COMP_ID_ODID_TXRX_2:
case MAV_COMP_ID_ODID_TXRX_3:
return ComponentType::RemoteId;
default:
return ComponentType::Custom;
}
Expand Down

0 comments on commit 41d3f18

Please sign in to comment.