Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <joint_commander.h>
00026
00027 namespace calvin_joint_commander
00028 {
00029
00030 JointCommander::JointCommander()
00031 {
00032 dynamic_reconfigure::Server<calvin_joint_commander::JointCommanderConfig>::CallbackType f;
00033 f = boost::bind(&calvin_joint_commander::JointCommander::update_config, this, _1, _2);
00034 dynamic_reconfigure_server_.setCallback(f);
00035
00036
00037 kinect_pitch_controller_pub_ = nh_.advertise<std_msgs::Float64>("kinect_pitch_joint_controller/command", 1);
00038 webcam_pitch_controller_pub_ = nh_.advertise<std_msgs::Float64>("webcam_pitch_joint_controller/command", 1);
00039 joint_states_pub_ = nh_.advertise<sensor_msgs::JointState>("joint_states", 100);
00040 }
00041
00042 JointCommander::~JointCommander()
00043 {
00044 }
00045
00046 void JointCommander::update_config(calvin_joint_commander::JointCommanderConfig &new_config, uint32_t level)
00047 {
00048 config_ = new_config;
00049 }
00050
00051 void JointCommander::loop_once()
00052 {
00053 if (config_.publish_controller_commands)
00054 {
00055 std_msgs::Float64 control_msg;
00056
00057
00058
00059 control_msg.data = config_.kinect_pitch_joint;
00060 kinect_pitch_controller_pub_.publish(control_msg);
00061 control_msg.data = config_.webcam_pitch_joint;
00062 webcam_pitch_controller_pub_.publish(control_msg);
00063 }
00064
00065 if (config_.publish_joint_states)
00066 {
00067 sensor_msgs::JointState joint_state_msg;
00068 joint_state_msg.header.stamp = ros::Time::now();
00069 joint_state_msg.name.push_back("kinect_pitch_joint");
00070 joint_state_msg.position.push_back(config_.kinect_pitch_joint);
00071 joint_state_msg.name.push_back("webcam_pitch_joint");
00072 joint_state_msg.position.push_back(config_.webcam_pitch_joint);
00073 joint_states_pub_.publish(joint_state_msg);
00074 }
00075 }
00076
00077 }
00078
00079 int main(int argc, char** argv)
00080 {
00081 ros::init(argc, argv, "joint_commander");
00082 calvin_joint_commander::JointCommander joint_commander_node;
00083
00084 ros::Rate r(25.0);
00085 while (ros::ok())
00086 {
00087 ros::spinOnce();
00088 joint_commander_node.loop_once();
00089 r.sleep();
00090 }
00091
00092 return 0;
00093 }