Skip to content

Instantly share code, notes, and snippets.

@simonlynen
Created May 4, 2015 12:54
Show Gist options
  • Save simonlynen/04c2f8341208c335e49d to your computer and use it in GitHub Desktop.
Save simonlynen/04c2f8341208c335e49d to your computer and use it in GitHub Desktop.
view_controller_msgs::CameraPlacement camera_placement;
camera_placement.interpolation_mode =
view_controller_msgs::CameraPlacement::LINEAR;
camera_placement.target_frame = "map";
ros::NodeHandle node_handle("~");
ros::Publisher cp_publisher =
node_handle.advertise<view_controller_msgs::CameraPlacement>(
"/rviz/camera_placement", 10, true);
double rate = 4;
ros::Rate loop_rate(rate);
while(true) {
double radius = 30;
double t = ros::Time::now().toSec();
geometry_msgs::Point point;
point.x = radius * cos(2 * M_PI * t / rate);
point.y = radius * sin( 2 * M_PI * t / rate);
point.z = 10;
camera_placement.eye.point = point;
camera_placement.eye.header.frame_id = "rotating_frame";
geometry_msgs::Point look_at;
look_at.x = look_at.y = look_at.z = 0;
camera_placement.focus.point = look_at;
camera_placement.focus.header.frame_id = "map";
geometry_msgs::Vector3 up;
up.x = 0;
up.y = 0;
up.z = 1;
camera_placement.up.vector = up;
camera_placement.up.header.frame_id = "map";
camera_placement.time_from_start = ros::Duration(1/rate);
ros::spinOnce();
loop_rate.sleep();
cp_publisher.publish(camera_placement);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment