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

Revision history [back]

click to hide/show revision 1
initial version

There are three ways to run a nodelet:

  1. Run the nodelet standalone using roslaunch:

    <launch>
        <node name="my_nodelet" pkg="nodelet" type="nodelet" args="standalone tegra_stereo/TegraStereoProc" />
    </launch>
    

    or rosrun:

    rosrun nodelet nodelet standalone tegra_stereo/TegraStereoProc
    
  2. Run the nodelet as part of a nodelet manager. This is described on the ROS wiki here: http://wiki.ros.org/nodelet/Tutorials/Running%20a%20nodelet

  3. Write a node wrapper, and then build and run it as you would a node. Here's what node wrapper code typically looks like:

    #include <ros/ros.h>
    #include <nodelet/loader.h>
    
    int main(int argc, char **argv){
      ros::init(argc, argv, "tegra_stereo_node");
    
      nodelet::Loader nodelet;
      nodelet::M_string remap(ros::names::getRemappings());
      nodelet::V_string nargv;
      std::string nodelet_name = ros::this_node::getName();
      nodelet.load(nodelet_name, "tegra_stereo/TegraStereoProc", remap, nargv);
      ros::spin();
    
      return 0;
    }
    

If any of these methods fail with an error message that pluginlib can't find your nodelet, make sure that you defined your nodelet in an XML file and exported it in your package.xml. Instructions to do so are on the ROS wiki here: http://wiki.ros.org/nodelet/Tutorials/Porting%20nodes%20to%20nodelets

Bonus Methods

If you're willing to install another package, Southwest Research Institute created swri_nodelet to make some of these tasks easier.

  1. Run the nodelet standalone using roslaunch:

    <launch>
        <node name="my_nodelet" pkg="swri_nodelet" type="nodelet" args="tegra_stereo/TegraStereoProc standalone" />
    </launch>
    

    or rosrun:

    rosrun swri_nodelet nodelet  tegra_stereo/TegraStereoProc standalone
    
  2. Run the nodelet with a nodelet manager using roslaunch:

    <launch>
      <node name="manager" pkg="nodelet" type="nodelet" args="manager" />
      <node name="my_nodelet" pkg="swri_nodelet" type="nodelet" args="tegra_stereo/TegraStereoProc my_manager"/>
    </launch>
    

    (Note that this syntax makes it easy to switch launch files back and forth between manager and standalone using args.)

  3. Automatically create a node wrapper with your node using swri_nodelet. This takes a couple of steps but saves you from writing boilerplate C++. Also, because it links the nodelet with the executable at compile time, you catch linker errors at compile time, instead of dealing with inscrutable runtime errors. Here's how to do it:

C++:

   #include <swri_nodelet/class_list_macros.h>
   SWRI_NODELET_EXPORT_CLASS(tegra_stereo TegraStereoProc)

Cmake:

   # (Add swri_nodelet to your find_package(catkin)

   add_library(my_nodelet_library src/TegraStereoProc.cpp)
   target_link_libraries(my_nodelet_library ${CATKIN_LIBRARIES})

   swri_nodelet_add_node(tegra_stereo_proc tegra_stereo TegraStereoProc)
   target_link_libraries(tegra_stereo_proc my_nodelet_library)

There are three ways to run a nodelet:

  1. Run the nodelet standalone using roslaunch:

    <launch>
        <node name="my_nodelet" pkg="nodelet" type="nodelet" args="standalone tegra_stereo/TegraStereoProc" />
    </launch>
    

    or rosrun:

    rosrun nodelet nodelet standalone tegra_stereo/TegraStereoProc
    
  2. Run the nodelet as part of a nodelet manager. This is described on the ROS wiki here: http://wiki.ros.org/nodelet/Tutorials/Running%20a%20nodelet

  3. Write a node wrapper, and then build and run it as you would a node. Here's what node wrapper code typically looks like:

    #include <ros/ros.h>
    #include <nodelet/loader.h>
    
    int main(int argc, char **argv){
      ros::init(argc, argv, "tegra_stereo_node");
    
      nodelet::Loader nodelet;
      nodelet::M_string remap(ros::names::getRemappings());
      nodelet::V_string nargv;
      std::string nodelet_name = ros::this_node::getName();
      nodelet.load(nodelet_name, "tegra_stereo/TegraStereoProc", remap, nargv);
      ros::spin();
    
      return 0;
    }
    

If any of these methods fail with an error message that pluginlib can't find your nodelet, make sure that you defined your nodelet in an XML file and exported it in your package.xml. Instructions to do so are on the ROS wiki here: http://wiki.ros.org/nodelet/Tutorials/Porting%20nodes%20to%20nodelets

Bonus Methods

If you're willing to install another package, Southwest Research Institute created swri_nodelet to make some of these tasks easier.

  1. Run the nodelet standalone using roslaunch:

    <launch>
        <node name="my_nodelet" pkg="swri_nodelet" type="nodelet" args="tegra_stereo/TegraStereoProc standalone" />
    </launch>
    

    or rosrun:

    rosrun swri_nodelet nodelet  tegra_stereo/TegraStereoProc standalone
    
  2. Run the nodelet with a nodelet manager using roslaunch:

    <launch>
      <node name="manager" pkg="nodelet" type="nodelet" args="manager" />
      <node name="my_nodelet" pkg="swri_nodelet" type="nodelet" args="tegra_stereo/TegraStereoProc my_manager"/>
    </launch>
    

    (Note that this syntax makes it easy to switch launch files back and forth between manager and standalone using args.)

  3. Automatically create a node wrapper with your node using swri_nodelet. This takes a couple of steps but saves you from writing boilerplate C++. Also, because it links the nodelet with the executable at compile time, you catch linker errors at compile time, instead of dealing with inscrutable runtime errors. Here's how to do it:

C++:

 #include <swri_nodelet/class_list_macros.h>
 SWRI_NODELET_EXPORT_CLASS(tegra_stereo TegraStereoProc)

Cmake:

 # (Add swri_nodelet to your find_package(catkin)

 add_library(my_nodelet_library src/TegraStereoProc.cpp)
 target_link_libraries(my_nodelet_library ${CATKIN_LIBRARIES})

 swri_nodelet_add_node(tegra_stereo_proc tegra_stereo TegraStereoProc)
 target_link_libraries(tegra_stereo_proc my_nodelet_library)

There are three ways to run a nodelet:

  1. Run the nodelet standalone using roslaunch:

    <launch>
        <node name="my_nodelet" pkg="nodelet" type="nodelet" args="standalone tegra_stereo/TegraStereoProc" />
    </launch>
    

    or rosrun:

    rosrun nodelet nodelet standalone tegra_stereo/TegraStereoProc
    
  2. Run the nodelet as part of a nodelet manager. This is described on the ROS wiki here: http://wiki.ros.org/nodelet/Tutorials/Running%20a%20nodelet

  3. Write a node wrapper, and then build and run it as you would a node. Here's what node wrapper code typically looks like:

    #include <ros/ros.h>
    #include <nodelet/loader.h>
    
    int main(int argc, char **argv){
      ros::init(argc, argv, "tegra_stereo_node");
    
      nodelet::Loader nodelet;
      nodelet::M_string remap(ros::names::getRemappings());
      nodelet::V_string nargv;
      std::string nodelet_name = ros::this_node::getName();
      nodelet.load(nodelet_name, "tegra_stereo/TegraStereoProc", remap, nargv);
      ros::spin();
    
      return 0;
    }
    

If any of these methods fail with an error message that pluginlib can't find your nodelet, make sure that you defined your nodelet in an XML file and exported it in your package.xml. Instructions to do so are on the ROS wiki here: http://wiki.ros.org/nodelet/Tutorials/Porting%20nodes%20to%20nodelets

Bonus Methods

If you're willing to install another package, Southwest Research Institute created swri_nodelet to make some of these tasks easier.

  1. Run the nodelet standalone using roslaunch:

    <launch>
        <node name="my_nodelet" pkg="swri_nodelet" type="nodelet" args="tegra_stereo/TegraStereoProc standalone" />
    </launch>
    

    or rosrun:

    rosrun swri_nodelet nodelet  tegra_stereo/TegraStereoProc standalone
    
  2. Run the nodelet with a nodelet manager using roslaunch:

    <launch>
      <node name="manager" pkg="nodelet" type="nodelet" args="manager" />
      <node name="my_nodelet" pkg="swri_nodelet" type="nodelet" args="tegra_stereo/TegraStereoProc my_manager"/>
    </launch>
    

    (Note that this syntax makes it easy to switch launch files back and forth between manager and standalone using args.)

  3. Automatically create a node wrapper with your node using swri_nodelet. This takes a couple of steps but saves you from writing boilerplate C++. Also, because it links the nodelet with the executable at compile time, you catch linker errors at compile time, instead of dealing with inscrutable runtime errors. Here's how to do it:

    C++:In you're nodelet's C++ file, replace the pluginlib macro with this:

    #include <swri_nodelet/class_list_macros.h>
    SWRI_NODELET_EXPORT_CLASS(tegra_stereo TegraStereoProc)
    

    Cmake:In your CMakeList, build your library and add a nodelet executable like this:

    # (Add swri_nodelet to your find_package(catkin)
    
    add_library(my_nodelet_library src/TegraStereoProc.cpp)
    target_link_libraries(my_nodelet_library ${CATKIN_LIBRARIES})
    
    swri_nodelet_add_node(tegra_stereo_proc tegra_stereo TegraStereoProc)
    target_link_libraries(tegra_stereo_proc my_nodelet_library)
    

There are three ways to run a nodelet:

  1. Run the nodelet standalone using roslaunch:

    <launch>
        <node name="my_nodelet" pkg="nodelet" type="nodelet" args="standalone tegra_stereo/TegraStereoProc" />
    </launch>
    

    or rosrun:

    rosrun nodelet nodelet standalone tegra_stereo/TegraStereoProc
    
  2. Run the nodelet as part of a nodelet manager. This is described on the ROS wiki here: http://wiki.ros.org/nodelet/Tutorials/Running%20a%20nodelet

  3. Write a node wrapper, and then build and run it as you would a node. Here's what node wrapper code typically looks like:

    #include <ros/ros.h>
    #include <nodelet/loader.h>
    
    int main(int argc, char **argv){
      ros::init(argc, argv, "tegra_stereo_node");
    
      nodelet::Loader nodelet;
      nodelet::M_string remap(ros::names::getRemappings());
      nodelet::V_string nargv;
      std::string nodelet_name = ros::this_node::getName();
      nodelet.load(nodelet_name, "tegra_stereo/TegraStereoProc", remap, nargv);
      ros::spin();
    
      return 0;
    }
    

If any of these methods fail with an error message that pluginlib can't find your nodelet, make sure that you defined your nodelet in an XML file and exported it in your package.xml. Instructions to do so are on the ROS wiki here: http://wiki.ros.org/nodelet/Tutorials/Porting%20nodes%20to%20nodelets

Bonus Methods

If you're willing to install another package, Southwest Research Institute created swri_nodelet to make some of these tasks easier.

  1. Run the nodelet standalone using roslaunch:

    <launch>
        <node name="my_nodelet" pkg="swri_nodelet" type="nodelet" args="tegra_stereo/TegraStereoProc standalone" />
    </launch>
    

    or rosrun:

    rosrun swri_nodelet nodelet  tegra_stereo/TegraStereoProc standalone
    
  2. Run the nodelet with a nodelet manager using roslaunch:

    <launch>
      <node name="manager" pkg="nodelet" type="nodelet" args="manager" />
      <node name="my_nodelet" pkg="swri_nodelet" type="nodelet" args="tegra_stereo/TegraStereoProc my_manager"/>
    </launch>
    

    (Note that this syntax makes it easy to switch launch files back and forth between manager and standalone using args.)

  3. Automatically create a node wrapper using swri_nodelet. This takes a couple of steps but saves you from writing boilerplate C++. Also, because it links the nodelet with the executable at compile time, you catch linker errors at compile time, instead of dealing with inscrutable runtime errors. Here's how to do it:

    In you're your nodelet's C++ file, replace the pluginlib macro with this:

    #include <swri_nodelet/class_list_macros.h>
    SWRI_NODELET_EXPORT_CLASS(tegra_stereo TegraStereoProc)
    

    In your CMakeList, build your library and add a nodelet executable like this:

    # (Add swri_nodelet to your find_package(catkin)
    
    add_library(my_nodelet_library src/TegraStereoProc.cpp)
    target_link_libraries(my_nodelet_library ${CATKIN_LIBRARIES})
    
    swri_nodelet_add_node(tegra_stereo_proc tegra_stereo TegraStereoProc)
    target_link_libraries(tegra_stereo_proc my_nodelet_library)