NodeOptions from launch file to main

asked 2020-01-29 14:24:34 -0500

mhubii gravatar image

updated 2020-01-29 14:26:34 -0500

Hi guys,

say we have a launch file

def generate_launch_description():

    return LaunchDescription([
        Node(
            package='package',
            node_executable='node',
            arguments=['just a string'])])

and we want to pass the arguments to node_executable

class MyNode : public Node
{
    MyNode() : Node("node", rclcpp::NodeOptions()) {
        this->get_node_options().arguments() // how do we pass these arguments from the 
                                             // launch file to the node here?
    };
}
int main(int argc, char** argv) {
    rclcpp::init(argc, argv);
    rclcpp::spin(std::make_shared<MyNode>());
    rclcpp::shutdown();
}

I think it is possible with components RCLCPP_COMPONENTS_REGISTER_NODE, but I have to have a main.

Best Martin

edit retag flag offensive close merge delete