26 : control_cycle_msec_(8),
43 result_[
"present_voltage"] = 0.0;
81 std::map<std::string, robotis_framework::Sensor *> sensors)
83 if (sensors[
"cm-740"] == NULL)
86 uint16_t gyro_x = sensors[
"cm-740"]->sensor_state_->bulk_read_table_[
"gyro_x"];
87 uint16_t gyro_y = sensors[
"cm-740"]->sensor_state_->bulk_read_table_[
"gyro_y"];
88 uint16_t gyro_z = sensors[
"cm-740"]->sensor_state_->bulk_read_table_[
"gyro_z"];
90 uint16_t acc_x = sensors[
"cm-740"]->sensor_state_->bulk_read_table_[
"acc_x"];
91 uint16_t acc_y = sensors[
"cm-740"]->sensor_state_->bulk_read_table_[
"acc_y"];
92 uint16_t acc_z = sensors[
"cm-740"]->sensor_state_->bulk_read_table_[
"acc_z"];
94 uint16_t present_volt = sensors[
"cm-740"]->sensor_state_->bulk_read_table_[
"present_voltage"];
109 uint8_t button_flag = sensors[
"cm-740"]->sensor_state_->bulk_read_table_[
"button"];
110 result_[
"button_mode"] = button_flag & 0x01;
111 result_[
"button_start"] = (button_flag & 0x02) >> 1;
116 result_[
"present_voltage"] = present_volt * 0.1;
125 return (raw_value - 512) * 500.0 * 2.0 / 1023 *
DEGREE2RADIAN;
131 return (raw_value - 512) * 4.0 * 2.0 / 1023;
138 imu_msg_.header.frame_id =
"body_link";
140 double filter_alpha = 0.4;
144 int _arrd_length = 2;
160 double roll = atan2(
result_[
"acc_y"],
162 double pitch = atan2(-result_[
"acc_x"],
163 sqrt(result_[
"acc_y"] * result_[
"acc_y"] + result_[
"acc_z"] * result_[
"acc_z"]));
168 imu_msg_.orientation.x = orientation.x();
169 imu_msg_.orientation.y = orientation.y();
170 imu_msg_.orientation.z = orientation.z();
171 imu_msg_.orientation.w = orientation.w();
178 std::string button_key =
"button_" + button_name;
179 std::string button_published =
"published_" + button_name;
181 bool pushed = (
result_[button_key] == 1.0);
185 if (pushed ==
true &&
buttons_[button_published] ==
false)
189 if (button_duration.
toSec() > 2.0)
209 if (button_duration.
toSec() < 2)
221 std_msgs::String button_msg;
222 button_msg.data = button_name;
225 publishStatusMsg(robotis_controller_msgs::StatusMsg::STATUS_INFO,
"Button : " + button_name);
230 double voltage_ratio = 0.4;
242 last_msg_time_ = now;
245 std::stringstream log_stream;
248 (present_volt_ < 11.0 ?
249 robotis_controller_msgs::StatusMsg::STATUS_WARN : robotis_controller_msgs::StatusMsg::STATUS_INFO),
257 robotis_controller_msgs::StatusMsg status_msg;
259 status_msg.type = type;
260 status_msg.module_name =
"SENSOR";
261 status_msg.status_msg = msg;
268 return alpha * x_new + (1.0 - alpha) * x_old;
void publish(const boost::shared_ptr< M > &message) const
ros::Publisher status_msg_pub_
Eigen::Quaterniond convertRPYToQuaternion(double roll, double pitch, double yaw)
void publishStatusMsg(unsigned int type, std::string msg)
std::map< std::string, bool > buttons_
boost::thread queue_thread_
ros::Publisher button_pub_
std::map< std::string, ros::Time > buttons_press_time_
double lowPassFilter(double alpha, double x_new, double x_old)
void publishButtonMsg(const std::string &button_name)
void handleVoltage(double present_volt)
std::map< std::string, double > result_
void process(std::map< std::string, robotis_framework::Dynamixel * > dxls, std::map< std::string, robotis_framework::Sensor * > sensors)
void setCallbackQueue(CallbackQueueInterface *queue)
double getAccValue(int raw_value)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void initialize(const int control_cycle_msec, robotis_framework::Robot *robot)
#define ROS_INFO_COND(cond,...)
double getGyroValue(int raw_value)
sensor_msgs::Imu imu_msg_
void handleButton(const std::string &button_name)