Bab 139 Gaya Hidup Putraku Itu Perlu Diatur
Lima ratus peri bunga kecil menarik puluhan perahu daun dengan tali anggur dan resmi berlayar layaknya sebuah kereta api. Pemandangan ini sangat luar biasa, membuat hati Wang Li bergemuruh karena takjub!
Kelima perwakilan itu kembali naik ke perahu yang sama dengan Wang Li: "Prajurit yang terhormat, Kepala Suku menunjuk kami berlima untuk memimpin pasukan. Jika prajurit memiliki perintah, sampaikan saja kepada kami. Nama saya Taji Lulu. Keahlian terbesar saya adalah mengumpulkan embun pagi dan senja. Embun memiliki khasiat obat yang luar biasa."
"Nama saya Taji Guoguo. Saya ahli dalam menanam tanaman jenis bunga dan buah."
"Nama saya Taji Yueyue. Saya ahli dalam menanam beberapa tanaman cahaya bulan di bawah sinar rembulan, di mana tanaman cahaya bulan sering kali memiliki kekuatan sihir yang ajaib."
"Nama saya Taji Yangyang. Saya ahli dalam menanam tanaman jenis matahari yang sangat biasa. Jika prajurit ingin meningkatkan hasil panen pangan, datanglah kepada saya."
"Nama saya Taji Manman. Saya ahli dalam menanam semak berduri dan tanaman merambat untuk pertahanan. Dinding duri di desa semuanya dibudidayakan oleh saya. Jika prajurit membutuhkannya, saya dapat menanam lapiselg_nodelet/src/elg_nodelet.cpp
// *****************************************************************************
// CALLBACKS
// *****************************************************************************
void ElgNodelet::imageCallback(const sensor_msgs::ImageConstPtr& image_msg,
const sensor_msgs::CameraInfoConstPtr& cinfo_msg)
{
//ROS_INFO_STREAM("Callback triggered!");
//ROS_INFO_STREAM("Image format: " << image_msg->encoding);
// Convert ROS image to cv_image
cv_bridge::CvImageConstPtr cv_ptr;
try
{
cv_ptr = cv_bridge::toCvShare(image_msg);
}
catch (cv_bridge::Exception& e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
return;
}
if (cv_ptr->image.empty())
{
ROS_WARN("[ELG_NODELET] Received empty image");
return;
}
// Create new estimation object
cv::Mat gray;
cv::cvtColor(cv_ptr->image, gray, CV_BGR2GRAY);
elg::GazeEstimation gaze_estimation(cinfo_msg, gray);
// Predict gaze
gaze_estimation.predict();
// Publish gaze results
if (gaze_estimation.has_gaze())
{
// ROS_INFO_STREAM("Publishing Gaze!");
// Publish PointStamped
geometry_msgs::PointStamped point_msg;
point_msg.header = image_msg->header;
point_msg.point.x = gaze_estimation.gaze_point().x;
point_msg.point.y = gaze_estimation.gaze_point().y;
point_msg.point.z = gaze_estimation.gaze_point().z;
pub_gaze_point_.publish(point_msg);
// Publish Visualization
if (pub_gaze_vis_.getNumSubscribers() > 0)
{
cv::Mat vis_image = cv_ptr->image.clone();
gaze_estimation.visualize(vis_image);
sensor_msgs::ImagePtr vis_msg = cv_bridge::CvImage(
image_msg->header, "bgr8", vis_image).toImageMsg();
pub_gaze_vis_.publish(vis_msg);
}
}
}
} // namespace elg_nodelet
// Register nodelet
PLUGINLIB_EXPORT_CLASS(elg_nodelet::ElgNodelet, nodelet::Nodelet)
/******************************************************************************
* Copyright (c) 2018, Vision for Robotics Lab
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Vision for Robotics Lab, ETH Zurich nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Tiziano Guadagnino
* ****************************************************************************/
#include <elg_nodelet/elg_nodelet.h>
#include <pluginlib/class_list_macros.h>
#include <opencv2/imgproc.hpp>
#include <cv_bridge/cv_bridge.h>
#include <elg/gaze_estimation.h>
namespace elg_nodelet
{
// *****************************************************************************
// CONSTRUCTOR / DESTRUCTOR
// *****************************************************************************
ElgNodelet::ElgNodelet()
{
}
ElgNodelet::~ElgNodelet()
{
if (sub_image_transport_)
{
sub_image_transport_.shutdown();
}
}
// *****************************************************************************
// INITIALIZATION
// *****************************************************************************
void ElgNodelet::onInit()
{
// Get NodeHandles
ros::NodeHandle nh = getNodeHandle();
ros::NodeHandle priv_nh = getPrivateNodeHandle();
// Initialize ROS publishers
pub_gaze_point_ = nh.advertise<geometry_msgs::PointStamped>("gaze_point", 1);
image_transport::ImageTransport it(nh);
pub_gaze_vis_ = it.advertise("gaze_vis", 1);
// Initialize ImageTransport subscriber with camera info synchronizer
image_transport::TransportHints hints("raw", ros::TransportHints(), priv_nh);
int queue_size = 5;
priv_nh.param<int>("queue_size", queue_size, 5);
sub_image_.reset(new image_transport::SubscriberImage(it, "image", queue_size, hints));
sub_cinfo_.reset(new message_filters::Subscriber<sensor_msgs::CameraInfo>(nh, "camera_info", queue_size));
sync_.reset(new Sync(SyncPolicy(queue_size), *sub_image_, *sub_cinfo_));
sync_->registerCallback(boost::bind(&ElgNodelet::imageCallback, this, _1, _2));
ROS_INFO("[ELG_NODELET] Initialized successfully");
}elg_nodelet/launch/usb_cam.launch
<?xml version="1.0"?>
<launch>
<arg name="camera_name" default="usb_cam" />
<!-- USB Camera -->
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
<param name="video_device" value="/dev/video0" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="yuyv" />
<param name="camera_frame_id" value="$(arg camera_name)" />
<param name="io_method" value="mmap"/>
</node>
<!-- Nodelet Manager -->
<node pkg="nodelet" type="nodelet" name="elg_nodelet_manager" args="manager" output="screen"/>
<!-- ELG Nodelet -->
<node pkg="nodelet" type="nodelet" name="elg_nodelet"
args="load elg_nodelet/ElgNodelet elg_nodelet_manager" output="screen">
<remap from="image" to="/usb_cam/image_raw"/>
<remap from="camera_info" to="/usb_cam/camera_info"/>
</node>
<node name="rqt_image_view" pkg="rqt_image_view" type="rqt_image_view" />
</launch>
elg_nodelet/include/elg_nodelet/elg_nodelet.h
;
//! ROS Image Transport Subscribers
boost::shared_ptr<image_transport::SubscriberImage> sub_image_;
boost::shared_ptr<message_filters::Subscriber<sensor_msgs::CameraInfo> > sub_cinfo_;
image_transport::SubscriberFilter sub_image_transport_;
//! Message Filters Synchronizer
typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image,
sensor_msgs::CameraInfo> SyncPolicy;
typedef message_filters::Synchronizer<SyncPolicy> Sync;
boost::shared_ptr<Sync> sync_;
// *****************************************************************************
// CALLBACKS
// *****************************************************************************
void imageCallback(const sensor_msgs::ImageConstPtr& image_msg,
const sensor_msgs::CameraInfoConstPtr& cinfo_msg);
};
} // namespace elg_nodelet
#endif // ELG_NODELET_H
/******************************************************************************
* Copyright (c) 2018, Vision for Robotics Lab
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Vision for Robotics Lab, ETH Zurich nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Tiziano Guadagnino
* ****************************************************************************/
#ifndef ELG_NODELET_H
#define ELG_NODELET_H
#include <ros/ros.h>
#include <nodelet/nodelet.h>
#include <image_transport/image_transport.h>
#include <image_transport/subscriber_filter.h>
#include <message_filters/subscriber.h>
#include <message_filters/synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <geometry_msgs/PointStamped.h>
namespace elg_nodelet
{
class ElgNodelet : public nodelet::Nodelet
{
public:
ElgNodelet();
virtual ~ElgNodelet();
private:
virtual void onInit();
// *****************************************************************************
// ROS SUBSCRIPTIONS / PUBLICATIONS
// *****************************************************************************
//! ROS Publishers
ros::Publisher pub_gaze_point_;
image_transport::Publisher pub_gaze_vis_