38 #include <sensor_msgs/JointState.h> 41 #include "laser_assembler/AssembleScans2.h" 44 #include "sensor_msgs/PointCloud2.h" 64 sub_ =
n_.
subscribe(
"joint_states", 1000, &PeriodicSnapshotter::rotCallback,
this);
76 int getIndex(
const sensor_msgs::JointState::ConstPtr& e)
78 for (
size_t i = 0; i < e->name.size(); ++i)
80 if (e->name[i] ==
"laser_rot_joint")
86 void rotCallback(
const sensor_msgs::JointState::ConstPtr& e)
90 last_time_ = e->header.stamp;
95 int index = getIndex(e);
99 double position = fmod(e->position[index], 2 * M_PI);
101 if (!arm_ && position > 3) {
106 if(arm_ && position > 0 && position < 1) {
110 srv.request.begin = last_time_;
111 srv.request.end = e->header.stamp;
116 ROS_INFO(
"Published Cloud with %u points", srv.response.cloud.width * srv.response.cloud.height) ;
121 ROS_ERROR(
"Error making service call\n") ;
125 last_time_ = e->header.stamp;
143 int main(
int argc,
char **argv)
145 ros::init(argc, argv,
"rotunit_snapshotter");
147 ROS_INFO(
"Waiting for [assemble_scans2] to be advertised");
149 ROS_INFO(
"Found assemble_scans2! Starting the snapshotter");
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
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)
bool call(MReq &req, MRes &res)
ROSCPP_DECL void spin(Spinner &spinner)
ros::ServiceClient client_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int main(int argc, char **argv)
ROSCPP_DECL bool waitForService(const std::string &service_name, int32_t timeout)