Skip to content

Commit 30a6c9b

Browse files
authored
Merge branch 'main' into feature/stabilize_x_offset
2 parents 2a45787 + 00f15a8 commit 30a6c9b

File tree

4 files changed

+45
-15
lines changed

4 files changed

+45
-15
lines changed

bitbots_lowlevel/bitbots_ros_control/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ find_package(controller_manager REQUIRED)
1616
find_package(diagnostic_msgs REQUIRED)
1717
find_package(dynamixel_workbench_toolbox REQUIRED)
1818
find_package(hardware_interface REQUIRED)
19+
find_package(moveit_core REQUIRED)
20+
find_package(moveit_ros_planning REQUIRED)
1921
find_package(pluginlib REQUIRED)
2022
find_package(rclcpp REQUIRED)
2123
find_package(realtime_tools REQUIRED)
@@ -60,6 +62,8 @@ ament_target_dependencies(
6062
diagnostic_msgs
6163
dynamixel_workbench_toolbox
6264
hardware_interface
65+
moveit_core
66+
moveit_ros_planning
6367
pluginlib
6468
rclcpp
6569
realtime_tools

bitbots_lowlevel/bitbots_ros_control/include/bitbots_ros_control/dynamixel_servo_hardware_interface.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class DynamixelServoHardwareInterface : public bitbots_ros_control::HardwareInte
7070
unsigned int joint_count_;
7171

7272
std::vector<std::string> joint_names_;
73+
std::vector<double> lower_joint_limits_;
74+
std::vector<double> upper_joint_limits_;
7375

7476
std::vector<double> goal_position_;
7577
std::vector<double> goal_effort_;

bitbots_lowlevel/bitbots_ros_control/src/dynamixel_servo_hardware_interface.cpp

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#include <moveit/robot_model/robot_model.h>
2+
#include <moveit/robot_model_loader/robot_model_loader.h>
3+
14
#include <bitbots_ros_control/dynamixel_servo_hardware_interface.hpp>
25
#include <bitbots_ros_control/utils.hpp>
36
#include <utility>
@@ -63,6 +66,18 @@ bool DynamixelServoHardwareInterface::init() {
6366
joint_map_[joint_names_[i]] = i;
6467
}
6568

69+
// read lower and upper limits
70+
robot_model_loader::RobotModelLoader rml(nh_, "robot_description", false);
71+
moveit::core::RobotModelPtr model = rml.getModel();
72+
lower_joint_limits_.resize(joint_count_);
73+
upper_joint_limits_.resize(joint_count_);
74+
for (const std::string &joint_name : joint_names_) {
75+
moveit::core::JointModel *jm = model->getJointModel(joint_name);
76+
// we use getVariableBounds()[0] because there is only a single variable for all of our joints
77+
lower_joint_limits_[joint_map_[joint_name]] = jm->getVariableBounds()[0].min_position_;
78+
upper_joint_limits_[joint_map_[joint_name]] = jm->getVariableBounds()[0].max_position_;
79+
}
80+
6681
std::string control_mode;
6782
control_mode = nh_->get_parameter("servos.control_mode").as_string();
6883
RCLCPP_INFO(nh_->get_logger(), "Control mode: %s", control_mode.c_str());
@@ -88,10 +103,19 @@ void DynamixelServoHardwareInterface::commandCb(const bitbots_msgs::msg::JointCo
88103
RCLCPP_ERROR(nh_->get_logger(), "Dynamixel Controller got command with inconsistent array lengths.");
89104
return;
90105
}
91-
// todo improve performance
92106
for (unsigned int i = 0; i < command_msg.joint_names.size(); i++) {
93107
int joint_id = joint_map_[command_msg.joint_names[i]];
94-
goal_position_[joint_id] = command_msg.positions[i];
108+
if (command_msg.positions[i] > upper_joint_limits_[joint_id] ||
109+
command_msg.positions[i] < lower_joint_limits_[joint_id]) {
110+
RCLCPP_WARN_STREAM(nh_->get_logger(), "Invalid position for " << command_msg.joint_names[i] << ": "
111+
<< command_msg.positions[i] << " not in ("
112+
<< lower_joint_limits_[joint_id] << ", "
113+
<< upper_joint_limits_[joint_id] << ")");
114+
goal_position_[joint_id] =
115+
std::clamp(command_msg.positions[i], lower_joint_limits_[joint_id], upper_joint_limits_[joint_id]);
116+
} else {
117+
goal_position_[joint_id] = command_msg.positions[i];
118+
}
95119
goal_velocity_[joint_id] = command_msg.velocities[i];
96120
goal_acceleration_[joint_id] = command_msg.accelerations[i];
97121
goal_effort_[joint_id] = command_msg.max_currents[i];

bitbots_wolfgang/wolfgang_description/urdf/robot.urdf

+13-13
Original file line numberDiff line numberDiff line change
@@ -724,15 +724,15 @@
724724
<axis xyz="0.0 0.0 1.0"/>
725725
<parent link="r_upper_arm"/>
726726
<child link="r_lower_arm"/>
727-
<limit effort="7.3" lower="-1.0472" upper="1.5708" velocity="8.17"/>
727+
<limit effort="7.3" lower="-0.78" upper="1.5708" velocity="8.17"/>
728728
<dynamics damping="0.65" friction="1.73"/>
729729
</joint>
730730
<joint name="RShoulderRoll" type="revolute">
731731
<origin rpy="1.5708 8.32338e-16 -1.5708" xyz="-0.01695 0.042 0.0"/>
732732
<axis xyz="-0.0 -0.0 -1.0"/>
733733
<parent link="r_shoulder"/>
734734
<child link="r_upper_arm"/>
735-
<limit effort="7.3" lower="0.0" upper="3.14159" velocity="8.17"/>
735+
<limit effort="7.3" lower="-0.12" upper="3.1416" velocity="8.17"/>
736736
<dynamics damping="0.65" friction="1.73"/>
737737
</joint>
738738
<joint name="RShoulderPitch" type="revolute">
@@ -1079,15 +1079,15 @@
10791079
<axis xyz="0.0 0.0 1.0"/>
10801080
<parent link="l_upper_arm"/>
10811081
<child link="l_lower_arm"/>
1082-
<limit effort="7.3" lower="-1.5708" upper="1.0472" velocity="8.17"/>
1082+
<limit effort="7.3" lower="-1.5708" upper="0.78" velocity="8.17"/>
10831083
<dynamics damping="0.65" friction="1.73"/>
10841084
</joint>
10851085
<joint name="LShoulderRoll" type="revolute">
10861086
<origin rpy="-1.5708 -5.19331e-15 1.5708" xyz="-0.01695 0.042 -2.77556e-17"/>
10871087
<axis xyz="-0.0 -0.0 -1.0"/>
10881088
<parent link="l_shoulder"/>
10891089
<child link="l_upper_arm"/>
1090-
<limit effort="7.3" lower="-3.14159" upper="0.0" velocity="8.17"/>
1090+
<limit effort="7.3" lower="-3.1416" upper="0.12" velocity="8.17"/>
10911091
<dynamics damping="0.65" friction="1.73"/>
10921092
</joint>
10931093
<joint name="LShoulderPitch" type="revolute">
@@ -2204,7 +2204,7 @@
22042204
<axis xyz="0.0 -1.0 0.0"/>
22052205
<parent link="r_ankle"/>
22062206
<child link="r_foot"/>
2207-
<limit effort="10" lower="-0.63" upper="1.58" velocity="5.76"/>
2207+
<limit effort="10" lower="-1.4" upper="1.58" velocity="5.76"/>
22082208
<dynamics damping="1.23" friction="2.55"/>
22092209
</joint>
22102210
<joint name="RAnklePitch" type="revolute">
@@ -2220,23 +2220,23 @@
22202220
<axis xyz="-0.0 -1.0 -0.0"/>
22212221
<parent link="r_upper_leg"/>
22222222
<child link="r_lower_leg"/>
2223-
<limit effort="12.9" lower="-2.88" upper="0.0" velocity="3.87"/>
2223+
<limit effort="12.9" lower="-2.8" upper="0.2" velocity="3.87"/>
22242224
<dynamics damping="2.92" friction="1.49"/>
22252225
</joint>
22262226
<joint name="RHipPitch" type="revolute">
22272227
<origin rpy="-1.5708 1.5708 0.0" xyz="-0.0265 -9.71445e-17 -0.0691"/>
22282228
<axis xyz="-0.0 1.0 -0.0"/>
22292229
<parent link="r_hip_2"/>
22302230
<child link="r_upper_leg"/>
2231-
<limit effort="10" lower="-2.246" upper="0.9" velocity="5.76"/>
2231+
<limit effort="10" lower="-2.77" upper="0.79" velocity="5.76"/>
22322232
<dynamics damping="1.23" friction="2.55"/>
22332233
</joint>
22342234
<joint name="RHipRoll" type="revolute">
22352235
<origin rpy="-3.14159 1.5708 0.0" xyz="-0.046 0.0414 6.93889e-18"/>
22362236
<axis xyz="-0.0 -0.0 -1.0"/>
22372237
<parent link="r_hip_1"/>
22382238
<child link="r_hip_2"/>
2239-
<limit effort="10" lower="-1.769" upper="0.871" velocity="5.76"/>
2239+
<limit effort="10" lower="-1.9" upper="1.6" velocity="5.76"/>
22402240
<dynamics damping="1.23" friction="2.55"/>
22412241
</joint>
22422242
<joint name="RHipYaw" type="revolute">
@@ -3353,7 +3353,7 @@
33533353
<axis xyz="-0.0 -1.0 -0.0"/>
33543354
<parent link="l_ankle"/>
33553355
<child link="l_foot"/>
3356-
<limit effort="10" lower="-1.58" upper="0.63" velocity="5.76"/>
3356+
<limit effort="10" lower="-1.58" upper="1.4" velocity="5.76"/>
33573357
<dynamics damping="1.23" friction="2.55"/>
33583358
</joint>
33593359
<joint name="LAnklePitch" type="revolute">
@@ -3369,23 +3369,23 @@
33693369
<axis xyz="-0.0 1.0 -0.0"/>
33703370
<parent link="l_upper_leg"/>
33713371
<child link="l_lower_leg"/>
3372-
<limit effort="12.9" lower="0" upper="2.88" velocity="3.87"/>
3372+
<limit effort="12.9" lower="-0.2" upper="2.8" velocity="3.87"/>
33733373
<dynamics damping="2.92" friction="1.49"/>
33743374
</joint>
33753375
<joint name="LHipPitch" type="revolute">
33763376
<origin rpy="2.67116e-16 -1.5708 0.0" xyz="0.026 6.93889e-18 -0.0691"/>
33773377
<axis xyz="7.95491e-17 -3.00167e-16 -1.0"/>
33783378
<parent link="l_hip_2"/>
33793379
<child link="l_upper_leg"/>
3380-
<limit effort="10" lower="-0.9" upper="2.246" velocity="5.76"/>
3380+
<limit effort="10" lower="-0.79" upper="2.77" velocity="5.76"/>
33813381
<dynamics damping="1.23" friction="2.55"/>
33823382
</joint>
33833383
<joint name="LHipRoll" type="revolute">
33843384
<origin rpy="3.14159 1.5708 0.0" xyz="-0.046 0.0414 6.93889e-18"/>
33853385
<axis xyz="-0.0 -0.0 -1.0"/>
33863386
<parent link="l_hip_1"/>
33873387
<child link="l_hip_2"/>
3388-
<limit effort="10" lower="-0.871" upper="1.769" velocity="5.76"/>
3388+
<limit effort="10" lower="-1.6" upper="1.9" velocity="5.76"/>
33893389
<dynamics damping="1.23" friction="2.55"/>
33903390
</joint>
33913391
<joint name="LHipYaw" type="revolute">
@@ -3622,7 +3622,7 @@
36223622
<axis xyz="-0.0 -0.0 1.0"/>
36233623
<parent link="neck"/>
36243624
<child link="head"/>
3625-
<limit effort="7.3" lower="-1.5708" upper="1.0472" velocity="8.17"/>
3625+
<limit effort="7.3" lower="-1.923" upper="1.24" velocity="8.17"/>
36263626
<dynamics damping="0.65" friction="1.73"/>
36273627
</joint>
36283628
<joint name="HeadPan" type="revolute">

0 commit comments

Comments
 (0)