#include "rclcpp_lifecycle/state.hpp"
#include "std_srvs/srv/set_bool.hpp"
#include "std_msgs/msg/u_int8.hpp"
+#include "std_msgs/msg/bool.hpp"
#include "a4wd3_open_manipulator/srv/get_error.hpp"
#include "a4wd3_open_manipulator/srv/ir_temp.hpp"
void cbGetIrTemp(const std::shared_ptr<a4wd3_open_manipulator::srv::IrTemp::Request> req, std::shared_ptr<a4wd3_open_manipulator::srv::IrTemp::Response> res);
void light_callback(const std_msgs::msg::UInt8 msg);
+ void laser_callback(const std_msgs::msg::Bool msg);
bool torque_enable(bool enable);
rclcpp::Service<a4wd3_open_manipulator::srv::GetError>::SharedPtr get_error_service_;
rclcpp::Service<a4wd3_open_manipulator::srv::IrTemp>::SharedPtr get_temp_service_;
rclcpp::Subscription<std_msgs::msg::UInt8>::SharedPtr sub_light;
+ rclcpp::Subscription<std_msgs::msg::Bool>::SharedPtr sub_laser;
double cmd[NUM_JOINTS] = {NAN, NAN, NAN, NAN, NAN};
double cmd_pre[NUM_JOINTS] = {NAN, NAN, NAN, NAN, NAN};
get_error_service_ = get_node()->create_service<a4wd3_open_manipulator::srv::GetError>("get_error", std::bind(&A4wd3OpenManipulatorI2C::cbGetError, this, std::placeholders::_1, std::placeholders::_2));
get_temp_service_ = get_node()->create_service<a4wd3_open_manipulator::srv::IrTemp>("get_ir_temp", std::bind(&A4wd3OpenManipulatorI2C::cbGetIrTemp, this, std::placeholders::_1, std::placeholders::_2));
sub_light = get_node()->create_subscription<std_msgs::msg::UInt8>("/headlight", rclcpp::SystemDefaultsQoS(), std::bind(&A4wd3OpenManipulatorI2C::light_callback, this, std::placeholders::_1));
+ sub_laser = get_node()->create_subscription<std_msgs::msg::Bool>("/headpointer", rclcpp::SystemDefaultsQoS(), std::bind(&A4wd3OpenManipulatorI2C::laser_callback, this, std::placeholders::_1));
RCLCPP_INFO(get_logger(), "Configuration successful");
return hardware_interface::CallbackReturn::SUCCESS;
}
}
+// ros2 topic pub -1 /headpointer std_msgs/msg/Bool "{data: true}"
+void A4wd3OpenManipulatorI2C::laser_callback(const std_msgs::msg::Bool msg) {
+ if (dynamixel_writebyte(0x21, 0x3, static_cast<uint8_t>(msg.data)) != 1) {
+ RCLCPP_ERROR(get_logger(), "I2C AVR id=0x21 Laser");
+ }
+}
+
int A4wd3OpenManipulatorI2C::dynamixel_write(
uint8_t * write_data, int write_num, uint8_t * read_data, int read_num)
{