Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ class OpenArm_v10HW : public hardware_interface::SystemInterface {
void return_to_zero();
bool parse_config(const hardware_interface::HardwareInfo& info);
void generate_joint_names();
void set_current_pose();

// Gripper mapping functions
double joint_to_motor_radians(double joint_value);
Expand Down
17 changes: 15 additions & 2 deletions openarm_hardware/src/v10_simple_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ hardware_interface::CallbackReturn OpenArm_v10HW::on_activate(
std::this_thread::sleep_for(std::chrono::milliseconds(100));
openarm_->recv_all();

// Return to zero position
return_to_zero();
set_current_pose();

RCLCPP_INFO(rclcpp::get_logger("OpenArm_v10HW"), "OpenArm V10 activated");
return CallbackReturn::SUCCESS;
Expand Down Expand Up @@ -317,6 +316,20 @@ void OpenArm_v10HW::return_to_zero() {
openarm_->recv_all();
}

void OpenArm_v10HW::set_current_pose() {
RCLCPP_INFO(rclcpp::get_logger("OpenArm_v10HW"),
"Setting current position...");

// Use read() to populate state arrays
read(rclcpp::Time(), rclcpp::Duration(0, 0));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if CAN communication fails? Won't pos_states_ be left holding a stale or default value after read()?
Would it make sense to add a safety check?


// Copy current states to commands and zero velocities/torques
for (size_t i = 0; i < joint_names_.size(); ++i) {
pos_commands_[i] = pos_states_[i];
vel_commands_[i] = 0.0;
tau_commands_[i] = 0.0;
}
}
// Gripper mapping helper functions
double OpenArm_v10HW::joint_to_motor_radians(double joint_value) {
// Joint 0=closed -> motor 0 rad, Joint 0.044=open -> motor -1.0472 rad
Expand Down