WebSocket报错总崩溃?教你快速定位并解决4大核心异常

第一章:WebSocket报错总崩溃?常见误区与认知重构

WebSocket 作为一种全双工通信协议,广泛应用于实时聊天、数据推送等场景。然而在实际开发中,频繁的连接中断、报错崩溃等问题常常让开发者误以为是代码逻辑缺陷,实则多源于对协议机制和网络环境的误解。

误解:WebSocket 连接建立即永久有效

许多开发者认为一旦 WebSocket 握手成功,连接就会一直保持。实际上,网络波动、代理超时、服务器负载都可能导致连接断开。正确的做法是实现重连机制:

const connect = () => {
  const ws = new WebSocket('wss://example.com/socket');
  
  ws.onopen = () => console.log('连接已建立');
  ws.onclose = () => {
    console.log('连接断开,5秒后重试');
    setTimeout(connect, 5000); // 自动重连
  };
  ws.onerror = (err) => console.error('连接错误:', err);
  ws.onmessage = (event) => console.log('收到消息:', event.data);
};
connect();

忽视心跳机制导致意外断连

大多数网关会在一定时间无数据传输后关闭连接。为维持活跃状态,需主动发送 ping 消息:
  • 设置定时器每30秒发送一次心跳包
  • 服务端响应 pong 以确认连接存活
  • 连续多次未响应则主动关闭并重连

错误处理粒度不足

将所有异常归为“连接失败”会掩盖根本原因。应根据状态码进行分类处理:
状态码含义建议操作
1006连接异常关闭立即尝试重连
4000+自定义业务关闭提示用户并停止重连
graph TD A[创建WebSocket] --> B{连接成功?} B -->|是| C[监听消息] B -->|否| D[记录错误日志] C --> E[发送心跳] E --> F{响应正常?} F -->|否| G[触发重连] G --> A

第二章:连接建立阶段的五大异常解析

2.1 理解WebSocket握手机制与状态码含义

WebSocket连接始于一次HTTP握手,客户端发送带有特定头信息的请求,表明希望升级为WebSocket协议。关键头部包括 Upgrade: websocketSec-WebSocket-Key,服务端验证后返回 101 Switching Protocols,表示协议切换成功。
握手请求示例
GET /chat HTTP/1.1
Host: example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Version: 13
该请求中,Sec-WebSocket-Key 是客户端生成的随机值,服务端结合固定字符串并计算SHA-1哈希,生成 Sec-WebSocket-Accept 响应头。
常见状态码含义
状态码含义
1000正常关闭
1006连接异常中断
1009消息过大被关闭

2.2 处理跨域限制导致的连接拒绝问题

在前后端分离架构中,浏览器出于安全策略默认禁止跨域请求,导致前端应用无法直接访问不同源的后端接口。
常见错误表现
当发起跨域请求时,浏览器控制台通常显示类似错误:
Access to fetch at 'http://api.example.com' from origin 'http://localhost:3000' has been blocked by CORS policy
该提示表明请求被同源策略拦截。
服务端解决方案
通过设置响应头允许跨域,例如在 Node.js Express 中:
app.use((req, res, next) => {
  res.header('Access-Control-Allow-Origin', 'http://localhost:3000');
  res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE');
  res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
  next();
});
上述代码显式授权指定来源、HTTP 方法与请求头字段,实现可控的跨域访问。

2.3 解决反向代理配置不当引发的400/502错误

在反向代理部署中,Nginx 作为前端网关时若配置不当,常导致客户端收到 400(Bad Request)或 502(Bad Gateway)错误。这类问题多源于请求头处理不当、后端服务不可达或协议转发配置缺失。
常见原因与排查路径
  • 后端服务未启动或监听端口异常
  • proxy_pass 地址配置错误或域名无法解析
  • 未正确传递 Host 头导致后端路由失败
典型修复配置示例

location / {
    proxy_pass http://backend:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}
上述配置确保原始请求信息被正确转发。其中,proxy_set_header Host $host; 防止因 Host 缺失导致后端拒绝请求;其余头字段用于传递客户端真实信息,避免认证或重定向异常。

2.4 客户端兼容性问题排查与降级方案设计

在多版本客户端并存的场景下,接口兼容性常引发异常。需建立系统化的排查流程,并设计可靠的降级机制。
常见兼容性问题类型
  • API字段变更:新增或删除字段导致解析失败
  • 协议不一致:如HTTP/2与HTTP/1.1行为差异
  • 时间格式处理:不同客户端对ISO8601支持不一
运行时特征识别代码示例

// 检测客户端UA并提取版本
function getClientInfo() {
  const ua = navigator.userAgent;
  const match = ua.match(/App\/(\d+\.\d+\.\d+)/);
  return {
    version: match ? match[1] : 'unknown',
    supportsNewAPI: match && compareVersion(match[1], '2.3.0') >= 0
  };
}
该函数通过正则匹配用户代理中的应用版本号,并判断是否支持新接口。compareVersion为自定义版本比较函数,用于决策是否启用新特性。
降级策略配置表
客户端版本使用接口数据格式
< 2.3.0/api/v1/dataJSON
>= 2.3.0/api/v2/enhancedProtobuf

2.5 实战演示:使用Chrome DevTools定位连接失败根源

在前端开发中,网络请求失败是常见问题。Chrome DevTools 提供了强大的诊断能力,帮助开发者快速定位问题根源。
打开Network面板监控请求
进入 DevTools 后切换至 Network 标签页,刷新页面即可捕获所有网络活动。重点关注状态码为红色的请求,如 500404ERR_CONNECTION_FAILED
分析请求详情
点击异常请求,查看其 Headers 和 Timing 信息。以下是一个典型的失败请求分析流程:
  • Name: 请求资源的URL
  • Status: HTTP 状态码或连接错误类型
  • Initiator: 发起请求的脚本文件及行号
  • Timing: 是否卡在“Stalled”或“Connecting”阶段
fetch('/api/data')
  .then(response => response.json())
  .catch(err => console.error('Request failed:', err));
// 错误可能源于CORS、服务不可达或DNS解析失败
若请求卡在 "Connecting" 阶段,通常表明客户端无法建立TCP连接,可能是后端服务宕机或防火墙拦截。结合控制台中的 CORS 错误提示,可进一步判断是否为跨域策略限制。

第三章:数据传输过程中的核心异常应对

3.1 帧格式错误与大数据分片发送策略

在高吞吐通信场景中,帧格式错误常导致接收端解析失败。典型原因包括长度字段溢出、校验和不匹配及协议标识错误。为降低单帧数据量过大引发的传输风险,需采用大数据分片机制。
分片策略设计原则
  • 单帧大小控制在MTU(通常1500字节)以内,避免IP层分片
  • 每片携带序列号与总片数,便于重组与丢包检测
  • 启用CRC32校验,提升帧完整性验证能力
示例分片结构定义
type DataFragment struct {
    PacketID   uint32 // 全局包唯一标识
    Seq        uint8  // 当前分片序号(从0开始)
    Total      uint8  // 分片总数
    Payload    []byte // 数据负载(建议≤1400字节)
    Checksum   uint32 // CRC32校验值
}
该结构确保每个分片可独立校验,并通过PacketIDSeq实现跨帧重组。接收方依据Total判断是否收齐全部分片。
传输可靠性增强
参数推荐值说明
最大分片大小1400 字节预留头部空间,防止IP分片
重传超时500ms平衡延迟与重传效率

3.2 处理网络中断后的消息丢失与重传机制

在分布式系统中,网络中断可能导致消息丢失。为保障可靠性,需引入确认机制与重传策略。
消息确认与超时重传
发送方应维护待确认的消息队列,接收方成功处理后返回ACK。若超时未收到确认,则触发重传。
  • 使用递增序列号标识每条消息,避免重复处理
  • 设置动态超时时间,基于RTT估算调整
  • 限制最大重传次数,防止无限重发
type Message struct {
    ID      uint64
    Payload []byte
    Retries int
}

func (c *Client) SendWithRetry(msg *Message) {
    for msg.Retries < 3 {
        if ack := c.sendAndWait(msg, 500*time.Millisecond); ack {
            return
        }
        msg.Retries++
        time.Sleep(backoffDuration(msg.Retries))
    }
}
上述代码实现带重试的可靠发送。每次发送后等待500ms,未收到ACK则递增重试计数并指数退避。参数Retries控制最大尝试次数,防止资源耗尽。

3.3 实战案例:心跳机制实现连接可用性检测

在长连接通信中,网络异常可能导致连接假死。心跳机制通过周期性发送探测包检测连接活性,是保障服务可靠性的关键技术。
心跳协议设计要点
  • 心跳间隔需权衡实时性与资源消耗,通常设置为30秒
  • 连续丢失3次心跳可判定连接失效
  • 支持双向心跳,客户端与服务端互发探测
Go语言实现示例
func startHeartbeat(conn net.Conn) {
    ticker := time.NewTicker(30 * time.Second)
    for {
        select {
        case <-ticker.C:
            _, err := conn.Write([]byte("PING"))
            if err != nil {
                log.Println("心跳发送失败,关闭连接")
                conn.Close()
                return
            }
        }
    }
}
该代码启动定时器每30秒发送一次PING指令。若写入失败,立即关闭连接并释放资源,防止无效连接堆积。

第四章:服务端与客户端典型异常场景剖析

4.1 服务端连接数超限导致的拒绝服务问题

当服务器并发连接数超过系统或应用层设定的阈值时,新的客户端请求将被拒绝,表现为“连接超时”或“Connection refused”,形成事实上的拒绝服务。
常见触发场景
  • 突发流量高峰,如秒杀活动
  • 恶意连接耗尽资源(非加密攻击)
  • 连接未及时释放导致堆积
内核参数调优示例
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.ip_local_port_range = 1024 65535
上述配置分别提升监听队列长度、SYN半连接队列及可用端口范围,缓解因资源不足引发的连接拒绝。
连接状态监控表
状态描述风险
ESTABLISHED活跃连接过高表示负载大
TIME_WAIT等待关闭过多占用端口
SYN_RECV半连接可能遭遇SYN洪泛

4.2 客户端未正确关闭连接引发的内存泄漏

在高并发服务中,客户端建立连接后未主动关闭会导致连接对象长期驻留内存,引发严重的内存泄漏问题。典型的场景包括HTTP长连接未设置超时、数据库连接未调用Close方法等。
常见泄漏代码示例
resp, err := http.Get("http://example.com")
if err != nil {
    log.Fatal(err)
}
// 忘记 resp.Body.Close(),导致连接未释放
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
上述代码未调用 resp.Body.Close(),致使底层TCP连接未释放,连接缓冲区和文件描述符持续累积。
资源释放最佳实践
  • 使用 defer resp.Body.Close() 确保连接释放
  • 为所有网络请求设置超时(如 context.WithTimeout
  • 使用连接池并配置最大空闲连接数
通过合理管理连接生命周期,可有效避免因资源未回收导致的内存增长。

4.3 消息队列积压与背压处理最佳实践

积压监控与动态限流
实时监控消息队列长度是应对积压的第一步。当消费者处理速度低于生产速度时,应触发告警并启动限流机制。
  1. 设置队列长度阈值,超过阈值则降低生产者速率
  2. 启用消费者自动伸缩,根据负载增加消费实例
  3. 引入延迟重试机制,避免瞬时高峰导致雪崩
基于令牌桶的背压控制
以下为 Go 实现的简单令牌桶算法示例:
type TokenBucket struct {
    capacity  int64
    tokens    int64
    rate      time.Duration
    lastCheck time.Time
}

func (tb *TokenBucket) Allow() bool {
    now := time.Now()
    elapsed := now.Sub(tb.lastCheck).Seconds()
    tb.tokens = min(tb.capacity, tb.tokens + int64(elapsed * float64(1/time.Second/tb.rate)))
    if tb.tokens >= 1 {
        tb.tokens--
        tb.lastCheck = now
        return true
    }
    return false
}
该代码通过周期性补充令牌控制请求流入速率,rate 决定填充频率,capacity 限制突发流量上限,有效防止下游过载。

4.4 实战演练:构建健壮的异常捕获与自动重连逻辑

在高可用系统中,网络抖动或服务瞬时不可用是常见问题,合理的异常捕获与自动重连机制能显著提升系统稳定性。
异常分类与捕获策略
需区分可重试异常(如网络超时)与不可重试异常(如认证失败)。通过封装错误判断函数,精准触发重连流程。
带指数退避的重连机制
采用指数退避策略避免频繁重试加剧网络压力:
func retryWithBackoff(operation func() error, maxRetries int) error {
    for i := 0; i < maxRetries; i++ {
        if err := operation(); err == nil {
            return nil
        }
        time.Sleep(time.Duration(1<
上述代码中,每次重试间隔随尝试次数指数增长(1s, 2s, 4s...),有效缓解服务端压力。结合上下文取消机制(context.WithCancel)可支持外部中断。
  • 优先处理临时性故障,如 I/O timeout
  • 设置最大重试上限,防止无限循环
  • 结合监控上报,便于故障追踪

第五章:从崩溃到稳定——WebSocket可靠通信的终极建议

心跳机制与自动重连策略
为防止连接因网络波动中断,必须实现双向心跳检测。客户端与服务端定期发送 ping/pong 消息,超时未响应则触发重连。
  • 设置合理的心跳间隔(通常 30s)
  • 采用指数退避算法避免重连风暴
  • 记录重连次数,超过阈值后提示用户或切换备用通道
const socket = new WebSocket('wss://example.com/ws');
let reconnectInterval = 1000;
let maxReconnectDelay = 30000;

function connect() {
  socket.onclose = () => {
    setTimeout(() => {
      console.log('尝试重连...');
      reconnectInterval = Math.min(reconnectInterval * 2, maxReconnectDelay);
      connect();
    }, reconnectInterval);
  };
}
消息确认与离线缓存
关键业务消息需引入 ACK 机制。客户端发送消息后启动定时器,等待服务端返回确认,否则重新投递。
消息类型是否需要 ACK缓存策略
实时聊天内存 + 本地存储
状态广播不缓存
服务端连接治理
使用连接池管理 WebSocket 实例,结合 Redis 存储会话状态,支持多实例间共享连接上下文。当某节点宕机,其他节点可快速恢复会话。
架构示意:
客户端 → 负载均衡(支持 WebSocket 协议升级) → Node.js 集群 ↔ Redis(存储 session)
内容概要:本文围绕SecureCRT自动化脚本开发在毕业设计中的应用,系统介绍了如何利用SecureCRT的脚本功能(支持Python、VBScript等)提升计算机、网络工程等相关专业毕业设计的效率与质量。文章从关键概念入手,阐明了SecureCRT脚本的核心对象(如crt、Screen、Session)及其在解决多设备调试、重复操作、跨场景验证等毕业设计常见痛点中的价值。通过三个典型应用场景——网络设备配置一致性验证、嵌入式系统稳定性测试、云平台CLI兼容性测试,展示了脚本的实际赋能效果,以Python实现的交换机端口安全配置验证脚本为例,深入解析了会话管理、屏幕同步、输出解析、异常处理和结果导出等关键技术细节。最后展望了低代码化、AI辅助调试和云边协同等未来发展趋势。; 适合人群:计算机、网络工程、物联网、云计算等相关专业,具备一定编程基础(尤其是Python)的本科或研究生毕业生,以及需要进行设备自动化操作的科研人员; 使用场景及目标:①实现批量网络设备配置的自动验证与报告生成;②长时间自动化采集嵌入式系统串口数据;③批量执行云平台CLI命令分析兼容性差异;目标是提升毕业设计的操作效率、增强实验可复现性与数据严谨性; 阅读建议:建议读者结合自身毕业设计课题,参考文中代码案例进行本地实践,重点关注异常处理机制与正则表达式的适配,注意敏感信息(如密码)的加密管理,同时可探索将脚本与外部工具(如Excel、数据库)集成以增强结果分析能力。
elcome to Atlas 200I DK A2 This system is based on Ubuntu 22.04.5 LTS (GNU/Linux 5.10.0+ aarch64) This system is only applicable to individual developers and cannot be used for c By using this system, you have agreed to the Huawei Software License Agreement. Please refer to the agreement for details on https://www.hiascend.com/software/p Reference resources * Home page: https://www.hiascend.com/hardware/developer-kit-a2 * Documentation: https://www.hiascend.com/hardware/developer-kit-a2/resource * Online courses: https://www.hiascend.com/edu/courses * Online experiments: https://www.hiascend.com/zh/edu/experiment * Forum: https://www.hiascend.com/forum/ * Code: https://gitee.com/HUAWEI-ASCEND/ascend-devkit * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/pro (base) root@davinci-mini:~# davinci-mini0 root@davinci-mini:/# cd racecar/ root@davinci-mini:/racecar# ls RedAndGreen Run_car.sh build_isolated docker-compose.yml nav.sh Run_car.log amcl_nav.launch.log devel_isolated gmapping.sh nav2.log root@davinci-mini:/racecar# bash nav_one.sh ... logging to /root/.ros/log/1ba06f92-cbc5-11f0-be3e-2c52afb5f6d1/roslaunch-davinci-mini-59.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://192.168.5.100:34989/ SUMMARY ======== CLEAR PARAMETERS * /ekf_se/ PARAMETERS * /amcl/base_frame_id: base_footprint * /amcl/first_map_only: True * /amcl/global_frame_id: map * /amcl/gui_publish_rate: 30.0 * /amcl/initial_cov_aa: 0.2 * /amcl/initial_cov_xx: 0.25 * /amcl/initial_cov_yy: 0.25 * /amcl/initial_pose_a: 0.0 * /amcl/initial_pose_x: 0.0 * /amcl/initial_pose_y: 0.0 * /amcl/kld_err: 0.01 * /amcl/kld_z: 0.99 * /amcl/laser_lambda_short: 0.1 * /amcl/laser_likelihood_max_dist: 2.0 * /amcl/laser_max_beams: 30 * /amcl/laser_model_type: likelihood_field * /amcl/laser_sigma_hit: 0.2 * /amcl/laser_z_hit: 0.5 * /amcl/laser_z_max: 0.05 * /amcl/laser_z_rand: 0.5 * /amcl/laser_z_short: 0.05 * /amcl/max_particles: 5000 * /amcl/min_particles: 100 * /amcl/odom_alpha1: 0.2 * /amcl/odom_alpha2: 0.2 * /amcl/odom_alpha3: 0.8 * /amcl/odom_alpha4: 0.2 * /amcl/odom_frame_id: odom * /amcl/odom_model_type: diff * /amcl/recovery_alpha_fast: 0.1 * /amcl/recovery_alpha_slow: 0.0 * /amcl/resample_interval: 2 * /amcl/tf_broadcast: True * /amcl/transform_tolerance: 0.1 * /amcl/update_min_a: 0.1 * /amcl/update_min_d: 0.1 * /amcl/use_map_topic: True * /car_controller/Angle_gain_d: -4.0 * /car_controller/Angle_gain_p: -4.0 * /car_controller/Lfw: 1.5 * /car_controller/Person1: 666 * /car_controller/Person2: 580 * /car_controller/Stopcar: 52 * /car_controller/Stoplight: 43 * /car_controller/Vcmd: 1.5 * /car_controller/baseAngle: 65.0 * /car_controller/baseSpeed: 1670 * /car_controller/first_lap: 100 * /car_controller/goalRadius: 0.7 * /car_controller/second_lap: 510 * /car_controller/vp_max_base: 75 * /car_controller/vp_min: 60 * /ekf_se/base_link_frame: /base_footprint * /ekf_se/debug: False * /ekf_se/debug_out_file: /path/to/debug/fi... * /ekf_se/frequency: 20 * /ekf_se/imu0: /imu_data * /ekf_se/imu0_config: [False, False, Fa... * /ekf_se/imu0_differential: False * /ekf_se/imu0_linear_acceleration_rejection_threshold: 2 * /ekf_se/imu0_nodelay: False * /ekf_se/imu0_pose_rejection_threshold: 2.0 * /ekf_se/imu0_queue_size: 8 * /ekf_se/imu0_relative: True * /ekf_se/imu0_remove_gravitational_acceleration: True * /ekf_se/imu0_twist_rejection_threshold: 2.0 * /ekf_se/initial_estimate_covariance: ['1e-9', 0, 0, 0,... * /ekf_se/map_frame: /map * /ekf_se/odom0: /rf2o_laser_odome... * /ekf_se/odom0_config: [False, False, Fa... * /ekf_se/odom0_differential: True * /ekf_se/odom0_nodelay: True * /ekf_se/odom0_pose_rejection_threshold: 8 * /ekf_se/odom0_queue_size: 5 * /ekf_se/odom0_twist_rejection_threshold: 4 * /ekf_se/odom1: /encoder_imu_odom * /ekf_se/odom1_config: [True, True, Fals... * /ekf_se/odom1_differential: True * /ekf_se/odom1_nodelay: True * /ekf_se/odom1_queue_size: 5 * /ekf_se/odom1_relative: False * /ekf_se/odom_frame: /odom * /ekf_se/print_diagnostics: False * /ekf_se/process_noise_covariance: [0.25, 0, 0, 0, 0... * /ekf_se/publish_acceleration: True * /ekf_se/publish_tf: True * /ekf_se/sensor_timeout: 0.025 * /ekf_se/transform_time_offset: 0.0001 * /ekf_se/transform_timeout: 0.025 * /ekf_se/two_d_mode: True * /ekf_se/world_frame: /odom * /move_base/GlobalPlanner/allow_unknown: True * /move_base/GlobalPlanner/cost_factor: 0.54 * /move_base/GlobalPlanner/default_tolerance: 0.2 * /move_base/GlobalPlanner/lethal_cost: 253 * /move_base/GlobalPlanner/neutral_cost: 21 * /move_base/GlobalPlanner/old_navfn_behavior: False * /move_base/GlobalPlanner/orientation_mode: 0 * /move_base/GlobalPlanner/orientation_window_size: 1 * /move_base/GlobalPlanner/publish_potential: True * /move_base/GlobalPlanner/use_dijkstra: False * /move_base/GlobalPlanner/use_grid_path: True * /move_base/GlobalPlanner/use_quadratic: True * /move_base/GlobalPlanner/visualize_potential: False * /move_base/NavfnROS/allow_unknown: False * /move_base/TebLocalPlannerROS/acc_lim_theta: 60 * /move_base/TebLocalPlannerROS/acc_lim_x: 0.188 * /move_base/TebLocalPlannerROS/allow_init_with_backwards_motion: False * /move_base/TebLocalPlannerROS/cmd_angle_instead_rotvel: False * /move_base/TebLocalPlannerROS/complete_global_plan: True * /move_base/TebLocalPlannerROS/costmap_converter_plugin: * /move_base/TebLocalPlannerROS/costmap_converter_rate: 8 * /move_base/TebLocalPlannerROS/costmap_converter_spin_thread: True * /move_base/TebLocalPlannerROS/costmap_obstacles_behind_robot_dist: 0.1 * /move_base/TebLocalPlannerROS/delete_detours_backwards: True * /move_base/TebLocalPlannerROS/dt_hysteresis: 0.05 * /move_base/TebLocalPlannerROS/dt_ref: 0.21 * /move_base/TebLocalPlannerROS/dynamic_obstacle_inflation_dist: 0.1 * /move_base/TebLocalPlannerROS/enable_homotopy_class_planning: True * /move_base/TebLocalPlannerROS/enable_multithreading: False * /move_base/TebLocalPlannerROS/exact_arc_length: True * /move_base/TebLocalPlannerROS/feasibility_check_no_poses: 10 * /move_base/TebLocalPlannerROS/footprint_model: polygon * /move_base/TebLocalPlannerROS/free_goal_vel: True * /move_base/TebLocalPlannerROS/global_plan_overwrite_orientation: True * /move_base/TebLocalPlannerROS/global_plan_prune_distance: 1 * /move_base/TebLocalPlannerROS/global_plan_viapoint_sep: -1 * /move_base/TebLocalPlannerROS/h_signature_prescaler: 0.5 * /move_base/TebLocalPlannerROS/h_signature_threshold: 0.1 * /move_base/TebLocalPlannerROS/include_costmap_obstacles: True * /move_base/TebLocalPlannerROS/include_dynamic_obstacles: True * /move_base/TebLocalPlannerROS/inflation_dist: 0.62 * /move_base/TebLocalPlannerROS/max_global_plan_lookahead_dist: 4.0 * /move_base/TebLocalPlannerROS/max_number_classes: 5 * /move_base/TebLocalPlannerROS/max_ratio_detours_duration_best_duration: 3.0 * /move_base/TebLocalPlannerROS/max_samples: 500 * /move_base/TebLocalPlannerROS/max_vel_theta: 85 * /move_base/TebLocalPlannerROS/max_vel_x: 3 * /move_base/TebLocalPlannerROS/max_vel_x_backwards: 1.2 * /move_base/TebLocalPlannerROS/max_vel_y: 0.288 * /move_base/TebLocalPlannerROS/min_turning_radius: 0.01 * /move_base/TebLocalPlannerROS/no_inner_iterations: -1 * /move_base/TebLocalPlannerROS/no_outer_iterations: -1 * /move_base/TebLocalPlannerROS/obstacle_cost_exponent: -1 * /move_base/TebLocalPlannerROS/obstacle_heading_threshold: 0.45 * /move_base/TebLocalPlannerROS/obstacle_poses_affected: 20 * /move_base/TebLocalPlannerROS/odom_topic: odom * /move_base/TebLocalPlannerROS/optimization_activate: True * /move_base/TebLocalPlannerROS/optimization_verbose: False * /move_base/TebLocalPlannerROS/oscillation_filter_duration: 10 * /move_base/TebLocalPlannerROS/oscillation_omega_eps: 10 * /move_base/TebLocalPlannerROS/oscillation_recovery: False * /move_base/TebLocalPlannerROS/oscillation_recovery_min_duration: 20 * /move_base/TebLocalPlannerROS/oscillation_v_eps: 10 * /move_base/TebLocalPlannerROS/penalty_epsilon: 0.01 * /move_base/TebLocalPlannerROS/publish_feedback: False * /move_base/TebLocalPlannerROS/roadmap_graph_area_length_scale: 1.0 * /move_base/TebLocalPlannerROS/roadmap_graph_area_width: 5 * /move_base/TebLocalPlannerROS/roadmap_graph_no_samples: 15 * /move_base/TebLocalPlannerROS/selection_alternative_time_cost: False * /move_base/TebLocalPlannerROS/selection_cost_hysteresis: 1.0 * /move_base/TebLocalPlannerROS/selection_obst_cost_scale: 1.0 * /move_base/TebLocalPlannerROS/selection_prefer_initial_plan: 0.95 * /move_base/TebLocalPlannerROS/shrink_horizon_backup: True * /move_base/TebLocalPlannerROS/shrink_horizon_min_duration: 3 * /move_base/TebLocalPlannerROS/switching_blocking_period: 0.0 * /move_base/TebLocalPlannerROS/teb_autosize: True * /move_base/TebLocalPlannerROS/type: polygon * /move_base/TebLocalPlannerROS/vertices: [[-0.175, -0.25],... * /move_base/TebLocalPlannerROS/viapoints_all_candidates: True * /move_base/TebLocalPlannerROS/visualize_hc_graph: True * /move_base/TebLocalPlannerROS/visualize_with_time_as_z_axis_scale: False * /move_base/TebLocalPlannerROS/weight_acc_lim_theta: 10 * /move_base/TebLocalPlannerROS/weight_acc_lim_x: 1 * /move_base/TebLocalPlannerROS/weight_adapt_factor: 20 * /move_base/TebLocalPlannerROS/weight_dynamic_obstacle: 10 * /move_base/TebLocalPlannerROS/weight_dynamic_obstacle_inflation: 5 * /move_base/TebLocalPlannerROS/weight_inflation: 50 * /move_base/TebLocalPlannerROS/weight_kinematics_forward_drive: 1000 * /move_base/TebLocalPlannerROS/weight_kinematics_nh: 1000 * /move_base/TebLocalPlannerROS/weight_kinematics_turning_radius: 1000 * /move_base/TebLocalPlannerROS/weight_max_vel_theta: 10 * /move_base/TebLocalPlannerROS/weight_max_vel_x: 1 * /move_base/TebLocalPlannerROS/weight_obstacle: 50 * /move_base/TebLocalPlannerROS/weight_optimaltime: 1000 * /move_base/TebLocalPlannerROS/weight_shortest_path: 1 * /move_base/TebLocalPlannerROS/weight_viapoint: 1 * /move_base/TebLocalPlannerROS/wheelbase: 0.335 * /move_base/TebLocalPlannerROS/xy_goal_tolerance: 0.01 * /move_base/TebLocalPlannerROS/yaw_goal_tolerance: 0.03 * /move_base/base_global_planner: navfn/NavfnROS * /move_base/base_local_planner: teb_local_planner... * /move_base/clearing_rotation_allowed: False * /move_base/controller_frequency: 10.0 * /move_base/controller_patience: 6.0 * /move_base/global_costmap/footprint: [[-0.175, -0.25],... * /move_base/global_costmap/footprint_padding: 0.01 * /move_base/global_costmap/global_frame: map * /move_base/global_costmap/height: 25.0 * /move_base/global_costmap/inflation/cost_scaling_factor: 2.0 * /move_base/global_costmap/inflation/inflation_radius: 0. 1 * /move_base/global_costmap/plugins: [{'name': 'static... * /move_base/global_costmap/publish_frequency: 1.0 * /move_base/global_costmap/resolution: 0.05 * /move_base/global_costmap/robot_base_frame: base_footprint * /move_base/global_costmap/rolling_window: True * /move_base/global_costmap/sensor/laser_scan_sensor/clearing: True * /move_base/global_costmap/sensor/laser_scan_sensor/data_type: LaserScan * /move_base/global_costmap/sensor/laser_scan_sensor/marking: True * /move_base/global_costmap/sensor/laser_scan_sensor/observation_persistence: 0.5 * /move_base/global_costmap/sensor/laser_scan_sensor/sensor_frame: laser_link * /move_base/global_costmap/sensor/laser_scan_sensor/topic: scan * /move_base/global_costmap/sensor/observation_sources: laser_scan_sensor * /move_base/global_costmap/static/map_topic: /map * /move_base/global_costmap/static/subscribe_to_updates: True * /move_base/global_costmap/track_unknown_space: False * /move_base/global_costmap/transform_tolerance: 0.5 * /move_base/global_costmap/update_frequency: 1.0 * /move_base/global_costmap/width: 25.0 * /move_base/local_costmap/footprint: [[-0.175, -0.25],... * /move_base/local_costmap/footprint_padding: 0.01 * /move_base/local_costmap/global_frame: map * /move_base/local_costmap/height: 3.0 * /move_base/local_costmap/inflation/cost_scaling_factor: 6.0 * /move_base/local_costmap/inflation/inflation_radius: 0.1 * /move_base/local_costmap/plugins: [{'name': 'sensor... * /move_base/local_costmap/publish_frequency: 1.0 * /move_base/local_costmap/resolution: 0.05 * /move_base/local_costmap/robot_base_frame: base_footprint * /move_base/local_costmap/rolling_window: True * /move_base/local_costmap/sensor/laser_scan_sensor/clearing: True * /move_base/local_costmap/sensor/laser_scan_sensor/data_type: LaserScan * /move_base/local_costmap/sensor/laser_scan_sensor/marking: True * /move_base/local_costmap/sensor/laser_scan_sensor/sensor_frame: laser_link * /move_base/local_costmap/sensor/laser_scan_sensor/topic: scan * /move_base/local_costmap/sensor/observation_sources: laser_scan_sensor * /move_base/local_costmap/track_unknown_space: False * /move_base/local_costmap/transform_tolerance: 0.5 * /move_base/local_costmap/update_frequency: 1.0 * /move_base/local_costmap/width: 3.0 * /move_base/oscillation_distance: 0.2 * /move_base/oscillation_timeout: 10.0 * /move_base/planner_frequency: 10.0 * /move_base/planner_patience: 5.0 * /move_base/shutdown_costmaps: False * /rf2o_laser_odometry/base_frame_id: base_footprint * /rf2o_laser_odometry/freq: 20.0 * /rf2o_laser_odometry/laser_scan_topic: scan * /rf2o_laser_odometry/odom_frame_id: odom * /rf2o_laser_odometry/odom_topic: odom_rf2o * /rf2o_laser_odometry/publish_tf: False * /rf2o_laser_odometry/verbose: True * /rosdistro: noetic * /rosversion: 1.15.13 NODES / amcl (amcl/amcl) car_controller (racecar/car_controller_new) ekf_se (robot_localization/ekf_localization_node) map_server (map_server/map_server) move_base (move_base/move_base) rf2o_laser_odometry (rf2o_laser_odometry/rf2o_laser_odometry_node) wheel_odom (encoder_driver/encoder_driver_node1) RLException: run_id on parameter server does not match declared run_id: 1a54deac-cbc5-11f0-9652-2c52afb5f6d1 vs 1ba06f92-cbc5-11f0-be3e-2c52afb5f6d1 The traceback for the exception was written to the log file ROS_MASTER_URI=http://192.168.5.100:11311 2025-11-27 19:13:12+0000 [-] Log opened. 2025-11-27 19:13:12+0000 [-] registered capabilities (classes): 2025-11-27 19:13:12+0000 [-] - <class 'rosbridge_library.capabilities.call_service.CallService'> 2025-11-27 19:13:12+0000 [-] - <class 'rosbridge_library.capabilities.advertise.Advertise'> 2025-11-27 19:13:12+0000 [-] - <class 'rosbridge_library.capabilities.publish.Publish'> 2025-11-27 19:13:12+0000 [-] - <class 'rosbridge_library.capabilities.subscribe.Subscribe'> 2025-11-27 19:13:12+0000 [-] - <class 'rosbridge_library.capabilities.defragmentation.Defragment'> 2025-11-27 19:13:12+0000 [-] - <class 'rosbridge_library.capabilities.advertise_service.AdvertiseService'> 2025-11-27 19:13:12+0000 [-] - <class 'rosbridge_library.capabilities.service_response.ServiceResponse'> 2025-11-27 19:13:12+0000 [-] - <class 'rosbridge_library.capabilities.unadvertise_service.UnadvertiseService'> 2025-11-27 19:13:13+0000 [-] WebSocketServerFactory starting on 9090 2025-11-27 19:13:13+0000 [-] Starting factory <autobahn.twisted.websocket.WebSocketServerFactory object at 0xe7ffca3420a0> 2025-11-27 19:13:13+0000 [-] [INFO] [1764270793.062939]: Rosbridge WebSocket server started at ws://0.0.0.0:9090 ^C终止 ROS 启动进程... lslidar_x10_driver_node: /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:81: boost::condition_variable::~condition_variable(): Assertion `!posix::pthread_mutex_destroy(&internal_mutex)' failed. 2025-11-27 19:14:41+0000 [autobahn.twisted.websocket.WebSocketServerFactory] (TCP Port 9090 Closed) [DEBUG] [1764270791.133628]: init_node, name[/encoder_vel], pid[87] [DEBUG] [1764270791.140349]: binding to 0.0.0.0 0 [DEBUG] [1764270791.143836]: bound to 0.0.0.0 43043 [DEBUG] [1764270791.147385]: ... service URL is rosrpc://192.168.5.100:43043 [DEBUG] [1764270791.150428]: [/encoder_vel/get_loggers]: new Service instance [DEBUG] [1764270791.155703]: ... service URL is rosrpc://192.168.5.100:43043 [DEBUG] [1764270791.158360]: [/encoder_vel/set_logger_level]: new Service instance True 2025-11-27 19:14:41+0000 [-] Stopping factory <autobahn.twisted.websocket.WebSocketServerFactory object at 0xe7ffca3420a0> 2025-11-27 19:14:41+0000 [-] Main loop terminated. WARNING: ignoring defunct <master /> tag ... logging to /root/.ros/log/1a54deac-cbc5-11f0-9652-2c52afb5f6d1/roslaunch-davinci-mini-53.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://192.168.5.100:39739/ SUMMARY ======== PARAMETERS * /encoder_vel/baud_rate: 57600 * /encoder_vel/k: 0.88 * /encoder_vel/serial_port: /dev/encoder * /lslidar_x10_driver_node/angle_disable_max: 0.0 * /lslidar_x10_driver_node/angle_disable_min: 0.0 * /lslidar_x10_driver_node/child_frame_id: laser_link * /lslidar_x10_driver_node/interface_selection: serial * /lslidar_x10_driver_node/lidar_name: M10 * /lslidar_x10_driver_node/max_range: 100.0 * /lslidar_x10_driver_node/min_range: 0 * /lslidar_x10_driver_node/scan_topic: scan * /lslidar_x10_driver_node/serial_port: /dev/laser * /lslidar_x10_driver_node/use_gps_ts: False * /rosbridge_server/websocket_port: 9090 * /rosdistro: noetic * /rosversion: 1.15.13 NODES / base_footprint2base_link (tf/static_transform_publisher) base_link2imu (tf/static_transform_publisher) base_link2laser_link (tf/static_transform_publisher) encoder_vel (encoder_driver/Encoder_vel.py) imu_sonser_spec (serial_imu/serial_imu) lslidar_x10_driver_node (lslidar_x10_driver/lslidar_x10_driver_node) racecar_driver (racecar_driver/racecar_driver_node) rosbridge_server (rosbridge_server/rosbridge_websocket) auto-starting new master process[master]: started with pid [66] ROS_MASTER_URI=http://192.168.5.100:11311 setting /run_id to 1a54deac-cbc5-11f0-9652-2c52afb5f6d1 process[rosout-1]: started with pid [79] started core service [/rosout] process[base_footprint2base_link-2]: started with pid [82] process[base_link2laser_link-3]: started with pid [83] process[base_link2imu-4]: started with pid [84] process[lslidar_x10_driver_node-5]: started with pid [85] process[imu_sonser_spec-6]: started with pid [86] process[encoder_vel-7]: started with pid [87] process[racecar_driver-8]: started with pid [88] process[rosbridge_server-9]: started with pid [89] [rosbridge_server-9] killing on exit [racecar_driver-8] killing on exit [encoder_vel-7] killing on exit [imu_sonser_spec-6] killing on exit [lslidar_x10_driver_node-5] killing on exit [base_link2imu-4] killing on exit [base_link2laser_link-3] killing on exit [base_footprint2base_link-2] killing on exit [rosout-1] killing on exit [master] killing on exit shutting down processing monitor... ... shutting down processing monitor complete done Run_car.launch 进程已终止。 amcl_nav.launch 进程已终止。 root@davinci-mini:/racecar# ^C root@davinci-mini:/racecar# bash nav_one.sh 2025-11-27 19:14:55+0000 [-] Log opened. 2025-11-27 19:14:55+0000 [-] registered capabilities (classes): 2025-11-27 19:14:55+0000 [-] - <class 'rosbridge_library.capabilities.call_service.CallService'> 2025-11-27 19:14:55+0000 [-] - <class 'rosbridge_library.capabilities.advertise.Advertise'> 2025-11-27 19:14:55+0000 [-] - <class 'rosbridge_library.capabilities.publish.Publish'> 2025-11-27 19:14:55+0000 [-] - <class 'rosbridge_library.capabilities.subscribe.Subscribe'> 2025-11-27 19:14:55+0000 [-] - <class 'rosbridge_library.capabilities.defragmentation.Defragment'> 2025-11-27 19:14:55+0000 [-] - <class 'rosbridge_library.capabilities.advertise_service.AdvertiseService'> 2025-11-27 19:14:55+0000 [-] - <class 'rosbridge_library.capabilities.service_response.ServiceResponse'> 2025-11-27 19:14:55+0000 [-] - <class 'rosbridge_library.capabilities.unadvertise_service.UnadvertiseService'> 2025-11-27 19:14:55+0000 [-] WebSocketServerFactory starting on 9090 2025-11-27 19:14:55+0000 [-] Starting factory <autobahn.twisted.websocket.WebSocketServerFactory object at 0xe7ffef3acfd0> 2025-11-27 19:14:55+0000 [-] [INFO] [1764270895.708127]: Rosbridge WebSocket server started at ws://0.0.0.0:9090 ... logging to /root/.ros/log/593a31d0-cbc5-11f0-acbf-2c52afb5f6d1/roslaunch-davinci-mini-235.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://192.168.5.100:35929/ SUMMARY ======== CLEAR PARAMETERS * /ekf_se/ PARAMETERS * /amcl/base_frame_id: base_footprint * /amcl/first_map_only: True * /amcl/global_frame_id: map * /amcl/gui_publish_rate: 30.0 * /amcl/initial_cov_aa: 0.2 * /amcl/initial_cov_xx: 0.25 * /amcl/initial_cov_yy: 0.25 * /amcl/initial_pose_a: 0.0 * /amcl/initial_pose_x: 0.0 * /amcl/initial_pose_y: 0.0 * /amcl/kld_err: 0.01 * /amcl/kld_z: 0.99 * /amcl/laser_lambda_short: 0.1 * /amcl/laser_likelihood_max_dist: 2.0 * /amcl/laser_max_beams: 30 * /amcl/laser_model_type: likelihood_field * /amcl/laser_sigma_hit: 0.2 * /amcl/laser_z_hit: 0.5 * /amcl/laser_z_max: 0.05 * /amcl/laser_z_rand: 0.5 * /amcl/laser_z_short: 0.05 * /amcl/max_particles: 5000 * /amcl/min_particles: 100 * /amcl/odom_alpha1: 0.2 * /amcl/odom_alpha2: 0.2 * /amcl/odom_alpha3: 0.8 * /amcl/odom_alpha4: 0.2 * /amcl/odom_frame_id: odom * /amcl/odom_model_type: diff * /amcl/recovery_alpha_fast: 0.1 * /amcl/recovery_alpha_slow: 0.0 * /amcl/resample_interval: 2 * /amcl/tf_broadcast: True * /amcl/transform_tolerance: 0.1 * /amcl/update_min_a: 0.1 * /amcl/update_min_d: 0.1 * /amcl/use_map_topic: True * /car_controller/Angle_gain_d: -4.0 * /car_controller/Angle_gain_p: -4.0 * /car_controller/Lfw: 1.5 * /car_controller/Person1: 666 * /car_controller/Person2: 580 * /car_controller/Stopcar: 52 * /car_controller/Stoplight: 43 * /car_controller/Vcmd: 1.5 * /car_controller/baseAngle: 65.0 * /car_controller/baseSpeed: 1670 * /car_controller/first_lap: 100 * /car_controller/goalRadius: 0.7 * /car_controller/second_lap: 510 * /car_controller/vp_max_base: 75 * /car_controller/vp_min: 60 * /ekf_se/base_link_frame: /base_footprint * /ekf_se/debug: False * /ekf_se/debug_out_file: /path/to/debug/fi... * /ekf_se/frequency: 20 * /ekf_se/imu0: /imu_data * /ekf_se/imu0_config: [False, False, Fa... * /ekf_se/imu0_differential: False * /ekf_se/imu0_linear_acceleration_rejection_threshold: 2 * /ekf_se/imu0_nodelay: False * /ekf_se/imu0_pose_rejection_threshold: 2.0 * /ekf_se/imu0_queue_size: 8 * /ekf_se/imu0_relative: True * /ekf_se/imu0_remove_gravitational_acceleration: True * /ekf_se/imu0_twist_rejection_threshold: 2.0 * /ekf_se/initial_estimate_covariance: ['1e-9', 0, 0, 0,... * /ekf_se/map_frame: /map * /ekf_se/odom0: /rf2o_laser_odome... * /ekf_se/odom0_config: [False, False, Fa... * /ekf_se/odom0_differential: True * /ekf_se/odom0_nodelay: True * /ekf_se/odom0_pose_rejection_threshold: 8 * /ekf_se/odom0_queue_size: 5 * /ekf_se/odom0_twist_rejection_threshold: 4 * /ekf_se/odom1: /encoder_imu_odom * /ekf_se/odom1_config: [True, True, Fals... * /ekf_se/odom1_differential: True * /ekf_se/odom1_nodelay: True * /ekf_se/odom1_queue_size: 5 * /ekf_se/odom1_relative: False * /ekf_se/odom_frame: /odom * /ekf_se/print_diagnostics: False * /ekf_se/process_noise_covariance: [0.25, 0, 0, 0, 0... * /ekf_se/publish_acceleration: True * /ekf_se/publish_tf: True * /ekf_se/sensor_timeout: 0.025 * /ekf_se/transform_time_offset: 0.0001 * /ekf_se/transform_timeout: 0.025 * /ekf_se/two_d_mode: True * /ekf_se/world_frame: /odom * /move_base/GlobalPlanner/allow_unknown: True * /move_base/GlobalPlanner/cost_factor: 0.54 * /move_base/GlobalPlanner/default_tolerance: 0.2 * /move_base/GlobalPlanner/lethal_cost: 253 * /move_base/GlobalPlanner/neutral_cost: 21 * /move_base/GlobalPlanner/old_navfn_behavior: False * /move_base/GlobalPlanner/orientation_mode: 0 * /move_base/GlobalPlanner/orientation_window_size: 1 * /move_base/GlobalPlanner/publish_potential: True * /move_base/GlobalPlanner/use_dijkstra: False * /move_base/GlobalPlanner/use_grid_path: True * /move_base/GlobalPlanner/use_quadratic: True * /move_base/GlobalPlanner/visualize_potential: False * /move_base/NavfnROS/allow_unknown: False * /move_base/TebLocalPlannerROS/acc_lim_theta: 60 * /move_base/TebLocalPlannerROS/acc_lim_x: 0.188 * /move_base/TebLocalPlannerROS/allow_init_with_backwards_motion: False * /move_base/TebLocalPlannerROS/cmd_angle_instead_rotvel: False * /move_base/TebLocalPlannerROS/complete_global_plan: True * /move_base/TebLocalPlannerROS/costmap_converter_plugin: * /move_base/TebLocalPlannerROS/costmap_converter_rate: 8 * /move_base/TebLocalPlannerROS/costmap_converter_spin_thread: True * /move_base/TebLocalPlannerROS/costmap_obstacles_behind_robot_dist: 0.1 * /move_base/TebLocalPlannerROS/delete_detours_backwards: True * /move_base/TebLocalPlannerROS/dt_hysteresis: 0.05 * /move_base/TebLocalPlannerROS/dt_ref: 0.21 * /move_base/TebLocalPlannerROS/dynamic_obstacle_inflation_dist: 0.1 * /move_base/TebLocalPlannerROS/enable_homotopy_class_planning: True * /move_base/TebLocalPlannerROS/enable_multithreading: False * /move_base/TebLocalPlannerROS/exact_arc_length: True * /move_base/TebLocalPlannerROS/feasibility_check_no_poses: 10 * /move_base/TebLocalPlannerROS/footprint_model: polygon * /move_base/TebLocalPlannerROS/free_goal_vel: True * /move_base/TebLocalPlannerROS/global_plan_overwrite_orientation: True * /move_base/TebLocalPlannerROS/global_plan_prune_distance: 1 * /move_base/TebLocalPlannerROS/global_plan_viapoint_sep: -1 * /move_base/TebLocalPlannerROS/h_signature_prescaler: 0.5 * /move_base/TebLocalPlannerROS/h_signature_threshold: 0.1 * /move_base/TebLocalPlannerROS/include_costmap_obstacles: True * /move_base/TebLocalPlannerROS/include_dynamic_obstacles: True * /move_base/TebLocalPlannerROS/inflation_dist: 0.62 * /move_base/TebLocalPlannerROS/max_global_plan_lookahead_dist: 4.0 * /move_base/TebLocalPlannerROS/max_number_classes: 5 * /move_base/TebLocalPlannerROS/max_ratio_detours_duration_best_duration: 3.0 * /move_base/TebLocalPlannerROS/max_samples: 500 * /move_base/TebLocalPlannerROS/max_vel_theta: 85 * /move_base/TebLocalPlannerROS/max_vel_x: 3 * /move_base/TebLocalPlannerROS/max_vel_x_backwards: 1.2 * /move_base/TebLocalPlannerROS/max_vel_y: 0.288 * /move_base/TebLocalPlannerROS/min_turning_radius: 0.01 * /move_base/TebLocalPlannerROS/no_inner_iterations: -1 * /move_base/TebLocalPlannerROS/no_outer_iterations: -1 * /move_base/TebLocalPlannerROS/obstacle_cost_exponent: -1 * /move_base/TebLocalPlannerROS/obstacle_heading_threshold: 0.45 * /move_base/TebLocalPlannerROS/obstacle_poses_affected: 20 * /move_base/TebLocalPlannerROS/odom_topic: odom * /move_base/TebLocalPlannerROS/optimization_activate: True * /move_base/TebLocalPlannerROS/optimization_verbose: False * /move_base/TebLocalPlannerROS/oscillation_filter_duration: 10 * /move_base/TebLocalPlannerROS/oscillation_omega_eps: 10 * /move_base/TebLocalPlannerROS/oscillation_recovery: False * /move_base/TebLocalPlannerROS/oscillation_recovery_min_duration: 20 * /move_base/TebLocalPlannerROS/oscillation_v_eps: 10 * /move_base/TebLocalPlannerROS/penalty_epsilon: 0.01 * /move_base/TebLocalPlannerROS/publish_feedback: False * /move_base/TebLocalPlannerROS/roadmap_graph_area_length_scale: 1.0 * /move_base/TebLocalPlannerROS/roadmap_graph_area_width: 5 * /move_base/TebLocalPlannerROS/roadmap_graph_no_samples: 15 * /move_base/TebLocalPlannerROS/selection_alternative_time_cost: False * /move_base/TebLocalPlannerROS/selection_cost_hysteresis: 1.0 * /move_base/TebLocalPlannerROS/selection_obst_cost_scale: 1.0 * /move_base/TebLocalPlannerROS/selection_prefer_initial_plan: 0.95 * /move_base/TebLocalPlannerROS/shrink_horizon_backup: True * /move_base/TebLocalPlannerROS/shrink_horizon_min_duration: 3 * /move_base/TebLocalPlannerROS/switching_blocking_period: 0.0 * /move_base/TebLocalPlannerROS/teb_autosize: True * /move_base/TebLocalPlannerROS/type: polygon * /move_base/TebLocalPlannerROS/vertices: [[-0.175, -0.25],... * /move_base/TebLocalPlannerROS/viapoints_all_candidates: True * /move_base/TebLocalPlannerROS/visualize_hc_graph: True * /move_base/TebLocalPlannerROS/visualize_with_time_as_z_axis_scale: False * /move_base/TebLocalPlannerROS/weight_acc_lim_theta: 10 * /move_base/TebLocalPlannerROS/weight_acc_lim_x: 1 * /move_base/TebLocalPlannerROS/weight_adapt_factor: 20 * /move_base/TebLocalPlannerROS/weight_dynamic_obstacle: 10 * /move_base/TebLocalPlannerROS/weight_dynamic_obstacle_inflation: 5 * /move_base/TebLocalPlannerROS/weight_inflation: 50 * /move_base/TebLocalPlannerROS/weight_kinematics_forward_drive: 1000 * /move_base/TebLocalPlannerROS/weight_kinematics_nh: 1000 * /move_base/TebLocalPlannerROS/weight_kinematics_turning_radius: 1000 * /move_base/TebLocalPlannerROS/weight_max_vel_theta: 10 * /move_base/TebLocalPlannerROS/weight_max_vel_x: 1 * /move_base/TebLocalPlannerROS/weight_obstacle: 50 * /move_base/TebLocalPlannerROS/weight_optimaltime: 1000 * /move_base/TebLocalPlannerROS/weight_shortest_path: 1 * /move_base/TebLocalPlannerROS/weight_viapoint: 1 * /move_base/TebLocalPlannerROS/wheelbase: 0.335 * /move_base/TebLocalPlannerROS/xy_goal_tolerance: 0.01 * /move_base/TebLocalPlannerROS/yaw_goal_tolerance: 0.03 * /move_base/base_global_planner: navfn/NavfnROS * /move_base/base_local_planner: teb_local_planner... * /move_base/clearing_rotation_allowed: False * /move_base/controller_frequency: 10.0 * /move_base/controller_patience: 6.0 * /move_base/global_costmap/footprint: [[-0.175, -0.25],... * /move_base/global_costmap/footprint_padding: 0.01 * /move_base/global_costmap/global_frame: map * /move_base/global_costmap/height: 25.0 * /move_base/global_costmap/inflation/cost_scaling_factor: 2.0 * /move_base/global_costmap/inflation/inflation_radius: 0. 1 * /move_base/global_costmap/plugins: [{'name': 'static... * /move_base/global_costmap/publish_frequency: 1.0 * /move_base/global_costmap/resolution: 0.05 * /move_base/global_costmap/robot_base_frame: base_footprint * /move_base/global_costmap/rolling_window: True * /move_base/global_costmap/sensor/laser_scan_sensor/clearing: True * /move_base/global_costmap/sensor/laser_scan_sensor/data_type: LaserScan * /move_base/global_costmap/sensor/laser_scan_sensor/marking: True * /move_base/global_costmap/sensor/laser_scan_sensor/observation_persistence: 0.5 * /move_base/global_costmap/sensor/laser_scan_sensor/sensor_frame: laser_link * /move_base/global_costmap/sensor/laser_scan_sensor/topic: scan * /move_base/global_costmap/sensor/observation_sources: laser_scan_sensor * /move_base/global_costmap/static/map_topic: /map * /move_base/global_costmap/static/subscribe_to_updates: True * /move_base/global_costmap/track_unknown_space: False * /move_base/global_costmap/transform_tolerance: 0.5 * /move_base/global_costmap/update_frequency: 1.0 * /move_base/global_costmap/width: 25.0 * /move_base/local_costmap/footprint: [[-0.175, -0.25],... * /move_base/local_costmap/footprint_padding: 0.01 * /move_base/local_costmap/global_frame: map * /move_base/local_costmap/height: 3.0 * /move_base/local_costmap/inflation/cost_scaling_factor: 6.0 * /move_base/local_costmap/inflation/inflation_radius: 0.1 * /move_base/local_costmap/plugins: [{'name': 'sensor... * /move_base/local_costmap/publish_frequency: 1.0 * /move_base/local_costmap/resolution: 0.05 * /move_base/local_costmap/robot_base_frame: base_footprint * /move_base/local_costmap/rolling_window: True * /move_base/local_costmap/sensor/laser_scan_sensor/clearing: True * /move_base/local_costmap/sensor/laser_scan_sensor/data_type: LaserScan * /move_base/local_costmap/sensor/laser_scan_sensor/marking: True * /move_base/local_costmap/sensor/laser_scan_sensor/sensor_frame: laser_link * /move_base/local_costmap/sensor/laser_scan_sensor/topic: scan * /move_base/local_costmap/sensor/observation_sources: laser_scan_sensor * /move_base/local_costmap/track_unknown_space: False * /move_base/local_costmap/transform_tolerance: 0.5 * /move_base/local_costmap/update_frequency: 1.0 * /move_base/local_costmap/width: 3.0 * /move_base/oscillation_distance: 0.2 * /move_base/oscillation_timeout: 10.0 * /move_base/planner_frequency: 10.0 * /move_base/planner_patience: 5.0 * /move_base/shutdown_costmaps: False * /rf2o_laser_odometry/base_frame_id: base_footprint * /rf2o_laser_odometry/freq: 20.0 * /rf2o_laser_odometry/laser_scan_topic: scan * /rf2o_laser_odometry/odom_frame_id: odom * /rf2o_laser_odometry/odom_topic: odom_rf2o * /rf2o_laser_odometry/publish_tf: False * /rf2o_laser_odometry/verbose: True * /rosdistro: noetic * /rosversion: 1.15.13 NODES / amcl (amcl/amcl) car_controller (racecar/car_controller_new) ekf_se (robot_localization/ekf_localization_node) map_server (map_server/map_server) move_base (move_base/move_base) rf2o_laser_odometry (rf2o_laser_odometry/rf2o_laser_odometry_node) wheel_odom (encoder_driver/encoder_driver_node1) [ WARN] [1764270901.074929580]: Failed to meet update rate! Took 0.1020085420000000076 ^C终止 ROS 启动进程... lslidar_x10_driver_node: /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:81: boost::condition_variable::~condition_variable(): Assertion `!posix::pthread_mutex_destroy(&internal_mutex)' failed. [ INFO] [1764270899.968804781]: ?????????????????????????????? [ INFO] [1764270901.013836659]: Subscribed to map topic. [ INFO] [1764270901.452807176]: Received a 608 X 384 map @ 0.050 m/pix [ INFO] [1764270901.485205220]: Initializing likelihood field model; this can take some time on large maps... [ INFO] [1764270901.599203612]: Done initializing likelihood field model. [DEBUG] [1764270895.085141]: init_node, name[/encoder_vel], pid[205] [DEBUG] [1764270895.091976]: binding to 0.0.0.0 0 [DEBUG] [1764270895.095563]: bound to 0.0.0.0 34779 [DEBUG] [1764270895.099010]: ... service URL is rosrpc://192.168.5.100:34779 [DEBUG] [1764270895.102058]: [/encoder_vel/get_loggers]: new Service instance [DEBUG] [1764270895.107122]: ... service URL is rosrpc://192.168.5.100:34779 [DEBUG] [1764270895.109904]: [/encoder_vel/set_logger_level]: new Service instance True 2025-11-27 19:16:49+0000 [autobahn.twisted.websocket.WebSocketServerFactory] (TCP Port 9090 Closed) 2025-11-27 19:16:49+0000 [-] Stopping factory <autobahn.twisted.websocket.WebSocketServerFactory object at 0xe7ffef3acfd0> 2025-11-27 19:16:49+0000 [-] Main loop terminated. ROS_MASTER_URI=http://192.168.5.100:11311 process[map_server-1]: started with pid [256] process[rf2o_laser_odometry-2]: started with pid [257] process[wheel_odom-3]: started with pid [258] process[ekf_se-4]: started with pid [259] process[amcl-5]: started with pid [266] process[move_base-6]: started with pid [268] process[car_controller-7]: started with pid [269] [car_controller-7] killing on exit [move_base-6] killing on exit [amcl-5] killing on exit [ekf_se-4] killing on exit [map_server-1] killing on exit [wheel_odom-3] killing on exit [rf2o_laser_odometry-2] killing on exit shutting down processing monitor... ... shutting down processing monitor complete done WARNING: ignoring defunct <master /> tag ... logging to /root/.ros/log/593a31d0-cbc5-11f0-acbf-2c52afb5f6d1/roslaunch-davinci-mini-159.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://192.168.5.100:35239/ SUMMARY ======== PARAMETERS * /encoder_vel/baud_rate: 57600 * /encoder_vel/k: 0.88 * /encoder_vel/serial_port: /dev/encoder * /lslidar_x10_driver_node/angle_disable_max: 0.0 * /lslidar_x10_driver_node/angle_disable_min: 0.0 * /lslidar_x10_driver_node/child_frame_id: laser_link * /lslidar_x10_driver_node/interface_selection: serial * /lslidar_x10_driver_node/lidar_name: M10 * /lslidar_x10_driver_node/max_range: 100.0 * /lslidar_x10_driver_node/min_range: 0 * /lslidar_x10_driver_node/scan_topic: scan * /lslidar_x10_driver_node/serial_port: /dev/laser * /lslidar_x10_driver_node/use_gps_ts: False * /rosbridge_server/websocket_port: 9090 * /rosdistro: noetic * /rosversion: 1.15.13 NODES / base_footprint2base_link (tf/static_transform_publisher) base_link2imu (tf/static_transform_publisher) base_link2laser_link (tf/static_transform_publisher) encoder_vel (encoder_driver/Encoder_vel.py) imu_sonser_spec (serial_imu/serial_imu) lslidar_x10_driver_node (lslidar_x10_driver/lslidar_x10_driver_node) racecar_driver (racecar_driver/racecar_driver_node) rosbridge_server (rosbridge_server/rosbridge_websocket) auto-starting new master process[master]: started with pid [169] ROS_MASTER_URI=http://192.168.5.100:11311 setting /run_id to 593a31d0-cbc5-11f0-acbf-2c52afb5f6d1 process[rosout-1]: started with pid [179] started core service [/rosout] process[base_footprint2base_link-2]: started with pid [186] process[base_link2laser_link-3]: started with pid [187] process[base_link2imu-4]: started with pid [188] process[lslidar_x10_driver_node-5]: started with pid [193] process[imu_sonser_spec-6]: started with pid [199] process[encoder_vel-7]: started with pid [205] process[racecar_driver-8]: started with pid [211] process[rosbridge_server-9]: started with pid [217] [rosbridge_server-9] killing on exit [racecar_driver-8] killing on exit [encoder_vel-7] killing on exit [imu_sonser_spec-6] killing on exit [lslidar_x10_driver_node-5] killing on exit [base_footprint2base_link-2] killing on exit [base_link2imu-4] killing on exit [base_link2laser_link-3] killing on exit [rosout-1] killing on exit [master] killing on exit shutting down processing monitor... ... shutting down processing monitor complete done Run_car.launch 进程已终止。 amcl_nav.launch 进程已终止。 root@davinci-mini:/racecar# bash nav_one.sh 2025-11-27 19:16:56+0000 [-] Log opened. 2025-11-27 19:16:56+0000 [-] registered capabilities (classes): 2025-11-27 19:16:56+0000 [-] - <class 'rosbridge_library.capabilities.call_service.CallService'> 2025-11-27 19:16:56+0000 [-] - <class 'rosbridge_library.capabilities.advertise.Advertise'> 2025-11-27 19:16:56+0000 [-] - <class 'rosbridge_library.capabilities.publish.Publish'> 2025-11-27 19:16:56+0000 [-] - <class 'rosbridge_library.capabilities.subscribe.Subscribe'> 2025-11-27 19:16:56+0000 [-] - <class 'rosbridge_library.capabilities.defragmentation.Defragment'> 2025-11-27 19:16:56+0000 [-] - <class 'rosbridge_library.capabilities.advertise_service.AdvertiseService'> 2025-11-27 19:16:56+0000 [-] - <class 'rosbridge_library.capabilities.service_response.ServiceResponse'> 2025-11-27 19:16:56+0000 [-] - <class 'rosbridge_library.capabilities.unadvertise_service.UnadvertiseService'> 2025-11-27 19:16:57+0000 [-] WebSocketServerFactory starting on 9090 2025-11-27 19:16:57+0000 [-] Starting factory <autobahn.twisted.websocket.WebSocketServerFactory object at 0xe7ffc75d7c70> 2025-11-27 19:16:57+0000 [-] [INFO] [1764271017.157078]: Rosbridge WebSocket server started at ws://0.0.0.0:9090 ... logging to /root/.ros/log/a199425e-cbc5-11f0-86b4-2c52afb5f6d1/roslaunch-davinci-mini-476.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://192.168.5.100:43287/ SUMMARY ======== CLEAR PARAMETERS * /ekf_se/ PARAMETERS * /amcl/base_frame_id: base_footprint * /amcl/first_map_only: True * /amcl/global_frame_id: map * /amcl/gui_publish_rate: 30.0 * /amcl/initial_cov_aa: 0.2 * /amcl/initial_cov_xx: 0.25 * /amcl/initial_cov_yy: 0.25 * /amcl/initial_pose_a: 0.0 * /amcl/initial_pose_x: 0.0 * /amcl/initial_pose_y: 0.0 * /amcl/kld_err: 0.01 * /amcl/kld_z: 0.99 * /amcl/laser_lambda_short: 0.1 * /amcl/laser_likelihood_max_dist: 2.0 * /amcl/laser_max_beams: 30 * /amcl/laser_model_type: likelihood_field * /amcl/laser_sigma_hit: 0.2 * /amcl/laser_z_hit: 0.5 * /amcl/laser_z_max: 0.05 * /amcl/laser_z_rand: 0.5 * /amcl/laser_z_short: 0.05 * /amcl/max_particles: 5000 * /amcl/min_particles: 100 * /amcl/odom_alpha1: 0.2 * /amcl/odom_alpha2: 0.2 * /amcl/odom_alpha3: 0.8 * /amcl/odom_alpha4: 0.2 * /amcl/odom_frame_id: odom * /amcl/odom_model_type: diff * /amcl/recovery_alpha_fast: 0.1 * /amcl/recovery_alpha_slow: 0.0 * /amcl/resample_interval: 2 * /amcl/tf_broadcast: True * /amcl/transform_tolerance: 0.1 * /amcl/update_min_a: 0.1 * /amcl/update_min_d: 0.1 * /amcl/use_map_topic: True * /car_controller/Angle_gain_d: -4.0 * /car_controller/Angle_gain_p: -4.0 * /car_controller/Lfw: 1.5 * /car_controller/Person1: 666 * /car_controller/Person2: 580 * /car_controller/Stopcar: 52 * /car_controller/Stoplight: 43 * /car_controller/Vcmd: 1.5 * /car_controller/baseAngle: 65.0 * /car_controller/baseSpeed: 1670 * /car_controller/first_lap: 100 * /car_controller/goalRadius: 0.7 * /car_controller/second_lap: 510 * /car_controller/vp_max_base: 75 * /car_controller/vp_min: 60 * /ekf_se/base_link_frame: /base_footprint * /ekf_se/debug: False * /ekf_se/debug_out_file: /path/to/debug/fi... * /ekf_se/frequency: 20 * /ekf_se/imu0: /imu_data * /ekf_se/imu0_config: [False, False, Fa... * /ekf_se/imu0_differential: False * /ekf_se/imu0_linear_acceleration_rejection_threshold: 2 * /ekf_se/imu0_nodelay: False * /ekf_se/imu0_pose_rejection_threshold: 2.0 * /ekf_se/imu0_queue_size: 8 * /ekf_se/imu0_relative: True * /ekf_se/imu0_remove_gravitational_acceleration: True * /ekf_se/imu0_twist_rejection_threshold: 2.0 * /ekf_se/initial_estimate_covariance: ['1e-9', 0, 0, 0,... * /ekf_se/map_frame: /map * /ekf_se/odom0: /rf2o_laser_odome... * /ekf_se/odom0_config: [False, False, Fa... * /ekf_se/odom0_differential: True * /ekf_se/odom0_nodelay: True * /ekf_se/odom0_pose_rejection_threshold: 8 * /ekf_se/odom0_queue_size: 5 * /ekf_se/odom0_twist_rejection_threshold: 4 * /ekf_se/odom1: /encoder_imu_odom * /ekf_se/odom1_config: [True, True, Fals... * /ekf_se/odom1_differential: True * /ekf_se/odom1_nodelay: True * /ekf_se/odom1_queue_size: 5 * /ekf_se/odom1_relative: False * /ekf_se/odom_frame: /odom * /ekf_se/print_diagnostics: False * /ekf_se/process_noise_covariance: [0.25, 0, 0, 0, 0... * /ekf_se/publish_acceleration: True * /ekf_se/publish_tf: True * /ekf_se/sensor_timeout: 0.025 * /ekf_se/transform_time_offset: 0.0001 * /ekf_se/transform_timeout: 0.025 * /ekf_se/two_d_mode: True * /ekf_se/world_frame: /odom * /move_base/GlobalPlanner/allow_unknown: True * /move_base/GlobalPlanner/cost_factor: 0.54 * /move_base/GlobalPlanner/default_tolerance: 0.2 * /move_base/GlobalPlanner/lethal_cost: 253 * /move_base/GlobalPlanner/neutral_cost: 21 * /move_base/GlobalPlanner/old_navfn_behavior: False * /move_base/GlobalPlanner/orientation_mode: 0 * /move_base/GlobalPlanner/orientation_window_size: 1 * /move_base/GlobalPlanner/publish_potential: True * /move_base/GlobalPlanner/use_dijkstra: False * /move_base/GlobalPlanner/use_grid_path: True * /move_base/GlobalPlanner/use_quadratic: True * /move_base/GlobalPlanner/visualize_potential: False * /move_base/NavfnROS/allow_unknown: False * /move_base/TebLocalPlannerROS/acc_lim_theta: 60 * /move_base/TebLocalPlannerROS/acc_lim_x: 0.188 * /move_base/TebLocalPlannerROS/allow_init_with_backwards_motion: False * /move_base/TebLocalPlannerROS/cmd_angle_instead_rotvel: False * /move_base/TebLocalPlannerROS/complete_global_plan: True * /move_base/TebLocalPlannerROS/costmap_converter_plugin: * /move_base/TebLocalPlannerROS/costmap_converter_rate: 8 * /move_base/TebLocalPlannerROS/costmap_converter_spin_thread: True * /move_base/TebLocalPlannerROS/costmap_obstacles_behind_robot_dist: 0.1 * /move_base/TebLocalPlannerROS/delete_detours_backwards: True * /move_base/TebLocalPlannerROS/dt_hysteresis: 0.05 * /move_base/TebLocalPlannerROS/dt_ref: 0.21 * /move_base/TebLocalPlannerROS/dynamic_obstacle_inflation_dist: 0.1 * /move_base/TebLocalPlannerROS/enable_homotopy_class_planning: True * /move_base/TebLocalPlannerROS/enable_multithreading: False * /move_base/TebLocalPlannerROS/exact_arc_length: True * /move_base/TebLocalPlannerROS/feasibility_check_no_poses: 10 * /move_base/TebLocalPlannerROS/footprint_model: polygon * /move_base/TebLocalPlannerROS/free_goal_vel: True * /move_base/TebLocalPlannerROS/global_plan_overwrite_orientation: True * /move_base/TebLocalPlannerROS/global_plan_prune_distance: 1 * /move_base/TebLocalPlannerROS/global_plan_viapoint_sep: -1 * /move_base/TebLocalPlannerROS/h_signature_prescaler: 0.5 * /move_base/TebLocalPlannerROS/h_signature_threshold: 0.1 * /move_base/TebLocalPlannerROS/include_costmap_obstacles: True * /move_base/TebLocalPlannerROS/include_dynamic_obstacles: True * /move_base/TebLocalPlannerROS/inflation_dist: 0.62 * /move_base/TebLocalPlannerROS/max_global_plan_lookahead_dist: 4.0 * /move_base/TebLocalPlannerROS/max_number_classes: 5 * /move_base/TebLocalPlannerROS/max_ratio_detours_duration_best_duration: 3.0 * /move_base/TebLocalPlannerROS/max_samples: 500 * /move_base/TebLocalPlannerROS/max_vel_theta: 85 * /move_base/TebLocalPlannerROS/max_vel_x: 3 * /move_base/TebLocalPlannerROS/max_vel_x_backwards: 1.2 * /move_base/TebLocalPlannerROS/max_vel_y: 0.288 * /move_base/TebLocalPlannerROS/min_turning_radius: 0.01 * /move_base/TebLocalPlannerROS/no_inner_iterations: -1 * /move_base/TebLocalPlannerROS/no_outer_iterations: -1 * /move_base/TebLocalPlannerROS/obstacle_cost_exponent: -1 * /move_base/TebLocalPlannerROS/obstacle_heading_threshold: 0.45 * /move_base/TebLocalPlannerROS/obstacle_poses_affected: 20 * /move_base/TebLocalPlannerROS/odom_topic: odom * /move_base/TebLocalPlannerROS/optimization_activate: True * /move_base/TebLocalPlannerROS/optimization_verbose: False * /move_base/TebLocalPlannerROS/oscillation_filter_duration: 10 * /move_base/TebLocalPlannerROS/oscillation_omega_eps: 10 * /move_base/TebLocalPlannerROS/oscillation_recovery: False * /move_base/TebLocalPlannerROS/oscillation_recovery_min_duration: 20 * /move_base/TebLocalPlannerROS/oscillation_v_eps: 10 * /move_base/TebLocalPlannerROS/penalty_epsilon: 0.01 * /move_base/TebLocalPlannerROS/publish_feedback: False * /move_base/TebLocalPlannerROS/roadmap_graph_area_length_scale: 1.0 * /move_base/TebLocalPlannerROS/roadmap_graph_area_width: 5 * /move_base/TebLocalPlannerROS/roadmap_graph_no_samples: 15 * /move_base/TebLocalPlannerROS/selection_alternative_time_cost: False * /move_base/TebLocalPlannerROS/selection_cost_hysteresis: 1.0 * /move_base/TebLocalPlannerROS/selection_obst_cost_scale: 1.0 * /move_base/TebLocalPlannerROS/selection_prefer_initial_plan: 0.95 * /move_base/TebLocalPlannerROS/shrink_horizon_backup: True * /move_base/TebLocalPlannerROS/shrink_horizon_min_duration: 3 * /move_base/TebLocalPlannerROS/switching_blocking_period: 0.0 * /move_base/TebLocalPlannerROS/teb_autosize: True * /move_base/TebLocalPlannerROS/type: polygon * /move_base/TebLocalPlannerROS/vertices: [[-0.175, -0.25],... * /move_base/TebLocalPlannerROS/viapoints_all_candidates: True * /move_base/TebLocalPlannerROS/visualize_hc_graph: True * /move_base/TebLocalPlannerROS/visualize_with_time_as_z_axis_scale: False * /move_base/TebLocalPlannerROS/weight_acc_lim_theta: 10 * /move_base/TebLocalPlannerROS/weight_acc_lim_x: 1 * /move_base/TebLocalPlannerROS/weight_adapt_factor: 20 * /move_base/TebLocalPlannerROS/weight_dynamic_obstacle: 10 * /move_base/TebLocalPlannerROS/weight_dynamic_obstacle_inflation: 5 * /move_base/TebLocalPlannerROS/weight_inflation: 50 * /move_base/TebLocalPlannerROS/weight_kinematics_forward_drive: 1000 * /move_base/TebLocalPlannerROS/weight_kinematics_nh: 1000 * /move_base/TebLocalPlannerROS/weight_kinematics_turning_radius: 1000 * /move_base/TebLocalPlannerROS/weight_max_vel_theta: 10 * /move_base/TebLocalPlannerROS/weight_max_vel_x: 1 * /move_base/TebLocalPlannerROS/weight_obstacle: 50 * /move_base/TebLocalPlannerROS/weight_optimaltime: 1000 * /move_base/TebLocalPlannerROS/weight_shortest_path: 1 * /move_base/TebLocalPlannerROS/weight_viapoint: 1 * /move_base/TebLocalPlannerROS/wheelbase: 0.335 * /move_base/TebLocalPlannerROS/xy_goal_tolerance: 0.01 * /move_base/TebLocalPlannerROS/yaw_goal_tolerance: 0.03 * /move_base/base_global_planner: navfn/NavfnROS * /move_base/base_local_planner: teb_local_planner... * /move_base/clearing_rotation_allowed: False * /move_base/controller_frequency: 10.0 * /move_base/controller_patience: 6.0 * /move_base/global_costmap/footprint: [[-0.175, -0.25],... * /move_base/global_costmap/footprint_padding: 0.01 * /move_base/global_costmap/global_frame: map * /move_base/global_costmap/height: 25.0 * /move_base/global_costmap/inflation/cost_scaling_factor: 2.0 * /move_base/global_costmap/inflation/inflation_radius: 0. 1 * /move_base/global_costmap/plugins: [{'name': 'static... * /move_base/global_costmap/publish_frequency: 1.0 * /move_base/global_costmap/resolution: 0.05 * /move_base/global_costmap/robot_base_frame: base_footprint * /move_base/global_costmap/rolling_window: True * /move_base/global_costmap/sensor/laser_scan_sensor/clearing: True * /move_base/global_costmap/sensor/laser_scan_sensor/data_type: LaserScan * /move_base/global_costmap/sensor/laser_scan_sensor/marking: True * /move_base/global_costmap/sensor/laser_scan_sensor/observation_persistence: 0.5 * /move_base/global_costmap/sensor/laser_scan_sensor/sensor_frame: laser_link * /move_base/global_costmap/sensor/laser_scan_sensor/topic: scan * /move_base/global_costmap/sensor/observation_sources: laser_scan_sensor * /move_base/global_costmap/static/map_topic: /map * /move_base/global_costmap/static/subscribe_to_updates: True * /move_base/global_costmap/track_unknown_space: False * /move_base/global_costmap/transform_tolerance: 0.5 * /move_base/global_costmap/update_frequency: 1.0 * /move_base/global_costmap/width: 25.0 * /move_base/local_costmap/footprint: [[-0.175, -0.25],... * /move_base/local_costmap/footprint_padding: 0.01 * /move_base/local_costmap/global_frame: map * /move_base/local_costmap/height: 3.0 * /move_base/local_costmap/inflation/cost_scaling_factor: 6.0 * /move_base/local_costmap/inflation/inflation_radius: 0.1 * /move_base/local_costmap/plugins: [{'name': 'sensor... * /move_base/local_costmap/publish_frequency: 1.0 * /move_base/local_costmap/resolution: 0.05 * /move_base/local_costmap/robot_base_frame: base_footprint * /move_base/local_costmap/rolling_window: True * /move_base/local_costmap/sensor/laser_scan_sensor/clearing: True * /move_base/local_costmap/sensor/laser_scan_sensor/data_type: LaserScan * /move_base/local_costmap/sensor/laser_scan_sensor/marking: True * /move_base/local_costmap/sensor/laser_scan_sensor/sensor_frame: laser_link * /move_base/local_costmap/sensor/laser_scan_sensor/topic: scan * /move_base/local_costmap/sensor/observation_sources: laser_scan_sensor * /move_base/local_costmap/track_unknown_space: False * /move_base/local_costmap/transform_tolerance: 0.5 * /move_base/local_costmap/update_frequency: 1.0 * /move_base/local_costmap/width: 3.0 * /move_base/oscillation_distance: 0.2 * /move_base/oscillation_timeout: 10.0 * /move_base/planner_frequency: 10.0 * /move_base/planner_patience: 5.0 * /move_base/shutdown_costmaps: False * /rf2o_laser_odometry/base_frame_id: base_footprint * /rf2o_laser_odometry/freq: 20.0 * /rf2o_laser_odometry/laser_scan_topic: scan * /rf2o_laser_odometry/odom_frame_id: odom * /rf2o_laser_odometry/odom_topic: odom_rf2o * /rf2o_laser_odometry/publish_tf: False * /rf2o_laser_odometry/verbose: True * /rosdistro: noetic * /rosversion: 1.15.13 NODES / amcl (amcl/amcl) car_controller (racecar/car_controller_new) ekf_se (robot_localization/ekf_localization_node) map_server (map_server/map_server) move_base (move_base/move_base) rf2o_laser_odometry (rf2o_laser_odometry/rf2o_laser_odometry_node) wheel_odom (encoder_driver/encoder_driver_node1) ^C终止 ROS 启动进程... [ INFO] [1764271020.971795831]: ?????????????????????????????? [ INFO] [1764271020.886512045]: Subscribed to map topic. [ INFO] [1764271021.127392896]: Received a 608 X 384 map @ 0.050 m/pix [ INFO] [1764271021.158670011]: Initializing likelihood field model; this can take some time on large maps... [ INFO] [1764271021.265183670]: Done initializing likelihood field model. lslidar_x10_driver_node: /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:81: boost::condition_variable::~condition_variable(): Assertion `!posix::pthread_mutex_destroy(&internal_mutex)' failed. 2025-11-27 19:18:26+0000 [autobahn.twisted.websocket.WebSocketServerFactory] (TCP Port 9090 Closed) 2025-11-27 19:18:26+0000 [-] Stopping factory <autobahn.twisted.websocket.WebSocketServerFactory object at 0xe7ffc75d7c70> 2025-11-27 19:18:26+0000 [-] Main loop terminated. [DEBUG] [1764271016.495434]: init_node, name[/encoder_vel], pid[443] [DEBUG] [1764271016.503376]: binding to 0.0.0.0 0 [DEBUG] [1764271016.507268]: bound to 0.0.0.0 38955 [DEBUG] [1764271016.511287]: ... service URL is rosrpc://192.168.5.100:38955 [DEBUG] [1764271016.514807]: [/encoder_vel/get_loggers]: new Service instance [DEBUG] [1764271016.520463]: ... service URL is rosrpc://192.168.5.100:38955 [DEBUG] [1764271016.523488]: [/encoder_vel/set_logger_level]: new Service instance True ROS_MASTER_URI=http://192.168.5.100:11311 process[map_server-1]: started with pid [496] process[rf2o_laser_odometry-2]: started with pid [497] process[wheel_odom-3]: started with pid [498] process[ekf_se-4]: started with pid [499] process[amcl-5]: started with pid [513] process[move_base-6]: started with pid [522] process[car_controller-7]: started with pid [526] [car_controller-7] killing on exit [move_base-6] killing on exit [amcl-5] killing on exit [ekf_se-4] killing on exit [wheel_odom-3] killing on exit [rf2o_laser_odometry-2] killing on exit [map_server-1] killing on exit shutting down processing monitor... ... shutting down processing monitor complete done WARNING: ignoring defunct <master /> tag ... logging to /root/.ros/log/a199425e-cbc5-11f0-86b4-2c52afb5f6d1/roslaunch-davinci-mini-400.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://192.168.5.100:37043/ SUMMARY ======== PARAMETERS * /encoder_vel/baud_rate: 57600 * /encoder_vel/k: 0.88 * /encoder_vel/serial_port: /dev/encoder * /lslidar_x10_driver_node/angle_disable_max: 0.0 * /lslidar_x10_driver_node/angle_disable_min: 0.0 * /lslidar_x10_driver_node/child_frame_id: laser_link * /lslidar_x10_driver_node/interface_selection: serial * /lslidar_x10_driver_node/lidar_name: M10 * /lslidar_x10_driver_node/max_range: 100.0 * /lslidar_x10_driver_node/min_range: 0 * /lslidar_x10_driver_node/scan_topic: scan * /lslidar_x10_driver_node/serial_port: /dev/laser * /lslidar_x10_driver_node/use_gps_ts: False * /rosbridge_server/websocket_port: 9090 * /rosdistro: noetic * /rosversion: 1.15.13 NODES / base_footprint2base_link (tf/static_transform_publisher) base_link2imu (tf/static_transform_publisher) base_link2laser_link (tf/static_transform_publisher) encoder_vel (encoder_driver/Encoder_vel.py) imu_sonser_spec (serial_imu/serial_imu) lslidar_x10_driver_node (lslidar_x10_driver/lslidar_x10_driver_node) racecar_driver (racecar_driver/racecar_driver_node) rosbridge_server (rosbridge_server/rosbridge_websocket) auto-starting new master process[master]: started with pid [410] ROS_MASTER_URI=http://192.168.5.100:11311 setting /run_id to a199425e-cbc5-11f0-86b4-2c52afb5f6d1 process[rosout-1]: started with pid [420] started core service [/rosout] process[base_footprint2base_link-2]: started with pid [427] process[base_link2laser_link-3]: started with pid [428] process[base_link2imu-4]: started with pid [429] process[lslidar_x10_driver_node-5]: started with pid [434] process[imu_sonser_spec-6]: started with pid [440] process[encoder_vel-7]: started with pid [443] process[racecar_driver-8]: started with pid [449] process[rosbridge_server-9]: started with pid [459] [rosbridge_server-9] killing on exit [racecar_driver-8] killing on exit [encoder_vel-7] killing on exit [imu_sonser_spec-6] killing on exit [lslidar_x10_driver_node-5] killing on exit [base_link2imu-4] killing on exit [base_link2laser_link-3] killing on exit [base_footprint2base_link-2] killing on exit [rosout-1] killing on exit [master] killing on exit shutting down processing monitor... ... shutting down processing monitor complete done Run_car.launch 进程已终止。 amcl_nav.launch 进程已终止。 分析一下有啥问题吗
11-28
你提供的日志是基于 **ROS (Robot Operating System)** 的一个机器人导航系统在 **华为 Atlas 200I DK A2** 开发板上运行时的完整启动和终止过程。从你的操作来看,你多次执行了 `bash nav_one.sh` 脚本(可能是用于启动自动导航任务),但每次都被中断或异常退出。 下面我将详细分析整个流程中的问题、潜在原因以及优化建议。 --- ### ✅ 正常行为部分 1. **环境初始化正常** - 系统为 Ubuntu 22.04 + ROS Noetic(尽管 Noetic 官方主要支持 x86/x64,但在 ARM 架构如 aarch64 上通过源码编译也可运行)。 - 使用的是 `davinci-mini` 设备,搭载激光雷达(lslidar_x10)、编码器、IMU 等传感器。 - 启动了必要的 TF 变换节点(`base_footprint2base_link`, `base_link2laser_link` 等),说明坐标系设置基本正确。 2. **地图加载成功** ```log [ INFO] [1764270901.452807176]: Received a 608 X 384 map @ 0.050 m/pix ``` 表明 `map_server` 成功加载了一张分辨率为 608×384、粒度为 5cm 的静态地图。 3. **AMCL 和 move_base 初始化完成** - AMCL(自适应蒙特卡洛定位)已订阅 `/map` 主题,初始化了 likelihood field 模型: ```log [ INFO] [1764270901.599203612]: Done initializing likelihood field model. ``` - move_base 已加载全局规划器(GlobalPlanner)和局部规划器(TebLocalPlannerROS),参数配置合理,适合差速驱动小车。 4. **EKF 融合定位启用** - `ekf_se` 节点融合了以下信息: - IMU 数据 (`/imu_data`) - 激光里程计 (`/rf2o_laser_odometry`) - 编码器里程计 (`/encoder_imu_odom`) - 这是一个典型的多传感器融合方案,提升定位精度。 --- ## ❌ 存在的问题与错误分析 ### 🔴 1. **频繁 Ctrl+C 中断导致进程非正常退出** 你在终端中反复按了 `^C`(Ctrl+C),导致: ```log ^C终止 ROS 启动进程... [car_controller-7] killing on exit [move_base-6] killing on exit ... shutting down processing monitor... ... shutting down processing monitor complete done ``` > **问题:这不是程序崩溃,而是人为强制终止。** #### ⚠️ 影响: - 所有 ROS 节点被 SIGINT 信号杀死。 - 若没有优雅关闭机制,可能导致资源未释放(例如串口锁死、共享内存残留等)。 - 多次快速重启可能造成 `run_id` 不一致问题(见下一点)。 --- ### 🔴 2. **Run ID 冲突警告(严重性中等)** 首次启动时报错: ```log RLException: run_id on parameter server does not match declared run_id: 1a54deac-cbc5-11f0-9652-2c52afb5f6d1 vs 1ba06f92-cbc5-11f0-be3e-2c52afb5f6d1 ``` 这是由于 `.ros` 目录下保留了旧的 `run_id` 参数,而新的 roslaunch 尝试使用不同的 UUID 引起的冲突。 #### ✅ 解决方法: 清理旧状态: ```bash rm -rf ~/.ros/log/* rosparam delete /run_id ``` 或者直接重启 `roscore` 或整个设备以清空状态。 --- ### 🔴 3. **Boost 条件变量析构断言失败(关键 Bug)** ```log lslidar_x10_driver_node: /usr/include/boost/thread/pthread/condition_variable_fwd.hpp:81: boost::condition_variable::~condition_variable(): Assertion `!posix::pthread_mutex_destroy(&internal_mutex)' failed. ``` 这是一个典型的 **线程资源竞争/析构顺序错误** 导致的 C++ 崩溃。 #### 📌 原因分析: - `lslidar_x10_driver_node` 是激光雷达驱动节点,在收到 SIGINT 后尝试退出。 - 但它内部使用的 Boost 线程库中,某个 `condition_variable` 在互斥锁仍被占用的情况下被析构。 - 很可能是: - 驱动线程未正确 join; - 或者主线程过早退出,子线程仍在访问共享资源; - 或驱动代码存在 bug(尤其是在 ARM 平台交叉编译时兼容性问题)。 #### ✅ 解决建议: 1. **升级或修复 lslidar 驱动** - 查看是否使用最新版驱动:[GitHub - LiSLIDAR/Livox-SDK](https://github.com/Livox-SDK) - 或改用更稳定的替代品,比如 `rplidar`, `ydlidar` 等开源驱动。 2. **添加延迟退出机制** 在 `nav_one.sh` 中,在 kill 前加个延时: ```bash trap 'echo "Shutting down..."; sleep 2; kill $(rosnode list | grep -v "/rosout" | xargs); sleep 1' INT TERM ``` 3. **避免频繁重启** - 改成调试模式运行关键节点,而不是每次都 `bash nav_one.sh`。 --- ### 🔴 4. **Encoder 和 Driver 节点频繁重启失败** 观察到如下现象: ```log process[encoder_vel-7]: started with pid [87] ... True ``` 只有一个 `True` 输出,且无后续日志 → 表示该节点可能立即退出或阻塞。 检查 `/dev/encoder` 是否存在: ```bash ls /dev/encoder ``` 如果不存在,则会报错无法打开串口。 #### ✅ 检查项: - 是否正确连接编码器硬件? - 波特率是否匹配?当前设为 `57600` - 是否有权限读取 `/dev/encoder`? ```bash ls -l /dev/encoder # 应类似 crw-rw---- 1 root dialout ``` 若无权限,加入用户组: ```bash usermod -aG dialout root ``` --- ### 🔴 5. **Failed to meet update rate 警告** ```log [ WARN] [1764270791.133628]: Failed to meet update rate! Took 0.102008542 s ``` 表示某节点期望 10Hz 更新,但实际耗时超过 100ms。 常见于: - CPU 占用过高(Atlas 200I DK A2 性能有限) - 频繁打印 debug 日志 - TF 查询延迟 #### ✅ 优化建议: - 降低 `controller_frequency` 和 `planner_frequency` 至 `5 Hz` - 关闭不必要的可视化输出(RViz 中 Topic 减少) - 使用 `top` 查看 CPU 使用情况: ```bash top -H -p $(pgrep -f "python|ros") ``` --- ### 🔴 6. **两个 launch 文件交替启动又终止** 日志末尾显示: ``` Run_car.launch 进程已终止。 amcl_nav.launch 进程已终止。 ``` 说明 `nav_one.sh` 实际上可能做了两件事: 1. 先启动 `Run_car.launch`(底层控制) 2. 再启动 `amcl_nav.launch`(导航) 但由于脚本逻辑不清或异常退出,两者都挂掉了。 #### ✅ 建议做法: 拆分测试: ```bash # 先单独测试底层驱动 roslaunch Run_car.launch # 再测试导航 roslaunch amcl_nav.launch map_file:=your_map.yaml ``` 确保每层稳定后再联合调试。 --- ## ✅ 推荐解决方案汇 | 问题 | 解法 | |------|------| | `run_id` 冲突 | 删除 `~/.ros/log` 和 `/run_id` 参数 | | Boost 断言崩溃 | 更新 `lslidar` 驱动或软重启设备 | | 编码器打不开 | 检查 `/dev/encoder` 是否存在及权限 | | 更新频率不达标 | 降低频率至 5Hz,减少日志输出 | | 节点频繁退出 | 分步启动调试,不要反复 Ctrl+C | --- ## 💡 建议增强稳定性措施 ### ✅ 修改 `nav_one.sh` 示例(增加容错): ```bash #!/bin/bash # 清理旧参数 rosparam delete /run_id > /dev/null 2>&1 || true # 设置工作空间 source /racecar/devel_isolated/setup.bash # 启动主控节点(分离模式) echo "Starting sensor and driver nodes..." roslaunch /racecar/Run_car.launch & LAUNCH_PID=$! # 等待关键主题出现 sleep 3 while ! rostopic list | grep -q "/scan"; do echo "Waiting for /scan topic..." sleep 1 done echo "Starting navigation stack..." roslaunch /racecar/amcl_nav.launch & # 捕获中断信号 trap "kill $LAUNCH_PID; wait $LAUNCH_PID; exit" INT TERM wait ``` --- ##
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值