Skip to content

Commit

Permalink
[roseus] Add ros::rospack-plugins function. It is equivalent to
Browse files Browse the repository at this point in the history
`rospack plugins ...`

```lisp
(ros::rospack-plugins "nodelet" "plugin")
=>
(("laser_proc" . "/opt/ros/hydro/share/laser_proc/nodelets.xml") ("velodyne_driver" . "/opt/ros/hydro/share/velodyne_driver/nodelet_velodyne.xml") ("yocs_velocity_smoother" . "/opt/ros/hydro/share/yocs_velocity_smoother/plugins/nodelets.xml") ("jsk_perception" . "/home/lueda/ros/hydro/src/jsk-ros-pkg/jsk_recognition/jsk_perception/jsk_perception_nodelets.xml") ("image_rotate" . "/home/lueda/ros/hydro/src/image_pipeline/image_rotate/nodelet_plugins.xml") ("stereo_image_proc" . "/home/lueda/ros/hydro/src/image_pipeline/stereo_image_proc/nodelet_plugins.xml") ("depth_image_proc" . "/home/lueda/ros/hydro/src/image_pipeline/depth_image_proc/nodelet_plugins.xml") ("kobuki_bumper2pc" . "/opt/ros/hydro/share/kobuki_bumper2pc/plugins/nodelet_plugins.xml") ("kobuki_safety_controller" . "/opt/ros/hydro/share/kobuki_safety_controller/plugins/nodelet_plugins.xml") ("naoqi_sensors" . "/home/lueda/ros/hydro/src/ros_naoqi/naoqi_bridge/naoqi_sensors/naoqicamera_nodelet.xml") ("velodyne_pointcloud" . "/opt/ros/hydro/share/velodyne_pointcloud/nodelets.xml") ("pointcloud_to_laserscan" . "/home/lueda/ros/hydro/src/perception_pcl/pointcloud_to_laserscan/nodelets.xml") ("openni2_camera" . "/opt/ros/hydro/share/openni2_camera/openni2_nodelets.xml") ("resized_image_transport" . "/home/lueda/ros/hydro/src/jsk-ros-pkg/jsk_recognition/resized_image_transport/nodelet.xml") ("image_proc" . "/home/lueda/ros/hydro/src/image_pipeline/image_proc/nodelet_plugins.xml") ("uvc_camera" . "/opt/ros/hydro/share/uvc_camera/nodelet_uvc_camera.xml") ("openni_camera" . "/opt/ros/hydro/share/openni_camera/openni_nodelets.xml") ("yocs_cmd_vel_mux" . "/opt/ros/hydro/share/yocs_cmd_vel_mux/plugins/nodelets.xml") ("pcl_ros" . "/home/lueda/ros/hydro/src/perception_pcl/pcl_ros/pcl_nodelets.xml") ("prosilica_camera" . "/home/lueda/ros/hydro/src/prosilica_driver/prosilica_camera/plugins/nodelet_plugins.xml") ("jsk_topic_tools" . "/home/lueda/ros/hydro/src/jsk-ros-pkg/jsk_common/jsk_topic_tools/jsk_topic_tools_nodelet.xml") ("jsk_pcl_ros" . "/home/lueda/ros/hydro/src/jsk-ros-pkg/jsk_recognition/jsk_pcl_ros/jsk_pcl_nodelets.xml") ("image_view" . "/home/lueda/ros/hydro/src/image_pipeline/image_view/nodelet_plugins.xml") ("nodelet_tutorial_math" . "/opt/ros/hydro/share/nodelet_tutorial_math/nodelet_math.xml") ("imagesift" . "/home/lueda/ros/hydro/src/jsk-ros-pkg/jsk_recognition/imagesift/nodelet.xml"))
```
  • Loading branch information
garaemon committed Sep 18, 2015
1 parent 22cb71e commit 76d42de
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions roseus/roseus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/algorithm/string.hpp>

#include <ros/init.h>
#include <ros/time.h>
Expand Down Expand Up @@ -1386,6 +1387,52 @@ pointer ROSEUS_ROSPACK_FIND(register context *ctx,int n,pointer *argv)
return(NIL);
}

pointer ROSEUS_ROSPACK_PLUGINS(register context *ctx,int n,pointer *argv)
{
// (roseus-rospack-plugins package-name attibute-name)
ckarg(2);
string pkg, attrib;
numunion nu;
pointer ret, first;
if (isstring(argv[0])) pkg.assign((char *)get_string(argv[0]));
else error(E_NOSTRING);
if (isstring(argv[1])) attrib.assign((char *)get_string(argv[1]));
else error(E_NOSTRING);
try {
rospack::Rospack rp;
std::vector<std::string> search_path;
rp.getSearchPathFromEnv(search_path);
rp.crawl(search_path, 1);
std::vector<std::string> flags;
if (rp.plugins(pkg, attrib, "", flags)) {
ret = cons(ctx, NIL, NIL);
first = ret;
vpush(ret);
for (size_t i = 0; i < flags.size(); i++) {
std::vector<std::string> parsed_string;
boost::algorithm::split(parsed_string, flags[i], boost::is_any_of(" "));
std::string package = parsed_string[0];
std::string value = parsed_string[1];
// flags[i] = laser_proc /opt/ros/hydro/share/laser_proc/nodelets.xml
pointer tmp = cons(ctx, cons(ctx,
makestring((char*)package.c_str(), package.length()),
makestring((char*)value.c_str(), value.length())),
NIL);
ccdr(ret) = tmp;
ret = tmp;
}
vpop(); // ret
return ccdr(first);
}
else {
return(NIL);
}
}
catch (runtime_error &e) {
}
return(NIL);
}

pointer ROSEUS_RESOLVE_NAME(register context *ctx,int n,pointer *argv)
{
ckarg(1);
Expand Down Expand Up @@ -1742,6 +1789,7 @@ pointer ___roseus(register context *ctx, int n, pointer *argv, pointer env)
_defun(ctx,"HAS-PARAM",argv[0],(pointer (*)())ROSEUS_HAS_PARAM, "Check whether a parameter exists on the parameter server.");

_defun(ctx,"ROSPACK-FIND",argv[0],(pointer (*)())ROSEUS_ROSPACK_FIND, "Returns ros package path");
_defun(ctx,"ROSPACK-PLUGINS",argv[0],(pointer (*)())ROSEUS_ROSPACK_PLUGINS, "Returns plugins of ros packages");
_defun(ctx,"RESOLVE-NAME",argv[0],(pointer (*)())ROSEUS_RESOLVE_NAME, "Returns ros resolved name");
_defun(ctx,"GET-NAME",argv[0],(pointer (*)())ROSEUS_GETNAME, "Returns current node name");
_defun(ctx,"GET-NAMESPACE",argv[0],(pointer (*)())ROSEUS_GETNAMESPACE, "Returns current node name space");
Expand Down

0 comments on commit 76d42de

Please sign in to comment.