Comments (7)
That's odd. Is that all your code? Is there any particular reason that you are not using a ROS loop?
from ardrone_autonomy.
Here's the main method:
ros::init(argc, argv, <nodename>);
ros::NodeHandle n;
ros::Rate loop_rate(10);
ros::Duration(1.0).sleep();
ros::Publisher launch = n.advertise<std_msgs::Empty>("ardrone/takeoff", 5);
ros::Publisher land = n.advertise<std_msgs::Empty>("ardrone/land", 5);
ros::Publisher reset = n.advertise<std_msgs::Empty>("ardrone/reset", 5);
ros::Publisher twist = n.advertise<geometry_msgs::Twist>("cmd_vel", 10);
ros::ServiceClient camchannel = n.serviceClient<ardrone_autonomy::CamSelect("ardrone/setcamchannel");
if(ros::ok()) {
ardrone_autonomy::CamSelect camsrv;
camsrv.request.channel = 1;
camchannel.call(camsrv)
launch.publish(at.empty_msg)
}
while(ros::ok()) {
ros::spinOnce()
loop_rate.sleep()
}
There's also a subscriber and a callback happening that I've left out: the problem existed before and after the subscriber was added. However, I have noticed that the seemingly extraneous ros::Duration(1.0).sleep()
statement is actually in the wrong place: it's meant to be after the initialization of the publishers, etc. This was adapted from code with the sleep statement in the "correct" place, that did not have this problem.
I'll check when I have access to the drone and report back tomorrow.
from ardrone_autonomy.
Where do you define the empty message? Also, I've found that sending the message for a small period of time gets past that problem. Example code here. Although you can use a much shorter time period as you see fit or watch the state of the robot to know when you can stop sending the takeoff message (much better)
from ardrone_autonomy.
Moving the sleep statement to in between the publisher initialization and the first message did the trick for me. However, I'll rewrite to check the state of the drone: that seems much more reliable.
Thanks for the help.
from ardrone_autonomy.
Also we can use getNumSubscribers() method, like this:
int main(int argc, char **argv) {
...
ros::Publisher takeoff_topic = nh.advertise<std_msgs::Empty>("ardrone/takeoff");
while (takeoff_topic.getNumSubscribers() == 0) {
sleep(1); //sleep a bit
}
takeoff_topic.publish(std_msgs::Empty()); //now we're ready to go
from ardrone_autonomy.
I am getting following error :
‘Empty’ is not a member of ‘std_msgs’
ros::Publisher launch = nh.advertise<std_msgs::Empty>("/ardrone/takeoff", 5);
any help please !
from ardrone_autonomy.
You should include #include <std_msgs/Empty.h> in your header file
from ardrone_autonomy.
Related Issues (20)
- Take back to the Initial State of Drones
- catkin_make ardrone_autonomy fail HOT 1
- cannot run ardrone_driver on indigo or kinetic
- catkin_make error in ubuntu mate 16.04 on raspberry pi 3 HOT 1
- Invoking "make -j4 -l4" failed on ROS Kinetic HOT 4
- camera resolution
- The video playback window freeze when control from xbox360 joystick
- IMU Raw Data
- Installing ardrone_autonaomy and tum simulator on Kinetic HOT 4
- ParameterGenerator
- ultrasound_freq is not set in data/config.ini if its 8
- Not able t build the package ! HOT 3
- Accuracy of Navdata and controlling the drone through velocity command. HOT 6
- How to plot the trajectory of the ardrone_autonomy in rviz?
- How to get linear acceleration in bebop autonomy?
- Cant install ardrone_autonomy HOT 1
- AR 2.0 not taking off after publishing empty message to /ardrone/takeoff
- no changes of vx of Navdata shows -0.0 HOT 1
- Battery (percentage) resets every time the drone takes off after landing
- min on other places of the library refers to macro-defined "min" on ardronelib
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ardrone_autonomy.