微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

KLR 2 Baru.exe 中 0x00007FF610DE1904 处未处理的异常:0xC0000005:访问冲突读取位置 0x000000BE306C4F20

如何解决KLR 2 Baru.exe 中 0x00007FF610DE1904 处未处理的异常:0xC0000005:访问冲突读取位置 0x000000BE306C4F20

我写了以下代码如何使用箭头键盘按下移动机械臂。但是,当我按下箭头键盘时,在 KLR 2 Baru.exe 中的 0x00007FF610DE1904 处发生了错误未处理异常:0xC0000005:访问冲突读取位置 0x000000BE306C4F20。 这是我的代码

//  Printing array elements
    int i,k = 0;
    cout << "Start controlling,if you want to stop,please enter ESC" << endl;
            while (button != ESC_ASCII_VALUE)
            {
                button = getch();

                if (button == ARROW_UP && k<8)
                {
                    cout << "Naik" << endl;
                    k < 8;
                    k = k + 1;
                    for (int s = 0; s < 4; ++s)
                    {
                        dxl_goal_position = numbers[i][k][s];
                        // Write goal position
                        dxl_comm_result = packetHandler->write2ByteTxRx(portHandler,servo_id[s],ADDR_MX_GOAL_POSITION,dxl_goal_position,&dxl_error);
                        if (dxl_comm_result != COMM_SUCCESS)
                        {
                            printf("%s\n",packetHandler->getTxRxResult(dxl_comm_result));
                        }
                        else if (dxl_error != 0)
                        {
                            printf("%s\n",packetHandler->getRxPacketError(dxl_error));
                        }
                        cout << "Servo ID: " << servo_id[s] << " & " << "Present Position: " << dxl_goal_position << endl;
                       
                    }
                }
                else if (button == ARROW_DOWN && k<8)
                {
                    cout << "Turun" << endl;
                    k < 8;
                    k = k - 1;
                    for (int s = 0; s < 4; ++s)
                    {
                        dxl_goal_position = numbers[i][k][s];
                        // Write goal position
                        dxl_comm_result = packetHandler->write2ByteTxRx(portHandler,packetHandler->getRxPacketError(dxl_error));
                        cout << "Servo ID: " << servo_id[s] << " & " << "Present Position: " << dxl_goal_position << endl;
                    }
                        }
                }
                else if (button == ARROW_LEFT && i < 8)
                {
                    cout << "Belok kiri" << endl;
                    i < 8;
                    i = i - 1;
                    for (int s = 0; s < 4; ++s)
                    {
                        dxl_goal_position = numbers[i][k][s];
                        // Write goal position
                        dxl_comm_result = packetHandler->write2ByteTxRx(portHandler,packetHandler->getRxPacketError(dxl_error));
                        }
                        cout << "Servo ID: " << servo_id[s] << " & " << "Present Position: " << dxl_goal_position << endl;
                    }
                }
                else if (button == ARROW_RIGHT && i < 8)
                {
                    cout << "Belok kanan" << endl;
                    i < 8;
                    i = i + 1;
                    for (int s = 0; s < 4; ++s)
                    {
                        dxl_goal_position = numbers[i][k][s];
                        // Write goal position
                        dxl_comm_result = packetHandler->write2ByteTxRx(portHandler,packetHandler->getRxPacketError(dxl_error));
                        }
                        cout << "Servo ID: " << servo_id[s] << " & " << "Present Position: " << dxl_goal_position << endl;
                    }
                }
                else if (button == ESC_ASCII_VALUE)
                    break;
            }

This is the error I encountered

我需要解决方案。我仍然是这个 C++ 的初学者。谢谢

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。