ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Controlling NAO's joints using actionlib with nao_controller

asked 2012-04-16 10:08:42 -0600

greczek_USC gravatar image

updated 2012-04-16 11:08:00 -0600

AHornung gravatar image

Hello, I am new to both the NAO ROS package and actionlib, and I am trying to test if I can control the NAO's joints using the action goals in nao_controller. I would like an example of how to form the goal object that is sent to the robot, i.e.:

client = actionlib.SimpleActionClient('joint_trajectory', JointTrajectoryAction)
goal = ???

Here is what I have been doing:

jt = JointAngleTrajectory()
jt.joint_names = ["HeadYaw", "HeadPitch"]
jt.joint_angles = [0, 0]
jt.times = [0.5, 0.5]
jtg = JointTrajectoryGoal()
jtg.trajectory = jt
jtag = JointTrajectoryActionGoal()
jtag.goal = jtg

But this gets me the error:

AttributeError: 'JointTrajectoryActionGoal' object has no attribute 'trajectory'

Could someone who has used nao_controller and/or actionlib before please clue me in on how to form this goal object? It would be nice to have an example to generalize to other goals in nao_controller like JointAnglesWithSpeedActionGoal.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-04-16 11:04:55 -0600

AHornung gravatar image

There are two nodes which already use the actionlib interface of nao_controller, you can have a look at them for example code: nao_remote/pose_manager to enter some default poses e.g. for teleoperation and nao_driver/test_joint_angles to test nao_controller.

Here's the relevant code from adjusted to your two joints:

goal = nao_msgs.msg.JointTrajectoryGoal()
goal.trajectory.joint_names = ["HeadYaw", "HeadPitch"]
point = JointTrajectoryPoint()
point.time_from_start = Duration(0.5)
point.positions = [0.0,0.0]
goal.trajectory.points = [point]

There are more examples in, e.g. moving a single joint to multiple keypoints or moving multiple joints to multiple keypoints.

edit flag offensive delete link more

Question Tools


Asked: 2012-04-16 10:08:42 -0600

Seen: 1,124 times

Last updated: Apr 16 '12