This example may be run after building mrs_lib by executing rosrun mrs_lib rheiv_example
.
A plane surface model in the cartesian form will be used in this example. The parameters , , and are elements of the parameter vector .
#include <ros/ros.h>
{
const int n_states = 3;
const int n_params = 4;
using rheiv_t = RHEIV<n_states, n_params>;
}
mrs_lib::zs_t f_z(const mrs_lib::xs_t& xs)
{
return xs;
}
int main()
{
const mrs_lib::dzdx_t dzdx = mrs_lib::dzdx_t::Identity();
const int n_pts = 4;
mrs_lib::xs_t xs(3, n_pts);
xs <<
0, 1, 0, 10,
0, 0, 1, 0,
0, 0, 0, 0.001;
const mrs_lib::P_t P = mrs_lib::P_t::Identity();
mrs_lib::Ps_t Ps;
Ps.reserve(n_pts);
for (int it = 0; it < n_pts; it++)
Ps.push_back(P);
std::cout << "initializing object:" << std::endl;
std::cout << "running fit" << std::endl;
mrs_lib::theta_t theta;
try
{
theta = rheiv.fit(xs, Ps);
{
std::cerr <<
"Iteration failed with message '" << ex.
what() <<
"'." << std::endl;
std::cout << "using last valid theta" << std::endl;
theta = rheiv.get_last_estimate();
}
std::cout << "finished:" << std::endl << theta << std::endl;
}