ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
It's a C++ error.
In your Controller.h
header, you declare controller_topic_
. However, in your constructor in Controller.cpp
, you declare and instantiate controller_topic_
again within the constructor scope. Anything outside the constructor can't see it.
It should work once you replace
Controller::Controller()
{
/* topics name */
std::string control_topic_name_ ="/cmd_vel";
std::string takeof_topic_name_ ="/ardrone/takeoff";
std::string land_topic_name_ = "/ardrone/land";
/* Initalisation of publishers */
ros::Publisher controller_topic_ = n_.advertise<geometry_msgs::Twist>(control_topic_name_,10);
ros::Publisher takeoff_topic_ = n_.advertise<std_msgs::Empty>("/ardrone/takeoff",10);
ros::Publisher land_topic_ = n_.advertise<std_msgs::Empty>(land_topic_name_,10);
}
with
Controller::Controller()
{
/* topics name */
this->control_topic_name_ ="/cmd_vel";
this->takeof_topic_name_ ="/ardrone/takeoff";
this->land_topic_name_ = "/ardrone/land";
/* Initalisation of publishers */
this->controller_topic_ = n_.advertise<geometry_msgs::Twist>(control_topic_name_,10);
this->takeoff_topic_ = n_.advertise<std_msgs::Empty>("/ardrone/takeoff",10);
this->land_topic_ = n_.advertise<std_msgs::Empty>(land_topic_name_,10);
}
Note - Do the same for the other constructor as well.
2 | No.2 Revision |
It's a C++ error.
In your Controller.h
header, you declare controller_topic_
. However, in your constructor in Controller.cpp
, you declare and instantiate controller_topic_
again within the constructor scope. Anything Anywhere outside the constructor can't see it.
It should work once you replace
Controller::Controller()
{
/* topics name */
std::string control_topic_name_ ="/cmd_vel";
std::string takeof_topic_name_ ="/ardrone/takeoff";
std::string land_topic_name_ = "/ardrone/land";
/* Initalisation of publishers */
ros::Publisher controller_topic_ = n_.advertise<geometry_msgs::Twist>(control_topic_name_,10);
ros::Publisher takeoff_topic_ = n_.advertise<std_msgs::Empty>("/ardrone/takeoff",10);
ros::Publisher land_topic_ = n_.advertise<std_msgs::Empty>(land_topic_name_,10);
}
with
Controller::Controller()
{
/* topics name */
this->control_topic_name_ ="/cmd_vel";
this->takeof_topic_name_ ="/ardrone/takeoff";
this->land_topic_name_ = "/ardrone/land";
/* Initalisation of publishers */
this->controller_topic_ = n_.advertise<geometry_msgs::Twist>(control_topic_name_,10);
this->takeoff_topic_ = n_.advertise<std_msgs::Empty>("/ardrone/takeoff",10);
this->land_topic_ = n_.advertise<std_msgs::Empty>(land_topic_name_,10);
}
Note - Do the same for the other constructor as well.