.. _program_listing_file__tmp_ws_src_rt_manipulators_cpp_rt_manipulators_lib_include_hardware.hpp: Program Listing for File hardware.hpp ===================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/rt_manipulators_cpp/rt_manipulators_lib/include/hardware.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2021 RT Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef RT_MANIPULATORS_LIB_INCLUDE_HARDWARE_HPP_ #define RT_MANIPULATORS_LIB_INCLUDE_HARDWARE_HPP_ #include #include #include #include #include #include #include "joint.hpp" #include "hardware_joints.hpp" #include "hardware_communicator.hpp" namespace rt_manipulators_cpp { using JointGroupName = std::string; using JointName = std::string; class Hardware { public: explicit Hardware(const std::string device_name); ~Hardware(); bool load_config_file(const std::string& config_yaml); bool connect(const int baudrate = 3000000); void disconnect(); bool torque_on(const std::string& group_name); bool torque_off(const std::string& group_name); bool sync_read(const std::string& group_name); bool sync_write(const std::string& group_name); bool start_thread(const std::vector& group_names, const std::chrono::milliseconds& update_cycle_ms); bool stop_thread(); bool get_position(const uint8_t id, double& position); bool get_position(const std::string& joint_name, double& position); bool get_positions(const std::string& group_name, std::vector& positions); bool get_velocity(const uint8_t id, double& velocity); bool get_velocity(const std::string& joint_name, double& velocity); bool get_velocities(const std::string& group_name, std::vector& velocities); bool get_current(const uint8_t id, double& current); bool get_current(const std::string& joint_name, double& current); bool get_currents(const std::string& group_name, std::vector& currents); bool get_voltage(const uint8_t id, double& voltage); bool get_voltage(const std::string& joint_name, double& voltage); bool get_voltages(const std::string& group_name, std::vector& voltages); bool get_temperature(const uint8_t id, int8_t& temperature); bool get_temperature(const std::string& joint_name, int8_t& temperature); bool get_temperatures(const std::string& group_name, std::vector& temperatures); bool get_max_position_limit(const uint8_t & id, double & max_position_limit); bool get_min_position_limit(const uint8_t & id, double & min_position_limit); bool set_position(const uint8_t id, const double position); bool set_position(const std::string& joint_name, const double position); bool set_positions(const std::string& group_name, std::vector& positions); bool set_velocity(const uint8_t id, const double velocity); bool set_velocity(const std::string& joint_name, const double velocity); bool set_velocities(const std::string& group_name, std::vector& velocities); bool set_current(const uint8_t id, const double current); bool set_current(const std::string& joint_name, const double current); bool set_currents(const std::string& group_name, std::vector& currents); bool write_max_acceleration_to_group(const std::string& group_name, const double acceleration_rpss); bool write_max_velocity_to_group(const std::string& group_name, const double velocity_rps); bool write_position_pid_gain(const uint8_t id, const uint16_t p, const uint16_t i, const uint16_t d); bool write_position_pid_gain(const std::string& joint_name, const uint16_t p, const uint16_t i, const uint16_t d); bool write_position_pid_gain_to_group(const std::string& group_name, const uint16_t p, const uint16_t i, const uint16_t d); bool write_velocity_pi_gain(const uint8_t id, const uint16_t p, const uint16_t i); bool write_velocity_pi_gain(const std::string& joint_name, const uint16_t p, const uint16_t i); bool write_velocity_pi_gain_to_group(const std::string& group_name, const uint16_t p, const uint16_t i); protected: std::shared_ptr comm_; private: bool write_operating_mode(const std::string& group_name); bool limit_goal_velocity_by_present_position(const std::string& group_name); bool limit_goal_current_by_present_position(const std::string& group_name); bool create_sync_read_group(const std::string& group_name); bool create_sync_write_group(const std::string& group_name); void read_write_thread(const std::vector& group_names, const std::chrono::milliseconds& update_cycle_ms); hardware_joints::Joints joints_; std::map addr_sync_read_position_; std::map addr_sync_read_velocity_; std::map addr_sync_read_current_; std::map addr_sync_read_voltage_; std::map addr_sync_read_temperature_; bool thread_enable_; std::shared_ptr read_write_thread_; }; } // namespace rt_manipulators_cpp #endif // RT_MANIPULATORS_LIB_INCLUDE_HARDWARE_HPP_