Code Monkey home page Code Monkey logo

hello-world's Introduction

hello-world

The helloworld project defines an idle mode for Reachy.
This project has been thought to:

  • be able to make Reachy move immediately after the robot setup, without having to do any code
  • start to elaborate a way to define behaviors for human-robot interaction, making independant components that can be reused and integrated in more complex programs. The idea is to be able to integrate this idle mode in any project requiring such a state, without having to re-code this behavior again and again.

Discover helloworld

Install the project

Clone the repository or download and extract the source code.
Then install the project by going in the repo and doing: pip3 install -e .

Try the Idle mode

Make sure your robot is in the correct position: it needs to have space around it and the arms straight towards the floor, with no table under it.

Try it finally with the following command:
bash launch.bash

Project organization

The project is organized as following:

  • hello-world/behaviors: contains the defined idle behaviors
  • movements: contains the .npy of movements recorded that are called in some behaviors
  • sounds: contains sounds to be play in some behaviors

Add new behaviors

Each new behavior should inherite from the Behavior class. It should as well define at least the init, calling the super().init inherited from the Behavior class, an async run function and an async teardown, calling the inheritied super().teardown function of Behavior. A prototype is shown below:

class NewBehavior(Behavior):
    def __init__(self, name: str, reachy, sub_behavior: bool = False) -> None:
        super().__init__(name, reachy, sub_behavior=sub_behavior)

        # Initialize any other element relevant for your behavior


    async def run(self):
        for j in self.reachy.r_arm.joints.values():
            j.torque_limit = 100.0
        for j in self.reachy.l_arm.joints.values():
            j.torque_limit = 100.0

        # Your behavior code here

        self.reachy.turn_off_smoothly('r_arm')
        self.reachy.turn_off_smoothly('l_arm')

    async def teardown(self):
        return await super().teardown()

In order to have your behavior called in the idle function, you should then add an entry for your function in the behaviors dictionary of the Idle class: in hello_world/behaviors/idle.py, setting sub_behavior to True:

class Idle(Behavior):
    """Idle class."""

    def __init__(self, name: str, reachy, sub_behavior: bool = False) -> None:
        super().__init__(name, reachy=reachy, sub_behavior=sub_behavior)
        self.reachy = reachy
        self.asleep_behavior = Asleep(name='asleep', reachy=self.reachy, sub_behavior=True)
        self.behaviors = {
            'look_hand': LookHand(name='look_hand', reachy=self.reachy, sub_behavior=True),
            'lonely': Lonely(name='lonely', reachy=self.reachy, sub_behavior=True),
            'scratch': Scratch(name='scratch', reachy=self.reachy, sub_behavior=True),
            'tshirt': Tshirt(name='tshirt', reachy=self.reachy, sub_behavior=True),
            'sweat_head': SweatHead(name='sweat_head', reachy=self.reachy, sub_behavior=True),
            'sneeze': Sneeze(name='sneeze', reachy=self.reachy, sub_behavior=True),
            'whistle': Whistle(name='whistle', reachy=self.reachy, sub_behavior=True),
            'hello': Hello(name='hello', reachy=self.reachy, sub_behavior=True),
            # Add your new behavior here :
            # 'NEW_BEHAVIOR': NewBehavior(name='new_behavior', reachy=self.reachy, sub_behavior=True),
        }

hello-world's People

Contributors

simheo avatar glannuzel avatar

Stargazers

Melik Alp Özcelik avatar Sören avatar Nathan Segers avatar

Watchers

Pierre Rouanet avatar Matthieu Lapeyre avatar Nathan Segers avatar

hello-world's Issues

Clean repo.

There are multiple unnecessary notebooks currently in the repo.

Add logging.

  • when starting the app
  • when connecting to the robot
  • inform the behavior it is playing

Add a notebook to play behaviors.

This would be helpful to play behavior without having to use the application which plays the behaviors randomly.
This would help the user to identify each behavior currently implemented and to develop new ones.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.