.. _program_listing_file__tmp_ws_src_crane_plus_crane_plus_control_include_crane_plus_control_crane_plus_driver.hpp: Program Listing for File crane_plus_driver.hpp ============================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/crane_plus/crane_plus_control/include/crane_plus_control/crane_plus_driver.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2020 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 CRANE_PLUS_CONTROL__CRANE_PLUS_DRIVER_HPP_ #define CRANE_PLUS_CONTROL__CRANE_PLUS_DRIVER_HPP_ #include #include #include #include class CranePlusDriver { public: CranePlusDriver(const std::string port_name, const int baudrate, std::vector id_list); ~CranePlusDriver(); bool open_port(void); void close_port(void); std::string get_last_error_log(void); bool torque_enable(const bool enable); bool write_goal_joint_positions(const std::vector & goal_positions); bool write_moving_speed_rpm(const uint8_t dxl_id, const double speed_rpm); bool write_moving_speed_rpm_all(const double speed_rpm); bool read_present_joint_positions(std::vector & joint_positions); bool read_present_joint_speeds(std::vector & joint_speeds); bool read_present_joint_loads(std::vector & joint_loads); bool read_present_joint_voltages(std::vector & joint_voltages); bool read_present_joint_temperatures(std::vector & joint_temperatures); private: std::shared_ptr dxl_port_handler_; std::shared_ptr dxl_packet_handler_; int baudrate_; std::vector id_list_; std::string last_error_log_; bool read_byte_data_from_each_joints(const uint16_t address, std::vector & buffer); bool read_word_data_from_each_joints(const uint16_t address, std::vector & buffer); bool parse_dxl_error( const std::string func_name, const uint8_t dxl_id, const int dxl_comm_result, const uint8_t dxl_packet_error); double dxl_pos_to_radian(const uint16_t position); uint16_t radian_to_dxl_pos(const double position); double dxl_speed_to_rps(const uint16_t speed); double dxl_load_to_percent(const uint16_t load); double dxl_voltage_to_actual_voltage(const uint8_t voltage); }; #endif // CRANE_PLUS_CONTROL__CRANE_PLUS_DRIVER_HPP_