Skip to content

Commit

Permalink
ROS tracker
Browse files Browse the repository at this point in the history
(cherry picked from commit f76e15e)
  • Loading branch information
preritj authored and lancejchen committed Jul 6, 2017
1 parent a080e9e commit bcd04b8
Show file tree
Hide file tree
Showing 11 changed files with 1,179 additions and 0 deletions.
24 changes: 24 additions & 0 deletions utils/didiros/src/bbox_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 2.8.3)
project(bbox_driver)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED
rospy
std_msgs
message_generation
)

## Generate messages in the 'msg' folder
add_message_files(
FILES
BboxArray.msg
Bbox.msg
)

## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs # Or other packages containing msgs
)
12 changes: 12 additions & 0 deletions utils/didiros/src/bbox_driver/msg/Bbox.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Dimensions
float32 l # length
float32 w # width
float32 h # height
# Position
float32 x
float32 y
float32 z
# orientation (yaw)
float32 yaw
# prediction score
float32 score
2 changes: 2 additions & 0 deletions utils/didiros/src/bbox_driver/msg/BboxArray.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Header header
Bbox[] bboxes
50 changes: 50 additions & 0 deletions utils/didiros/src/bbox_driver/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0"?>
<package>
<name>bbox_driver</name>
<version>0.0.0</version>
<description>The bbox_driver message package</description>

<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="[email protected]">Jane Doe</maintainer> -->
<maintainer email="[email protected]">prerit</maintainer>


<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>


<!-- Url tags are optional, but mutiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/radar_driver</url> -->


<!-- Author tags are optional, mutiple are allowed, one per tag -->
<!-- Authors do not have to be maintianers, but could be -->
<!-- Example: -->
<!-- <author email="[email protected]">Jane Doe</author> -->


<!-- The *_depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use run_depend for packages you need at runtime: -->
<!-- <run_depend>message_runtime</run_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<buildtool_depend>catkin</buildtool_depend>


<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->

</export>
</package>
46 changes: 46 additions & 0 deletions utils/didiros/src/ped_tracker/scripts/camera_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python

from __future__ import print_function
import rospy
from sensor_msgs.msg import CameraInfo
import sys, os
import yaml

def load_cam_info(calib_file):
cam_info = CameraInfo()
with open(calib_file,'r') as cam_calib_file :
cam_calib = yaml.load(cam_calib_file)
cam_info.height = cam_calib['image_height']
cam_info.width = cam_calib['image_width']
cam_info.K = cam_calib['camera_matrix']['data']
cam_info.D = cam_calib['distortion_coefficients']['data']
cam_info.R = cam_calib['rectification_matrix']['data']
cam_info.P = cam_calib['projection_matrix']['data']
cam_info.distortion_model = cam_calib['distortion_model']
return cam_info

if __name__ == "__main__":
calib_file=None
argv = rospy.myargv()
if len(argv) == 2:
calib_file = argv[1]
else :
print('Invalid argument, use as follows')
print(argv[0]+' <calibration file>')
sys.exit(1)

if not os.path.exists(calib_file) :
print(calib_file+' does not exist.')
sys.exit(1)

try:
#load_cam_info(calib_file)
pub = rospy.Publisher('camera', CameraInfo, queue_size=1)
rospy.init_node('CameraInfo')
cam_info = load_cam_info(calib_file)
rate = rospy.Rate(30) # 30 Hz
while not rospy.is_shutdown():
pub.publish(cam_info)
rate.sleep()
except rospy.ROSInterruptException:
pass
Loading

0 comments on commit bcd04b8

Please sign in to comment.