Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot visualize anything in rviz by "visual_tools" #112

Open
Yan-Xiaodi opened this issue Dec 21, 2021 · 2 comments
Open

Cannot visualize anything in rviz by "visual_tools" #112

Yan-Xiaodi opened this issue Dec 21, 2021 · 2 comments

Comments

@Yan-Xiaodi
Copy link

Yan-Xiaodi commented Dec 21, 2021

Hello, recently I want to use the moveit_visual tools to visualize something(text、trajectory...),but it doesn't work ;I am confused about that;
The code is like below(part of) that I copyed from the moveit tutorials.

#include <moveit/move_group_interface/move_group_interface.h>
#include <moveit/planning_scene_interface/planning_scene_interface.h>

#include <moveit_msgs/DisplayRobotState.h>
#include <moveit_msgs/DisplayTrajectory.h>

#include <moveit_msgs/AttachedCollisionObject.h>
#include <moveit_msgs/CollisionObject.h>

#include <moveit_visual_tools/moveit_visual_tools.h>

int main(int argc, char** argv)
{
    ros::init(argc, argv, "move_group_interface_tutorial");
    ros::NodeHandle node_handle;
    ros::AsyncSpinner spinner(1);
    spinner.start();

    // BEGIN_TUTORIAL
    //
    // Setup
    // ^^^^^
    //
    // MoveIt operates on sets of joints called "planning groups" and stores them in an object called
    // the `JointModelGroup`. Throughout MoveIt the terms "planning group" and "joint model group"
    // are used interchangably.
    static const std::string PLANNING_GROUP = "xarm6";

    // The :move_group_interface:`MoveGroupInterface` class can be easily
    // setup using just the name of the planning group you would like to control and plan for.
    moveit::planning_interface::MoveGroupInterface move_group(PLANNING_GROUP);

    // We will use the :planning_scene_interface:`PlanningSceneInterface`
    // class to add and remove collision objects in our "virtual world" scene
    moveit::planning_interface::PlanningSceneInterface planning_scene_interface;

    // Raw pointers are frequently used to refer to the planning group for improved performance.
    const robot_state::JointModelGroup* joint_model_group =
        move_group.getCurrentState()->getJointModelGroup(PLANNING_GROUP);

    namespace rvt = rviz_visual_tools;
    moveit_visual_tools::MoveItVisualTools visual_tools("link_base");
    visual_tools.deleteAllMarkers();

    visual_tools.loadRemoteControl();

    Eigen::Isometry3d text_pose = Eigen::Isometry3d::Identity();
    text_pose.translation().z() = 1.0;

    ROS_INFO_NAMED("tutorial", "Planning frame: %s", move_group.getPlanningFrame().c_str());
    ROS_INFO_NAMED("tutorial", "End effector link: %s", move_group.getEndEffectorLink().c_str());
    ROS_INFO_NAMED("tutorial", "Available Planning Groups:");
    std::copy(move_group.getJointModelGroupNames().begin(),
            move_group.getJointModelGroupNames().end(), std::ostream_iterator<std::string>(std::cout, ", "));
            
    geometry_msgs::Pose target_pose1;
    geometry_msgs::PoseStamped armPose_now = move_group.getCurrentPose();
    target_pose1.orientation = armPose_now.pose.orientation;
    target_pose1.position.x = 0.28;
    target_pose1.position.y = 0.0;
    target_pose1.position.z = 0.4;
    move_group.setPoseTarget(target_pose1);

    moveit::planning_interface::MoveGroupInterface::Plan my_plan;

    bool success = (move_group.plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS);

    ROS_INFO_NAMED("tutorial", "Visualizing plan 1 (pose goal) %s", success ? "" : "FAILED");

    ROS_INFO_NAMED("tutorial", "Visualizing plan 1 as trajectory line");
    visual_tools.publishAxisLabeled(target_pose1, "pose1");
    visual_tools.publishText(text_pose, "Pose Goal", rvt::WHITE, rvt::XLARGE);
    visual_tools.publishTrajectoryLine(my_plan.trajectory_, joint_model_group);
    move_group.move();
    ...
}

image

Can someone help me about that? I search from google but cannot found the reason....Thanks~

@hlhfhmt
Copy link

hlhfhmt commented Feb 4, 2023

I have the same problem with you, visual_tools.publishTrajectoryLine() shows nothing. is there anyone who solved it? thanks.

@hlhfhmt
Copy link

hlhfhmt commented Feb 5, 2023

I add a MarkerArrray in Display panel, change the Marker topic with '/rviz_visual_tool'. Finally, it works. The text and marker appear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants