33 #include <sensor_msgs/JointState.h> 34 #include <std_msgs/Float32.h> 35 #include <std_msgs/Empty.h> 36 #include <std_msgs/Int8.h> 75 int main(
int argc,
char** argv)
79 std::string name_prefix;
87 nh.
param<std::string>(
"name_prefix", name_prefix,
"left_hand");
103 sensor_msgs::JointState channel_pos;
104 channel_pos.name.resize(9);
105 channel_pos.position.resize(9, 0.0);
108 channel_pos.name[0] = name_prefix +
"_" +
"Thumb_Flexion";
109 channel_pos.name[1] = name_prefix +
"_" +
"Thumb_Opposition";
110 channel_pos.name[2] = name_prefix +
"_" +
"Index_Finger_Distal";
111 channel_pos.name[3] = name_prefix +
"_" +
"Index_Finger_Proximal";
112 channel_pos.name[4] = name_prefix +
"_" +
"Middle_Finger_Distal";
113 channel_pos.name[5] = name_prefix +
"_" +
"Middle_Finger_Proximal";
114 channel_pos.name[6] = name_prefix +
"_" +
"Ring_Finger";
115 channel_pos.name[7] = name_prefix +
"_" +
"Pinky";
116 channel_pos.name[8] = name_prefix +
"_" +
"Finger_Spread";
120 double normalized_time = 0;
146 for (
size_t channel = 0; channel < 9; ++channel)
148 double cur_pos = 0.0;
150 channel_pos.position[channel] = cur_pos;
157 double cur_pos = 0.4 + 0.3 * sin(normalized_time * 2 * 3.14);
160 channel_pos.position[8] = 0.3;
162 channel_pos.position[0] = 1 - cur_pos;
165 channel_pos.position[7] = cur_pos;
166 channel_pos.position[2] = cur_pos;
167 channel_pos.position[3] = cur_pos;
168 channel_pos.position[4] = cur_pos;
169 channel_pos.position[5] = cur_pos;
170 channel_pos.position[6] = cur_pos;
173 channel_pos_pub.
publish(channel_pos);
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
void runCallback(const std_msgs::Empty &)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void speedCallback(const std_msgs::Float32ConstPtr &msg)
ROSCPP_DECL void spinOnce()
void loopCallback(const std_msgs::Float32ConstPtr &msg)