tilt_transform.cpp
Go to the documentation of this file.
00001 #include<tf/transform_broadcaster.h>
00002 #include<ros/ros.h>
00003 #include<dynamixel_msgs/JointState.h>
00004 
00005 /* This node publishes the tf between the laser scan and the servo.  This is based on the angle published by the servo. */
00006 
00007 //Module that applies transform to laser scan of tilting hokuyo laser
00008 using namespace std;
00009 
00010 //global variables
00011 float pos;
00012 
00013 //Recieves position values from dynamixel servo and uses angle to apply transform to laser scan
00014 void obtainValues(const dynamixel_msgs::JointState &msg) 
00015 {
00016     //gets position from message
00017     pos = msg.current_pos;
00018     
00019     //perform transform
00020     static tf::TransformBroadcaster br;
00021     tf::Transform transform;
00022     transform.setOrigin( tf::Vector3(0.0, 0.0, 0.0) );
00023     tf::Quaternion q;
00024     q.setRPY(pos, 0, 0);
00025     transform.setRotation(q);
00026     br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "servo", "laser"));
00027 }
00028 
00029 //main
00030 int main(int argc, char **argv) 
00031 {
00032     //initialize
00033     ros::init(argc, argv, "tilt_transform");
00034     ros::NodeHandle nh;
00035   
00036     //subscirber to current position
00037     ros::Subscriber position_sub = nh.subscribe("/tilt_controller/state", 5, &obtainValues);
00038 
00039     //wait for updates in position
00040     ros::spin();
00041 }


spin_hokuyo
Author(s):
autogenerated on Sat Jun 8 2019 20:41:35