ROS basic 5 days (C++) action_custom_msg

Hello,

I am having some problem compiling my file. My custom message compiled well but when I include my .cpp file, this error occured.

this is my code for action_custom_msg.cpp

#include <ros/ros.h>
#include <actionlib/server/simple_action_server.h>
#include <std_msgs/Empty.h>
#include <actions_quiz/CustomActionMsgAction.h>

class ActionClass {
protected:

ros::NodeHandle nh_;
actionlib::SimpleActionServer<actions_quiz::CustomActionMsgAction> as_;
std::string action_name_;
actions_quiz::CustomActionMsgActionFeedback feedback_;
actions_quiz::CustomActionMsgActionResult result_;

bool success_;
std::string TakeoffLand_;

ros::Publisher takeoff_pub_;
std_msgs::Empty takeoff_msg_;
ros::Publisher land_pub_;
std_msgs::Empty land_msg_;

public:

ActionClass(std::string name) :
as_(nh_, name, boost::bind(&ActionClass::executeCB, this, 1), false),
action_name
(name)
{
as_.start();
success_ = true;
takeoff_pub_ = nh_.advertise<std_msgs::Empty>("/drone/takeoff", 1000);
land_pub_ = nh_.advertise<std_msgs::Empty>("/drone/land", 1000);
}

~ActionClass(void) {}

void executeCB(const actions_quiz::CustomActionMsgActionConstPtr &goal)
{

// Takeoff the drone
this->takeoff_drone();

// start executing the action
for(int i=0; i<4; i++)
{
  // check that preempt has not been requested by the client
  if (as_.isPreemptRequested() || !ros::ok())
  {
    ROS_INFO("%s: Preempted", action_name_.c_str());
    // set the action state to preempted
    as_.setPreempted();
    success_ = false;
    break;
  } 
        
//   feedback_.feedback = i;
  // publish the feedback
//   as_.publishFeedback(feedback_);
  // this sleep is not necessary, the sequence is computed at 1 Hz for demonstration purposes
//   rate_->sleep();
}

if(success_)
{
//   result_.result = (sideSeconds_*4) + (turnSeconds_*4);
//   ROS_INFO("The total seconds it took the drone to perform the square was %i seconds", result_.result);
  ROS_INFO("%s: Succeeded", action_name_.c_str());
  // set the action state to succeeded
//   as_.setSucceeded(result_);
  // Stop and land drone
  this->land_drone();
}

}

void takeoff_drone(void)
{
ROS_INFO(“Taking Off Drone…”);
int i = 0;
while (i < 4)
{
takeoff_pub_.publish(takeoff_msg_);
i++;
// rate_->sleep();
}
}

void land_drone(void)
{
ROS_INFO(“Landing Drone…”);
int i = 0;
while (i < 4)
{
land_pub_.publish(land_msg_);
i++;
// rate_->sleep();
}
}

};

int main(int argc, char** argv)
{
ros::init(argc, argv, “action_custom_msg”);

ActionClass move_square(“action_custom_msg_as”);
ros::spin();

return 0;
}

Hi, welcome to the community!

You first need to make sure that the error is coming from the file you are looking at. One way to check is compiling without it.

Could you please post your code in the correct formatting? it is very hard to spot any obvious errors now.