Skip to content

Commit 4cd050f

Browse files
authored
exposing the publishers to the user (#48)
1 parent 820ce18 commit 4cd050f

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

include/moveit_visual_tools/moveit_visual_tools.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <moveit_msgs/Grasp.h>
5353
#include <moveit_msgs/DisplayRobotState.h>
5454
#include <moveit_msgs/WorkspaceParameters.h>
55+
#include <moveit_msgs/DisplayTrajectory.h>
5556

5657
// ROS Messages
5758
#include <trajectory_msgs/JointTrajectory.h>
@@ -554,6 +555,7 @@ class MoveItVisualTools : public rviz_visual_tools::RvizVisualTools
554555
const moveit::core::RobotState& robot_state, bool blocking = false);
555556
bool publishTrajectoryPath(const moveit_msgs::RobotTrajectory& trajectory_msg,
556557
const moveit_msgs::RobotState& robot_state, bool blocking = false);
558+
void publishTrajectoryPath(const moveit_msgs::DisplayTrajectory& display_trajectory_msg);
557559

558560
/**
559561
* \brief Display a line of the end effector path from a robot trajectory path
@@ -633,14 +635,16 @@ class MoveItVisualTools : public rviz_visual_tools::RvizVisualTools
633635
* To use, add a RobotState marker to Rviz and subscribe to the DISPLAY_ROBOT_STATE_TOPIC, above
634636
* \param robot_state - joint values of robot
635637
* \param color - how to highlight the robot (solid-ly) if desired, default keeps color as specified in URDF
636-
* \param highlight_links - if the |color| is not |DEFAULT|, allows selective robot links to be highlighted. by default (empty) all links are highlighted
638+
* \param highlight_links - if the |color| is not |DEFAULT|, allows selective robot links to be highlighted. by
639+
* default (empty) all links are highlighted
637640
*/
638641
bool publishRobotState(const moveit::core::RobotState& robot_state,
639642
const rviz_visual_tools::colors& color = rviz_visual_tools::DEFAULT,
640643
const std::vector<std::string>& highlight_links = {});
641644
bool publishRobotState(const moveit::core::RobotStatePtr& robot_state,
642645
const rviz_visual_tools::colors& color = rviz_visual_tools::DEFAULT,
643646
const std::vector<std::string>& highlight_links = {});
647+
void publishRobotState(const moveit_msgs::DisplayRobotState& display_robot_state_msg);
644648

645649
/**
646650
* \brief Fake removing a Robot State display in Rviz by simply moving it very far away

src/moveit_visual_tools.cpp

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include <moveit_visual_tools/moveit_visual_tools.h>
3939

4040
// MoveIt Messages
41-
#include <moveit_msgs/DisplayTrajectory.h>
4241
#include <moveit_msgs/CollisionObject.h>
4342

4443
// MoveIt
@@ -1236,10 +1235,7 @@ bool MoveItVisualTools::publishTrajectoryPath(const moveit_msgs::RobotTrajectory
12361235
display_trajectory_msg.trajectory[0] = trajectory_msg;
12371236
display_trajectory_msg.trajectory_start = robot_state;
12381237

1239-
// Publish message
1240-
loadTrajectoryPub(); // always call this before publishing
1241-
pub_display_path_.publish(display_trajectory_msg);
1242-
ros::spinOnce();
1238+
publishTrajectoryPath(display_trajectory_msg);
12431239

12441240
// Wait the duration of the trajectory
12451241
if (blocking)
@@ -1266,6 +1262,14 @@ bool MoveItVisualTools::publishTrajectoryPath(const moveit_msgs::RobotTrajectory
12661262
return true;
12671263
}
12681264

1265+
void MoveItVisualTools::publishTrajectoryPath(const moveit_msgs::DisplayTrajectory& display_trajectory_msg)
1266+
{
1267+
// Publish message
1268+
loadTrajectoryPub(); // always call this before publishing
1269+
pub_display_path_.publish(display_trajectory_msg);
1270+
ros::spinOnce();
1271+
}
1272+
12691273
bool MoveItVisualTools::publishTrajectoryLine(const moveit_msgs::RobotTrajectory& trajectory_msg,
12701274
const moveit::core::LinkModel* ee_parent_link,
12711275
const robot_model::JointModelGroup* arm_jmg,
@@ -1439,7 +1443,8 @@ bool MoveItVisualTools::publishRobotState(const robot_state::RobotState& robot_s
14391443
const rviz_visual_tools::colors& color,
14401444
const std::vector<std::string>& highlight_links)
14411445
{
1442-
// when only a subset of links should be colored, the default message is used rather than the cached solid robot messages
1446+
// when only a subset of links should be colored, the default message is used rather than the cached solid robot
1447+
// messages
14431448
rviz_visual_tools::colors base_color = color;
14441449
if (!highlight_links.empty())
14451450
base_color = rviz_visual_tools::DEFAULT;
@@ -1491,9 +1496,7 @@ bool MoveItVisualTools::publishRobotState(const robot_state::RobotState& robot_s
14911496
}
14921497

14931498
// Publish
1494-
loadRobotStatePub();
1495-
pub_robot_state_.publish(display_robot_msg);
1496-
ros::spinOnce();
1499+
publishRobotState(display_robot_msg);
14971500

14981501
// remove highlight links from default message
14991502
if (!highlight_links.empty())
@@ -1502,6 +1505,13 @@ bool MoveItVisualTools::publishRobotState(const robot_state::RobotState& robot_s
15021505
return true;
15031506
}
15041507

1508+
void MoveItVisualTools::publishRobotState(const moveit_msgs::DisplayRobotState& robot_state_msg)
1509+
{
1510+
loadRobotStatePub();
1511+
pub_robot_state_.publish(robot_state_msg);
1512+
ros::spinOnce();
1513+
}
1514+
15051515
bool MoveItVisualTools::hideRobot()
15061516
{
15071517
static const std::string VJOINT_NAME = "virtual_joint";

0 commit comments

Comments
 (0)