#include "rclcpp/rclcpp.hpp"
#include "rclcpp_lifecycle/state.hpp"
#include "std_srvs/srv/set_bool.hpp"
+#include "std_msgs/msg/u_int8.hpp"
#include "a4wd3_open_manipulator/srv/get_error.hpp"
#define I2C_FILE "/dev/i2c-7"
const std::shared_ptr<a4wd3_open_manipulator::srv::GetError::Request> req,
std::shared_ptr<a4wd3_open_manipulator::srv::GetError::Response> res);
+ void light_callback(const std_msgs::msg::UInt8 msg);
+
bool torque_enable(bool enable);
bool setup_dynamixels();
rclcpp::Service<std_srvs::srv::SetBool>::SharedPtr torque_enable_service_;
rclcpp::Service<a4wd3_open_manipulator::srv::GetError>::SharedPtr get_error_service_;
+ rclcpp::Subscription<std_msgs::msg::UInt8>::SharedPtr sub_light;
double cmd[NUM_JOINTS] = {NAN, NAN, NAN, NAN, NAN};
double cmd_pre[NUM_JOINTS] = {NAN, NAN, NAN, NAN, NAN};
"get_error", std::bind(
&A4wd3OpenManipulatorI2C::cbGetError, this, std::placeholders::_1,
std::placeholders::_2));
+ sub_light = get_node()->create_subscription<std_msgs::msg::UInt8>("/headlight", 10, std::bind(&A4wd3OpenManipulatorI2C::light_callback, this, std::placeholders::_1));
RCLCPP_INFO(get_logger(), "Configuration successful");
return hardware_interface::CallbackReturn::SUCCESS;
return ret;
}
+// ros2 topic pub -1 /headlight std_msgs/msg/UInt8 "{data: 1}"
+void A4wd3OpenManipulatorI2C::light_callback(const std_msgs::msg::UInt8 msg) {
+ if (dynamixel_writebyte(0x21, 0x1, msg.data) != 1) {
+ RCLCPP_ERROR(get_logger(), "I2C AVR id=0x21 LED");
+ }
+}
+
int A4wd3OpenManipulatorI2C::dynamixel_write(
uint8_t * write_data, int write_num, uint8_t * read_data, int read_num)
{