#################################### ##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= [[ROS/Tutorials|ROS tutorials]] ## descriptive title for the tutorial ## title = How to Write a Generic Teleoperation Node ## multi-line description to be displayed in search ## description = This tutorial goes over generic teleoperation code that is used as an example in many of the teleoperation tutorials. ## the next tutorial description (optional) ## next = ## links to next tutorial (optional) ## next.0.link= ## next.1.link= ## what level user is this tutorial for ## level= BeginnerCategory ## keywords = #################################### <> <> ##start ==== The Code ==== <> ==== The Code Explained ==== Now, let's break down the code piece by piece. <> * turtlesim/Velocity.h includes the turtle velocity msg so that we can publish velocity commands to the turtle * joy/Joy.h includes the joystick msg so that we can listen to the joy topic <> Here we create the !TeleopTurtle class and define the joyCallback function that will take a joy msg. We also create a node handle, publisher, and subscriber for later use. <> Here we initialize some parameters: the linear_ and angular_ variables are used to define which axes of the joystick will control our turtle. We also check the parameter server for new scalar values for driving the turtle. <> Here we create a publisher that will advertise on the command_velocity topic of the turtle. <> Here we subscribe to the joystick topic for the input to drive the turtle. If our node is slow in processing incoming messages on the joystick topic, up to 10 messages will be buffered before any are lost. <> Here we take the data from the joystick and manipulate it by scaling it and using independent axes to control the linear and angular velocities of the turtle. Finally we publish the prepared message. <> Lastly we initialize our ROS node, create a teleop_turtle, and spin our node until `Ctrl-C` is pressed. ##end ## AUTOGENERATED DO NOT DELETE ## TutorialCategory ## JoyStickDriverCategory