Search code examples
ros

rviz not publishing the camera topic


I want the robot on rviz to publish the camera topic. instead of the gazebo. cause I am facing some error spawning the robot in gazebo platfrom.But I don't know why launching the robot on the rviz platform does not publish the camera topic.

<launch>

  <!-- specify the planning pipeline -->
  <arg name="pipeline" default="ompl" />

  <!-- By default, we do not start a database (it can be large) -->
  <arg name="db" default="false" />
  <!-- Allow user to specify database location -->
  <arg name="db_path" default="$(find new_techman)/default_warehouse_mongo_db" />

  <!-- By default, we are not in debug mode -->
  <arg name="debug" default="false" />

  <!-- By default, we will load or override the robot_description -->
  <arg name="load_robot_description" default="true"/>

  <!-- Set execution mode for fake execution controllers -->
  <arg name="execution_type" default="interpolate" />

  <!--
  By default, hide joint_state_publisher's GUI

  MoveIt!'s "demo" mode replaces the real robot driver with the joint_state_publisher.
  The latter one maintains and publishes the current joint configuration of the simulated robot.
  It also provides a GUI to move the simulated robot around "manually".
  This corresponds to moving around the real robot without the use of MoveIt.
  -->
  <arg name="use_gui" default="false" />
  <arg name="use_rviz" default="true" />

  <!-- If needed, broadcast static tf for robot root -->


  <!-- We do not have a robot connected, so publish fake joint states -->
  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" unless="$(arg use_gui)">
    <rosparam param="source_list">[move_group/fake_controller_joint_states]</rosparam>
  </node>
  <node name="joint_state_publisher" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" if="$(arg use_gui)">
    <rosparam param="source_list">[move_group/fake_controller_joint_states]</rosparam>
  </node>

  <!-- Given the published joint states, publish tf for the robot links -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="true" output="screen" />

  <!-- Run the main MoveIt! executable without trajectory execution (we do not have controllers configured by default) -->
  <include file="$(find new_techman)/launch/move_group.launch">
    <arg name="allow_trajectory_execution" value="true"/>
    <arg name="fake_execution" value="true"/>
    <arg name="execution_type" value="$(arg execution_type)"/>
    <arg name="info" value="true"/>
    <arg name="debug" value="$(arg debug)"/>
    <arg name="pipeline" value="$(arg pipeline)"/>
    <arg name="load_robot_description" value="$(arg load_robot_description)"/>
  </include>

  <!-- Run Rviz and load the default config to see the state of the move_group node -->
  <include file="$(find new_techman)/launch/moveit_rviz.launch" if="$(arg use_rviz)">
    <arg name="rviz_config" value="$(find new_techman)/launch/moveit.rviz"/>
    <arg name="debug" value="$(arg debug)"/>
  </include>

  <!-- If database loading was enabled, start mongodb as well -->
  <include file="$(find new_techman)/launch/default_warehouse_db.launch" if="$(arg db)">
    <arg name="moveit_warehouse_database_path" value="$(arg db_path)"/>
  </include>

</launch>

this was my rviz launch file


Solution

  • But I don't know why launching the robot on the rviz platform does not publish the camera topic.

    That's easy: Because Rviz is a visualization tool and wasn't originally made for simulating a virtual environment. In other words: It can show you what the robot sees but it doesn't pretend to be the robot. Publishing a camera topic would basically mean that the visualized robot in Rviz pretends to see something itself: the Rviz-world.

    cause I am facing some error spawning the robot in gazebo platfrom.

    Other than Rviz, Gazebo is a very good choice for simulating a robot as well as designing an environment that a simulated robot-camera can see and publish. If you have trouble spawning the robot, you should probably look for a way to solve that rather than trying to use Rviz as simulation-tool.


    But there does seem to be a way to use Rviz for simulation, as stated here:

    rviz_camera_stream publishes an image rendered in rviz. It builds in jade at least, but likely works in hydro and indigo, and following the fork back leads to a pre-catkin version.

    It needs an input camera_info to get camera intrinsics and resolution. The distortion coefficients are ignored, but a image_proc like node that implements http://code.opencv.org/issues/1387 could address that downstream. (Do gazebo cameras support distortion yet? http://gazebosim.org/tutorials?tut=ca... says version 5.0 does)

    The input camera_info topic and output image topic are set in the rviz plugin gui.

    Old suggestion:

    One hacky solution is to run a screen grab node http://wiki.ros.org/screengrab_ros and position the rviz window just so, though it would be very brittle and hard to automate with launch files.