Interacting with Pepper

Control the robot's base and arms from a second terminal connected to the running simulation container.

Getting Started

1

Enter the Running Container

Open a new terminal window on your host machine and run this command to find the Pepper container and open a bash session inside it:

sudo docker exec -it $(sudo docker ps -q -f ancestor=ghcr.io/00ducky13/pepper_stage1_ros:latest) bash

Control Methods

A

Moving the Base (Command Line Publish)

rostopic pub

Pepper listens to the /pepper/cmd_vel namespace. To make the robot drive in a circle, publish a continuous velocity command at 10 Hz:

rostopic pub -r 10 /pepper/cmd_vel geometry_msgs/Twist "{linear: {x: 0.3, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.5}}"
Press Ctrl+C in the terminal to stop the command.
B

Keyboard Teleop (RC Car Mode)

teleop_twist_keyboard

Install the standard ROS teleop package inside the container and use topic remapping to route your keyboard strokes to Pepper's specific topic:

apt-get update && apt-get install ros-noetic-teleop-twist-keyboard -y
rosrun teleop_twist_keyboard teleop_twist_keyboard.py cmd_vel:=/pepper/cmd_vel

Keep that terminal window active and use these keys:

i forward   , backward   j turn left   l turn right   k stop

C

Python Script (Arm Control)

JointTrajectory

Unlike the base, Pepper's arms use JointTrajectory controllers. Create a Python file called wave_arm.py inside the container:

cat << 'EOF' > wave_arm.py
#!/usr/bin/env python3
import rospy
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint

def wave_arm():
    rospy.init_node('pepper_arm_commander', anonymous=True)

    # Publish to the Right Arm controller topic
    pub = rospy.Publisher('/pepper/RightArm_controller/command', JointTrajectory, queue_size=10)

    # Wait a second for the publisher to properly connect to Gazebo
    rospy.sleep(1)

    # Create the trajectory message
    traj = JointTrajectory()
    traj.joint_names = ['RShoulderPitch', 'RShoulderRoll', 'RElbowYaw', 'RElbowRoll', 'RWristYaw']

    # Target pose in radians
    point = JointTrajectoryPoint()
    point.positions = [0.0, -0.5, 0.0, 0.5, 0.0]
    point.time_from_start = rospy.Duration(2.0)

    traj.points.append(point)

    rospy.loginfo("Sending command to lift Pepper's right arm...")
    pub.publish(traj)

if __name__ == '__main__':
    try:
        wave_arm()
    except rospy.ROSInterruptException:
        pass
EOF

Make it executable and run it:

chmod +x wave_arm.py
./wave_arm.py
← Back to Setup Guide