ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Multiple SimpleActionServer member variables

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

mikkola gravatar image

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

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
{
public:
    RobotAI(std::string name);
    ~RobotAI(void);
    void executeInspectAreaCB(const robot_ai::InspectAreaGoalConstPtr &goal);

private:
    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
2

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

BennyRe gravatar image

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

Yes.

edit flag offensive delete link more

Comments

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 image mikkola  ( 2015-11-19 00:34:22 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-18 00:55:46 -0500

Seen: 359 times

Last updated: Nov 18 '15