diff --git a/launch/lesson05 b/launch/lesson05 new file mode 100644 index 0000000000000000000000000000000000000000..22eacd81d14c2235d96f6b2893cf08a1cef6d2bd --- /dev/null +++ b/launch/lesson05 @@ -0,0 +1,25 @@ +from launch import LaunchDescription +from launch_ros.actions import Node + + +def generate_launch_description(): + return LaunchDescription([ + Node( + package = 'rgt_plot', + namespace = '', + executable = 'rgt_plot' + name = 'plot' + ), + Node( + package = 'turtlesim', + namespace = '', + executable = 'turtlesim_node', + name = 'sim' + ), + Node( + package = 'lesson_05', + namespace = '', + executable = 'step_4' + name = 'square' + ) + ]) diff --git a/lesson_05/step_4.py b/lesson_05/step_4.py index 0aadceeac49995ffb174c923ca75f496161bf2eb..24e0203d16625f794cd88433dfcdf9e954d0d1f9 100644 --- a/lesson_05/step_4.py +++ b/lesson_05/step_4.py @@ -27,12 +27,7 @@ class RurMover(Node): msg_pub = Twist() msg_pub.linear.x = self.LINEAR_SPEED error = angle_diff(self.desired_heading, msg.theta) - if error < 0: - msg_pub.angular.z = math.radians(90.0) - self.get_logger().info('Turn left') - else: - msg_pub.angular.z = math.radians(-90.0) - self.get_logger().info('Turn right') + msg_pub.angular.z = 10 * error self.publisher_twist.publish(msg_pub) def pub_timer_callback(self): @@ -51,4 +46,4 @@ def main(args=None): rclpy.shutdown() if __name__ == '__main__': - main() \ No newline at end of file + main()