Skip to content

Commit a9150c8

Browse files
committed
stable
1 parent 1ab60e5 commit a9150c8

File tree

16 files changed

+529
-149
lines changed

16 files changed

+529
-149
lines changed

drv_brain/launch/includes/drv_workstation_v2.launch.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212

1313
<!-- broadcast transform among frames -->
1414
<node ns="$(arg vision_namespace)" name="drv_tf" pkg="drv_tf" type="drv_tf" output="screen">
15-
<param name="camera_frame_id" value="/$(arg camera_frame)" />
16-
<param name="root_frame_id" value="/$(arg base_link_frame)" />
15+
<param name="camera_frame_id" value="$(arg camera_frame)" />
16+
<param name="root_frame_id" value="$(arg base_link_frame)" />
1717

1818
<!-- Modify following values according to the structure of NVG 2.0 -->
1919
<param name="pitch_offset_value" value="90.0" />
2020

2121
<param name="dx_camera_to_pitch_value" value="0.0" />
22-
<param name="dy_camera_to_pitch_value" value="0.03" />
22+
<param name="dy_camera_to_pitch_value" value="0.06" />
2323
<param name="dz_camera_to_pitch_value" value="0.0" />
24-
<param name="dx_pitch_to_yaw_value" value="0.01" />
25-
<param name="dy_pitch_to_yaw_value" value="0.01" />
26-
<param name="dz_pitch_to_yaw_value" value="0.01" />
24+
<param name="dx_pitch_to_yaw_value" value="0.12" />
25+
<param name="dy_pitch_to_yaw_value" value="0.0" />
26+
<param name="dz_pitch_to_yaw_value" value="0.159" />
2727
</node>
2828

2929

@@ -32,15 +32,15 @@
3232
</node>
3333

3434
<!-- initialize user selection service -->
35-
<node name="drv_user" pkg="drv_user" type="drv_user.py" output="screen">
35+
<node ns="$(arg vision_namespace)" name="drv_user" pkg="drv_user" type="drv_user.py" output="screen">
3636
</node>
3737

3838
<!-- initialize search client -->
3939
<node ns="$(arg vision_namespace)" name="drv_search" pkg="drv_search" type="drv_search" output="screen">
4040
</node>
4141

4242
<!-- initialize tracking function -->
43-
<node ns="$(arg vision_namespace)" name="drv_track_node" pkg="drv_track" type="drv_track_node" output="screen">
43+
<node ns="$(arg vision_namespace)" name="drv_track_node" pkg="drv_track" type="drv_track_node">
4444
</node>
4545

4646
<!-- initialize grasp planning function -->
@@ -51,7 +51,7 @@
5151
</node>
5252

5353
<!-- initialize face recognition service -->
54-
<node name="drv_face_service" pkg="drv_face_service" type="drv_face_service" output="screen">
54+
<node ns="$(arg vision_namespace)" name="drv_face_service" pkg="drv_face_service" type="drv_face_service" output="screen">
5555
<param name="face_likehood_threshold" value="0.9"/>
5656
</node>
5757

@@ -61,7 +61,7 @@
6161

6262
<!-- initialize visualization -->
6363
<param name="use_gui" value="true"/>
64-
<node name="rviz" pkg="rviz" type="rviz" >
64+
<node ns="$(arg vision_namespace)" name="rviz" pkg="rviz" type="rviz" >
6565
</node>
6666

6767

drv_brain/src/drv_brain.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ void pubInfo(string info)
9191

9292
void teleOpCallback(const std_msgs::Int32MultiArrayConstPtr &msg)
9393
{
94-
if (msg->data.empty())
94+
if (msg->data.empty() || (msg->data[0] == 0 && msg->data[1] ==0))
9595
return;
9696

9797
int pitch_temp = pitchAngle_ + msg->data[0];
98-
if (pitch_temp < 40 || pitch_temp > 130)
98+
if (pitch_temp < 60 || pitch_temp > 140)
9999
return;
100100
else
101101
pitchAngle_ = pitch_temp;
@@ -153,14 +153,14 @@ void trackCallback(const std_msgs::BoolConstPtr &msg)
153153
{
154154
if (!msg->data)
155155
{
156-
ROS_INFO_THROTTLE(21, "Target lost!");
156+
ROS_INFO_THROTTLE(21, "Track report: Target lost!");
157157
foundTarget_ = false;
158158
ros::param::set(param_vision_feedback_track, -1);
159159
ros::param::set(param_vision_feedback, 1);
160160
}
161161
else
162162
{
163-
ROS_INFO_THROTTLE(21, "Tracking the target...");
163+
ROS_INFO_THROTTLE(21, "Track report: Tracking the target...");
164164
foundTarget_ = true;
165165
ros::param::set(param_vision_feedback_track, 1);
166166
ros::param::set(param_vision_feedback, 1);
@@ -174,13 +174,13 @@ void graspCallback(const std_msgs::BoolConstPtr &msg)
174174
{
175175
if (!msg->data)
176176
{
177-
ROS_INFO_THROTTLE(21, "Failed to locate the target.");
177+
ROS_INFO_THROTTLE(21, "Grasp report: Failed to locate the target.");
178178
ros::param::set(param_vision_feedback_grasp, -1);
179179
ros::param::set(param_vision_feedback, 1);
180180
}
181181
else
182182
{
183-
ROS_INFO_THROTTLE(21, "Target location confirmed.");
183+
ROS_INFO_THROTTLE(21, "Grasp report: Target location confirmed.");
184184
ros::param::set(param_vision_feedback_grasp, 1);
185185
ros::param::set(param_vision_feedback, 3);
186186
}
@@ -278,7 +278,7 @@ int main(int argc, char **argv)
278278
// Initialize servo position
279279
if (!servo_initialized_)
280280
{
281-
pubServo(70, 90);
281+
pubServo(90, 90);
282282
servo_initialized_ = true;
283283
ROS_INFO("Servo initialized.\n");
284284
}

drv_face_client/src/drv_face_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ int main(int argc, char **argv)
125125
image_transport::ImageTransport rgb_it(nh);
126126
facePubImage_ = rgb_it.advertise("search/labeled_image", 1);
127127

128-
image_transport::Subscriber sub_rgb = it_rgb_sub.subscribe("rgb/image_rect_color", 1, imageCallback, hints_rgb);
128+
image_transport::Subscriber sub_rgb = it_rgb_sub.subscribe("image_rect_color", 1, imageCallback, hints_rgb);
129129

130130
ros::ServiceClient client = nh.serviceClient<drv_msgs::face_recognize>("drv_face_service");
131131

drv_face_service/src/drv_face_service.cpp

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,59 @@
77

88
#include "processface.h"
99

10-
char* caffe_path_env = std::getenv("Caffe_ROOT");
10+
char* drv_path_env = std::getenv("DRV");
1111

12-
std::string caffe_path = std::string(caffe_path_env);
12+
std::string drv_path = std::string(drv_path_env);
1313

14-
std::string prototxt = caffe_path + "/models/neu_face/neu_face_deploy.prototxt";
15-
std::string caffemodel = caffe_path + "/models/neu_face/finetune_neu_face.caffemodel";
14+
std::string prototxt = drv_path + "/supplements/face_recognize/neu_face_deploy.prototxt";
15+
std::string caffemodel = drv_path + "/supplements/face_recognize/finetune_neu_face.caffemodel";
1616
ProcessFace pf_(prototxt, caffemodel, 0, false);
1717

1818
bool recognize_face(drv_msgs::face_recognize::Request &req,
1919
drv_msgs::face_recognize::Response &res)
2020
{
21-
size_t im = req.images_in.size();
22-
vector<int> result_id;
23-
for (size_t i = 0;i < im; i++)
24-
{
25-
cv_bridge::CvImagePtr src = cv_bridge::toCvCopy(req.images_in[i], "bgr8");
26-
int id = 0;
27-
float result_trust = 0.0;
28-
pf_.processFace(src->image, id, result_trust);
29-
30-
if (result_trust < 0.9)
31-
result_id.push_back(0);
32-
else
33-
result_id.push_back(id + 1); // result id start at 0, while known person id start at 1
34-
}
35-
res.face_label_ids = result_id;
36-
return true; // return bool is necessary for service
21+
size_t im = req.images_in.size();
22+
vector<int> result_id;
23+
for (size_t i = 0;i < im; i++)
24+
{
25+
cv_bridge::CvImagePtr src = cv_bridge::toCvCopy(req.images_in[i], "bgr8");
26+
int id = 0;
27+
float result_trust = 0.0;
28+
pf_.processFace(src->image, id, result_trust);
29+
30+
if (result_trust < 0.9)
31+
result_id.push_back(0);
32+
else
33+
result_id.push_back(id + 1); // result id start at 0, while known person id start at 1
34+
}
35+
res.face_label_ids = result_id;
36+
return true; // return bool is necessary for service
3737
}
3838

3939
int main(int argc, char **argv)
4040
{
41-
ros::init(argc, argv, "face_recognize_server");
42-
ros::NodeHandle n;
43-
44-
std::ifstream f_pt(prototxt.c_str());
45-
if (!f_pt)
46-
{
47-
ROS_ERROR("Can not find prototxt for face detection.");
48-
return -1;
49-
}
50-
std::ifstream f_mo(caffemodel.c_str());
51-
if (!f_mo)
52-
{
53-
ROS_ERROR("Can not find caffemodel for face detection.");
54-
return -1;
55-
}
56-
57-
ros::ServiceServer service = n.advertiseService("drv_face_service", recognize_face);
58-
ROS_INFO("Ready to recognize face.");
59-
ros::spin();
60-
61-
return 0;
41+
ros::init(argc, argv, "face_recognize_server");
42+
ros::NodeHandle n;
43+
ros::NodeHandle pnh("~");
44+
45+
46+
47+
std::ifstream f_pt(prototxt.c_str());
48+
if (!f_pt)
49+
{
50+
ROS_ERROR("Can not find prototxt for face detection.");
51+
return -1;
52+
}
53+
std::ifstream f_mo(caffemodel.c_str());
54+
if (!f_mo)
55+
{
56+
ROS_ERROR("Can not find caffemodel for face detection.");
57+
return -1;
58+
}
59+
60+
ros::ServiceServer service = n.advertiseService("drv_face_service", recognize_face);
61+
ROS_INFO("Ready to recognize face.");
62+
ros::spin();
63+
64+
return 0;
6265
}

drv_grasp/src/drv_grasp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ int main(int argc, char **argv)
349349
ros::init(argc, argv, "drv_grasp");
350350

351351
ros::NodeHandle nh;
352-
ros::NodeHandle pnh;
352+
ros::NodeHandle pnh("~");
353353

354354
pnh.getParam("root_frame_id", root_frame_);
355355
pnh.getParam("camera_optical_frame_id", camera_optical_frame_);

drv_motor/src/drv_motor.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <std_msgs/Int8.h>
1313
#include <std_msgs/UInt16MultiArray.h>
1414
#include <std_msgs/Float32MultiArray.h>
15-
#include <std_msgs/Int32MultiArray.h>
1615

1716

1817
#include <stdio.h>
@@ -44,16 +43,18 @@ float calculate(float ab, float bc, float cd, float ad, float theta_a)
4443
return to_deg(result);
4544
}
4645

47-
void calculatePitch(float &pitch_angle)
46+
void setBoundary(int &pitch_angle, int &yaw_angle)
4847
{
4948
// Set the boundry of pitch value for NVG 2.0
5049
if (pitch_angle > 140) pitch_angle = 140.0;
51-
if (pitch_angle < 60) pitch_angle = 60.0;
50+
else if (pitch_angle < 60) pitch_angle = 60.0;
51+
if (yaw_angle > 180) yaw_angle = 180.0;
52+
else if (yaw_angle < 0) yaw_angle = 0.0;
5253
}
5354

54-
void motorPublish(float pitch_angle, float yaw_angle, float pitch_speed, float yaw_speed)
55+
void motorPublish(int pitch_angle, int yaw_angle, int pitch_speed, int yaw_speed)
5556
{
56-
std_msgs::Float32MultiArray array;
57+
std_msgs::UInt16MultiArray array;
5758
array.data.push_back(pitch_angle);
5859
array.data.push_back(yaw_angle);
5960
array.data.push_back(pitch_speed);
@@ -64,10 +65,10 @@ void motorPublish(float pitch_angle, float yaw_angle, float pitch_speed, float y
6465
void servoCallback(const std_msgs::UInt16MultiArrayConstPtr &msg)
6566
{
6667
// this callback should always active
67-
float pitchAngle = 70.0;
68-
float yawAngle = 90.0;
69-
float pitchSpeed = 50.0;
70-
float yawSpeed = 50.0;
68+
int pitchAngle = 90;
69+
int yawAngle = 90;
70+
int pitchSpeed = 50;
71+
int yawSpeed = 50;
7172
if (msg->data.size() == 2) {
7273
pitchAngle = msg->data[0];
7374
yawAngle = msg->data[1];
@@ -88,7 +89,7 @@ void servoCallback(const std_msgs::UInt16MultiArrayConstPtr &msg)
8889
ROS_WARN_THROTTLE(11, "Servo message has wrong number of params.");
8990
}
9091

91-
calculatePitch(pitchAngle);
92+
setBoundary(pitchAngle, yawAngle);
9293
motorPublish(pitchAngle, yawAngle, pitchSpeed, yawSpeed);
9394
}
9495

@@ -98,7 +99,7 @@ int main(int argc, char **argv)
9899

99100
ros::NodeHandle nh;
100101

101-
motorPub_ = nh.advertise<std_msgs::Float32MultiArray>("motor", 1, true);
102+
motorPub_ = nh.advertise<std_msgs::UInt16MultiArray>("motor", 1, true);
102103

103104
// This node should be launched in namespace /vision
104105
ros::Subscriber sub_servo_cmd = nh.subscribe<std_msgs::UInt16MultiArray>("servo", 2, servoCallback);

drv_recognize/scripts/drv_recognize_client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import rospy
44
import cv2
55
from drv_msgs.srv import *
6-
from sensor_msgs.msg import Image
6+
from sensor_msgs.msg import CompressedImage
77
from cv_bridge import CvBridge
88

99

@@ -25,16 +25,14 @@ def image_callback(img_msg):
2525

2626
bg = CvBridge()
2727
cv_img_labeled = bg.imgmsg_to_cv2(resp.img_out, 'bgr8')
28-
cv2.imshow("Image window", cv_img_labeled)
29-
cv2.waitKey(1)
3028

3129
print resp.obj_info.labels
3230
print resp.obj_info.box_array
3331

3432

3533
def image_listener():
3634
rospy.init_node('recognize_client', anonymous=True)
37-
rospy.Subscriber('rgb/image_rect_color', Image, image_callback, queue_size=1, buff_size=921600)
35+
rospy.Subscriber('image_rect_color', CompressedImage, image_callback, queue_size=1, buff_size=921600)
3836

3937
while not rospy.is_shutdown():
4038
rospy.spin()

drv_search/src/drv_search.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int main(int argc, char **argv)
124124
searchPubTarget_ = nh.advertise<drv_msgs::recognized_target>("search/recognized_target", 1, true);
125125

126126
// ros::Subscriber sub_rgb = nh.subscribe("/rgb/image/compressed", 1, imageCallback);
127-
image_transport::Subscriber sub_rgb = it_rgb_sub.subscribe("rgb/image_rect_color", 1, imageCallback, hints_rgb);
127+
image_transport::Subscriber sub_rgb = it_rgb_sub.subscribe("image_rect_color", 1, imageCallback, hints_rgb);
128128
// ros::Subscriber sub_depth = nh.subscribe("/depth/image_raw", 1, depthCallback );
129129

130130
ros::ServiceClient client = nh.serviceClient<drv_msgs::recognize>("drv_recognize");

drv_tf/src/drv_tf.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ std::string cameraPitchFrame_ = "/camera_pitch_frame";
5454
std::string cameraYawFrame_ = "/camera_yaw_frame"; // Base of NEU Vision Gear
5555
std::string rootFrame_ = "/base_link"; // Root frame that NVG link to
5656

57-
MoveMean mm(50); // the value represent the strengh to stablize the camera.
57+
MoveMean mm(10); // the value represent the strengh to stablize the camera.
5858

5959
void configCallback(drv_tf::tfConfig &config, uint32_t level)
6060
{
@@ -72,16 +72,15 @@ void servoCallback(const std_msgs::UInt16MultiArrayConstPtr &msg)
7272

7373
void imuPitchCallback(const std_msgs::Float32ConstPtr & msg)
7474
{
75-
float imuPitchTemp = 0.0;
7675
pitch_ = msg->data - pitch_offset_; // notice that pitch_ < 0
77-
mm.getMoveMean(pitch_, imuPitchTemp);
78-
pitch_ = imuPitchTemp * to_rad;
76+
mm.getMoveMean(pitch_);
77+
pitch_ *= to_rad;
7978
}
8079

8180
void imuYawCallback(const std_msgs::Float32ConstPtr & msg)
8281
{
8382
// This callback only valid for NVG 2.0
84-
yaw_ = (msg->data - 90) * to_rad;
83+
// yaw_ = (msg->data - 90) * to_rad;
8584
}
8685

8786
void imageCallback(const sensor_msgs::ImageConstPtr &image_msg)
@@ -177,7 +176,7 @@ int main(int argc, char** argv){
177176
ros::NodeHandle rgb_pnh(pnh, "rgb");
178177
image_transport::ImageTransport it_rgb_sub(rgb_nh);
179178
image_transport::TransportHints hints_rgb("compressed", ros::TransportHints(), rgb_pnh);
180-
image_transport::Subscriber sub_rgb = it_rgb_sub.subscribe("rgb/image_rect_color", 1, imageCallback, hints_rgb);
179+
image_transport::Subscriber sub_rgb = it_rgb_sub.subscribe("image_rect_color", 1, imageCallback, hints_rgb);
181180

182181
ROS_INFO("TF initialized.");
183182

0 commit comments

Comments
 (0)