Mission Project

Project Name: Obstacle Avoidance System

- This mission is a group project
- Try different combinations of instructions with your team so that the robot successfully avoids the obstacle.
- It is recommended that the final code be on the Leaders computer. (Simultaneous commands to the robot must be avoided!)

Overall Description:

For this mission, with the examples discussed earlier, lets try to create a function that contains instructions for the robot to move around an obstacle.

For this mission you are tasked to create:

  • Move and Turn function

  • Main function that would manage the sequence of move functions.

One thing to keep in mind is that the instructions if not ordered correctly will try to send multiple commands to the robot at the same time. In order to avoid that you may try to apply time.sleep() function to wait until the command is complete.

Example:

import rospy
import json
from std_msgs.msg import UInt8MultiArray, String
from nav_msgs.msg import Odometry
import time
import math
import threading

rospy.init_node('zetabot')
move_pub = rospy.Publisher('/robot_command', String, queue_size=1)

def move():
    tmp = {"MoveForward": 1}
    msg = json.dumps(tmp)
    rospy.loginfo("Sent: %s", msg)
    move_pub.publish(msg)

def back():
    tmp = {"MoveBackward": 1}
    msg = json.dumps(tmp)
    rospy.loginfo("Sent: %s", msg)
    move_pub.publish(msg)

def stop():
    tmp = {"Stop": 0}
    msg = json.dumps(tmp)
    rospy.loginfo("Sent: %s", msg)
    move_pub.publish(msg)