Skip to content

Commit 39451d8

Browse files
committed
Adapt joint names
Signed-off-by: Florian Vahl <florian@flova.de>
1 parent 57f7a09 commit 39451d8

5 files changed

Lines changed: 58 additions & 57 deletions

File tree

src/bitbots_misc/bitbots_teleop/bitbots_teleop/joy_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def joy_cb(self, msg: Joy):
224224
self.denormalize_joy(self.config["head"]["gain_tilt"], self.config["head"]["stick_tilt"], msg, -1)
225225
)
226226

227-
self.head_msg.joint_names = ["HeadPan", "HeadTilt"]
227+
self.head_msg.joint_names = ["head_yaw_joint", "head_pitch_joint"]
228228
self.head_msg.positions = [pan_goal, tilt_goal]
229229
self.head_pub.publish(self.head_msg)
230230

src/bitbots_misc/bitbots_teleop/scripts/teleop_keyboard.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def __init__(self):
144144
self.head_msg.max_torques = [-1.0] * 2
145145
self.head_msg.velocities = [5.0] * 2
146146
self.head_msg.accelerations = [40.0] * 2
147-
self.head_msg.joint_names = ["HeadPan", "HeadTilt"]
147+
self.head_msg.joint_names = ["head_yaw_joint", "head_pitch_joint"]
148148
self.head_msg.positions = [0.0] * 2
149149

150150
self.head_mode_msg = HeadMode(head_mode=HeadMode.DONT_MOVE)
@@ -194,9 +194,9 @@ def generate_kick_goal(self, x, y, direction):
194194
return kick_goal
195195

196196
def joint_state_cb(self, msg):
197-
if "HeadPan" in msg.name and "HeadTilt" in msg.name:
198-
self.head_pan_pos = msg.position[msg.name.index("HeadPan")]
199-
self.head_tilt_pos = msg.position[msg.name.index("HeadTilt")]
197+
if "head_yaw_joint" in msg.name and "head_pitch_joint" in msg.name:
198+
self.head_pan_pos = msg.position[msg.name.index("head_yaw_joint")]
199+
self.head_tilt_pos = msg.position[msg.name.index("head_pitch_joint")]
200200

201201
def loop(self):
202202
try:

src/bitbots_misc/bitbots_utils/scripts/motor_goals_viz_helper.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self):
1818
# get rid of additional ROS args when used in launch file
1919

2020
parser = argparse.ArgumentParser()
21-
parser.add_argument("--robot-type", "-t", help="What type of robot to use", default="wolfgang")
21+
parser.add_argument("--robot-type", "-t", help="What type of robot to use", default="piplus")
2222
parser.add_argument("--walking", "-w", help="Directly get walking motor goals", action="store_true")
2323
parser.add_argument("--animation", "-a", help="Directly get animation motor goals", action="store_true")
2424
parser.add_argument("--head", help="Directly get head motor goals", action="store_true")
@@ -100,28 +100,31 @@ def __init__(self):
100100
"neckYaw",
101101
"neckPitch",
102102
]
103-
self.joint_goals = [
104-
float(0),
105-
float(0),
106-
float(0),
107-
float(0),
108-
float(0),
109-
float(0),
110-
float(0),
111-
float(0),
112-
float(0),
113-
float(0),
114-
float(0),
115-
float(0),
116-
float(0),
117-
float(0),
118-
float(0),
119-
float(0),
120-
float(0),
121-
float(0),
122-
float(0),
123-
float(0),
103+
self.joint_goals = [0.0] * 20
104+
elif self.args.robot_type == "piplus":
105+
self.joint_names = [
106+
"head_yaw_joint",
107+
"head_pitch_joint",
108+
"l_shoulder_pitch_joint",
109+
"l_shoulder_roll_joint",
110+
"l_elbow_joint",
111+
"r_shoulder_pitch_joint",
112+
"r_shoulder_roll_joint",
113+
"r_elbow_joint",
114+
"l_hip_roll_joint",
115+
"l_hip_roll_joint",
116+
"l_hip_pitch_joint",
117+
"l_calf_joint",
118+
"l_ankle_pitch_joint",
119+
"l_ankle_roll_joint",
120+
"r_hip_roll_joint",
121+
"r_hip_roll_joint",
122+
"r_hip_pitch_joint",
123+
"r_calf_joint",
124+
"r_ankle_pitch_joint",
125+
"r_ankle_roll_joint",
124126
]
127+
self.joint_goals = [0.0] * 22
125128
else:
126129
print(f"Unknown robot type {self.args.robot_type}")
127130
exit()

src/bitbots_motion/bitbots_animation_rqt/bitbots_animation_rqt/record_ui.py

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,35 +95,33 @@ def __init__(self, context):
9595
# Motor hierarchy
9696
self._motor_hierarchy = { # TODO this should be a parameter / loaded from the urdf
9797
"Body": {
98-
"Head": ["HeadPan", "HeadTilt"],
98+
"Head": ["head_yaw_joint", "head_pitch_joint"],
9999
"Arms": {
100100
"Left": [
101-
"LShoulderPitch",
102-
"LShoulderRoll",
103-
"LElbow",
101+
"l_shoulder_pitch_joint",
102+
"l_shoulder_roll_joint",
103+
"l_elbow_joint",
104104
],
105105
"Right": [
106-
"RShoulderPitch",
107-
"RShoulderRoll",
108-
"RElbow",
106+
"r_shoulder_pitch_joint",
107+
"r_shoulder_roll_joint",
108+
"r_elbow_joint",
109109
],
110110
},
111111
"Legs": {
112112
"Left": [
113-
"LHipYaw",
114-
"LHipRoll",
115-
"LHipPitch",
116-
"LKnee",
117-
"LAnklePitch",
118-
"LAnkleRoll",
113+
"l_hip_roll_joint",
114+
"l_hip_pitch_joint",
115+
"l_calf_joint",
116+
"l_ankle_pitch_joint",
117+
"l_ankle_roll_joint",
119118
],
120119
"Right": [
121-
"RHipYaw",
122-
"RHipRoll",
123-
"RHipPitch",
124-
"RKnee",
125-
"RAnklePitch",
126-
"RAnkleRoll",
120+
"r_hip_roll_joint",
121+
"r_hip_pitch_joint",
122+
"r_calf_joint",
123+
"r_ankle_pitch_joint",
124+
"r_ankle_roll_joint",
127125
],
128126
},
129127
}
@@ -301,8 +299,8 @@ def connect_gui_callbacks(self) -> None:
301299
self._widget.actionAnimation_until_Frame.triggered.connect(self.play_until)
302300
self._widget.actionDuplicate_Frame.triggered.connect(self.duplicate)
303301
self._widget.actionDelete_Frame.triggered.connect(self.delete)
304-
self._widget.actionLeft.triggered.connect(lambda: self.mirror_frame("R"))
305-
self._widget.actionRight.triggered.connect(lambda: self.mirror_frame("L"))
302+
self._widget.actionLeft.triggered.connect(lambda: self.mirror_frame("r"))
303+
self._widget.actionRight.triggered.connect(lambda: self.mirror_frame("l"))
306304
self._widget.actionInvert.triggered.connect(self.invert_frame)
307305
self._widget.actionUndo.triggered.connect(self.undo)
308306
self._widget.actionRedo.triggered.connect(self.redo)
@@ -588,12 +586,12 @@ def redo(self):
588586
self._widget.statusBar.showMessage(status)
589587
self.update_frames()
590588

591-
def mirror_frame(self, source: Literal["L", "R"]) -> None:
589+
def mirror_frame(self, source: Literal["l", "r"]) -> None:
592590
"""
593591
Copies all motor values from one side of the robot to the other. Inverts values, if necessary
594592
"""
595593
# Get direction to mirror to
596-
mirrored_source = {"R": "L", "L": "R"}[source]
594+
mirrored_source = {"r": "l", "l": "r"}[source]
597595

598596
# Go through all active motors
599597
for motor_name, angle in self._working_angles.items():
@@ -626,10 +624,10 @@ def invert_frame(self):
626624
# Go through all active motors
627625
for motor_name, angle in self._working_angles.items():
628626
# Check if the motor is on the right or left side and get the mirrored motor name
629-
if motor_name.startswith("R"):
630-
mirrored_motor_name = "L" + motor_name[1:]
631-
elif motor_name.startswith("L"):
632-
mirrored_motor_name = "R" + motor_name[1:]
627+
if motor_name.startswith("r"):
628+
mirrored_motor_name = "l" + motor_name[1:]
629+
elif motor_name.startswith("l"):
630+
mirrored_motor_name = "r" + motor_name[1:]
633631
else:
634632
# Just copy over if the motor is not on the left or right side
635633
mirrored_motors[motor_name] = angle

src/bitbots_motion/bitbots_head_mover/src/move_head.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ class HeadMover {
377377
// Send the motor goals including the position, speed and acceleration
378378
bitbots_msgs::msg::JointCommand pos_msg;
379379
pos_msg.header.stamp = rclcpp::Clock().now();
380-
pos_msg.joint_names = {"HeadPan", "HeadTilt"};
380+
pos_msg.joint_names = {"head_yaw_joint", "head_pitch_joint"};
381381
pos_msg.positions = {goal_pan, goal_tilt};
382382
pos_msg.velocities = {pan_speed, tilt_speed};
383383
pos_msg.accelerations = {params_.max_acceleration_pan, params_.max_acceleration_pan};
@@ -395,9 +395,9 @@ class HeadMover {
395395

396396
// Iterate over all joints and find the head pan and tilt joints
397397
for (size_t i = 0; i < current_joint_state_->name.size(); i++) {
398-
if (current_joint_state_->name[i] == "HeadPan") {
398+
if (current_joint_state_->name[i] == "head_yaw_joint") {
399399
head_pan = current_joint_state_->position[i];
400-
} else if (current_joint_state_->name[i] == "HeadTilt") {
400+
} else if (current_joint_state_->name[i] == "head_pitch_joint") {
401401
head_tilt = current_joint_state_->position[i];
402402
}
403403
}

0 commit comments

Comments
 (0)