Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in the code #77

Open
ahkhan03 opened this issue Feb 15, 2016 · 1 comment
Open

Problem in the code #77

ahkhan03 opened this issue Feb 15, 2016 · 1 comment

Comments

@ahkhan03
Copy link

I have written code to issue the command to /tum_ardrone/com topic will running drone_autopilot and drone_stateestimation. I have written followings simple code which just take off and land the drone. When I echoed /tum_ardrone/com while issuing commands through GUI, I found same string commands as given below in the code.

std_msgs::String cpp2ros(std::string in) {
    std_msgs::String out;
    out.data = in;
    return out;
}

int main(int argc, char **argv)
{
    ros::init(argc, argv, "tumdrone");

    ros::NodeHandle tumdrone;

    cv::Mat image = cv::imread("/home/ameerhamzakhan/image.jpg");
    cv::imshow("Image", image);

    ros::Publisher pubCommand = tumdrone.advertise<std_msgs::String>("/tum_ardrone/com", 100);

    char commandKey = 0;

    while(ros::ok()) {
        if(commandKey == 'q') {
            pubCommand.publish(cpp2ros("u l Autopilot: Cleared Command Queue"));

            pubCommand.publish(cpp2ros("u l Autopilot: Start Controlling"));

            pubCommand.publish(cpp2ros("c clearCommands"));

            pubCommand.publish(cpp2ros("c takeoff"));

            pubCommand.publish(cpp2ros("c land"));
        }

        commandKey = cv::waitKey(1);
    }

    return 0;
}

Here I am using openCV image just to monitor 'q' key presses because I find it convenient this way, and it has nothing to do with the rest of code.

@ahkhan03
Copy link
Author

Btw I have found the solution. I forget to issue the following command:

pubCommand.publish(cpp2ros("c start"));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant