Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilizing Pepper's head #93

Open
pmdoll opened this issue May 17, 2019 · 0 comments
Open

Stabilizing Pepper's head #93

pmdoll opened this issue May 17, 2019 · 0 comments

Comments

@pmdoll
Copy link

pmdoll commented May 17, 2019

Good morning,

I have a short program to control pepper's head movements but sometimes the head "springs" back to it's original state. I want pepper's head to stay at it's last position until I send the next command.

The pepper's head stays in it's given position until she sees a person. After that it seems as though autonomous life is kicked in but printed statements say otherwise.

Also, is it possible to control pepper's head movement via ROS? If so, how?
Thanks

#!/usr/bin/env python

# -*- encoding: UTF-8 -*-

import time
import almath
import argparse
from naoqi import ALProxy
from pprint import pprint

tts = None
motion = None
posture = None
autonomouslife = None
basicawareness = False
fractionMaxSpeed = 0.1


def init(robotIP, PORT):
    global tts, motion, posture, autonomouslife, basicawareness
    tts = ALProxy("ALTextToSpeech", robotIP, PORT)
    autonomouslife = ALProxy("ALAutonomousLife", robotIP, PORT)
    basicawareness = ALProxy("ALBasicAwareness", robotIP, PORT)
    motion = ALProxy("ALMotion", robotIP, PORT)
    posture = ALProxy("ALRobotPosture", robotIP, PORT)


def say(something_to_say):
    tts.say(str(something_to_say))


def standup():
    say('Standing up')
    posture.goToPosture("Stand", 5)
    time.sleep(4.0)
    say('I am ready')


def set_head_stiffness(value=0):
    say('Setting heading stiffness to ' + str(value))
    motion.setStiffnesses("Head", value)
    time.sleep(1.0)


def head_yaw(angle):

    names = "HeadYaw"
    angles = angle * almath.TO_RAD
    say('setting head yaw to ' + str(angle) + 'degrees')
    # motion.setAngles(names, angles, fractionMaxSpeed)
    motion.angleInterpolation(names, angles, 3.0, True)
    time.sleep(2.0)

    say('done head yaw')


def head_pitch(angle):

    names = "HeadPitch"
    angles = angle * almath.TO_RAD
    say('setting head pitch to ' + str(angle) + 'degrees')
    # motion.setAngles(names, angles, fractionMaxSpeed)
    motion.angleInterpolation(names, angles, 3.0, True)
    time.sleep(2.0)

    say('done head pitch')


def check_auto_life():
    st = autonomouslife.getAutonomousAbilitiesStatus()
    pprint(st)
    print '\n\n'
    tts.say('auto life is ' + autonomouslife.getState())


def main(angle, robotIP, PORT=9559):
    init(robotIP, PORT)
    al_state = autonomouslife.getState()
    if al_state != 'disabled':
        say('auto life is ' + al_state)
        autonomouslife.setState('disabled')

    check_auto_life()

    tts.say('disabling basic life awareness')
    basicawareness.setEnabled(False)
    basicawareness.pauseAwareness()
    basicawareness.setStimulusDetectionEnabled('People', False)

    standup()
    set_head_stiffness(0.5)
    head_pitch(0)
    head_yaw(0)

    check_auto_life()

    head_pitch(angle)
    check_auto_life()
    head_pitch(0)

    head_yaw(angle)
    check_auto_life()
    head_yaw(0)
    head_pitch(0)
    w = 3
    say('Waiting for ' + str(w) + ' seconds')
    check_auto_life()
    time.sleep(w)
    say('Bye bye ')
    check_auto_life()


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--ip", type=str, default="192.168.11.182",
                        help="Robot ip address")
    parser.add_argument("--port", type=int, default=9559,
                        help="Robot port number")
    parser.add_argument("--angle", type=float, default=0,
                        help="Head angle in degrees")

    args = parser.parse_args()
    main(args.angle, args.ip, args.port)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant