-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working publisher that keeps the turtle rotating.
- Loading branch information
Showing
3 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,13 @@ | |
<package format="3"> | ||
<name>ros2_turtlesim_teleop_python</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<description>TurtleSim Python Controller</description> | ||
<maintainer email="[email protected]">norbert</maintainer> | ||
<license>MIT</license> | ||
|
||
<exec_depend>geometry_msgs</exec_depend> | ||
<exec_depend>rclpy</exec_depend> | ||
|
||
<test_depend>ament_copyright</test_depend> | ||
<test_depend>ament_flake8</test_depend> | ||
<test_depend>ament_pep257</test_depend> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,35 @@ | ||
def main(): | ||
print('Hi from ros2_turtlesim_teleop_python.') | ||
import geometry_msgs.msg | ||
import rclpy | ||
from rclpy.node import Node | ||
import geometry_msgs | ||
import rclpy.destroyable | ||
|
||
class TurtlePublisher(Node): | ||
def __init__(self): | ||
super().__init__('turtlesim_teleop_python') | ||
self.publisher_ = self.create_publisher(geometry_msgs.msg.Twist, 'turtle1/cmd_vel', 10) | ||
timer_period = 0.5 # seconds | ||
self.timer = self.create_timer(timer_period, self.timer_callback) | ||
self.i = 0 | ||
|
||
def timer_callback(self): | ||
msg = geometry_msgs.msg.Twist() | ||
msg.linear.x = 0.0 | ||
msg.linear.y = 0.0 | ||
msg.linear.z = 1.0 | ||
msg.angular = msg.linear | ||
|
||
self.publisher_.publish(msg) | ||
self.get_logger().info('Publishing: ' + str(msg)) | ||
self.i += 1 | ||
|
||
def main(args=None): | ||
print('Hi from ros2_turtlesim_teleop_python.') | ||
rclpy.init(args=args) | ||
turtle_publisher = TurtlePublisher() | ||
rclpy.spin(turtle_publisher) | ||
turtle_publisher.destroy_node() | ||
rclpy.shutdown() | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,9 @@ | |
], | ||
install_requires=['setuptools'], | ||
zip_safe=True, | ||
maintainer='norbert', | ||
maintainer='Norbert Schulz', | ||
maintainer_email='[email protected]', | ||
description='TODO: Package description', | ||
description='TurtleSim Python Controller', | ||
license='MIT', | ||
tests_require=['pytest'], | ||
entry_points={ | ||
|