Problems trying to use RViz ViewController API
Hello everyone,
I'm trying to create a camera controller for RViz, which will allow me to track a flying target while standing stationary in the /map frame.
I found this topic and decided to use the ViewController API.
I wrote the following code:
#include <ros/ros.h>
#include <rviz/display.h>
#include "rviz/common.h"
#include "rviz/properties/forwards.h"
#include <last_letter_msgs/SimStates.h>
#define UPDATE_RATE 30
rviz::ViewController * cameraControls;
ros::Subscriber sub;
/////////////////////////////////////
// Callback to point camera to UAV //
/////////////////////////////////////
void pointCamera(const last_letter_msgs::SimStates& state){
float x = state.pose.position.x;
float y = state.pose.position.y;
float z = state.pose.position.z;
cameraControls.lookat(x,y,z);
}
//////////////////
//Main function //
//////////////////
int main(int argc, char **argv)
{
ros::init(argc, argv, "sceneControls");
ros::NodeHandle n;
sub = n.subscribe("states",1, pointCamera);
ros::Duration(10).sleep(); //wait for other nodes to get raised
ros::Rate spinner(UPDATE_RATE);
spinner.sleep();
cameraControls = VisualizationManager::getCurrentViewController;
ROS_INFO("sceneControls up");
while (ros::ok())
{
ros::spinOnce();
spinner.sleep();
if (isnan(uav.states.velocity.linear.x))
{
ROS_FATAL("State NAN detected on sceneControls!");
}
}
return 0;
}
However, I get this error message on catkin_make
:
In file included from /opt/ros/indigo/include/rviz/properties/status_property.h:32:0,
from /opt/ros/indigo/include/rviz/display.h:38,
from /home/george/catkin_ws/src/last_letter/last_letter/include/cameraController.hpp:2,
from /home/george/catkin_ws/src/last_letter/last_letter/src/cameraController.cpp:1:
/opt/ros/indigo/include/rviz/properties/property.h:34:19: fatal error: QObject: No such file or directory
#include <QObject>
^
compilation terminated.
make[2]: *** [last_letter/last_letter/CMakeFiles/cameraController.dir/src/cameraController.cpp.o] Error 1
make[1]: *** [last_letter/last_letter/CMakeFiles/cameraController.dir/all] Error 2
make: *** [all] Error 2
I'm running ROS Indigo on Ubuntu 14.04.2.
Thanks in advance!