rigid_model.cpp
Go to the documentation of this file.
00001 /*
00002  * rigid_model.cpp
00003  *
00004  *  Created on: Oct 21, 2009
00005  *      Author: sturm
00006  */
00007 
00008 #include "articulation_models/models/rigid_model.h"
00009 #include "articulation_models/utils.h"
00010 
00011 
00012 using namespace std;
00013 
00014 using namespace articulation_msgs;
00015 
00016 namespace articulation_models {
00017 
00018 void readParamsFromModel();
00019 void writeParamsToModel();
00020 
00021 RigidModel::RigidModel():GenericModel() {
00022         rigid_position = tf::Vector3(0,0,0);
00023         rigid_orientation = tf::Quaternion(0,0,0,1);
00024         rigid_width = 1;
00025         rigid_height = 1;
00026 
00027         complexity = 6;
00028 }
00029 
00030 void RigidModel::readParamsFromModel() {
00031         GenericModel::readParamsFromModel();
00032         getParam("rigid_position",rigid_position);
00033         getParam("rigid_orientation",rigid_orientation);
00034         getParam("rigid_width",rigid_width);
00035         getParam("rigid_height",rigid_height);
00036 }
00037 
00038 void RigidModel::writeParamsToModel() {
00039         GenericModel::writeParamsToModel();
00040         setParam("rigid_position",rigid_position,ParamMsg::PARAM);
00041         setParam("rigid_orientation",rigid_orientation,ParamMsg::PARAM);
00042         setParam("rigid_width",rigid_width,ParamMsg::PARAM);
00043         setParam("rigid_height",rigid_height,ParamMsg::PARAM);
00044 }
00045 
00046 geometry_msgs::Pose RigidModel::predictPose(V_Configuration q) {
00047         return transformToPose( tf::Transform(rigid_orientation,rigid_position) );
00048 }
00049 
00050 void RigidModel::projectConfigurationToChannels() {
00051         int ch_w = openChannel("width",false);
00052         int ch_h = openChannel("height",false);
00053 
00054         size_t n = model.track.pose.size();
00055         for(size_t i=0;i<n;i++) {
00056                 if(ch_w>=0) model.track.channels[ch_w].values[i] = rigid_width;
00057                 if(ch_h>=0) model.track.channels[ch_h].values[i] = rigid_height;
00058         }
00059 }
00060 
00061 bool RigidModel::guessParameters() {
00062         if(model.track.pose.size() == 0)
00063                 return false;
00064 
00065         size_t i = rand() % getSamples();
00066 
00067         tf::Transform pose = poseToTransform(model.track.pose[i]);
00068 
00069         rigid_position = pose.getOrigin();
00070         rigid_orientation = pose.getRotation();
00071         return true;
00072 }
00073 
00074 void RigidModel::updateParameters(std::vector<double> delta) {
00075         rigid_position = rigid_position + tf::Vector3(delta[0],delta[1],delta[2]);
00076         tf::Quaternion q;
00077         q.setEuler(delta[3],delta[4],delta[5]);
00078         rigid_orientation = rigid_orientation * q;
00079 }
00080 
00081 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


articulation_models
Author(s): Juergen Sturm
autogenerated on Wed Dec 26 2012 15:35:18