为什么每次上传航点后都睡一秒钟?

时间:2018-09-19 07:54:18

标签: ros dji-sdk

我正在使用DJI Onboard-SDK-ROS和DJI矩阵M600。当我上传航点任务时,我必须等待很长时间才能完成上传(每个航点精确地为1秒)。问题出在方法dji_sdk_node_mission_services.cpp中的missionWpUploadCallback中。

这里:

for (auto waypoint : request.waypoint_task.mission_waypoint) {
        wpData.latitude = waypoint.latitude * C_PI / 180;
        wpData.longitude = waypoint.longitude * C_PI / 180;
        wpData.altitude = waypoint.altitude;
        wpData.damping = waypoint.damping_distance;
        wpData.yaw = waypoint.target_yaw;
        wpData.gimbalPitch = waypoint.target_gimbal_pitch;
        wpData.turnMode = waypoint.turn_mode;
        wpData.hasAction = waypoint.has_action;
        wpData.actionTimeLimit = waypoint.action_time_limit;
        wpData.actionNumber = 15;
        wpData.actionRepeat = waypoint.waypoint_action.action_repeat;
        wpData.index = i;
        std::copy(waypoint.waypoint_action.command_list.begin(),
                  waypoint.waypoint_action.command_list.end(), wpData.commandList);
        std::copy(waypoint.waypoint_action.command_parameter.begin(),
                  waypoint.waypoint_action.command_parameter.end(),
                  wpData.commandParameter);

        uploadAck = vehicle->missionManager->wpMission->uploadIndexData(
                &wpData, WAIT_TIMEOUT);

        ROS_DEBUG("uploaded waypoint lat: %f lon: %f alt: %f", waypoint.latitude,
                  waypoint.longitude, waypoint.altitude);

        response.cmd_set = (int) uploadAck.ack.info.cmd_set;
        response.cmd_id = (int) uploadAck.ack.info.cmd_id;
        response.ack_data = (unsigned int) uploadAck.ack.data;

        if (ACK::getError(uploadAck.ack)) {
            ACK::getErrorCodeMessage(uploadAck.ack, __func__);
            response.result = false;
        } else {
            response.result = true;
        }

        ROS_INFO("uploaded the %dth waypoint\n", (wpData.index + 1));
        i += 1;
        sleep(1);
    }

在周期结束时我评论了sleep(1)命令时,任务仍被上传并执行(至少在仿真中如此)。

所以我的问题是sleep(1)命令背后的原因是什么,有必要吗?

我见过关于同一件事here的问题,但正如我上面说的,即使没有睡觉,任务上传也没有问题。

0 个答案:

没有答案