Real robot lab very slow

Hi, I tried for the first time turtlebot real robot lab the robot get commands for line 2/3 seconds, then stop, if i relaunch my node, the robot restart, move for 2/3 seconds, then suddendly stop…
The same code work without problema in simulation…

Thanks,
Igor

Hi, welcome to the community!

Did the same issue happen when you moved it around with the joystick?

The robot has a velocity limit for safety, so that might explain the stopping. Try using a linear velocity lower than 0.15.

When I use the joystick the movement is continuous, when I use my node the robot advance for a few centimeters, stop, wait, then restart. The robot follows the programmed path, but with a stop and go pace…

this is my node code (it’s ros2, but I launch ros1 bridge…):

import rclpy

from rclpy.node import Node

from geometry_msgs.msg import Twist

from sensor_msgs.msg import LaserScan

class WallController(Node):

    x = 0 

    z = 0

    def __init__(self):

        super().__init__('WallController')

        self.publisher_cmd_vel = self.create_publisher(Twist, 'cmd_vel', 10)

        self.subscriber_scan = self.create_subscription(LaserScan, 'scan', self.scan_callback, 10)

        self.publisher_cmd_vel

        self.subscriber_scan

    def move(self,x,z):

        msg = Twist()

        self.x = x

        self.z = z

        msg.linear.x = self.x

        msg.angular.z = self.z

        self.publisher_cmd_vel.publish(msg)  

    def scan_callback(self, msg):

        steps = (msg.angle_max - msg.angle_min)/msg.angle_increment 

        right_step = int(steps / 4.0 * 1.0)

        front_step = int(steps / 2.0)

        self.get_logger().info('STEPS: %f,%f %f' % (steps, front_step, front_step))

        right_wall_distance = msg.ranges[right_step]

        front_wall_distance = msg.ranges[front_step]        

        if front_wall_distance < 0.6:

            self.move(0.0, 0.48)

        else:

            if right_wall_distance < 0.5:

                self.move(0.10, 0.15)              

            elif right_wall_distance >= 0.5 and right_wall_distance < 0.6:

                self.move(0.14, 0.0)

            else:

                self.move(0.10, -0.15)

        self.get_logger().info('%f,%f %f:%f' % (front_wall_distance, right_wall_distance, self.x, self.z))

def main(args=None):

    rclpy.init(args=args)

    wall_controller = WallController()

    rclpy.spin(wall_controller)

    wall_controller.destroy_node()

    

    rclpy.shutdown()

if __name__ == '__main__':

    main()

Have you tried spinning your node at a faster rate? Maybe the publishing needs to be faster.

Here is some info that can be useful:

https://answers.ros.org/question/358343/rate-and-sleep-function-in-rclpy-library-for-ros2/

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.