How can i make summit move?

Hi, in unit 4 , I’m suppose i send my command to the new robot summit, but when i try to do so i get a scan error as shown in the picture, it keeps going forever. any idea on what is my mistake ?
the code i used is indicated in the picture as well.

Can you do the following command and paste the answer here:

rostopic list

/clock
/rosout
/rosout_agg
/scan
/summit_1/camera/image_raw
/summit_1/cmd_vel
/summit_1/joint_states
/summit_1/odom
/summit_1/scan
/tf
/tf_static

This is the right laser scan topic. Let me check and revert; something is not right.

Sorry about that, we will see into that issue as soon as posisble

Hi, can you show us here your robot_class.py? Becuase you should have this version:

#!/usr/bin/env python

import rospy
from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan
import time


class RobotControl():

    def __init__(self, robot_name="cooper"):
        rospy.init_node('robot_control_node', anonymous=True)

        if robot_name == "summit":
            rospy.loginfo("Robot Summit...")
            cmd_vel_topic = "/summit_1/cmd_vel"
            # We check that sensors are working
            self._check_summit_laser_ready()
        else:      
            rospy.loginfo("Robot Cooper...")      
            cmd_vel_topic='/cooper_1/cmd_vel'
            self._check_laser_ready()

        # We start the publisher
        self.vel_publisher = rospy.Publisher(cmd_vel_topic, Twist, queue_size=1)
        self.cmd = Twist()        

        self.laser_subscriber = rospy.Subscriber(
            '/cooper_1/scan', LaserScan, self.laser_callback)
        self.summit_laser_subscriber = rospy.Subscriber(
            '/summit_1/scan', LaserScan, self.summit_laser_callback)
        
        self.ctrl_c = False
        self.rate = rospy.Rate(1)
        rospy.on_shutdown(self.shutdownhook)

    
    def _check_summit_laser_ready(self):
        self.summit_laser_msg = None
        rospy.loginfo("Checking Summit Laser...")
        while self.summit_laser_msg is None and not rospy.is_shutdown():
            try:
                self.summit_laser_msg = rospy.wait_for_message("/summit_1/scan", LaserScan, timeout=1.0)
                rospy.logdebug("Current /summit_1/scan READY=>" + str(self.summit_laser_msg))

            except:
                rospy.logerr("Current /summit_1/scan not ready yet, retrying for getting scan")
        rospy.loginfo("Checking Summit Laser...DONE")
        return self.summit_laser_msg

    def _check_laser_ready(self):
        self.laser_msg = None
        rospy.loginfo("Checking Laser...")
        while self.laser_msg is None and not rospy.is_shutdown():
            try:
                self.laser_msg = rospy.wait_for_message("/cooper_1/scan", LaserScan, timeout=1.0)
                rospy.logdebug("Current /kobuki/laser/scan READY=>" + str(self.laser_msg))

            except:
                rospy.logerr("Current /cooper_1/scan not ready yet, retrying for getting scan")
        rospy.loginfo("Checking Laser...DONE")
        return self.laser_msg

    def publish_once_in_cmd_vel(self):
        """
        This is because publishing in topics sometimes fails the first time you publish.
        In continuous publishing systems, this is no big deal, but in systems that publish only
        once, it IS very important.
        """
        while not self.ctrl_c:
            connections = self.vel_publisher.get_num_connections()
            if connections > 0:
                self.vel_publisher.publish(self.cmd)
                #rospy.loginfo("Cmd Published")
                break
            else:
                self.rate.sleep()

    def shutdownhook(self):
        rospy.loginfo("Shutdown: stopping robot...")
        self.ctrl_c = True
        # Immediately publish zero velocity
        stop_cmd = Twist()
        self.vel_publisher.publish(stop_cmd)
        # Give it time to send
        rospy.sleep(0.5)

    def laser_callback(self, msg):
        self.laser_msg = msg

    def summit_laser_callback(self, msg):
        self.summit_laser_msg = msg

    def get_laser(self, pos):
        time.sleep(1)
        return self.laser_msg.ranges[pos]

    def get_laser_summit(self, pos):
        time.sleep(1)
        return self.summit_laser_msg.ranges[pos]

    def get_laser_full_summit(self):
        return self.summit_laser_msg.ranges

    def get_front_laser(self):
        time.sleep(1)
        return self.laser_msg.ranges[360]

    def get_laser_full(self):
        time.sleep(1)
        return self.laser_msg.ranges

    def stop_robot(self):
        #rospy.loginfo("shutdown time! Stop the robot")
        self.cmd.linear.x = 0.0
        self.cmd.angular.z = 0.0
        self.publish_once_in_cmd_vel()

    def move_straight(self):

        # Initilize velocities
        self.cmd.linear.x = 0.5
        self.cmd.linear.y = 0
        self.cmd.linear.z = 0
        self.cmd.angular.x = 0
        self.cmd.angular.y = 0
        self.cmd.angular.z = 0

        # Publish the velocity
        self.publish_once_in_cmd_vel()

    def move_straight_time(self, motion, speed, time):

        # Initilize velocities
        self.cmd.linear.y = 0
        self.cmd.linear.z = 0
        self.cmd.angular.x = 0
        self.cmd.angular.y = 0
        self.cmd.angular.z = 0

        if motion == "forward":
            self.cmd.linear.x = speed
        elif motion == "backward":
            self.cmd.linear.x = - speed

        i = 0
        # loop to publish the velocity estimate, current_distance = velocity * (t1 - t0)
        while (i <= time):

            # Publish the velocity
            self.vel_publisher.publish(self.cmd)
            i += 1
            self.rate.sleep()

        # set velocity to zero to stop the robot
        self.stop_robot()

        s = "Moved robot " + motion + " for " + str(time) + " seconds at " + str(speed) + "  m/s"
        return s


    def turn(self, clockwise, speed, time):

        # Initilize velocities
        self.cmd.linear.x = 0
        self.cmd.linear.y = 0
        self.cmd.linear.z = 0
        self.cmd.angular.x = 0
        self.cmd.angular.y = 0

        if clockwise == "clockwise":
            self.cmd.angular.z = -speed
        else:
            self.cmd.angular.z = speed

        i = 0
        # loop to publish the velocity estimate, current_distance = velocity * (t1 - t0)
        while (i <= time):

            # Publish the velocity
            self.vel_publisher.publish(self.cmd)
            i += 1
            self.rate.sleep()

        # set velocity to zero to stop the robot
        self.stop_robot()

        s = "Turned robot " + clockwise + " for " + str(time) + " seconds at " + str(speed) + "  radians/second"
        return s


if __name__ == '__main__':
    
    robotcontrol_object = RobotControl()
    try:
        robotcontrol_object.move_straight_time(motion="forward", speed=2.0, time=1.0)

    except rospy.ROSInterruptException:
        pass

It seems as if you had an older version previous to the update to the new simulations version. This update was done around 1 month ago.

Your issue should be fixed by using the script I provided here. But I would like to know where did you get the other old code, to rule out that we might have missed that code somewhere.

i’m not sure, i have not used this file before,modifying it is not part of my course. this the one i have now :

#!/usr/bin/env python

import rospy
from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan
import time

class RobotControl():

def __init__(self, robot_name="cooper"):
    rospy.init_node('robot_control_node', anonymous=True)

    if robot_name == "summit":
        rospy.loginfo("Robot Summit...")
        cmd_vel_topic = "/summit_xl_control/cmd_vel"
        # We check that sensors are working
        self._check_summit_laser_ready()
    else:      
        rospy.loginfo("Robot Cooper...")      
        cmd_vel_topic='/cooper_1/cmd_vel'
        self._check_laser_ready()

    # We start the publisher
    self.vel_publisher = rospy.Publisher(cmd_vel_topic, Twist, queue_size=1)
    self.cmd = Twist()        

    self.laser_subscriber = rospy.Subscriber(
        '/cooper_1/scan', LaserScan, self.laser_callback)
    self.summit_laser_subscriber = rospy.Subscriber(
        '/hokuyo_base/scan', LaserScan, self.summit_laser_callback)
    
    self.ctrl_c = False
    self.rate = rospy.Rate(1)
    rospy.on_shutdown(self.shutdownhook)


def _check_summit_laser_ready(self):
    self.summit_laser_msg = None
    rospy.loginfo("Checking Summit Laser...")
    while self.summit_laser_msg is None and not rospy.is_shutdown():
        try:
            self.summit_laser_msg = rospy.wait_for_message("/hokuyo_base/scan", LaserScan, timeout=1.0)
            rospy.logdebug("Current /hokuyo_base/scan READY=>" + str(self.summit_laser_msg))

        except:
            rospy.logerr("Current /hokuyo_base/scan not ready yet, retrying for getting scan")
    rospy.loginfo("Checking Summit Laser...DONE")
    return self.summit_laser_msg

def _check_laser_ready(self):
    self.laser_msg = None
    rospy.loginfo("Checking Laser...")
    while self.laser_msg is None and not rospy.is_shutdown():
        try:
            self.laser_msg = rospy.wait_for_message("/cooper_1/scan", LaserScan, timeout=1.0)
            rospy.logdebug("Current /kobuki/laser/scan READY=>" + str(self.laser_msg))

        except:
            rospy.logerr("Current /cooper_1/scan not ready yet, retrying for getting scan")
    rospy.loginfo("Checking Laser...DONE")
    return self.laser_msg

def publish_once_in_cmd_vel(self):
    """
    This is because publishing in topics sometimes fails the first time you publish.
    In continuous publishing systems, this is no big deal, but in systems that publish only
    once, it IS very important.
    """
    while not self.ctrl_c:
        connections = self.vel_publisher.get_num_connections()
        if connections > 0:
            self.vel_publisher.publish(self.cmd)
            #rospy.loginfo("Cmd Published")
            break
        else:
            self.rate.sleep()

def shutdownhook(self):
    rospy.loginfo("Shutdown: stopping robot...")
    self.ctrl_c = True
    # Immediately publish zero velocity
    stop_cmd = Twist()
    self.vel_publisher.publish(stop_cmd)
    # Give it time to send
    rospy.sleep(0.5)

def laser_callback(self, msg):
    self.laser_msg = msg

def summit_laser_callback(self, msg):
    self.summit_laser_msg = msg

def get_laser(self, pos):
    time.sleep(1)
    return self.laser_msg.ranges[pos]

def get_laser_summit(self, pos):
    time.sleep(1)
    return self.summit_laser_msg.ranges[pos]

def get_laser_full_summit(self):
    return self.summit_laser_msg.ranges

def get_front_laser(self):
    time.sleep(1)
    return self.laser_msg.ranges[360]

def get_laser_full(self):
    time.sleep(1)
    return self.laser_msg.ranges

def stop_robot(self):
    #rospy.loginfo("shutdown time! Stop the robot")
    self.cmd.linear.x = 0.0
    self.cmd.angular.z = 0.0
    self.publish_once_in_cmd_vel()

def move_straight(self):

    # Initilize velocities
    self.cmd.linear.x = 0.5
    self.cmd.linear.y = 0
    self.cmd.linear.z = 0
    self.cmd.angular.x = 0
    self.cmd.angular.y = 0
    self.cmd.angular.z = 0

    # Publish the velocity
    self.publish_once_in_cmd_vel()

def move_straight_time(self, motion, speed, time):

    # Initilize velocities
    self.cmd.linear.y = 0
    self.cmd.linear.z = 0
    self.cmd.angular.x = 0
    self.cmd.angular.y = 0
    self.cmd.angular.z = 0

    if motion == "forward":
        self.cmd.linear.x = speed
    elif motion == "backward":
        self.cmd.linear.x = - speed

    i = 0
    # loop to publish the velocity estimate, current_distance = velocity * (t1 - t0)
    while (i <= time):

        # Publish the velocity
        self.vel_publisher.publish(self.cmd)
        i += 1
        self.rate.sleep()

    # set velocity to zero to stop the robot
    self.stop_robot()

    s = "Moved robot " + motion + " for " + str(time) + " seconds at " + str(speed) + "  m/s"
    return s


def turn(self, clockwise, speed, time):

    # Initilize velocities
    self.cmd.linear.x = 0
    self.cmd.linear.y = 0
    self.cmd.linear.z = 0
    self.cmd.angular.x = 0
    self.cmd.angular.y = 0

    if clockwise == "clockwise":
        self.cmd.angular.z = -speed
    else:
        self.cmd.angular.z = speed

    i = 0
    # loop to publish the velocity estimate, current_distance = velocity * (t1 - t0)
    while (i <= time):

        # Publish the velocity
        self.vel_publisher.publish(self.cmd)
        i += 1
        self.rate.sleep()

    # set velocity to zero to stop the robot
    self.stop_robot()

    s = "Turned robot " + clockwise + " for " + str(time) + " seconds at " + str(speed) + "  radians/second"
    return s

if name == ‘main’:

robotcontrol_object = RobotControl()
try:
    robotcontrol_object.move_straight()

except rospy.ROSInterruptException:
    pass

Thank you this resolved the issue . really appreciate your help.

You have the old version of the script. Did you start this course some months ago? It might have happened that you started it with that version and we upgraded in the middle

yes i started it about 2 months ago.