一键起飞

参考及引用

1. CSDN博主「战争果子」的原创文章,遵循CC 4.0 BY-SA版权协议。

原文:https://blog.csdn.net/EnthusiasmZing/article/details/79165152快速链接

2. 飞行控制参考网站

https://gaas.gitbook.io/guide/software-realization-build-your-own-autonomous-drone/wu-ren-ji-zi-dong-jia-shi-xi-lie-offboard-kong-zhi-yi-ji-gazebo-fang-zhen快速链接

目录

  • 一键起飞
    • 参考及引用
      • 1. CSDN博主「战争果子」的原创文章,遵循CC 4.0 BY-SA版权协议。
      • 2. 飞行控制参考网站
      • 一、一键起飞功能包创建及代码编译
      • 二、一键起飞代码运行
      • 三、任意修改一键起飞后无人机的位置
      • 四、一键起飞python版
  • 飞行控制
    • 一、代码
    • 二、运行

一、一键起飞功能包创建及代码编译

  1. 创建新的功能包,名为offboard_run

终端输入

cd catkin_ws/src      //在catkin_ws/src/这个文件夹里面再进行创建

然后在src文件夹内

catkin_create_pkg offboard_run rospy roscpp

  1. 在新创建的功能包offboard_runsrc文件内(路径:catkin_ws/src/offboard_run/src
    ),放入一键起飞代码
/*** @file offb_node.cpp* @brief Offboard control example node, written with MAVROS version 0.19.x, PX4 Pro 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, char **argv)
{ros::init(argc, argv, "offb_node");ros::NodeHandle nh;ros::Subscriber state_sub = nh.subscribe<mavros_msgs::State>("mavros/state", 10, state_cb);ros::Publisher local_pos_pub = nh.advertise<geometry_msgs::PoseStamped>("mavros/setpoint_position/local", 10);ros::ServiceClient arming_client = nh.serviceClient<mavros_msgs::CommandBool>("mavros/cmd/arming");ros::ServiceClient set_mode_client = nh.serviceClient<mavros_msgs::SetMode>("mavros/set_mode");//the setpoint publishing rate MUST be faster than 2Hzros::Rate rate(20.0);// wait for FCU connectionwhile(ros::ok() && !current_state.connected){ros::spinOnce();rate.sleep();}geometry_msgs::PoseStamped pose;pose.pose.position.x = 0;pose.pose.position.y = 0;pose.pose.position.z = 2;//send a few setpoints before startingfor(int i = 100; ros::ok() && i > 0; --i){local_pos_pub.publish(pose);ros::spinOnce();rate.sleep();}mavros_msgs::SetMode offb_set_mode;offb_set_mode.request.custom_mode = "OFFBOARD";mavros_msgs::CommandBool arm_cmd;arm_cmd.request.value = true;ros::Time last_request = ros::Time::now();while(ros::ok()){if( current_state.mode != "OFFBOARD" &&(ros::Time::now() - last_request > ros::Duration(5.0))){if( set_mode_client.call(offb_set_mode) &&offb_set_mode.response.mode_sent){ROS_INFO("Offboard enabled");}last_request = ros::Time::now();} else {if( !current_state.armed &&(ros::Time::now() - last_request > ros::Duration(5.0))){if( arming_client.call(arm_cmd) &&arm_cmd.response.success){ROS_INFO("Vehicle armed");}last_request = ros::Time::now();}}local_pos_pub.publish(pose);ros::spinOnce();rate.sleep();}return 0;
}
————————————————
版权声明:本文为CSDN博主「战争果子」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/EnthusiasmZing/article/details/79165152


3. 对一键起飞代码进行编译

①到我们创建的offboard_run功能包里面的CMakeLists.txt文件,在Build的最后添加下面两行代码,然后保存关闭

add_executable(offboard_run1 src/offboard_run1.cpp)
target_link_libraries(offboard_run1 ${catkin_LIBRARIES})


②到catkin_ws目录下对工作空间进行编译(也就是对刚刚我们添加的C++代码进行编译)


终端输入

catkin_make


出现上图所示结果说明编译已完成

二、一键起飞代码运行

  1. 打开PX4仿真
    终端先输入
cd PX4_Firmware/

再输入

roslaunch px4 mavros_posix_sitl.launch


仿真界面出现后,我们打开一个新的终端(ctrl+alt+T

终端输入

rosrun offboard_run offboard_run1

运行一键起飞代码,从仿真界面可以看到无人机已经起飞

注意:
运行代码可以使用rosrun的命令

rosrun [代码所在功能包的名] [代码文件名(不用加.cpp)]

最后,结束无人机的悬停直接在终端ctrl+C停止,这时无人机出发安全着陆模式,自行着陆

三、任意修改一键起飞后无人机的位置

只需修改代码文件里面的x、y、z数值即可,记得重新保存和编译,再运行

或者另创建offboard_run2.cppoffboard_run3.cpp等文件,每个代码里设定的坐标位置各不相同

四、一键起飞python版

1.在offboard_run功能包先创建一个文件夹,名为scripts,专门放置python文件

然后把一键起飞的python代码放进scripts文件内,这里给它的命名为px4_mavros_run.py

import rospy
from mavros_msgs.msg import GlobalPositionTarget, State, PositionTarget
from mavros_msgs.srv import CommandBool, CommandTOL, SetMode
from geometry_msgs.msg import PoseStamped, Twist
from sensor_msgs.msg import Imu, NavSatFix
from std_msgs.msg import Float32, Float64, String
import time
from pyquaternion import Quaternion
import math
import threadingclass Px4Controller:def __init__(self):self.imu = Noneself.gps = Noneself.local_pose = Noneself.current_state = Noneself.current_heading = Noneself.takeoff_height = 3.2self.local_enu_position = Noneself.cur_target_pose = Noneself.global_target = Noneself.received_new_task = Falseself.arm_state = Falseself.offboard_state = Falseself.received_imu = Falseself.frame = "BODY"self.state = None'''ros subscribers'''self.local_pose_sub = rospy.Subscriber("/mavros/local_position/pose", PoseStamped, self.local_pose_callback)self.mavros_sub = rospy.Subscriber("/mavros/state", State, self.mavros_state_callback)self.gps_sub = rospy.Subscriber("/mavros/global_position/global", NavSatFix, self.gps_callback)self.imu_sub = rospy.Subscriber("/mavros/imu/data", Imu, self.imu_callback)self.set_target_position_sub = rospy.Subscriber("gi/set_pose/position", PoseStamped, self.set_target_position_callback)self.set_target_yaw_sub = rospy.Subscriber("gi/set_pose/orientation", Float32, self.set_target_yaw_callback)self.custom_activity_sub = rospy.Subscriber("gi/set_activity/type", String, self.custom_activity_callback)'''ros publishers'''self.local_target_pub = rospy.Publisher('mavros/setpoint_raw/local', PositionTarget, queue_size=10)'''ros services'''self.armService = rospy.ServiceProxy('/mavros/cmd/arming', CommandBool)self.flightModeService = rospy.ServiceProxy('/mavros/set_mode', SetMode)print("Px4 Controller Initialized!")def start(self):rospy.init_node("offboard_node")for i in range(10):if self.current_heading is not None:breakelse:print("Waiting for initialization.")time.sleep(0.5)self.cur_target_pose = self.construct_target(0, 0, self.takeoff_height, self.current_heading)#print ("self.cur_target_pose:", self.cur_target_pose, type(self.cur_target_pose))for i in range(10):self.local_target_pub.publish(self.cur_target_pose)self.arm_state = self.arm()self.offboard_state = self.offboard()time.sleep(0.2)if self.takeoff_detection():print("Vehicle Took Off!")else:print("Vehicle Took Off Failed!")return'''main ROS thread'''while self.arm_state and self.offboard_state and (rospy.is_shutdown() is False):self.local_target_pub.publish(self.cur_target_pose)if (self.state is "LAND") and (self.local_pose.pose.position.z < 0.15):if(self.disarm()):self.state = "DISARMED"time.sleep(0.1)def construct_target(self, x, y, z, yaw, yaw_rate = 1):target_raw_pose = PositionTarget()target_raw_pose.header.stamp = rospy.Time.now()target_raw_pose.coordinate_frame = 9target_raw_pose.position.x = xtarget_raw_pose.position.y = ytarget_raw_pose.position.z = ztarget_raw_pose.type_mask = PositionTarget.IGNORE_VX + PositionTarget.IGNORE_VY + PositionTarget.IGNORE_VZ \+ PositionTarget.IGNORE_AFX + PositionTarget.IGNORE_AFY + PositionTarget.IGNORE_AFZ \+ PositionTarget.FORCEtarget_raw_pose.yaw = yawtarget_raw_pose.yaw_rate = yaw_ratereturn target_raw_pose'''cur_p : poseStampedtarget_p: positionTarget'''def position_distance(self, cur_p, target_p, threshold=0.1):delta_x = math.fabs(cur_p.pose.position.x - target_p.position.x)delta_y = math.fabs(cur_p.pose.position.y - target_p.position.y)delta_z = math.fabs(cur_p.pose.position.z - target_p.position.z)if (delta_x + delta_y + delta_z < threshold):return Trueelse:return Falsedef local_pose_callback(self, msg):self.local_pose = msgself.local_enu_position = msgdef mavros_state_callback(self, msg):self.mavros_state = msg.modedef imu_callback(self, msg):global global_imu, current_headingself.imu = msgself.current_heading = self.q2yaw(self.imu.orientation)self.received_imu = Truedef gps_callback(self, msg):self.gps = msgdef FLU2ENU(self, msg):FLU_x = msg.pose.position.x * math.cos(self.current_heading) - msg.pose.position.y * math.sin(self.current_heading)FLU_y = msg.pose.position.x * math.sin(self.current_heading) + msg.pose.position.y * math.cos(self.current_heading)FLU_z = msg.pose.position.zreturn FLU_x, FLU_y, FLU_zdef set_target_position_callback(self, msg):print("Received New Position Task!")if msg.header.frame_id == 'base_link':'''BODY_FLU'''# For Body frame, we will use FLU (Forward, Left and Up)#           +Z     +X#            ^    ^#            |  /#            |/#  +Y <------bodyself.frame = "BODY"print("body FLU frame")ENU_X, ENU_Y, ENU_Z = self.FLU2ENU(msg)ENU_X = ENU_X + self.local_pose.pose.position.xENU_Y = ENU_Y + self.local_pose.pose.position.yENU_Z = ENU_Z + self.local_pose.pose.position.zself.cur_target_pose = self.construct_target(ENU_X,ENU_Y,ENU_Z,self.current_heading)else:'''LOCAL_ENU'''# For world frame, we will use ENU (EAST, NORTH and UP)#     +Z     +Y#      ^    ^#      |  /#      |/#    world------> +Xself.frame = "LOCAL_ENU"print("local ENU frame")self.cur_target_pose = self.construct_target(msg.pose.position.x,msg.pose.position.y,msg.pose.position.z,self.current_heading)'''Receive A Custom Activity'''def custom_activity_callback(self, msg):print("Received Custom Activity:", msg.data)if msg.data == "LAND":print("LANDING!")self.state = "LAND"self.cur_target_pose = self.construct_target(self.local_pose.pose.position.x,self.local_pose.pose.position.y,0.1,self.current_heading)if msg.data == "HOVER":print("HOVERING!")self.state = "HOVER"self.hover()else:print("Received Custom Activity:", msg.data, "not supported yet!")def set_target_yaw_callback(self, msg):print("Received New Yaw Task!")yaw_deg = msg.data * math.pi / 180.0self.cur_target_pose = self.construct_target(self.local_pose.pose.position.x,self.local_pose.pose.position.y,self.local_pose.pose.position.z,yaw_deg)'''return yaw from current IMU'''def q2yaw(self, q):if isinstance(q, Quaternion):rotate_z_rad = q.yaw_pitch_roll[0]else:q_ = Quaternion(q.w, q.x, q.y, q.z)rotate_z_rad = q_.yaw_pitch_roll[0]return rotate_z_raddef arm(self):if self.armService(True):return Trueelse:print("Vehicle arming failed!")return Falsedef disarm(self):if self.armService(False):return Trueelse:print("Vehicle disarming failed!")return Falsedef offboard(self):if self.flightModeService(custom_mode='OFFBOARD'):return Trueelse:print("Vechile Offboard failed")return Falsedef hover(self):self.cur_target_pose = self.construct_target(self.local_pose.pose.position.x,self.local_pose.pose.position.y,self.local_pose.pose.position.z,self.current_heading)def takeoff_detection(self):if self.local_pose.pose.position.z > 0.1 and self.offboard_state and self.arm_state:return Trueelse:return Falseif __name__ == '__main__':con = Px4Controller()con.start()

然后记得对python文件进行权限修改,在执行处打勾

2. 同样,先启动PX4仿真(参考上面的步骤)
然后到刚才存放python代码的目录内,打开终端

在终端直接输入

python px4_mavros_run.py

此时能看到无人机起飞成功

飞行控制

一、代码

  1. 把控制无人机的代码放进catkin_ws/src/offboard_run/scripts,这里有两个python代码文件,同时放进该路径

    commander.py代码如下:
import rospy
from mavros_msgs.msg import GlobalPositionTarget, State
from mavros_msgs.srv import CommandBool, CommandTOL, SetMode
from geometry_msgs.msg import PoseStamped, Twist
from sensor_msgs.msg import Imu, NavSatFix
from std_msgs.msg import Float32, String
from pyquaternion import Quaternion
import time
import mathclass Commander:def __init__(self):rospy.init_node("commander_node")rate = rospy.Rate(20)self.position_target_pub = rospy.Publisher('gi/set_pose/position', PoseStamped, queue_size=10)self.yaw_target_pub = rospy.Publisher('gi/set_pose/orientation', Float32, queue_size=10)self.custom_activity_pub = rospy.Publisher('gi/set_activity/type', String, queue_size=10)def move(self, x, y, z, BODY_OFFSET_ENU=True):self.position_target_pub.publish(self.set_pose(x, y, z, BODY_OFFSET_ENU))def turn(self, yaw_degree):self.yaw_target_pub.publish(yaw_degree)# land at current positiondef land(self):self.custom_activity_pub.publish(String("LAND"))# hover at current positiondef hover(self):self.custom_activity_pub.publish(String("HOVER"))# return to home position with defined heightdef return_home(self, height):self.position_target_pub.publish(self.set_pose(0, 0, height, False))def set_pose(self, x=0, y=0, z=2, BODY_FLU = True):pose = PoseStamped()pose.header.stamp = rospy.Time.now()# ROS uses ENU internally, so we will stick to this conventionif BODY_FLU:pose.header.frame_id = 'base_link'else:pose.header.frame_id = 'map'pose.pose.position.x = xpose.pose.position.y = ypose.pose.position.z = zreturn poseif __name__ == "__main__":con = Commander()time.sleep(2)con.move(1, 0, 0)time.sleep(2)con.turn(90)time.sleep(2)con.land()

conclude.py代码如下:

import rospy
from mavros_msgs.msg import GlobalPositionTarget, State,PositionTarget
from mavros_msgs.srv import CommandBool, CommandTOL, SetMode
from geometry_msgs.msg import PoseStamped, Twist
from sensor_msgs.msg import Imu, NavSatFix
from std_msgs.msg import Float32,Float64,String
from pyquaternion import Quaternion
import time
import math
import threadingclass Px4Controller:def __init__(self):self.imu = Noneself.gps = Noneself.local_pose = Noneself.current_state = Noneself.current_heading = Noneself.takeoff_height = 3.2self.local_enu_position = Noneself.cur_target_pose = Noneself.global_target = Noneself.received_new_task = Falseself.arm_state = Falseself.offboard_state = Falseself.received_imu = Falseself.frame = "BODY"self.state = None'''ros subscribers'''self.local_pose_sub = rospy.Subscriber("/mavros/local_position/pose", PoseStamped, self.local_pose_callback)self.mavros_sub = rospy.Subscriber("/mavros/state", State, self.mavros_state_callback)self.gps_sub = rospy.Subscriber("/mavros/global_position/global", NavSatFix, self.gps_callback)self.imu_sub = rospy.Subscriber("/mavros/imu/data", Imu, self.imu_callback)self.set_target_position_sub = rospy.Subscriber("gi/set_pose/position", PoseStamped, self.set_target_position_callback)self.set_target_yaw_sub = rospy.Subscriber("gi/set_pose/orientation", Float32, self.set_target_yaw_callback)self.custom_activity_sub = rospy.Subscriber("gi/set_activity/type", String, self.custom_activity_callback)'''ros publishers'''self.local_target_pub = rospy.Publisher('mavros/setpoint_raw/local', PositionTarget, queue_size=10)'''ros services'''self.armService = rospy.ServiceProxy('/mavros/cmd/arming', CommandBool)self.flightModeService = rospy.ServiceProxy('/mavros/set_mode', SetMode)print("Px4 Controller Initialized!")def start(self):rospy.init_node("offboard_node")for i in range(10):if self.current_heading is not None:breakelse:print("Waiting for initialization.")time.sleep(0.5)self.cur_target_pose = self.construct_target(0, 0, self.takeoff_height, self.current_heading)#print ("self.cur_target_pose:", self.cur_target_pose, type(self.cur_target_pose))for i in range(10):self.local_target_pub.publish(self.cur_target_pose)self.arm_state = self.arm()self.offboard_state = self.offboard()time.sleep(0.2)if self.takeoff_detection():print("Vehicle Took Off!")else:print("Vehicle Took Off Failed!")return'''main ROS thread'''while self.arm_state and self.offboard_state and (rospy.is_shutdown() is False):self.local_target_pub.publish(self.cur_target_pose)if (self.state is "LAND") and (self.local_pose.pose.position.z < 0.15):if(self.disarm()):self.state = "DISARMED"time.sleep(0.1)def construct_target(self, x, y, z, yaw, yaw_rate = 1):target_raw_pose = PositionTarget()target_raw_pose.header.stamp = rospy.Time.now()target_raw_pose.coordinate_frame = 9target_raw_pose.position.x = xtarget_raw_pose.position.y = ytarget_raw_pose.position.z = ztarget_raw_pose.type_mask = PositionTarget.IGNORE_VX + PositionTarget.IGNORE_VY + PositionTarget.IGNORE_VZ \+ PositionTarget.IGNORE_AFX + PositionTarget.IGNORE_AFY + PositionTarget.IGNORE_AFZ \+ PositionTarget.FORCEtarget_raw_pose.yaw = yawtarget_raw_pose.yaw_rate = yaw_ratereturn target_raw_pose'''cur_p : poseStampedtarget_p: positionTarget'''def position_distance(self, cur_p, target_p, threshold=0.1):delta_x = math.fabs(cur_p.pose.position.x - target_p.position.x)delta_y = math.fabs(cur_p.pose.position.y - target_p.position.y)delta_z = math.fabs(cur_p.pose.position.z - target_p.position.z)if (delta_x + delta_y + delta_z < threshold):return Trueelse:return Falsedef local_pose_callback(self, msg):self.local_pose = msgself.local_enu_position = msgdef mavros_state_callback(self, msg):self.mavros_state = msg.modedef imu_callback(self, msg):global global_imu, current_headingself.imu = msgself.current_heading = self.q2yaw(self.imu.orientation)self.received_imu = Truedef gps_callback(self, msg):self.gps = msgdef FLU2ENU(self, msg):FLU_x = msg.pose.position.x * math.cos(self.current_heading) - msg.pose.position.y * math.sin(self.current_heading)FLU_y = msg.pose.position.x * math.sin(self.current_heading) + msg.pose.position.y * math.cos(self.current_heading)FLU_z = msg.pose.position.zreturn FLU_x, FLU_y, FLU_zdef set_target_position_callback(self, msg):print("Received New Position Task!")if msg.header.frame_id == 'base_link':'''BODY_FLU'''# For Body frame, we will use FLU (Forward, Left and Up)#           +Z     +X#            ^    ^#            |  /#            |/#  +Y <------bodyself.frame = "BODY"print("body FLU frame")ENU_X, ENU_Y, ENU_Z = self.FLU2ENU(msg)ENU_X = ENU_X + self.local_pose.pose.position.xENU_Y = ENU_Y + self.local_pose.pose.position.yENU_Z = ENU_Z + self.local_pose.pose.position.zself.cur_target_pose = self.construct_target(ENU_X,ENU_Y,ENU_Z,self.current_heading)else:'''LOCAL_ENU'''# For world frame, we will use ENU (EAST, NORTH and UP)#     +Z     +Y#      ^    ^#      |  /#      |/#    world------> +Xself.frame = "LOCAL_ENU"print("local ENU frame")self.cur_target_pose = self.construct_target(msg.pose.position.x,msg.pose.position.y,msg.pose.position.z,self.current_heading)'''Receive A Custom Activity'''def custom_activity_callback(self, msg):print("Received Custom Activity:", msg.data)if msg.data == "LAND":print("LANDING!")self.state = "LAND"self.cur_target_pose = self.construct_target(self.local_pose.pose.position.x,self.local_pose.pose.position.y,0.1,self.current_heading)if msg.data == "HOVER":print("HOVERING!")self.state = "HOVER"self.hover()else:print("Received Custom Activity:", msg.data, "not supported yet!")def set_target_yaw_callback(self, msg):print("Received New Yaw Task!")yaw_deg = msg.data * math.pi / 180.0self.cur_target_pose = self.construct_target(self.local_pose.pose.position.x,self.local_pose.pose.position.y,self.local_pose.pose.position.z,yaw_deg)'''return yaw from current IMU'''def q2yaw(self, q):if isinstance(q, Quaternion):rotate_z_rad = q.yaw_pitch_roll[0]else:q_ = Quaternion(q.w, q.x, q.y, q.z)rotate_z_rad = q_.yaw_pitch_roll[0]return rotate_z_raddef arm(self):if self.armService(True):return Trueelse:print("Vehicle arming failed!")return Falsedef disarm(self):if self.armService(False):return Trueelse:print("Vehicle disarming failed!")return Falsedef offboard(self):if self.flightModeService(custom_mode='OFFBOARD'):return Trueelse:print("Vechile Offboard failed")return Falsedef hover(self):self.cur_target_pose = self.construct_target(self.local_pose.pose.position.x,self.local_pose.pose.position.y,self.local_pose.pose.position.z,self.current_heading)def takeoff_detection(self):if self.local_pose.pose.position.z > 0.1 and self.offboard_state and self.arm_state:return Trueelse:return Falseclass Commander:def __init__(self):rospy.init_node("commander_node")rate = rospy.Rate(20)self.position_target_pub = rospy.Publisher('gi/set_pose/position', PoseStamped, queue_size=10)self.yaw_target_pub = rospy.Publisher('gi/set_pose/orientation', Float32, queue_size=10)self.custom_activity_pub = rospy.Publisher('gi/set_activity/type', String, queue_size=10)def move(self, x, y, z, BODY_OFFSET_ENU=True):self.position_target_pub.publish(self.set_pose(x, y, z, BODY_OFFSET_ENU))def turn(self, yaw_degree):self.yaw_target_pub.publish(yaw_degree)# land at current positiondef land(self):self.custom_activity_pub.publish(String("LAND"))# hover at current positiondef hover(self):self.custom_activity_pub.publish(String("HOVER"))# return to home position with defined heightdef return_home(self, height):self.position_target_pub.publish(self.set_pose(0, 0, height, False))def set_pose(self, x=0, y=0, z=2, BODY_FLU = True):pose = PoseStamped()pose.header.stamp = rospy.Time.now()# ROS uses ENU internally, so we will stick to this conventionif BODY_FLU:pose.header.frame_id = 'base_link'else:pose.header.frame_id = 'map'pose.pose.position.x = xpose.pose.position.y = ypose.pose.position.z = zreturn poseif __name__ == "__main__":con = Px4Controller()con.start()con = Commander()time.sleep(2)con.move(1, 0, 0)time.sleep(2)con.turn(90)time.sleep(2)con.land()

注意:记得修改python代码可执行权限

二、运行

  1. 打开PX4仿真
    终端先输入
cd PX4_Firmware/

再输入

roslaunch px4 mavros_posix_sitl.launch

  1. catkin_ws/src/offboard_run/scripts下打开终端,输入
python px4_mavros_run.py

使飞机起飞

  1. catkin_ws/src/offboard_ru/scripts下,在终端输入
ipython
  1. 随后依次输入
from commander import Commander        //输入后回车
con=Commander ( )                     //输入后回车
  1. 然后依据catkin_ws/src/offboard_run/scripts里面的commander.py
    在上一步(第4步)接着输入指令,使其飞行,如:
    输入con.move(1,0,0), 则向北飞行1m
    输入con.turn(90),则转动90°方向

基于ROS的PX4+Gazebo仿真——PX4一键起飞及飞行控制相关推荐

  1. ROS开发笔记(5)——基于 python 开发 Turtlebot3 Gazebo仿真环境下键盘操控移动机器人(Teleop-bot )

    前文中记录了随机移动机器人的开发过程,本文内容为Turtlebot3 Gazebo仿真环境下Teleop-bot 键盘操控移动机器人,主要包含以下几个部分: 1.键盘驱动(按键驱动发布keys话题) ...

  2. 【ROS】ROS入门笔记-Gazebo仿真与实物测试篇

    前面我们学习了ROS的一些基础知识,现在我们来学习ROS环境下的Gazebo仿真. 本文所需的源码下载地址为 https://github.com/guyuehome/guyueclass 文章目录 ...

  3. 基于ROS的蛇形机器人基本仿生运动与自主爬台阶控制

    摘要: 设计了一种带正交关节和主动轮组合的蛇形机器人.该机器人不仅能够实现基本的蜿蜒运动.纵向行波运动.横向翻滚运动和横向行波运动,且针对台阶式障碍物提出了一种自主爬越台阶的控制策略.机器人通过激光测 ...

  4. Gazebo仿真PX4运行roslaunch PX4 mavros_posix_sitl.launch时报错Required process [sitl-2] has died 解决方法

    报错如图.解决方法为卸载Gazebo9安装Gazebo9.19. 参考下文中4.4部分,问题类似但解决方法相同:https://blog.csdn.net/qq_38768959/article/de ...

  5. 【ros】运行gazebo仿真报错

    第一处红字: [joint_state_publisher-5] process has died [pid 6192, exit code 1, cmd /opt/ros/melodic/lib/j ...

  6. 单片机16个灯四种花样c语言,基于Proteus的MSP430单片机仿真实例5-16个花样灯控制...

    一.任务要求 利用MSP430F247单片机的P1和P4端口控制16个发光二极管D1~D16,发光二极管有8种花样显示,显示速度可调,由P2端口的三个按键控制,分别是模式按键.加速按键.减速按键.模式 ...

  7. PX4无人机-Gazebo仿真实现移动物体的跟踪

    原文链接PX4无人机-Gazebo仿真实现移动物体的跟踪末尾有演示视频 这个学期我们有一个智能机器人系统的课设,我们组分配到的题目是<仿真环境下使用无人机及相机跟踪移动物体>,本文主要记录 ...

  8. PX4-AutoPilot教程-0-使用VMware虚拟机安装Ubuntu系统并搭建PX4开发环境(ROS+mavros+jMAVSim+gazebo+QGC+QT)

    使用VMware虚拟机安装Ubuntu系统并搭建PX4开发环境 本教程使用VMware虚拟机安装Ubuntu18.04系统(官方推荐使用版本),搭建PX4固件版本为v1.9.2,飞控板为pixhawk ...

  9. Ubuntu20.04+MAVROS+PX4+Gazebo保姆级安装教程

    Ubuntu20.04+MAVROS+PX4+Gazebo 安装PX4步骤 安装MAVROS 安装QGC PX4仿真 安装PX4步骤 从github上clone源码 git clone https:/ ...

最新文章

  1. Spring(07)——单例注入多例之lookup-method
  2. 体验Vysor Pro
  3. [云炬创业管理笔记]第五章打磨最有效的商业模式测试5
  4. boost::hana::if_用法的测试程序
  5. 12岁上大学,23岁获博士学位,这位天才科学家正式加盟清华
  6. MATLAB基础学习笔记01:初探MATLAB世界
  7. python web框架哪个好_盘点:9款流行Web框架及其优缺点
  8. 【KG】知识图谱基本概念工程落地常见问题
  9. opencv3.2.0 Cmake 3.8.0 + tdm-gcc-5.1.0-3 OpenThread
  10. VS2012+ArcGIS Engine10.2安装教程
  11. java毕业设计——基于java+JDBC+sqlserver的POS积分管理系统设计与实现(毕业论文+程序源码)——POS积分管理系统
  12. OpenWiFi简介与学习记录
  13. HBGGP的工程建立过程
  14. 酷播云html5倍速功能视频播放器,Chrome扩展推荐:一个能16倍速播放的免费视频倍速播放器...
  15. 基于Web的电子商务解决方案(1)(转)
  16. Error: Socket descriptor not found. Hint: the problem might be solved applying the following:
  17. MyBatis 配置 settings 标签
  18. flowable工作流技术学习
  19. web框架详解之 tornado 四 模板引擎、session、验证码、xss
  20. Trimmomatic

热门文章

  1. Pytorch介绍与基本使用
  2. LINUX学习基础篇(二十二)硬盘结构
  3. Acrobat Pro DC 2020 Mac使用教程
  4. 实战Linux Bluetooth编程
  5. 【1023】KANO模型再理解
  6. 7.15亿元转让债转股 内蒙古建行拟退出包钢集团
  7. SAP工具箱之一键生成报表
  8. # 用Python浪漫表白(爱人表白树/玫瑰)
  9. ACCESS数据库转换成SQL数据库
  10. 三星s5 安装android,三星galaxy s5安装不了第三方软件怎么办?如何解决