21 #include <std_msgs/String.h> 63 if (msg->data ==
"user_long")
76 if (set_port_result ==
false)
102 std_msgs::String init_msg;
103 init_msg.data =
"ini_pose";
105 g_init_pose_pub.
publish(init_msg);
116 uint8_t torque_result = 0;
117 bool torque_on =
true;
124 std::string default_device_name = map_it->second;
128 if (torque_result != 1)
132 if(torque_on ==
false)
142 int main(
int argc,
char **argv)
160 g_init_pose_pub = nh.
advertise<std_msgs::String>(
"/robotis/base/ini_pose", 0);
161 g_demo_command_pub = nh.
advertise<std_msgs::String>(
"/ball_tracker/command", 0);
167 if (g_is_simulation ==
false)
172 if (set_port_result ==
false)
178 int torque_on_count = 0;
180 while (torque_on_count < 5)
198 int led_full_unit = 0x1F;
200 int led_value = led_full_unit << led_range;
212 std::string robot_name;
213 nh.
param<std::string>(
"gazebo_robot_name", robot_name,
"");
214 if (robot_name !=
"")
218 if (g_robot_file ==
"")
220 ROS_ERROR(
"NO robot file path in the ROS parameters.");
225 if (controller->
initialize(g_robot_file, g_init_file) ==
false)
227 ROS_ERROR(
"ROBOTIS Controller Initialize Fail!");
232 if (g_offset_file !=
"")
254 std_msgs::String init_msg;
255 init_msg.data =
"ini_pose";
257 g_init_pose_pub.
publish(init_msg);
ros::Publisher g_init_pose_pub
virtual int read1ByteTxRx(PortHandler *port, uint8_t id, uint16_t address, uint8_t *data, uint8_t *error=0)=0
void initializeDevice(const std::string init_file_path)
void publish(const boost::shared_ptr< M > &message) const
void dxlTorqueCheckCallback(const std_msgs::String::ConstPtr &msg)
std::string gazebo_robot_name_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
const double PROTOCOL_VERSION
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
std::string g_device_name
void buttonHandlerCallback(const std_msgs::String::ConstPtr &msg)
void addMotionModule(MotionModule *module)
const int DXL_BROADCAST_ID
ROSCPP_DECL void spin(Spinner &spinner)
std::map< std::string, std::string > port_default_device_
virtual void closePort()=0
virtual const char * getRxPacketError(uint8_t error)=0
bool initialize(const std::string robot_file_path, const std::string init_file_path)
const std::string SUB_CONTROLLER_DEVICE
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void loadOffset(const std::string path)
virtual int write1ByteTxRx(PortHandler *port, uint8_t id, uint16_t address, uint8_t data, uint8_t *error=0)=0
const int RGB_LED_CTRL_TABLE
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::Publisher g_demo_command_pub
const int TORQUE_ON_CTRL_TABLE
void addSensorModule(SensorModule *module)
const int SUB_CONTROLLER_ID
virtual int write2ByteTxRx(PortHandler *port, uint8_t id, uint16_t address, uint16_t data, uint8_t *error=0)=0
const int POWER_CTRL_TABLE
int read1Byte(const std::string joint_name, uint16_t address, uint8_t *data, uint8_t *error=0)
virtual bool setBaudRate(const int baudrate)=0
std::string g_offset_file
void setCtrlModule(std::string module_name)