Ask Your Question

Multiple SimpleActionServer member variables

asked 2015-11-18 00:55:46 -0600

mikkola gravatar image

updated 2015-11-18 05:35:45 -0600

I am building a AI module for a robot. The module will provide two actions, so I've been learning about actionlib through the tutorials.

I implemented the first tutorial and got it working nicely in my application.

My current approach for one action is roughly as follows. The action server is started in the class constructor.

class RobotAI
    RobotAI(std::string name);
    void executeInspectAreaCB(const robot_ai::InspectAreaGoalConstPtr &goal);

    ros::NodeHandle nh_;

    // Action servers and messages that are used to published feedback/result
    actionlib::SimpleActionServer<robot_ai::InspectAreaAction> inspect_as_; 
    std::string inspect_action_name_;
    robot_ai::InspectAreaFeedback inspect_feedback_;
    robot_ai::InspectAreaResult inspect_result_;

However, now that I'm implementing two actions and I would like to manage them within a single robot AI class, I was wondering what would be the best way of achieving this? Should I just add another SimpleActionServer to my current class to handle the other action? Or should I make a class as implemented in the first tutorial for both actions and include them as member variables for my AI class?

I am using ROS Indigo on Ubuntu 14.04.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-11-18 10:00:01 -0600

BennyRe gravatar image

Should I just add another SimpleActionServer to my current class to handle the other action?


edit flag offensive delete link more


Well, after scratching my head for a while before realising the two servers can't have the same name (d'oh), this works great! Thank you very much.

mikkola gravatar imagemikkola ( 2015-11-19 00:34:22 -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: 2015-11-18 00:55:46 -0600

Seen: 123 times

Last updated: Nov 18 '15