PX4固件之Ros实现Offboard节点控制
这部分跟ardupilot固件流程没有区别。
主要对Ros、Mavros、gazebo、Mavproxy等深入了解一下。
首先运行Px4的gazebo仿真
cd Firmware/
sudo make posix_sitl_default gazebo
运行mavros
roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"
出现 mission received,表示连接成功。
运行Offboard节点控制,无人机会解锁起飞2m
rosrun offboard offboard
代码如下:
/**
* @file offb_node.cpp
* @brief offboard example node, written with mavros version 0.14.2, px4 flight
* stack and tested in Gazebo SITL
*/
#include <ros/ros.h>
#include <geometry_msgs/PoseStamped.h>
#include <mavros_msgs/CommandBool.h>
#include <mavros_msgs/SetMode.h>
#include <mavros_msgs/State.h>
mavros_msgs::State current_state;
void state_cb(const mavros_msgs::State::ConstPtr& msg){
current_state = *msg;
}
int main(int argc,