Hey all ,
So i have this issue with Task2.py for the prerequisites exam
my robot stop within 1 meter in the wall and turn right 90
but I’m facing this issue
s = “Turned robot " + clockwise + " for " + str(time) + " seconds”
TypeError: cannot concatenate ‘str’ and ‘int’ objects
here is my code :
from robot_control_class import RobotControl
import time
# Create an instance of the RobotControl class
robotcontrol = RobotControl()
# Keep moving the robot forwards until it detects an obstacle at less than 1 meter in front of it
while True:
a = robotcontrol.get_laser(360)
print("Current distance to wall: %f" % a)
if a <= 1.3:
robotcontrol.stop_robot()
print("Current distance to wall: %f" % a)
break
robotcontrol.move_straight()
time.sleep(0.5) # add a delay to limit the frequency of the loop
# Turn the robot 90 degrees to the right
robotcontrol.turn(90, -1, 1.8)
# Concatenate a string and an integer
clockwise = "clockwise"
time = 5
s = "Turned robot " + clockwise + " for " + str(time) + " seconds"
# Print the resulting string
print(s)