ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Giving high-level control programatically on tum_simulator

asked 2014-08-25 14:17:42 -0600

alfa_80 gravatar image

updated 2014-08-25 14:19:07 -0600

I am confused how I can give high-level control like take off, landing etc programatically on tum_simulator. Via terminal of course, I can do something like (taken from the link provided):

Take off:
rostopic pub -1 /ardrone/takeoff std_msgs/Empty

Fly forward:
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist  '{linear:  {x: 1.0, y: 0.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'

Can anybody give me a hint or better still directly give a C++ snippet for take off and fly forward for me to easily grasp it.

Thanks in advance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-08-25 15:21:51 -0600

bvbdort gravatar image

Here is snippet for publish for "Fly forward", create a node for publishing messages.

ros::Rate loop_rate(10); // publishing frequency
while (ros::ok())

    //define publisher with topicname "/cmd_vel"
    ros::Publisher cmd_vel_pub;
    cmd_vel_pub = nh_.advertise<geometry_msgs::Twist>("/cmd_vel", 1); 
    //declare message of geometry_msgs::Twist type
    geometry_msgs::Twist cmd_vel;    
    //populate message
    cmd_vel.linear.x = 1.0;
    cmd_vel.linear.y = 0.0;
    cmd_vel.linear.z = 0.0;
    cmd_vel.angular.x = 0.0;
    cmd_vel.angular.y = 0.0;
    cmd_vel.angular.z = 0.0;    
    //publish message

    ros::spinOnce(); // not required if you dont have callbacks

edit flag offensive delete link more


@bvbdort:thanks, this is awesome :-)

alfa_80 gravatar image alfa_80  ( 2014-08-26 02:41:19 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-08-25 14:17:42 -0600

Seen: 203 times

Last updated: Aug 25 '14