1

阿木币

0

精华

8 小时

在线时间

应届白菜

Rank: 1

发表于 2021-10-26 18:27:36 10146 浏览 8 回复

飞控与板载

运行roslaunch mavros px4.launch 之后,执行自己的控制程序,不断发送一个点的位置之后。
0: DROPPED Message SET_POSITION_TARGET_LOCAL_NED: MAVConnSerial::send_message: TX queue overflow
eason已获得悬赏 3 阿木币

最佳答案

数据丢失很严重,串口通讯波特率是多少呢

扫一扫浏览分享
回复

使用道具 举报

106

阿木币

1

精华

396 小时

在线时间

技术大V

Rank: 4

发表于 2021-10-27 09:09:31
数据丢失很严重,串口通讯波特率是多少呢
回复 点赞

使用道具 举报

1

阿木币

0

精华

8 小时

在线时间

应届白菜

Rank: 1

 楼主| 发表于 2021-10-27 10:27:09
eason 发表于 2021-10-27 09:09
数据丢失很严重,串口通讯波特率是多少呢

57600,请问合适的波特率是多少呢
回复 点赞

使用道具 举报

106

阿木币

1

精华

396 小时

在线时间

技术大V

Rank: 4

发表于 2021-10-27 10:36:59
最好是921600
回复 点赞

使用道具 举报

1

阿木币

0

精华

8 小时

在线时间

应届白菜

Rank: 1

 楼主| 发表于 2021-10-27 10:48:57

我已经把px4.launch文件和qgc里面的波特率都改成了921600,但是还是相同的错误
回复 点赞

使用道具 举报

106

阿木币

1

精华

396 小时

在线时间

技术大V

Rank: 4

发表于 2021-10-27 14:59:38
你用的那个硬件接口,机载又是用的什么,都描述清晰一点
回复 点赞

使用道具 举报

1

阿木币

0

精华

8 小时

在线时间

应届白菜

Rank: 1

 楼主| 发表于 2021-10-28 15:49:40
eason 发表于 2021-10-27 14:59
你用的那个硬件接口,机载又是用的什么,都描述清晰一点

机载电脑用的是妙算2-c ,用的飞机是JCV600 接口是妙算2-c的urat0 接 飞机的p2(映射成telem2),波特率115200,px4.launch能够运行成功,mavros/state显示连接成功,当我用控制程序给飞机发位置时,报了上述的错误。
回复 点赞

使用道具 举报

1

阿木币

0

精华

8 小时

在线时间

应届白菜

Rank: 1

 楼主| 发表于 2021-10-28 15:50:42
#include <ros/ros.h>
#include <geometry_msgs/PoseStamped.h>
#include <mavros_msgs/CommandBool.h>
#include <mavros_msgs/SetMode.h>
#include <mavros_msgs/State.h>
#include <geometry_msgs/TwistStamped.h>
#include <mavros_msgs/AttitudeTarget.h>

// mavros_msgs::AttitudeTarget targetattitude;
// geometry_msgs::TwistStamped vel_cmd;
// geometry_msgs::PoseStamped pose;

mavros_msgs::State current_state;
void state_cb(const mavros_msgs::State::ConstPtr& msg){
    current_state = *msg;
    std::cout << current_state.mode << std::endl;
}
geometry_msgs::PoseStamped current_pose;
void pose_callback(const geometry_msgs::PoseStamped::ConstPtr& msg)
{
    current_pose = *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::Subscriber pose_sub =  nh.subscribe<geometry_msgs::PoseStamped>("/mavros/local_position/pose", 1, pose_callback);
    //  ros::Publisher  vision_pub = nh.advertise<geometry_msgs::PoseStamped>("/mavros/vision_pose/pose", 100);
    //  ros::Publisher local_vel_pub = nh.advertise<geometry_msgs::TwistStamped>("/mavros/setpoint_velocity/vel_cmd",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");
    //  ros::Publisher attitude_set_pub = nh.advertise<mavros_msgs::AttitudeTarget>("/mavros/setpoint_raw/attitude", 10);

    //点的发布频率在2hz以上
    ros::Rate rate(20.0);

    // 等待FCU连接
    while(ros::ok() && !current_state.connected){
        ROS_INFO("waiting for connect!!!");
        ros::spinOnce();
        rate.sleep();
    }

    ros::Time last_request = ros::Time::now();
    geometry_msgs::PoseStamped next_pose;
    geometry_msgs::PoseStamped pose;
    pose.pose.position.x = 0;
    pose.pose.position.y = 0;
    pose.pose.position.z = 2;

    //send a few setpoints before starting
    for(int i = 200; ros::ok() && i > 0; --i)
    {
        local_pos_pub.publish(pose);
        ros::spinOnce();
        rate.sleep();
    }

    ROS_INFO("READY FOR OFFBOARD MODE");
    geometry_msgs::PoseStamped captured_pose;
    while(ros::ok() && current_state.mode  != "OFFBOARD" )
    {
        captured_pose = current_pose;
        ros::spinOnce();
        ROS_INFO("POSITION CAPTURED");
        local_pos_pub.publish(captured_pose);
        ROS_INFO("POSITION CAPTURED %f", captured_pose.pose.position.x);
    }


    //发速度似乎有点问题
    // vel_cmd.twist.linear.x = 0;
    // vel_cmd.twist.linear.y = 0;
    // vel_cmd.twist.linear.z = -0.1;

//     targetattitude.orientation.x = 0;
//     targetattitude.orientation.y = 0;
//     targetattitude.orientation.z = 0;
//     targetattitude.orientation.w = 1;
//     targetattitude.thrust = 0.1;

    while(ros::ok() && current_state.mode == "OFFBOARD"){
            captured_pose = current_pose;
            next_pose.pose.position.x = captured_pose.pose.position.x;
            next_pose.pose.position.y = captured_pose.pose.position.y;
            next_pose.pose.position.z = captured_pose.pose.position.z;
            local_pos_pub.publish(next_pose);
        //    local_vel_pub.publish(vel_cmd);
        // attitude_set_pub.publish(targetattitude);
           ros::spinOnce();
     }

    rate.sleep();
    return 0;
}
回复 点赞

使用道具 举报

1

阿木币

0

精华

8 小时

在线时间

应届白菜

Rank: 1

 楼主| 发表于 2021-10-28 15:51:17
sunan 发表于 2021-10-28 15:50
#include
#include
#include

这个是我执行的控制的代码
回复 点赞

使用道具 举报

返回列表
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表