Acrome-SMD Docs
All Acrome ProductsReferencesBlogCase StudiesContact Us
  • ACROME SMD
  • Electronics
    • 🔴SMD Red
      • Troubleshooting Guide
    • 🔵SMD Blue
    • 🟢SMD Green
    • Gateway Modules
      • Arduino Gateway Module
      • USB Gateway Module
    • Electrical Motors
      • Brushed DC Motors (BDC)
      • Stepper DC Motors (SDC)
      • Brushless DC Motor (BLDC)
      • Linear Actuator with Feedback – 75 lbs
    • Add-on Modules
      • Ambient Light Sensor Module
      • Button Module
      • Buzzer Module
      • IMU Module
      • Joystick Module
      • Potentiometer Module
      • Reflectance Sensor Module
      • RGB LED Module
      • Servo Module
      • Ultrasonic Distance Sensor Module
  • SMD Kits
    • Starter Kit
      • What You Can Build
    • Education Kit
      • What You Can Build
    • Motion Kit
      • What You Can Build
  • Software
    • Libraries
      • Python Library
      • Arduino Library
      • Java Library
      • Matlab Library
    • SMD UI
    • SMD Blockly
      • Introducing Customized Blockly Blocks
  • SMD Applications
    • Basics
      • Blink
      • Action - Reaction
      • Autonomous Lighting
      • Smart Doorbell
      • Security System
      • Distance Buzzer Warning
      • Distance Auto Stop
      • Smart Light Control
    • Interactive
      • Automatic Trash Bin
      • Radar
      • Chrome Dino Game Player
      • Play Chrome Dino Game With Joystick
      • Snake Game With Joystick
      • Pan-Tilt with Joystick Module
      • Joystick Mouse Control
      • Rev Up the Engine
      • Motor Rotation Based on Turn Input Value
      • Basic Motor Speed Control Application
      • Basic Motor Control Application Using PWM Input
      • Basic Motor Position Control Application
      • Basic Motor Torque Control Application
      • Motor Rotation Based on Joystick Counting
    • Robotics
      • Differential Robot Projects
      • Mouse Cursor Tracker Motion Robot
      • Waypoint tracker robot
      • Braitenberg Robot
      • Line-Follower Robot
      • Teleoperation Robot
      • Obstacle Avoidance Robot
      • ESP32 Wireless Controlled Mobile Robot
  • AI
    • Object Tracking Robot
    • Groq Chatbot-Controlled Robot
  • ROS
    • Teleoperation Robot with ROS
  • Mechanics
    • Building Set
      • Plates
        • 2x2 Plate Package
        • 2x3 120° Plate Package
        • 3x3 Plate Package
        • 3x5 Plate Package
        • 3x9 Plate Package
        • 11x19 Plate
        • 9x19 Plate
        • 5x19 Plate
        • 3x19 Plate
        • 9x11 Plate
        • 5x13 Plate
      • Joints
        • 60° Joint Package
        • 90° Joint Package
        • 120° Joint Package
        • Slot Joint M2 Package
        • Slot Joint M3 Package
        • U Joint Package
      • Mounts
        • Add-on Mount Package
        • Motor L Mount Package
        • Pan-Tilt Package
      • Wheels
        • Ball Wheel Package
        • Caster Wheel Package
        • Wheel Package
      • Cables
        • Power Cable 10 cm Package
        • Power Cable 20 cm Package
        • Power Cable 35 cm Package
        • RJ-11 Cable 7.5 cm Package
        • RJ-11 Cable 20 cm Package
        • RJ-11 Cable 35 cm Package
        • RJ-45 Cable 7.5 cm Package
        • RJ-45 Cable 20 cm Package
        • RJ-45 Cable 35 cm Package
      • Fasteners
        • M2x5 Allen Hex Screw Package
        • M3x6 Allen Hex Screw Package
        • M3x8 Allen Hex Screw Package
        • M3 Hex Nut Package
  • Help
    • Manual
    • Shops
    • Reach Us
Powered by GitBook
On this page
  • Step 1: Hardware & Software Overview
  • Step 2: Assemble
  • Step 3: Run & Test
  • Codes
  1. SMD Applications
  2. Robotics

Braitenberg Robot

PreviousWaypoint tracker robotNextLine-Follower Robot

Last updated 1 month ago

The Braitenberg Robot is an autonomous mobile robot inspired by Braitenberg Vehicles. It reacts to environmental stimuli, such as light or obstacles, using simple sensor-based behaviors. The robot’s movements are determined by sensor input, enabling it to navigate and interact with its surroundings without predefined paths or waypoints.

About Tools and Materials:

Step 1: Hardware & Software Overview

Project Key Components

  1. The 100 RPM BDC Motor with Encoder is used to rotate the radar mechanism in a full circle. The user can precisely control the motor and get the position through the built-in encoder.

Key Features

• Light-Based Behavior Moves based on light intensity using sensors.

• Autonomous Navigation Adjusts speed and direction dynamically.

• Multiple Modes Fear (avoids light), Love (follows light), Aggression, and Wander.

• SMD Red Motor Control Uses PWM for precise movement.

• Button-Controlled Mode Switching Changes behavior with a button press.

• RGB LED Feedback LED color indicates the active mode.

Step 2: Assemble

Ensure the SMD is powered and all connections are properly secured.

Project Wiring Diagram

Step 3: Run & Test

Run the Python script to initialize the system and scan for connected modules.

Observe the motor movement and RGB LED color changes based on light sensor inputs.

If the robot does not respond correctly, check the sensor values and motor operation.

Codes

from smd.red import *
import time
import sys

class Braitenberg:
    """ Port and SMD ids are assigned. Modules connected to SMDs are printed.
        The operation mode is set for velocity modes. Torque is enabled
    """
    def __init__(self):
        # SMD setup
        self.port = "/dev/ttyUSB0"
        self.m = Master(self.port)
        self.m.attach(Red(0))
        self.m.attach(Red(1))
        print(self.m.scan_modules(0))  # Print the scanned modules for the first SMD ID.
        print(self.m.scan_modules(1))  # Print the scanned modules for the second SMD ID.
        
        # Motor setup
        # SMD 0 is left motor
        # SMD 1 is right motor
        self.m.set_operation_mode(0, 2)
        self.m.set_operation_mode(1, 2)
        self.m.enable_torque(0, True)
        self.m.enable_torque(1, True)

    def map(self, value, fromLow, fromHigh, toLow, toHigh):
        """_summary_

        Args:
            value (_type_): value of light data from the light sensor
            fromLow (_type_): minimum value of light coming from the light sensor
            fromHigh (_type_): maximum value of light coming from the light sensor
            toLow (_type_): minimum value of velocity
            toHigh (_type_): maximum value of velocity

        Returns:
            _type_: Velocity value is returned in direct proportion to the incoming light value.
        """
        return int((value - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow)

    def stop(self):
        """The motors are stopped by setting the Velocity value to 0.
        """

        self.m.set_velocity(0, 0)
        self.m.set_velocity(1, 0)

    def get_light_values(self):
        """ Incoming light data is assigned to right and left light variables

        Returns:
            _type_: right and left light values are returned
        """
        left_light = self.m.get_light(0, 1)
        right_light = self.m.get_light(0, 2)
        return left_light, right_light

    def fear(self):
        """ The right motor is related to the light sensor on the right, the left motor is related to the light data 
        from the left sensor in direct proportion. Motor speeds increase in direct proportion to the light data, and 
        accordingly the robot tends to move away from the light.
        """
        left_light, right_light = self.get_light_values()
        
        if left_light is not None and right_light is not None:
            # Adjust PWM values based on light intensity.
            left_stim = self.map(left_light, 0, 2300, 40, 100)
            right_stim = self.map(right_light, 0, 2300, 40, 100)
            print(f"left_light {left_light},  righ_light {right_light} ")

            self.m.set_velocity(0, -left_stim)
            self.m.set_velocity(1, right_stim)
        else:
            self.stop()  # Stop if any sensor is None.
    
    def love(self):
        """
        The right motor is related to the light sensor on the right, the left motor is inversely
        related to the light data from the left sensor. Motor speeds increase inversely proportional to
        the light data, and accordingly the robot tends to approach the light. However, as the robot 
        approaches the light source, its speed decreases.
        """
        
        left_light, right_light = self.get_light_values()

        if left_light is not None and right_light is not None:
            # Adjust PWM values based on light intensity.
            left_stim = self.map(left_light, 0, 1500, 100 ,0)
            right_stim = self.map(right_light, 0, 1500, 100, 0)

            
            if right_stim and left_stim > -1:

                self.m.set_velocity(0, -left_stim)
                self.m.set_velocity(1, right_stim)
            else:
                self.stop()
            print(f"left_stim {left_stim},  right_stim {right_stim} ")

        else:
            self.stop()  # Stop if any sensor is None.

    def wander_around(self):
        
        """The right motor is inversely related to the light sensor on the left,
        the left motor is inversely related to the light data from the right sensor. 
        Motor speeds increase inversely proportional to the light data, and accordingly
        the robot tends to move away from the light. However, as the robot moves away from 
        the light source, its speed increases.
        """
        left_light, right_light = self.get_light_values()

        if left_light is not None and right_light is not None:
            # Adjust PWM values based on light intensity.
            left_stim = self.map(right_light, 0, 1500, 100, 0)
            right_stim = self.map(left_light, 0, 1500, 100, 0)
            self.m.set_velocity(0, right_stim)
            self.m.set_velocity(1, -left_stim)

            print(f"left pwm: {left_stim}, right pwm: {right_stim}")

        else:
            self.stop()  # Stop if any sensor is None.
    
    def agression(self):
        """ The right motor is related to the light sensor on the right, the left motor is related to the light data 
        from the left sensor in direct proportion. Motor speeds increase in direct proportion to the light data, and 
        accordingly the robot tends to move away from the light.
        """

        left_light, right_light = self.get_light_values()

        if left_light is not None and right_light is not None:
            left_stim = self.map(left_light, 0, 1500, 0, 100)
            right_stim = self.map(right_light, 0, 1500, 0, 100)
            self.m.set_velocity(0, -right_stim)
            self.m.set_velocity(1, left_stim)

            print(f"Left: {left_stim}, Right: {right_stim}")

        else:
            self.stop()

    def run(self):
        c = 0
        while True:
            button =self.m.get_button(0, 1)
            
            if button == 1:
                c += 1
                time.sleep(0.4)
                 
            if c == 0:
                print(0) 
                self.fear()
                self.m.set_rgb(0, 1, red = 0, green = 0, blue = 255)
            
            elif c == 1:
                print(1)
                self.love()
                self.m.set_rgb(0, 1, red = 255, green = 0, blue = 255)
            elif c == 2:
                print(2)
                self.agression()
                self.m.set_rgb(0, 1, red = 255, green =0 , blue = 0)
            elif c == 3:
                print(3)
                self.wander_around()
                self.m.set_rgb(0, 1, red = 0, green = 255, blue = 0)
            elif c > 2:
                c = 0


if __name__ == "__main__":

    try:
        
        vehicle = Braitenberg()
        vehicle.run()


    except KeyboardInterrupt:  
        vehicle.stop()
        sys.exit(0)

2x ()

()

()

2x ()

2x ()

()

()

The SMD acts as a bridge between the script and the modules. It is responsible for interpreting the commands sent by the script and translating them into actions that read input from the and meanwhile, actuate the motor for the continuous reading of the script.

The emits light in different colors by mixing red, green, and blue channels. This allows users to create a variety of lighting effects, controlled via the .

The serves as a physical interface for user input. Users can press the button to cycle through different colors for the , and if the button is held down, the system will rapidly cycle through colors, allowing for faster color selection.

The detects the intensity of the surrounding light and allows the system to decide when to automatically turn on or off the , depending on the environment’s lighting conditions.

Connect the to the PC or Arduino board using a or .

Connect the with encoders to the motor ports of the SMD.

Attach the , , and to the SMD using RJ-45 cables.

Power on the and ensure all connections are secure.

Press the to switch between different robot behaviors (Fear, Love, Aggression, Wander).

SMD Red
Purchase Here
SMD USB Gateway
Purchase Here
Arduino Gateway Module
Purchase Here
BDC Motor
Purchase Here
Ambient Light Sensor Module
Purchase Here
RGB LED Module
Purchase Here
Button Module
Purchase Here
SMD
Ultrasonic Distance Sensor Module
BDC Motor
RGB LED Module
RGB LED Module
Button Module
Button Module
Button Module
RGB LED Module
Ambient Light Sensor Module
Ambient Light Sensor
RGB LED Module
SMD Red
USB Gateway Module
Arduino Gateway Module
BDC Motors
Ambient Light Sensor Module
Button Module
RGB LED Module
SMD Red
button module