remove send setpoints
This commit is contained in:
Submodule src/px4_msgs updated: b64ef0475c...4db0a3f14e
Submodule src/px4_ros_com updated: 1562ff30d5...0bcf68bcb6
@@ -1,46 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(send_setpoints)
|
||||
|
||||
# Default to C99
|
||||
if(NOT CMAKE_C_STANDARD)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
endif()
|
||||
|
||||
# Default to C++14
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
endif()
|
||||
|
||||
# find dependencies
|
||||
find_package(ament_cmake REQUIRED)
|
||||
# uncomment the following section in order to fill in
|
||||
# further dependencies manually.
|
||||
# find_package(<dependency> REQUIRED)
|
||||
find_package(rclcpp REQUIRED)
|
||||
find_package(px4_ros_com REQUIRED)
|
||||
find_package(px4_msgs REQUIRED)
|
||||
|
||||
add_executable(send_setpoint src/send_setpoint.cpp)
|
||||
ament_target_dependencies(send_setpoint rclcpp px4_ros_com px4_msgs)
|
||||
|
||||
install(TARGETS
|
||||
send_setpoint
|
||||
DESTINATION lib/${PROJECT_NAME}
|
||||
)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
find_package(ament_lint_auto REQUIRED)
|
||||
# the following line skips the linter which checks for copyrights
|
||||
# uncomment the line when a copyright and license is not present in all source files
|
||||
#set(ament_cmake_copyright_FOUND TRUE)
|
||||
# the following line skips cpplint (only works in a git repo)
|
||||
# uncomment the line when this package is not in a git repo
|
||||
#set(ament_cmake_cpplint_FOUND TRUE)
|
||||
ament_lint_auto_find_test_dependencies()
|
||||
endif()
|
||||
|
||||
ament_package()
|
||||
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||
<package format="3">
|
||||
<name>send_setpoints</name>
|
||||
<version>0.0.0</version>
|
||||
<description>package to send attitude setpoints to pixhawk so it can be armed</description>
|
||||
<maintainer email="semmer99@gmail.com">ubuntu</maintainer>
|
||||
<license>Apache License 2.0</license>
|
||||
|
||||
<buildtool_depend>ament_cmake</buildtool_depend>
|
||||
|
||||
<test_depend>ament_lint_auto</test_depend>
|
||||
<test_depend>ament_lint_common</test_depend>
|
||||
|
||||
<export>
|
||||
<build_type>ament_cmake</build_type>
|
||||
</export>
|
||||
</package>
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
|
||||
We need to send attitude setpoints to be able to arm the drone:
|
||||
https://mavlink.io/en/messages/common.html#SET_ATTITUDE_TARGET
|
||||
We need attitude setpoints because we don't have a GPS:
|
||||
https://discuss.px4.io/t/cannot-arm-drone-with-companion-computer-arming-denied-manual-control-lost/31565/9
|
||||
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "rclcpp/rclcpp.hpp"
|
||||
|
||||
#include <px4_msgs/msg/offboard_control_mode.hpp>
|
||||
#include <px4_msgs/msg/timesync.hpp>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
class SetpointSender : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
SetpointSender() : Node("setpoint_sender")
|
||||
{
|
||||
// create a publisher on the offboard control mode topic
|
||||
offboard_control_mode_publisher_ = this->create_publisher<px4_msgs::msg::OffboardControlMode>("/fmu/in/offboard_control_mode", 10);
|
||||
// create timer to send heartbeat messages (offboard control) every 100ms
|
||||
timer_ = this->create_wall_timer(100ms, std::bind(&SetpointSender::send_heartbeat, this));
|
||||
start_time = this->get_clock()->now().seconds();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief Publish offboard control mode messages as a heartbeat.
|
||||
* Only the attitude is enabled, because that is how the drone will be controlled.
|
||||
*
|
||||
*/
|
||||
void send_heartbeat()
|
||||
{
|
||||
// set message to enable attitude
|
||||
auto msg = px4_msgs::msg::OffboardControlMode();
|
||||
msg.position = false;
|
||||
msg.velocity = false;
|
||||
msg.acceleration = false;
|
||||
msg.attitude = true;
|
||||
msg.body_rate = false;
|
||||
msg.actuator = false;
|
||||
|
||||
// get timestamp and publish message
|
||||
msg.timestamp = this->get_clock()->now().nanoseconds() / 1000;
|
||||
offboard_control_mode_publisher_->publish(msg);
|
||||
RCLCPP_INFO(this->get_logger(), "sent offboard control mode message!");
|
||||
|
||||
// check if 5 seconds have elapsed
|
||||
if (this->get_clock()->now().seconds() - start_time > 5)
|
||||
{
|
||||
RCLCPP_INFO(this->get_logger(), "5 seconds elapsed!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
rclcpp::Publisher<px4_msgs::msg::OffboardControlMode>::SharedPtr offboard_control_mode_publisher_;
|
||||
rclcpp::TimerBase::SharedPtr timer_;
|
||||
double start_time;
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
rclcpp::init(argc, argv);
|
||||
rclcpp::spin(std::make_shared<SetpointSender>());
|
||||
rclcpp::shutdown();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user