TURTLEBOT4 - TU PRIMER NODO PYTHON

  Рет қаралды 11

Innova 3D México 2.0

Innova 3D México 2.0

Күн бұрын

Пікірлер: 4
@IN3DMEX2.0
@IN3DMEX2.0 2 ай бұрын
$ ssh ubuntu@ip_raspberry $ source /opt/ros/humble/setup.bash $ mkdir Turtlebot4 $ cd Turtlebot4 $ mkdir src $ cd src $ ros2 pkg create --build-type ament_python --node-name turtlebot4_first_python_node turtlebot4_python_tutorials $ nano package.xml En package.xml, agregar debajo de 'license' ament_cmake_python rclpy irobot_create_msgs $ cd turtlebot4_python_tutorials $ ls $ cd turtlebot4_python_tutorials $ nano turtlebot4_first_python_node.py
@IN3DMEX2.0
@IN3DMEX2.0 2 ай бұрын
from irobot_create_msgs.msg import InterfaceButtons, LightringLeds import rclpy from rclpy.node import Node from rclpy.qos import qos_profile_sensor_data class TurtleBot4FirstNode(Node): lights_on_ = False def __init__(self): super().__init__('turtlebot4_first_python_node') # Subscribe to the /interface_buttons topic self.interface_buttons_subscriber = self.create_subscription( InterfaceButtons, '/interface_buttons', self.interface_buttons_callback, qos_profile_sensor_data ) # Interface buttons subscription callback def interface_buttons_callback(self, create3_buttons_msg: InterfaceButtons): # Button 1 is pressed if create3_buttons_msg.button_1.is_pressed: self.get_logger().info('Button 1 Pressed!') def main(args=None): rclpy.init(args=args) node = TurtleBot4FirstNode() rclpy.spin(node) node.destroy_node() rclpy.shutdown() if __name__ == '__main__': main()
@IN3DMEX2.0
@IN3DMEX2.0 2 ай бұрын
$ cd .. $ colcon build $ source install/local_setup.bash ros2 run turtlebot4_python_tutorials turtlebot4_first_python_node ----------------------------------------------------------- ¡¡sólo si hay problema en correr el nodo cd ~/Turtlebot4/src git clone github.com/iRobotEducation/irobot_create_msgs.git ----------------------------------------------------------- $ cd src $ cd turtlebot4_python_tutorials $ cd turtlebot4_python_tutorials $ nano turtlebot4_first_python_node.py
@IN3DMEX2.0
@IN3DMEX2.0 2 ай бұрын
from irobot_create_msgs.msg import InterfaceButtons, LightringLeds import rclpy from rclpy.node import Node from rclpy.qos import qos_profile_sensor_data class TurtleBot4FirstNode(Node): lights_on_ = False def __init__(self): super().__init__('turtlebot4_first_python_node') # Subscribe to the /interface_buttons topic self.interface_buttons_subscriber = self.create_subscription( InterfaceButtons, '/interface_buttons', self.interface_buttons_callback, qos_profile_sensor_data) # Create a publisher for the /cmd_lightring topic self.lightring_publisher = self.create_publisher( LightringLeds, '/cmd_lightring', qos_profile_sensor_data) # Interface buttons subscription callback def interface_buttons_callback(self, create3_buttons_msg: InterfaceButtons): # Button 1 is pressed if create3_buttons_msg.button_1.is_pressed: self.get_logger().info('Button 1 Pressed!') self.button_1_function() # Perform a function when Button 1 is pressed def button_1_function(self): # Create a ROS 2 message lightring_msg = LightringLeds() # Stamp the message with the current time lightring_msg.header.stamp = self.get_clock().now().to_msg() # Lights are currently off if not self.lights_on_: # Override system lights lightring_msg.override_system = True # LED 0 lightring_msg.leds[0].red = 255 lightring_msg.leds[0].blue = 0 lightring_msg.leds[0].green = 0 # LED 1 lightring_msg.leds[1].red = 0 lightring_msg.leds[1].blue = 255 lightring_msg.leds[1].green = 0 # LED 2 lightring_msg.leds[2].red = 0 lightring_msg.leds[2].blue = 0 lightring_msg.leds[2].green = 255 # LED 3 lightring_msg.leds[3].red = 255 lightring_msg.leds[3].blue = 255 lightring_msg.leds[3].green = 0 # LED 4 lightring_msg.leds[4].red = 255 lightring_msg.leds[4].blue = 0 lightring_msg.leds[4].green = 255 # LED 5 lightring_msg.leds[5].red = 0 lightring_msg.leds[5].blue = 255 lightring_msg.leds[5].green = 255 # Lights are currently on else: # Disable system override. The system will take back control of the lightring. lightring_msg.override_system = False # Publish the message self.lightring_publisher.publish(lightring_msg) # Toggle the lights on status self.lights_on_ = not self.lights_on_ def main(args=None): rclpy.init(args=args) node = TurtleBot4FirstNode() rclpy.spin(node) node.destroy_node() rclpy.shutdown() if __name__ == '__main__': main() ---------------------------------------------------------------------------------------------------------------- $ cd .. $ colcon build $ source install/local_setup.bash
Why is Python 150X slower than C?
10:45
Mehul - Codedamn
Рет қаралды 11 М.
M4 Mac Mini CLUSTER 🤯
18:06
Alex Ziskind
Рет қаралды 238 М.
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 19 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 117 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 8 МЛН
NVIDIA’s New AI: Stunning Voice Generator!
6:21
Two Minute Papers
Рет қаралды 63 М.
Explosión de Agujeros Negros y el Fin del Tiempo
31:13
Date un Vlog
Рет қаралды 216 М.
Como acceder al puerto 3306 MySQL vía Linux
21:37
Alexner Aquino Heredia
Рет қаралды 154
Switching to Linux: Drives & Partitions
17:11
ExplainingComputers
Рет қаралды 47 М.
Python RAG Tutorial (with Local LLMs): AI For Your PDFs
21:33
pixegami
Рет қаралды 305 М.
Aprende Python en 15 Minutos 📗
19:48
Victor Robles WEB
Рет қаралды 960 М.
Unboxing the Raspberry Pi CM5 Development Kit
11:36
Level 2 Jeff
Рет қаралды 6 М.
An open source app we can all learn from
29:09
Theo - t3․gg
Рет қаралды 90 М.
Aprende Python ahora! curso completo e intensivo desde cero
5:05:50
HolaMundo
Рет қаралды 1,1 МЛН
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 19 МЛН