Joint Control
Selected Joint
#include <iostream>
#include "bysense_joint.h" // Include the header file for the Joint class
int main() {
// Assuming joint IDs are integers from 1 to 12 for 12 joints
int joint_id = 1; // Change this value to access different joints (1 to 12)
// Create an instance of the Joint class for the specified joint ID
bysense::core::Joint selected_joint;
// Initialize the joint with the provided ID (assuming a constructor or initialization method exists)
myJoint.set_ID(joint_id); // Set the joint ID
// Set joint properties
selected_joint.set_position_rad(1.5); // Set the position to 1.5 radians
selected_joint.set_posmax_rad(2.0); // Set the maximum position to 2.0 radians
selected_joint.set_posmin_rad(0.0); // Set the minimum position to 0.0 radians
selected_joint.set_torque_Nm(10.0); // Set the torque to 10 Nm
selected_joint.set_max_torque_Nm(20.0); // Set the maximum torque to 20 Nm
selected_joint.set_velocity_rads(1.0); // Set the velocity to 1 rad/s
selected_joint.set_max_velocity_rads(5.0); // Set the maximum velocity to 5 rad/s
// Retrieve and display joint properties
std::cout << "Joint ID: " << selected_joint.get_ID() << std::endl;
std::cout << "Joint ID Name: " << selected_joint.get_IDnames() << std::endl;
std::cout << "Current Position (rad): " << selected_joint.get_position_rad() << std::endl;
std::cout << "Max Position (rad): " << selected_joint.get_posmax_rad() << std::endl;
std::cout << "Min Position (rad): " << selected_joint.get_posmin_rad() << std::endl;
std::cout << "Current Torque (Nm): " << selected_joint.get_torque_Nm() << std::endl;
std::cout << "Max Torque (Nm): " << selected_joint.get_max_torque_Nm() << std::endl;
std::cout << "Current Velocity (rad/s): " << selected_joint.get_velocity_rads() << std::endl;
std::cout << "Max Velocity (rad/s): " << selected_joint.get_max_velocity_rads() << std::endl;
std::cout << "Current Controller Temperature (°C): " << selected_joint.get_temp_controller_C() << std::endl;
std::cout << "Max Controller Temperature (°C): " << selected_joint.get_maxtemp_controller_C() << std::endl;
// Set PID controller values
selected_joint.set_kp(0.1); // Set proportional gain
selected_joint.set_ki(0.05); // Set integral gain
selected_joint.set_kd(0.01); // Set derivative gain
// Display PID controller values
std::cout << "Kp: " << selected_joint.get_kp() << std::endl;
std::cout << "Ki: " << selected_joint.get_ki() << std::endl;
std::cout << "Kd: " << selected_joint.get_kd() << std::endl;
return 0;
}
All Joints
Last updated