Skip to content

Commit a06d831

Browse files
committed
idk
1 parent 2aae0ff commit a06d831

File tree

3 files changed

+46
-41
lines changed

3 files changed

+46
-41
lines changed

src/arm_hardware_interface/include/arm_hardware_interface/ArmSerialProtocol.h

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ struct MotorConfigAxis1 {
3535
// ---------------------------------------------------------
3636
// Maximum acceleration for trajectory generation (revolutions/s^2)
3737
// Moteus Config: servo.default_accel_limit
38-
float max_acceleration = 20.0f;
38+
float max_acceleration = 0.5f;
3939

4040
// Maximum velocity limit (revolutions/s)
4141
// Moteus Config: servo.velocity_limit (soft) or servo.max_velocity (hard limit)
42-
float max_velocity = 10.0f;
42+
float max_velocity = 1.0f;
4343

4444
// Position Limits (revolutions)
4545
// Moteus Config: servopos.position_min / servopos.position_max
@@ -58,9 +58,9 @@ struct MotorConfigAxis1 {
5858
// 3. PID Tuning Parameters
5959
// ---------------------------------------------------------
6060
// Moteus Config: servo.pid_position.kp, ki, kd
61-
float kp = 50.0f;
61+
float kp = 10.0f;
6262
float ki = 0.0f;
63-
float kd = 1.0f;
63+
float kd = 0.0f;
6464

6565
// ---------------------------------------------------------
6666
// 4. Safety Limits (Voltage & Power)
@@ -105,16 +105,18 @@ struct MotorConfigAxis1 {
105105
};
106106

107107
struct MotorConfigAxis2 {
108-
float max_acceleration = 20.0f;
109-
float max_velocity = 10.0f;
108+
float max_acceleration = 0.5f;
109+
float max_velocity = 1.0f;
110110
float position_min = -10.0f;
111111
float position_max = 10.0f;
112-
float max_current_A = 0.0f; // Used to enforce Max Torque
113-
float kp = 50.0f;
112+
float max_current_A = 10.0f; // Used to enforce Max Torque
113+
float kp = 15.0f;
114114
float ki = 0.0f;
115-
float kd = 1.0f;
115+
float kd = 0.0f;
116116
float max_voltage = 26.0f;
117117
float max_power_W = 450.0f;
118+
float def_timeout = std::numeric_limits<double>::quiet_NaN();
119+
118120
// gear reduction
119121

120122
std::vector<std::pair<std::string, std::string>> get_configs() const {
@@ -128,23 +130,26 @@ struct MotorConfigAxis2 {
128130
{"servo.pid_position.ki", std::to_string(ki)},
129131
{"servo.pid_position.kd", std::to_string(kd)},
130132
{"servo.max_voltage", std::to_string(max_voltage)},
133+
{"servo.default_timeout_s", std::to_string(def_timeout)},
131134
{"servo.max_power_W", std::to_string(max_power_W)}};
132135
}
133136
};
134137

135138
struct MotorConfigAxis3 {
136-
float max_acceleration = std::numeric_limits<double>::quiet_NaN();
137-
float max_velocity = std::numeric_limits<double>::quiet_NaN();
139+
// float max_acceleration = std::numeric_limits<double>::quiet_NaN();
140+
float max_acceleration = 0.5;
141+
float max_velocity = 0.5;
142+
// float max_velocity = std::numeric_limits<double>::quiet_NaN();
138143
// float position_min = -12.0f;
139144
// float position_max = 10.0f;
140-
float position_min = std::numeric_limits<double>::quiet_NaN();
141-
float position_max = std::numeric_limits<double>::quiet_NaN();
142-
// float max_current_A = 20.0f; // Used to enforce Max Torque
143-
// float kp = 50.0f;
144-
// float ki = 0.0f;
145-
// float kd = 1.0f;
146-
// float max_voltage = 48.0f;
147-
// float max_power_W = 450.0f;
145+
float position_min = -10.0; //std::numeric_limits<double>::quiet_NaN();
146+
float position_max = 10.0; //std::numeric_limits<double>::quiet_NaN();
147+
float max_current_A = 4.0f; // Used to enforce Max Torque
148+
float kp = 15.0f; //1200 with reduction. accel 3
149+
float ki = 0.0f;
150+
float kd = 0.0f;
151+
float max_voltage = 26.0f;
152+
float max_power_W = 250.0f;
148153
// gear reduction
149154
float def_timeout = std::numeric_limits<double>::quiet_NaN();
150155

@@ -156,12 +161,12 @@ struct MotorConfigAxis3 {
156161
{"servopos.position_min", std::to_string(position_min)},
157162
{"servopos.position_max", std::to_string(position_max)},
158163
{"servo.default_timeout_s", std::to_string(def_timeout)},
159-
// {"servo.max_current_A", std::to_string(max_current_A)},
160-
// {"servo.pid_position.kp", std::to_string(kp)},
161-
// {"servo.pid_position.ki", std::to_string(ki)},
162-
// {"servo.pid_position.kd", std::to_string(kd)},
163-
// {"servo.max_voltage", std::to_string(max_voltage)},
164-
// {"servo.max_power_W", std::to_string(max_power_W)}
164+
{"servo.max_current_A", std::to_string(max_current_A)},
165+
{"servo.pid_position.kp", std::to_string(kp)},
166+
{"servo.pid_position.ki", std::to_string(ki)},
167+
{"servo.pid_position.kd", std::to_string(kd)},
168+
{"servo.max_voltage", std::to_string(max_voltage)},
169+
{"servo.max_power_W", std::to_string(max_power_W)}
165170
};
166171
}
167172
};
@@ -176,7 +181,7 @@ struct MotorConfigAxis4 {
176181
float ki = 0.0f;
177182
float kd = 1.0f;
178183
float max_voltage = 26.0f;
179-
float max_power_W = 450.0f;
184+
float max_power_W = 150.0f;
180185
// gear reduction
181186

182187
std::vector<std::pair<std::string, std::string>> get_configs() const {
@@ -204,7 +209,7 @@ struct MotorConfigAxis5 {
204209
float ki = 0.0f;
205210
float kd = 1.0f;
206211
float max_voltage = 26.0f;
207-
float max_power_W = 450.0f;
212+
float max_power_W = 150.0f;
208213
// gear reduction
209214

210215
std::vector<std::pair<std::string, std::string>> get_configs() const {
@@ -223,19 +228,19 @@ struct MotorConfigAxis5 {
223228
};
224229

225230
struct MotorConfigAxis6 {
226-
float max_acceleration = 20.0f;
227-
float max_velocity = 10.0f;
231+
float max_acceleration = 0.20f;
232+
float max_velocity = 1.5f;
228233
// float position_min = -10.0f;
229234
// float position_max = 10.0f;
230235
float position_min = std::numeric_limits<double>::quiet_NaN();
231236
float position_max = std::numeric_limits<double>::quiet_NaN();
232-
float max_current_A = 1.5f; // Used to enforce Max Torque
233-
float kp = 15.0f;
237+
float max_current_A = 0.5f; // Used to enforce Max Torque
238+
float kp = 0.01f;
234239
float ki = 0.0f;
235-
float kd = 1.0f;
240+
float kd = 0.0f;
236241
float max_voltage = 26.0f;
237-
float max_power_W = 450.0f;
238-
float gear_red = (1.0f);
242+
float max_power_W = 150.0f;
243+
float gear_red = (1.0f/66.0f);
239244

240245
// gear reduction
241246

src/arm_hardware_interface/src/MoteusInterface.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ArmSerial::ArmSerial() : Node("ArmSerialDriver") {
4444

4545
// Stop everything to clear faults and configure
4646
for (const auto &pair : controllers) {
47-
pair.second->SetStop();
47+
// pair.second->SetStop();
4848
RCLCPP_INFO(this->get_logger(), "moteuss jointsff %d", NUM_JOINTS);
4949
ConfigureMotor(pair.first, *pair.second);
5050
RCLCPP_INFO(this->get_logger(), "moteuaas jointsff %d", NUM_JOINTS);
@@ -478,12 +478,12 @@ void ArmSerial::send_velocity_command(float vel[NUM_JOINTS]) {
478478
// position_command.velocity = vel[pair.first - 1];
479479
RCLCPP_INFO(this->get_logger(), "vel %f id: %d", position_command.velocity, pair.first);
480480

481-
if (position_command.velocity == 0) {
482-
RCLCPP_INFO(this->get_logger(), "velocity stop %f", position_command.velocity);
483-
pair.second->SetStop();
484-
} else {
481+
// if (position_command.velocity == 0) {
482+
// RCLCPP_INFO(this->get_logger(), "velocity stop %f", position_command.velocity);
483+
// pair.second->SetStop();
484+
// } else {
485485
command_frames.push_back(pair.second->MakePosition(position_command));
486-
}
486+
// }
487487
}
488488

489489
// Now send them in a single call to Transport::Cycle.

src/external_pkgs/moteus_ros2

0 commit comments

Comments
 (0)