Skip to content

Controller example for the Robot Wrestling Tournament. Demonstrates how to access the LEDs and play a custom motion file.

License

Notifications You must be signed in to change notification settings

cyberbotics/wrestling-charlie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Humanoid Robot Wrestling Controller Example

webots.cloud - Competition

Charlie controller

Demonstrates how to access the LEDs and play a custom motion file.

Beats Bob by moving forwards and pushing him to the ground.

This controller is a simple example of how to use the Motion_library class from the motion.py module to add a custom motion file, here Shove.motion.

Here is the participant.py file:

from controller import Robot
import sys
sys.path.append('..')
from utils.motion_library import MotionLibrary


class Charlie (Robot):
    def __init__(self):
        Robot.__init__(self)
        self.time_step = int(self.getBasicTimeStep())

        # there are 7 controllable LEDs on the NAO robot, but we will use only the ones in the eyes
        self.leds = {
            'right': self.getDevice('Face/Led/Right'),
            'left':  self.getDevice('Face/Led/Left')
        }

        self.library = MotionLibrary()
        # adding a custom motion to the library
        self.library.add('Shove', './Shove.motion', loop=True)

    def run(self):
        self.library.play('Stand')

        self.leds['right'].set(0xff0000)  # set the eyes to red
        self.leds['left'].set(0xff0000)

        while self.step(self.time_step) != -1:
            # When the robot is done standing for stabilization, it moves forwards
            if self.library.get('Stand').isOver():
                self.library.play('ForwardLoop')  # walk forward
                self.library.play('Shove')        # play the shove motion


# create the Robot instance and run main loop
wrestler = Charlie()
wrestler.run()

David is a more advanced robot controller able to win against Charlie.

About

Controller example for the Robot Wrestling Tournament. Demonstrates how to access the LEDs and play a custom motion file.

Resources

License

Stars

Watchers

Forks