## page was renamed from ensenso_driver/Tutorials/MultiCamera ## For instruction on writing tutorials ## http://www.ros.org/wiki/WritingTutorials #################################### ##FILL ME IN #################################### ## for a custom note with links: ## note = ## for the canned note of "This tutorial assumes that you have completed the previous tutorials:" just add the links ## note.0=[[ensenso_driver/Tutorials/FirstSteps|First Steps]] ## descriptive title for the tutorial ## title = Running a Camera as a Nodelet ## multi-line description to be displayed in search ## description = This tutorial explains you how to run a camera as a nodelet with a nodelet manager. ## the next tutorial description (optional) ## next= ## links to next tutorial (optional) ## next.0.link=[[ensenso_driver/Tutorials/CameraFramesMultiple|Camera Frames with multiple Cameras]] ## next.1.link= ## what level user is this tutorial for ## level= BeginnerCategory ## keywords = #################################### <<IncludeCSTemplate(TutorialCSHeaderTemplate)>> <<TableOfContents(4)>> = Introduction = Running a node as nodelet has several advantages. The biggest one being that messages no further have to be serialized but can be passed intraprocess with zero copy costs. = Using Nodelets = With regard to this package, running the nodes as nodelets allows us to run several Ensenso stereo cameras and/or mono cameras within the same !NxLib instance. That for example makes it possible to generate textured point clouds, which is described in the [[ensenso_driver/Tutorials/TexturedPointCloud|TexturedPointCloud]] tutorial. This package provides a nodelet implementation for both the [[ensenso_driver/Nodes/ensenso_camera_mono_node|ensenso_camera_mono_node]] and the [[ensenso_driver/Nodes/ensenso_camera_node|ensenso_camera_node]]. = Launch File = In order to run a stereo camera node as a nodelet you can use the `nodelet.launch` file provided by this package. The following code shows the provided launch file. {{{ #!xml block=launch_file <!-- Open an Ensenso stereo camera in a nodelet. --> <launch> <arg name="serial" default="" doc="Serial of the stereo camera (default: first found camera)" /> <arg name="settings" default="" doc="JSON file with camera parameters" /> <arg name="camera_frame" default="" doc="The camera's tf frame (default: optical_frame_SERIAL)" /> <arg name="link_frame" default="" doc="The camera's link tf frame (default: camera_frame)" /> <arg name="target_frame" default="" doc="The tf frame the data will be returned in (default: camera_frame)" /> <arg name="tcp_port" default="-1" doc="The TCP port to open on the NxLib (-1=off, 0=autoSelect, >0=portNumber)" /> <arg name="threads" default="-1" doc="The number of threads used by the NxLib for this node (-1=autoDetect)" /> <arg name="wait_for_camera" default="false" doc="Whether this node should wait for the camera to become available" /> <node pkg="nodelet" type="nodelet" name="manager_" args="manager" output="screen" /> <node pkg="nodelet" type="nodelet" name="Ensenso_$(arg serial)" args="load ensenso_camera/stereo_camera_nodelet /manager_" output="screen"> <param name="serial" type="string" value="$(arg serial)" /> <param name="settings" type="string" value="$(arg settings)" /> <param name="camera_frame" type="string" value="$(arg camera_frame)" /> <param name="link_frame" type="string" value="$(arg link_frame)" /> <param name="target_frame" type="string" value="$(arg target_frame)" /> <param name="tcp_port" type="int" value="$(arg tcp_port)" /> <param name="threads" type="int" value="$(arg threads)" /> <param name="wait_for_camera" type="bool" value="$(arg wait_for_camera)" /> </node> </launch> }}} The launch file accepts all the arguments that the [[ensenso_driver/Nodes/ensenso_camera_node|ensenso_camera_node]] accepts and has default values for each argument. <<CodeRef(launch_file,4,19)>> In order to get an overwiew of the requried and optional arguments you can always run: {{{ roslaunch ensenso_camera nodelet.launch --ros-args }}} The output, however, is slightly wrong since all arguments are provided with a default value so that you can simply run the launch file without providing any arguments as shown at the end of this tutorial. A nodelet is started in the same fashion as its corresponding node, however, with the slight difference that it requires a nodelet manager to be run in. This is why a nodelet is always run from within a launch file, in which a nodelet manager is started and then given to the nodelet. The crucial part is the manager's name, which has to be given to the nodelet via the `load` argument. That way the nodelet is handled by this specific nodelet manager. <<CodeRef(launch_file,21,24)>> The last lines define the nodelet with its parameters. The parameters are mapped to the ones of the node, defined in [[ensenso_driver/Nodes/ensenso_camera_node|ensenso_camera_node]]. The load argument of nodelet needs the nodelet class and the nodelet manager's name. If you want to start a nodelet for a supported mono camera, you need to use `ensenso_camera/nodelet_mono` instead of the `ensenso_camera/nodelet` class as it is also shown in the [[ensenso_driver/Tutorials/SeveralNodelets|SeveralNodelets]] tutorial. <<CodeRef(launch_file,23,33)>> Since the launch is provided by this package and we do not need to specify any required arguments, we can simply call {{{ roslaunch ensenso_camera nodelet.launch }}} without any arguments given. In this case, the wrapped [[ensenso_driver/Nodes/ensenso_camera_node|ensenso_camera_node]] will select and open the first stereo camera it can find. If you want to open a stereo camera with a specific serial you can run the following command with your camera serial replaced: {{{ roslaunch ensenso_camera \ nodelet.launch \ serial:=<serial of Ensenso stereo camera> }}} This way you can provide any of the other listed arguments in order to change the node's behavior as described in the [[ensenso_driver/Nodes/ensenso_camera_node|ensenso_camera_node documentation]]. ## AUTOGENERATED DO NOT DELETE ## TutorialCategory ## FILL IN THE STACK TUTORIAL CATEGORY HERE