SMACC2
Loading...
Searching...
No Matches
cl_px4_mr::CpOffboardKeepAlive Class Reference

#include <cp_offboard_keep_alive.hpp>

Inheritance diagram for cl_px4_mr::CpOffboardKeepAlive:
Inheritance graph
Collaboration diagram for cl_px4_mr::CpOffboardKeepAlive:
Collaboration graph

Public Member Functions

 CpOffboardKeepAlive ()
 
virtual ~CpOffboardKeepAlive ()
 
void onInitialize () override
 
void update () override
 
void enable ()
 
void disable ()
 
bool isEnabled () const
 
- Public Member Functions inherited from smacc2::ISmaccComponent
 ISmaccComponent ()
 
virtual ~ISmaccComponent ()
 
virtual std::string getName () const
 
- Public Member Functions inherited from smacc2::ISmaccUpdatable
 ISmaccUpdatable ()
 
 ISmaccUpdatable (rclcpp::Duration duration)
 
void executeUpdate (rclcpp::Node::SharedPtr node)
 
void setUpdatePeriod (rclcpp::Duration duration)
 

Private Attributes

rclcpp::Publisher< px4_msgs::msg::OffboardControlMode >::SharedPtr publisher_
 
CpTrajectorySetpointtrajectorySetpoint_ = nullptr
 
bool enabled_ = false
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccComponent
template<typename TOrthogonal , typename TClient >
void onComponentInitialization ()
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
template<typename TComponent >
void requiresComponent (TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename TComponent >
void requiresComponent (std::string name, TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
 
template<typename TClient >
void requiresClient (TClient *&requiredClientStorage)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createSiblingNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger () const
 
ISmaccStateMachinegetStateMachine ()
 
- Protected Member Functions inherited from smacc2::ISmaccUpdatable
- Protected Attributes inherited from smacc2::ISmaccComponent
ISmaccStateMachinestateMachine_
 
ISmaccClientowner_
 

Detailed Description

Definition at line 26 of file cp_offboard_keep_alive.hpp.

Constructor & Destructor Documentation

◆ CpOffboardKeepAlive()

cl_px4_mr::CpOffboardKeepAlive::CpOffboardKeepAlive ( )

Definition at line 21 of file cp_offboard_keep_alive.cpp.

21{}

◆ ~CpOffboardKeepAlive()

cl_px4_mr::CpOffboardKeepAlive::~CpOffboardKeepAlive ( )
virtual

Definition at line 23 of file cp_offboard_keep_alive.cpp.

23{}

Member Function Documentation

◆ disable()

void cl_px4_mr::CpOffboardKeepAlive::disable ( )

Definition at line 66 of file cp_offboard_keep_alive.cpp.

67{
68 enabled_ = false;
69 RCLCPP_INFO(getLogger(), "CpOffboardKeepAlive: DISABLED");
70}
rclcpp::Logger getLogger() const

References enabled_, and smacc2::ISmaccComponent::getLogger().

Referenced by cl_px4_mr::CbLand::onEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enable()

void cl_px4_mr::CpOffboardKeepAlive::enable ( )

Definition at line 60 of file cp_offboard_keep_alive.cpp.

61{
62 enabled_ = true;
63 RCLCPP_INFO(getLogger(), "CpOffboardKeepAlive: ENABLED");
64}

References enabled_, and smacc2::ISmaccComponent::getLogger().

Referenced by cl_px4_mr::CbTakeOff::onEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEnabled()

bool cl_px4_mr::CpOffboardKeepAlive::isEnabled ( ) const

Definition at line 72 of file cp_offboard_keep_alive.cpp.

72{ return enabled_; }

References enabled_.

◆ onInitialize()

void cl_px4_mr::CpOffboardKeepAlive::onInitialize ( )
overridevirtual

Reimplemented from smacc2::ISmaccComponent.

Definition at line 25 of file cp_offboard_keep_alive.cpp.

26{
27 auto node = this->getNode();
28 publisher_ = node->create_publisher<px4_msgs::msg::OffboardControlMode>(
29 "/fmu/in/offboard_control_mode", rclcpp::QoS(1).best_effort());
30
32
33 RCLCPP_INFO(getLogger(), "CpOffboardKeepAlive: initialized (disabled)");
34}
rclcpp::Publisher< px4_msgs::msg::OffboardControlMode >::SharedPtr publisher_
void requiresComponent(TComponent *&requiredComponentStorage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
rclcpp::Node::SharedPtr getNode()

References smacc2::ISmaccComponent::getLogger(), smacc2::ISmaccComponent::getNode(), publisher_, smacc2::ISmaccComponent::requiresComponent(), and trajectorySetpoint_.

Here is the call graph for this function:

◆ update()

void cl_px4_mr::CpOffboardKeepAlive::update ( )
overridevirtual

Implements smacc2::ISmaccUpdatable.

Definition at line 36 of file cp_offboard_keep_alive.cpp.

37{
38 if (!enabled_) return;
39
40 auto node = this->getNode();
41
42 px4_msgs::msg::OffboardControlMode msg;
43 msg.timestamp = node->get_clock()->now().nanoseconds() / 1000;
44 msg.position = true;
45 msg.velocity = false;
46 msg.acceleration = false;
47 msg.attitude = false;
48 msg.body_rate = false;
49 msg.thrust_and_torque = false;
50 msg.direct_actuator = false;
51 publisher_->publish(msg);
52
53 // Republish the latest trajectory setpoint to keep PX4 happy
55 {
57 }
58}

References enabled_, smacc2::ISmaccComponent::getNode(), publisher_, cl_px4_mr::CpTrajectorySetpoint::republishLast(), and trajectorySetpoint_.

Here is the call graph for this function:

Member Data Documentation

◆ enabled_

bool cl_px4_mr::CpOffboardKeepAlive::enabled_ = false
private

Definition at line 42 of file cp_offboard_keep_alive.hpp.

Referenced by disable(), enable(), isEnabled(), and update().

◆ publisher_

rclcpp::Publisher<px4_msgs::msg::OffboardControlMode>::SharedPtr cl_px4_mr::CpOffboardKeepAlive::publisher_
private

Definition at line 40 of file cp_offboard_keep_alive.hpp.

Referenced by onInitialize(), and update().

◆ trajectorySetpoint_

CpTrajectorySetpoint* cl_px4_mr::CpOffboardKeepAlive::trajectorySetpoint_ = nullptr
private

Definition at line 41 of file cp_offboard_keep_alive.hpp.

Referenced by onInitialize(), and update().


The documentation for this class was generated from the following files: