commit e230795cd9b4d2119b23660fe4cb0869974b5393 Author: andre neto Date: Mon Jan 15 12:27:47 2024 +0000 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b999678 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/.catkin_tools +/.catkin_workspace +/.vscode +/build +/devel \ No newline at end of file diff --git a/guide.txt b/guide.txt new file mode 100644 index 0000000..bea8245 --- /dev/null +++ b/guide.txt @@ -0,0 +1,17 @@ +MAPPING: +source devel/setup.bash && roslaunch p3dx_slam p3dx_slam.launch +source devel/setup.bash && roslaunch robot robot.launch +rosrun map_server map_saver -f ~/arena + + +WAYPOINTS: +source devel/setup.bash && roslaunch p3dx_navigation p3dx_navigation.launch map_file:=$HOME/arena.yaml +source devel/setup.bash && roslaunch robot robot.launch +source devel/setup.bash && rosrun waypoints waypoints_server + + +OBJECT DETECTION: +# ASTRA RIGT PORT | HOKUYO + SILVER LEFT PORT +# password: +source devel/setup.bash && ROS_MASTER_URI=http://10.8.0.18:11311 && roslaunch darknet_ros darknet_ros.launch +source devel/setup.bash && roslaunch object_detection object_detection diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 120000 index 0000000..2016816 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1 @@ +/opt/ros/noetic/share/catkin/cmake/toplevel.cmake \ No newline at end of file diff --git a/src/estop/CMakeLists.txt b/src/estop/CMakeLists.txt new file mode 100644 index 0000000..b07d349 --- /dev/null +++ b/src/estop/CMakeLists.txt @@ -0,0 +1,189 @@ +cmake_minimum_required(VERSION 2.8.3) +project(estop) + +## 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 COMPONENTS + roscpp + std_msgs + std_srvs +) + +## System dependencies are found with CMake's conventions +# find_package(Boost REQUIRED COMPONENTS system) + + +## Uncomment this if the package has a setup.py. This macro ensures +## modules and global scripts declared therein get installed +## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html +# catkin_python_setup() + +################################################ +## Declare ROS messages, services and actions ## +################################################ + +## To declare and build messages, services or actions from within this +## package, follow these steps: +## * Let MSG_DEP_SET be the set of packages whose message types you use in +## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). +## * In the file package.xml: +## * add a build_depend tag for "message_generation" +## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET +## * If MSG_DEP_SET isn't empty the following dependency has been pulled in +## but can be declared for certainty nonetheless: +## * add a run_depend tag for "message_runtime" +## * In this file (CMakeLists.txt): +## * add "message_generation" and every package in MSG_DEP_SET to +## find_package(catkin REQUIRED COMPONENTS ...) +## * add "message_runtime" and every package in MSG_DEP_SET to +## catkin_package(CATKIN_DEPENDS ...) +## * uncomment the add_*_files sections below as needed +## and list every .msg/.srv/.action file to be processed +## * uncomment the generate_messages entry below +## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) + +## Generate messages in the 'msg' folder +# add_message_files( +# FILES +# Message1.msg +# Message2.msg +# ) + +## Generate services in the 'srv' folder +# add_service_files( +# FILES +# Service1.srv +# Service2.srv +# ) + +## Generate actions in the 'action' folder +# add_action_files( +# FILES +# Action1.action +# Action2.action +# ) + +## Generate added messages and services with any dependencies listed here +# generate_messages( +# DEPENDENCIES +# std_msgs +# ) + +################################################ +## Declare ROS dynamic reconfigure parameters ## +################################################ + +## To declare and build dynamic reconfigure parameters within this +## package, follow these steps: +## * In the file package.xml: +## * add a build_depend and a run_depend tag for "dynamic_reconfigure" +## * In this file (CMakeLists.txt): +## * add "dynamic_reconfigure" to +## find_package(catkin REQUIRED COMPONENTS ...) +## * uncomment the "generate_dynamic_reconfigure_options" section below +## and list every .cfg file to be processed + +## Generate dynamic reconfigure parameters in the 'cfg' folder +# generate_dynamic_reconfigure_options( +# cfg/DynReconf1.cfg +# cfg/DynReconf2.cfg +# ) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if you package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( +# INCLUDE_DIRS include +# LIBRARIES random_walk + CATKIN_DEPENDS roscpp std_msgs std_srvs +# DEPENDS system_lib +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +# include_directories(include) +include_directories( + include ${catkin_INCLUDE_DIRS} +) + +## Declare a C++ library +# add_library(random_walk +# src/${PROJECT_NAME}/random_walk.cpp +# ) + +## Add cmake target dependencies of the library +## as an example, code may need to be generated before libraries +## either from message generation or dynamic reconfigure +# add_dependencies(random_walk ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Declare a C++ executable +add_executable(estop src/emergency_stop.cpp) + +## Add cmake target dependencies of the executable +## same as for the library above +# add_dependencies(random_walk_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Specify libraries to link a library or executable target against +# target_link_libraries(random_walk_node +# ${catkin_LIBRARIES} +# ) +target_link_libraries(estop ${catkin_LIBRARIES}) + +############# +## Install ## +############# + +# all install targets should use catkin DESTINATION variables +# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html + +## Mark executable scripts (Python etc.) for installation +## in contrast to setup.py, you can choose the destination +# install(PROGRAMS +# scripts/my_python_script +# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark executables and/or libraries for installation +# install(TARGETS random_walk random_walk_node +# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark cpp header files for installation +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +# FILES_MATCHING PATTERN "*.h" +# PATTERN ".svn" EXCLUDE +# ) + +## Mark other files for installation (e.g. launch and bag files, etc.) +#install(FILES +# rndw_tsbot_lrf.launch +# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +#) + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test_random_walk.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) + diff --git a/src/estop/launch/rndw_bringup_sbot_lrf.launch b/src/estop/launch/rndw_bringup_sbot_lrf.launch new file mode 100644 index 0000000..56ab290 --- /dev/null +++ b/src/estop/launch/rndw_bringup_sbot_lrf.launch @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/estop/launch/rndw_bringup_sbot_sonars.launch b/src/estop/launch/rndw_bringup_sbot_sonars.launch new file mode 100644 index 0000000..2c2fe20 --- /dev/null +++ b/src/estop/launch/rndw_bringup_sbot_sonars.launch @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/estop/launch/rndw_bringup_tbot_lrf.launch b/src/estop/launch/rndw_bringup_tbot_lrf.launch new file mode 100644 index 0000000..e0da538 --- /dev/null +++ b/src/estop/launch/rndw_bringup_tbot_lrf.launch @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/estop/launch/rndw_bringup_tbot_sonars.launch b/src/estop/launch/rndw_bringup_tbot_sonars.launch new file mode 100644 index 0000000..e514879 --- /dev/null +++ b/src/estop/launch/rndw_bringup_tbot_sonars.launch @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/estop/launch/rndw_tsbot_lrf.launch b/src/estop/launch/rndw_tsbot_lrf.launch new file mode 100644 index 0000000..6f08b4b --- /dev/null +++ b/src/estop/launch/rndw_tsbot_lrf.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/estop/launch/rndw_tsbot_sonars.launch b/src/estop/launch/rndw_tsbot_sonars.launch new file mode 100644 index 0000000..84552b4 --- /dev/null +++ b/src/estop/launch/rndw_tsbot_sonars.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/estop/package.xml b/src/estop/package.xml new file mode 100644 index 0000000..119ef86 --- /dev/null +++ b/src/estop/package.xml @@ -0,0 +1,53 @@ + + + estop + 2.0.0 + +This package contains a node that allows to stop the robot's motors in an emergency by hitting any key. It also allows to enable the robot's motion by hitting the key 'G'. +The node finishes cleanly by hitting upper case 'Q' (not 'q'). + + + + Rui P. Rocha + + + + + LGPLv3 + + + + + + + + + + + Rui P. Rocha + + + + + + + + + + + + + catkin + roscpp + std_msgs + std_srvs + + + + + + + + + + diff --git a/src/estop/src/emergency_stop.cpp b/src/estop/src/emergency_stop.cpp new file mode 100644 index 0000000..05afded --- /dev/null +++ b/src/estop/src/emergency_stop.cpp @@ -0,0 +1,127 @@ +#include +#include +#include +#include +#include +#include +#include + +bool state = true; // current robot's motors state (default is true) + +void stateChanged(const std_msgs::Bool::ConstPtr& pt){ + state = pt->data; + if (state) ROS_INFO("[estop] robot's motors have been ENABLED"); + else ROS_INFO("[estop] robot's motors have been DISABLED"); +} + +static struct termios olds, news; + +/* Initialize new terminal i/o settings */ +void initTermios(int echo) +{ + tcgetattr(0, &olds); /* grab old terminal i/o settings */ + news = olds; /* make new settings same as old settings */ + news.c_lflag &= ~ICANON; /* disable buffered i/o */ + news.c_lflag &= echo ? ECHO : ~ECHO; /* set echo mode */ + tcsetattr(0, TCSANOW, &news); /* use these new terminal i/o settings now */ +} + +/* Restore old terminal i/o settings */ +void resetTermios(void) +{ + tcsetattr(0, TCSANOW, &olds); +} + +/* Read 1 character - echo defines echo mode */ +char getch_(int echo) +{ + char ch; + initTermios(echo); + ch = getchar(); + resetTermios(); + return ch; +} + +/* Read 1 character without echo */ +char getch(void) +{ + return getch_(0); +} + +/* Read 1 character with echo */ +char getche(void) +{ + return getch_(1); +} + +bool kbhit(void) +{ + struct termios oldt, newt; + int ch; + int oldf; + + tcgetattr(STDIN_FILENO, &oldt); + newt = oldt; + newt.c_lflag &= ~(ICANON | ECHO); + tcsetattr(STDIN_FILENO, TCSANOW, &newt); + oldf = fcntl(STDIN_FILENO, F_GETFL, 0); + fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK); + + ch = getchar(); + + tcsetattr(STDIN_FILENO, TCSANOW, &oldt); + fcntl(STDIN_FILENO, F_SETFL, oldf); + + if(ch != EOF) + { + ungetc(ch, stdin); + return true; + } + + return false; +} + +int main(int argc, char** argv){ + + ros::init(argc, argv, "estop"); + ros::NodeHandle n; + ros::NodeHandle pn("~"); + ros::Rate rate(50.0); + char c; + bool r; + + // ROS subscriber + ros::Subscriber motors_st_sub; + motors_st_sub = n.subscribe("/motors_state", 50, stateChanged); + + // ROS clients + ros::ServiceClient clEnable = n.serviceClient("enable_motors"); + ros::ServiceClient clDisable = n.serviceClient("disable_motors"); + std_srvs::Empty req; + + // node's main loop + while (n.ok() && c != 'Q') { + if (kbhit()) { + c = getch(); + ROS_INFO("[estop] The key \'%c\' has been hitted", c); + if (state) { + ROS_INFO("[estop] Call service disable_motors"); + r = clDisable.call(req); + if (!r) ROS_WARN("[estop] Service returned an error"); + } + else if (c == 'g' || c == 'G') { + ROS_INFO("[estop] Call service enable_motors"); + r = clEnable.call(req); + if (!r) ROS_WARN("[estop] Service returned an error"); + } + + if (c == 'Q') ROS_INFO("[estop] Exit key (\'Q\') has been hitted!"); + } + + ros::spinOnce(); // trigger callbacks once + rate.sleep(); // sleep some time to attain desired processing rate + } + + return(0); +} + diff --git a/src/laser_proc/CHANGELOG.rst b/src/laser_proc/CHANGELOG.rst new file mode 100644 index 0000000..b0846fe --- /dev/null +++ b/src/laser_proc/CHANGELOG.rst @@ -0,0 +1,45 @@ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Changelog for package laser_proc +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +0.1.6 (2020-04-24) +------------------ +* Update required cmake version +* Contributors: Jon Binney + +0.1.5 (2018-08-09) +------------------ +* update to use non deprecated pluginlib macro +* Contributors: Jonathan Binney, Mikael Arguedas + +0.1.4 (2014-03-30) +------------------ +* Install fix for Android. +* Contributors: Chad Rockey + +0.1.3 (2013-08-21) +------------------ +* No more Willow Garage email. +* Contributors: Chad Rockey + +0.1.2 (2013-03-14) +------------------ +* Uncaught except when subscribing to most_intense on non-intensity scans. +* Updated function to be const. +* Contributors: chadrockey + +0.1.1 (2013-03-08) +------------------ +* Merge pull request `#1 `_ from ros-perception/fix_pluginlib_depend + Add missing dependency on pluginlib +* Add missing dependency on pluginlib +* Contributors: Chad Rockey, William Woodall + +0.1.0 (2013-03-04) +------------------ +* Minor fixes. +* Added ROS nodelet/node. +* Adjusted advertiseLaser to be more standard. Fixed seg fault with first and laser publishers. +* Preparing to test with urg_node +* Initial commit +* Contributors: Chad Rockey, chadrockey diff --git a/src/laser_proc/CMakeLists.txt b/src/laser_proc/CMakeLists.txt new file mode 100644 index 0000000..5fe4705 --- /dev/null +++ b/src/laser_proc/CMakeLists.txt @@ -0,0 +1,88 @@ +cmake_minimum_required(VERSION 3.0.2) +project(laser_proc) + +## 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 COMPONENTS roscpp sensor_msgs rosconsole nodelet pluginlib) + +################################################### +## Declare things to be passed to other projects ## +################################################### + +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( + INCLUDE_DIRS include + LIBRARIES laser_proc_library laser_publisher laser_transport laser_proc_ROS LaserProcNodelet + CATKIN_DEPENDS roscpp sensor_msgs rosconsole nodelet + DEPENDS +) + +########### +## Build ## +########### + +## Specify additional locations of header files +include_directories(include ${catkin_INCLUDE_DIRS}) + +## Library that does actual conversion +add_library(laser_proc_library src/LaserProc.cpp) +target_link_libraries(laser_proc_library ${catkin_LIBRARIES}) + +## Publisher library +add_library(laser_publisher src/LaserPublisher.cpp) +target_link_libraries(laser_publisher laser_proc_library ${catkin_LIBRARIES}) + +## Factory for making LaserPublishers +add_library(laser_transport src/LaserTransport.cpp) +target_link_libraries(laser_transport laser_publisher ${catkin_LIBRARIES}) + +## ROS Library +add_library(laser_proc_ROS src/LaserProcROS.cpp) +target_link_libraries(laser_proc_ROS laser_transport ${catkin_LIBRARIES}) + +## Nodelet wrapper +add_library(LaserProcNodelet src/LaserProcNodelet.cpp) +target_link_libraries(LaserProcNodelet laser_proc_ROS ${catkin_LIBRARIES}) + +## Node wrapper +add_executable(laser_proc src/laser_proc.cpp) +target_link_libraries(laser_proc laser_proc_ROS ${catkin_LIBRARIES}) + +############# +## Install ## +############# + +## Mark executables and/or libraries for installation +install(TARGETS laser_proc_library laser_publisher laser_transport laser_proc_ROS LaserProcNodelet laser_proc + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +## Mark cpp header files for installation +install(DIRECTORY include/${PROJECT_NAME}/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING PATTERN "*.h" + PATTERN ".svn" EXCLUDE +) + +## Mark other files for installation (e.g. launch and bag files, etc.) +install(FILES nodelets.xml + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +) + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) diff --git a/src/laser_proc/README.md b/src/laser_proc/README.md new file mode 100644 index 0000000..5be7e9e --- /dev/null +++ b/src/laser_proc/README.md @@ -0,0 +1,4 @@ +laser_proc +========== + +Converts representations of sensor_msgs/LaserScan and sensor_msgs/MultiEchoLaserScan \ No newline at end of file diff --git a/src/laser_proc/include/laser_proc/LaserProc.h b/src/laser_proc/include/laser_proc/LaserProc.h new file mode 100644 index 0000000..68d1744 --- /dev/null +++ b/src/laser_proc/include/laser_proc/LaserProc.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#ifndef LASER_PROC_H +#define LASER_PROC_H + +#include +#include +#include + +#include +#include +#include +#include +#include + +namespace laser_proc +{ + class LaserProc + { + + public: + + static sensor_msgs::LaserScanPtr getFirstScan(const sensor_msgs::MultiEchoLaserScan& msg); + + static sensor_msgs::LaserScanPtr getLastScan(const sensor_msgs::MultiEchoLaserScan& msg); + + static sensor_msgs::LaserScanPtr getMostIntenseScan(const sensor_msgs::MultiEchoLaserScan& msg); + + private: + + static void fillLaserScan(const sensor_msgs::MultiEchoLaserScan& msg, sensor_msgs::LaserScan& out); + + static size_t getFirstValue(const sensor_msgs::LaserEcho& ranges, float& range); + + static size_t getLastValue(const sensor_msgs::LaserEcho& ranges, float& range); + + static void getMostIntenseValue(const sensor_msgs::LaserEcho& ranges, const sensor_msgs::LaserEcho& intensities, float& range, float& intensity); + + }; + + +}; // laser_proc + +#endif \ No newline at end of file diff --git a/src/laser_proc/include/laser_proc/LaserProcROS.h b/src/laser_proc/include/laser_proc/LaserProcROS.h new file mode 100644 index 0000000..3f41490 --- /dev/null +++ b/src/laser_proc/include/laser_proc/LaserProcROS.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#ifndef LASER_PROC_ROS_H +#define LASER_PROC_ROS_H + +#include +#include +#include +#include +#include + +namespace laser_proc +{ + class LaserProcROS + { + public: + LaserProcROS(ros::NodeHandle& n, ros::NodeHandle& pnh); + + ~LaserProcROS(); + + private: + + void scanCb(const sensor_msgs::MultiEchoLaserScanConstPtr& msg) const; + + /** + * Callback that is called when there is a new subscriber. + * + * Will not subscribe until we have a subscriber for our LaserScans (lazy subscribing). + * + */ + void connectCb(const ros::SingleSubscriberPublisher& pub); + + /** + * Callback called when a subscriber unsubscribes. + * + * If all current subscribers of our LaserScans stop listening, stop subscribing (lazy subscribing). + * + */ + void disconnectCb(const ros::SingleSubscriberPublisher& pub); + + ros::NodeHandle nh_; ///< Nodehandle used to subscribe in the connectCb. + laser_proc::LaserPublisher pub_; ///< Publisher + ros::Subscriber sub_; ///< Multi echo subscriber + + boost::mutex connect_mutex_; ///< Prevents the connectCb and disconnectCb from being called until everything is initialized. + }; + + +}; // depthimage_to_laserscan + +#endif \ No newline at end of file diff --git a/src/laser_proc/include/laser_proc/LaserPublisher.h b/src/laser_proc/include/laser_proc/LaserPublisher.h new file mode 100644 index 0000000..e4e67ec --- /dev/null +++ b/src/laser_proc/include/laser_proc/LaserPublisher.h @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#ifndef IMAGE_PROC_LASER_PUBLISHER_H +#define IMAGE_PROC_LASER_PUBLISHER_H + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +namespace laser_proc +{ + + class LaserTransport; + + class LaserPublisher + { + public: + LaserPublisher() {} + + /*! + * \brief Returns the number of subscribers that are currently connected to + * this LaserPublisher. + * + * Returns sum of all child publishers. + */ + uint32_t getNumSubscribers() const; + + /*! + * \brief Returns the topics of this LaserPublisher. + */ + std::vector getTopics() const; + + /*! + * \brief Publish a MultiEchoLaserScan on the topics associated with this LaserPublisher. + */ + void publish(const sensor_msgs::MultiEchoLaserScan& msg) const; + + /*! + * \brief Publish a MultiEchoLaserScan on the topics associated with this LaserPublisher. + */ + void publish(const sensor_msgs::MultiEchoLaserScanConstPtr& msg) const; + + /*! + * \brief Shutdown the advertisements associated with this Publisher. + */ + void shutdown(); + + operator void*() const; + bool operator< (const LaserPublisher& rhs) const { return impl_ < rhs.impl_; } + bool operator!=(const LaserPublisher& rhs) const { return impl_ != rhs.impl_; } + bool operator==(const LaserPublisher& rhs) const { return impl_ == rhs.impl_; } + + private: + LaserPublisher(ros::NodeHandle& nh, uint32_t queue_size, + const ros::SubscriberStatusCallback& connect_cb, + const ros::SubscriberStatusCallback& disconnect_cb, + const ros::VoidPtr& tracked_object, bool latch, bool publish_echoes = true); + + struct Impl; + typedef boost::shared_ptr ImplPtr; + typedef boost::weak_ptr ImplWPtr; + + ImplPtr impl_; + + friend class LaserTransport; + }; + +}; // laser_proc + +#endif \ No newline at end of file diff --git a/src/laser_proc/include/laser_proc/LaserTransport.h b/src/laser_proc/include/laser_proc/LaserTransport.h new file mode 100644 index 0000000..73b215f --- /dev/null +++ b/src/laser_proc/include/laser_proc/LaserTransport.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#ifndef IMAGE_PROC_LASER_TRANSPORT_H +#define IMAGE_PROC_LASER_TRANSPORT_H + +#include + +#include + +namespace laser_proc +{ + class LaserTransport + { + public: + static LaserPublisher advertiseLaser(ros::NodeHandle& nh, uint32_t queue_size, bool latch=false); + + static LaserPublisher advertiseLaser(ros::NodeHandle& nh, uint32_t queue_size, + const ros::SubscriberStatusCallback& connect_cb, + const ros::SubscriberStatusCallback& disconnect_cb=ros::SubscriberStatusCallback(), + const ros::VoidPtr& tracked_object=ros::VoidPtr(), bool latch=false, bool publish_echoes=true); + + }; + +}; // laser_proc + +#endif \ No newline at end of file diff --git a/src/laser_proc/nodelets.xml b/src/laser_proc/nodelets.xml new file mode 100644 index 0000000..6e6f9f2 --- /dev/null +++ b/src/laser_proc/nodelets.xml @@ -0,0 +1,11 @@ + + + + + Nodelet to convert sensor_msgs/MultiEchoLaserScans to sensor_msgs/LaserScans. + + + + diff --git a/src/laser_proc/package.xml b/src/laser_proc/package.xml new file mode 100644 index 0000000..da32e19 --- /dev/null +++ b/src/laser_proc/package.xml @@ -0,0 +1,34 @@ + + + laser_proc + 0.1.6 + laser_proc + + Chad Rockey + + BSD + + http://ros.org/wiki/laser_proc + https://github.com/ros-perception/laser_proc/issues + https://github.com/ros-perception/laser_proce + + Chad Rockey + + catkin + + roscpp + rosconsole + sensor_msgs + pluginlib + nodelet + + roscpp + rosconsole + sensor_msgs + pluginlib + nodelet + + + + + \ No newline at end of file diff --git a/src/laser_proc/src/LaserProc.cpp b/src/laser_proc/src/LaserProc.cpp new file mode 100644 index 0000000..87dd4e3 --- /dev/null +++ b/src/laser_proc/src/LaserProc.cpp @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#include + +using namespace laser_proc; + +sensor_msgs::LaserScanPtr LaserProc::getFirstScan(const sensor_msgs::MultiEchoLaserScan& msg){ + sensor_msgs::LaserScanPtr out(new sensor_msgs::LaserScan()); + fillLaserScan(msg, *out); + out->ranges.resize(msg.ranges.size()); + if(msg.ranges.size() == msg.intensities.size()){ + out->intensities.resize(msg.intensities.size()); + } + + for(size_t i = 0; i < out->ranges.size(); i++){ + size_t index = getFirstValue(msg.ranges[i], out->ranges[i]); + if(out->intensities.size() > 0){ + if(msg.intensities[i].echoes.size() > 0){ + out->intensities[i] = msg.intensities[i].echoes[index]; + } else { + out->intensities[i] = 0.0; + } + } + } + return out; +} + +sensor_msgs::LaserScanPtr LaserProc::getLastScan(const sensor_msgs::MultiEchoLaserScan& msg){ + sensor_msgs::LaserScanPtr out(new sensor_msgs::LaserScan()); + fillLaserScan(msg, *out); + out->ranges.resize(msg.ranges.size()); + if(msg.ranges.size() == msg.intensities.size()){ + out->intensities.resize(msg.intensities.size()); + } + for(size_t i = 0; i < out->ranges.size(); i++){ + size_t index = getLastValue(msg.ranges[i], out->ranges[i]); + if(out->intensities.size() > 0){ + if(msg.intensities[i].echoes.size() > 0){ + out->intensities[i] = msg.intensities[i].echoes[index]; + } else { + out->intensities[i] = 0.0; + } + } + } + return out; +} + +sensor_msgs::LaserScanPtr LaserProc::getMostIntenseScan(const sensor_msgs::MultiEchoLaserScan& msg){ + sensor_msgs::LaserScanPtr out(new sensor_msgs::LaserScan()); + fillLaserScan(msg, *out); + if(msg.ranges.size() == msg.intensities.size()){ + out->ranges.resize(msg.ranges.size()); + out->intensities.resize(msg.intensities.size()); + } else { + std::stringstream ss; + ss << "getMostIntenseScan::Size of ranges does not equal size of intensities, cannot create scan."; + throw std::runtime_error(ss.str()); + } + for(size_t i = 0; i < out->intensities.size(); i++){ + getMostIntenseValue(msg.ranges[i], msg.intensities[i], out->ranges[i], out->intensities[i]); + } + return out; +} + +void LaserProc::fillLaserScan(const sensor_msgs::MultiEchoLaserScan& msg, sensor_msgs::LaserScan& out){ + out.header = msg.header; + out.angle_min = msg.angle_min; + out.angle_max = msg.angle_max; + out.angle_increment = msg.angle_increment; + out.time_increment = msg.time_increment; + out.scan_time = msg.scan_time; + out.range_min = msg.range_min; + out.range_max = msg.range_max; +} + +///< @TODO I'm assuming all laserscanners/drivers output the ranges in order received (shortest to longest). If this is not the case, please make an issue. +size_t LaserProc::getFirstValue(const sensor_msgs::LaserEcho& ranges, float& range){ + if(ranges.echoes.size() > 0){ + size_t index = 0; + range = ranges.echoes[index]; + return index; + } + + range = std::numeric_limits::quiet_NaN(); + return 0; // Value doesn't matter +} + +///< @TODO I'm assuming all laserscanners/drivers output the ranges in order received (shortest to longest). If this is not the case, please make an issue. +size_t LaserProc::getLastValue(const sensor_msgs::LaserEcho& ranges, float& range){ + if(ranges.echoes.size() > 0){ + size_t index = ranges.echoes.size()-1; + range = ranges.echoes[index]; + return index; + } + + range = std::numeric_limits::quiet_NaN(); + return 0; // Value doesn't matter +} + +void LaserProc::getMostIntenseValue(const sensor_msgs::LaserEcho& ranges, const sensor_msgs::LaserEcho& intensities, float& range, float& intensity){ + if(intensities.echoes.size() == 0){ + range = std::numeric_limits::quiet_NaN(); + intensity = 0.0; + return; + } + + std::vector::const_iterator max_iter = std::max_element(intensities.echoes.begin(), intensities.echoes.end()); + size_t index = std::distance(intensities.echoes.begin(), max_iter); + + if(ranges.echoes.size() > 0){ + range = ranges.echoes[index]; + intensity = *max_iter; + } else { + range = std::numeric_limits::quiet_NaN(); + intensity = 0.0; + return; + } +} \ No newline at end of file diff --git a/src/laser_proc/src/LaserProcNodelet.cpp b/src/laser_proc/src/LaserProcNodelet.cpp new file mode 100644 index 0000000..5e07e39 --- /dev/null +++ b/src/laser_proc/src/LaserProcNodelet.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#include +#include + + +namespace laser_proc +{ + +class LaserProcNodelet : public nodelet::Nodelet +{ +public: + LaserProcNodelet() {}; + + ~LaserProcNodelet() {} + +private: + virtual void onInit() + { + lp.reset(new LaserProcROS(getNodeHandle(), getPrivateNodeHandle())); + }; + + boost::shared_ptr lp; +}; + +} + +#include +PLUGINLIB_EXPORT_CLASS(laser_proc::LaserProcNodelet, nodelet::Nodelet) + diff --git a/src/laser_proc/src/LaserProcROS.cpp b/src/laser_proc/src/LaserProcROS.cpp new file mode 100644 index 0000000..93d7682 --- /dev/null +++ b/src/laser_proc/src/LaserProcROS.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#include + +using namespace laser_proc; + +LaserProcROS::LaserProcROS(ros::NodeHandle& n, ros::NodeHandle& pnh):nh_(n){ + boost::mutex::scoped_lock lock(connect_mutex_); + + // Lazy subscription to multi echo topic + pub_ = laser_proc::LaserTransport::advertiseLaser(n, 10, boost::bind(&LaserProcROS::connectCb, this, _1), boost::bind(&LaserProcROS::disconnectCb, this, _1), ros::VoidPtr(), false, false); +} + +LaserProcROS::~LaserProcROS(){ + sub_.shutdown(); +} + + + +void LaserProcROS::scanCb(const sensor_msgs::MultiEchoLaserScanConstPtr& msg) const{ + pub_.publish(msg); +} + +void LaserProcROS::connectCb(const ros::SingleSubscriberPublisher& pub){ + boost::mutex::scoped_lock lock(connect_mutex_); + if (!sub_ && pub_.getNumSubscribers() > 0) { + ROS_DEBUG("Connecting to multi echo topic."); + sub_ = nh_.subscribe("echoes", 10, &LaserProcROS::scanCb, this); + } +} + +void LaserProcROS::disconnectCb(const ros::SingleSubscriberPublisher& pub){ + boost::mutex::scoped_lock lock(connect_mutex_); + if (pub_.getNumSubscribers() == 0) { + ROS_DEBUG("Unsubscribing from multi echo topic."); + sub_.shutdown(); + } +} \ No newline at end of file diff --git a/src/laser_proc/src/LaserPublisher.cpp b/src/laser_proc/src/LaserPublisher.cpp new file mode 100644 index 0000000..d04cd32 --- /dev/null +++ b/src/laser_proc/src/LaserPublisher.cpp @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#include + +namespace laser_proc { + +typedef sensor_msgs::LaserScanPtr (*PublishFunction)(const sensor_msgs::MultiEchoLaserScan& msg); + +struct LaserPublisher::Impl +{ + Impl() + : unadvertised_(false) + { + } + + ~Impl() + { + shutdown(); + } + + bool isValid() const + { + return !unadvertised_; + } + + void shutdown() + { + if (!unadvertised_) { + unadvertised_ = true; + for(size_t i = 0; i < pubs_.size(); i++){ + pubs_[i].shutdown(); + } + } + } + + ros::Publisher echo_pub_; + std::vector pubs_; + std::vector functs_; + bool unadvertised_; +}; + +///< @TODO Make a static class that creates these +LaserPublisher::LaserPublisher(ros::NodeHandle& nh, uint32_t queue_size, + const ros::SubscriberStatusCallback& connect_cb, + const ros::SubscriberStatusCallback& disconnect_cb, + const ros::VoidPtr& tracked_object, bool latch, bool publish_echoes) + : impl_(new Impl) +{ + if(publish_echoes){ + impl_->echo_pub_ = nh.advertise("echoes", queue_size, connect_cb, disconnect_cb, tracked_object, latch); + } + impl_->pubs_.push_back(nh.advertise("first", queue_size, connect_cb, disconnect_cb, tracked_object, latch)); + impl_->functs_.push_back(laser_proc::LaserProc::getFirstScan); + impl_->pubs_.push_back(nh.advertise("last", queue_size, connect_cb, disconnect_cb, tracked_object, latch)); + impl_->functs_.push_back(laser_proc::LaserProc::getLastScan); + impl_->pubs_.push_back(nh.advertise("most_intense", queue_size, connect_cb, disconnect_cb, tracked_object, latch)); + impl_->functs_.push_back(laser_proc::LaserProc::getMostIntenseScan); +} + +uint32_t LaserPublisher::getNumSubscribers() const +{ + if (impl_ && impl_->isValid()){ + uint32_t num = impl_->echo_pub_.getNumSubscribers(); + for(size_t i = 0; i < impl_->pubs_.size(); i++){ + num = num + impl_->pubs_[i].getNumSubscribers(); + } + return num; + } + return 0; +} + +std::vector LaserPublisher::getTopics() const +{ + std::vector topics; + topics.push_back(impl_->echo_pub_.getTopic()); + if (impl_ && impl_->isValid()){ + for(size_t i = 0; i < impl_->pubs_.size(); i++){ + topics.push_back(impl_->pubs_[i].getTopic()); + } + } + return topics; +} + +void LaserPublisher::publish(const sensor_msgs::MultiEchoLaserScan& msg) const +{ + if (!impl_ || !impl_->isValid()) { + ROS_ASSERT_MSG(false, "Call to publish() on an invalid image_transport::LaserPublisher"); + return; + } + + // Publish original MultiEchoLaserScan + if(impl_->echo_pub_){ + if(impl_->echo_pub_.getNumSubscribers() > 0){ + impl_->echo_pub_.publish(msg); + } + } + + // If needed, publish LaserScans + for(size_t i = 0; i < impl_->pubs_.size(); i++){ + if(impl_->pubs_[i].getNumSubscribers() > 0){ + try{ + impl_->pubs_[i].publish(impl_->functs_[i](msg)); + } catch(std::runtime_error& e){ + ROS_ERROR_THROTTLE(1.0, "Could not publish to topic %s: %s", impl_->pubs_[i].getTopic().c_str(), e.what()); + } + } + } +} + +void LaserPublisher::publish(const sensor_msgs::MultiEchoLaserScanConstPtr& msg) const +{ + if (!impl_ || !impl_->isValid()) { + ROS_ASSERT_MSG(false, "Call to publish() on an invalid image_transport::LaserPublisher"); + return; + } + + // Publish original MultiEchoLaserScan + if(impl_->echo_pub_){ + impl_->echo_pub_.publish(msg); + } + + // If needed, publish LaserScans + for(size_t i = 0; i < impl_->pubs_.size(); i++){ + if(impl_->pubs_[i].getNumSubscribers() > 0){ + try{ + impl_->pubs_[i].publish(impl_->functs_[i](*msg)); + } catch(std::runtime_error& e){ + ROS_ERROR_THROTTLE(1.0, "Could not publish to topic %s: %s", impl_->pubs_[i].getTopic().c_str(), e.what()); + } + } + } +} + +void LaserPublisher::shutdown() +{ + if (impl_) { + impl_->shutdown(); + impl_.reset(); + } +} + +LaserPublisher::operator void*() const +{ + return (impl_ && impl_->isValid()) ? (void*)1 : (void*)0; +} + +} //namespace laser_proc + diff --git a/src/laser_proc/src/LaserTransport.cpp b/src/laser_proc/src/LaserTransport.cpp new file mode 100644 index 0000000..afa6614 --- /dev/null +++ b/src/laser_proc/src/LaserTransport.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#include + +namespace laser_proc { + +LaserPublisher LaserTransport::advertiseLaser(ros::NodeHandle& nh, uint32_t queue_size, bool latch){ + return advertiseLaser(nh, queue_size, ros::SubscriberStatusCallback(), ros::SubscriberStatusCallback(), ros::VoidPtr(), latch); +} + +LaserPublisher LaserTransport::advertiseLaser(ros::NodeHandle& nh, uint32_t queue_size, + const ros::SubscriberStatusCallback& connect_cb, + const ros::SubscriberStatusCallback& disconnect_cb, + const ros::VoidPtr& tracked_object, bool latch, bool publish_echoes){ + return LaserPublisher(nh, queue_size, connect_cb, disconnect_cb, tracked_object, latch, publish_echoes); +} + +} //namespace laser_proc + diff --git a/src/laser_proc/src/laser_proc.cpp b/src/laser_proc/src/laser_proc.cpp new file mode 100644 index 0000000..2688729 --- /dev/null +++ b/src/laser_proc/src/laser_proc.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#include + +int main(int argc, char **argv){ + ros::init(argc, argv, "laser_proc"); + ros::NodeHandle n; + ros::NodeHandle pnh("~"); + + laser_proc::LaserProcROS lp(n, pnh); + + ros::spin(); + + return 0; +} \ No newline at end of file diff --git a/src/object_detection/CMakeLists.txt b/src/object_detection/CMakeLists.txt new file mode 100644 index 0000000..5bb155f --- /dev/null +++ b/src/object_detection/CMakeLists.txt @@ -0,0 +1,203 @@ +cmake_minimum_required(VERSION 3.0.2) +project(object_detection) + +## Compile as C++11, supported in ROS Kinetic and newer +# add_compile_options(-std=c++11) + +## 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) + +## System dependencies are found with CMake's conventions +# find_package(Boost REQUIRED COMPONENTS system) + + +## Uncomment this if the package has a setup.py. This macro ensures +## modules and global scripts declared therein get installed +## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html +# catkin_python_setup() + +################################################ +## Declare ROS messages, services and actions ## +################################################ + +## To declare and build messages, services or actions from within this +## package, follow these steps: +## * Let MSG_DEP_SET be the set of packages whose message types you use in +## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). +## * In the file package.xml: +## * add a build_depend tag for "message_generation" +## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET +## * If MSG_DEP_SET isn't empty the following dependency has been pulled in +## but can be declared for certainty nonetheless: +## * add a exec_depend tag for "message_runtime" +## * In this file (CMakeLists.txt): +## * add "message_generation" and every package in MSG_DEP_SET to +## find_package(catkin REQUIRED COMPONENTS ...) +## * add "message_runtime" and every package in MSG_DEP_SET to +## catkin_package(CATKIN_DEPENDS ...) +## * uncomment the add_*_files sections below as needed +## and list every .msg/.srv/.action file to be processed +## * uncomment the generate_messages entry below +## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) + +## Generate messages in the 'msg' folder +# add_message_files( +# FILES +# Message1.msg +# Message2.msg +# ) + +## Generate services in the 'srv' folder +# add_service_files( +# FILES +# Service1.srv +# Service2.srv +# ) + +## Generate actions in the 'action' folder +# add_action_files( +# FILES +# Action1.action +# Action2.action +# ) + +## Generate added messages and services with any dependencies listed here +#generate_messages( +# DEPENDENCIES +# std_msgs +# darknet_ros_msgs +#) + +################################################ +## Declare ROS dynamic reconfigure parameters ## +################################################ + +## To declare and build dynamic reconfigure parameters within this +## package, follow these steps: +## * In the file package.xml: +## * add a build_depend and a exec_depend tag for "dynamic_reconfigure" +## * In this file (CMakeLists.txt): +## * add "dynamic_reconfigure" to +## find_package(catkin REQUIRED COMPONENTS ...) +## * uncomment the "generate_dynamic_reconfigure_options" section below +## and list every .cfg file to be processed + +## Generate dynamic reconfigure parameters in the 'cfg' folder +# generate_dynamic_reconfigure_options( +# cfg/DynReconf1.cfg +# cfg/DynReconf2.cfg +# ) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if your package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( +# INCLUDE_DIRS include +# LIBRARIES object_detection + CATKIN_DEPENDS message_runtime +# DEPENDS system_lib +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +include_directories( +# include +# ${catkin_INCLUDE_DIRS} +) + +## Declare a C++ library +# add_library(${PROJECT_NAME} +# src/${PROJECT_NAME}/object_detection.cpp +# ) + +## Add cmake target dependencies of the library +## as an example, code may need to be generated before libraries +## either from message generation or dynamic reconfigure +# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Declare a C++ executable +## With catkin_make all packages are built within a single CMake context +## The recommended prefix ensures that target names across packages don't collide +# add_executable(${PROJECT_NAME}_node src/object_detection_node.cpp) + +## Rename C++ executable without prefix +## The above recommended prefix causes long target names, the following renames the +## target back to the shorter version for ease of user use +## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" +# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "") + +## Add cmake target dependencies of the executable +## same as for the library above +# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Specify libraries to link a library or executable target against +# target_link_libraries(${PROJECT_NAME}_node +# ${catkin_LIBRARIES} +# ) + +############# +## Install ## +############# + +# all install targets should use catkin DESTINATION variables +# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html + +## Mark executable scripts (Python etc.) for installation +## in contrast to setup.py, you can choose the destination +catkin_install_python(PROGRAMS + scripts/object_detection.py + DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +## Mark executables for installation +## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html +# install(TARGETS ${PROJECT_NAME}_node +# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark libraries for installation +## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html +# install(TARGETS ${PROJECT_NAME} +# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} +# ) + +## Mark cpp header files for installation +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +# FILES_MATCHING PATTERN "*.h" +# PATTERN ".svn" EXCLUDE +# ) + +## Mark other files for installation (e.g. launch and bag files, etc.) +# install(FILES +# # myfile1 +# # myfile2 +# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +# ) + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test_object_detection.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) diff --git a/src/object_detection/buffer/buffer.csv b/src/object_detection/buffer/buffer.csv new file mode 100644 index 0000000..e69de29 diff --git a/src/object_detection/package.xml b/src/object_detection/package.xml new file mode 100644 index 0000000..555854b --- /dev/null +++ b/src/object_detection/package.xml @@ -0,0 +1,58 @@ + + + object_detection + 0.0.0 + The object_detection package + + + + + ryken + + + + + + TODO + + + + + + + + + + + + + + + + + + + roscpp + + message_generation + message_runtime + + + + + + + + + + + + catkin + + + + + + + + diff --git a/src/object_detection/scripts/object_detection.py b/src/object_detection/scripts/object_detection.py new file mode 100755 index 0000000..858f613 --- /dev/null +++ b/src/object_detection/scripts/object_detection.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python + +import rospy +import csv +import cv2 + +from message_filters import ApproximateTimeSynchronizer, Subscriber +from darknet_ros_msgs.msg import BoundingBoxes +from sensor_msgs.msg import Image +from nav_msgs.msg import Odometry + +from cv_bridge import CvBridge + + +def calc_center(xmin, xmax, ymin, ymax): + + x0 = (xmin + xmax)/2 + y0 = (ymin + ymax)/2 + + return [x0, y0] + +def calc_centroid(xmin, xmax, ymin, ymax): + + dx = abs(xmax - xmin) + dy = abs(ymax - ymin) + + [x0, y0] = calc_center(xmin, xmax, ymin, ymax) + + c_xmin = x0 - dx/4 + c_xmax = x0 + dx/4 + c_ymin = y0 - dy/4 + c_ymax = y0 + dy/4 + + return c_xmin, c_xmax, c_ymin, c_ymax + +def new_object(box, image, odom): + + FLAG = False + + b_xmin, b_xmax, b_ymin, b_ymax = calc_centroid(box.xmin, box.xmax, box.ymin, box.ymax) + x0, y0 = calc_center(box.xmin, box.xmax, box.ymin, box.ymax) + + rospy.loginfo("%s: %f, %f", box.Class, x0, y0) + + with open("/home/ryken/Desktop/real/src/object_detection/buffer/buffer.csv") as file_in: + reader = csv.reader(file_in.readlines()) + + with open("/home/ryken/Desktop/real/src/object_detection/buffer/buffer.csv", "w") as file_out: + writer = csv.writer(file_out) + + for row in reader: + + if box.Class == row[0]: + + x0, y0 = calc_center(box.xmin, box.xmax, box.ymin, box.ymax) + c_xmin, c_xmax, c_ymin, c_ymax = float(row[1]), float(row[2]), float(row[3]), float(row[4]) + + if x0 < c_xmax and x0 > c_xmin and y0 < c_ymax and y0 > c_ymin: + FLAG = True + writer.writerow([box.Class, b_xmin, b_xmax, b_ymin, b_ymax, box.probability, odom.pose.pose.position.x, odom.pose.pose.position.y]) + img = bridge. imgmsg_to_cv2(image, "bgr8") + cv2.imwrite("/home/ryken/Desktop/real/src/object_detection/results/"+box.Class+".jpeg", img) + else: + FLAG = False + else: + writer.writerow(row) + + if not FLAG: + writer.writerow([box.Class, b_xmin, b_xmax, b_ymin, b_ymax, box.probability, odom.pose.pose.position.x, odom.pose.pose.position.y]) + img = bridge. imgmsg_to_cv2(image, "bgr8") + cv2.imwrite("/home/ryken/Desktop/real/src/object_detection/results/"+box.Class+".jpeg", img) + +def callback(boxes, image, odom): + for box in boxes.bounding_boxes: + if box.probability >= 0.7: + new_object(box, image, odom) + +if __name__ == '__main__': + + with open("/home/ryken/Desktop/real/src/object_detection/buffer/buffer.csv", "w") as file_out: + writer = csv.writer(file_out) + + rospy.init_node('object_detection') + + bridge = CvBridge() + + boxes = Subscriber("darknet_ros/bounding_boxes", BoundingBoxes, queue_size=1) + image = Subscriber("darknet_ros/detection_image", Image, queue_size=1) + odom = Subscriber("odom", Odometry, queue_size=1) + ts = ApproximateTimeSynchronizer([boxes, image, odom], 5, 0.2, allow_headerless=False) + ts.registerCallback(callback) + + try: + rospy.loginfo("Started Object Detection...") + rospy.spin() + except rospy.ROSInterruptException: + rospy.loginfo("Shutting down Object Detection...") diff --git a/src/p3dx_description/.project b/src/p3dx_description/.project new file mode 100644 index 0000000..47c483c --- /dev/null +++ b/src/p3dx_description/.project @@ -0,0 +1,27 @@ + + + p3dx_description + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/src/p3dx_description/CMakeLists.txt b/src/p3dx_description/CMakeLists.txt new file mode 100644 index 0000000..e7e43d5 --- /dev/null +++ b/src/p3dx_description/CMakeLists.txt @@ -0,0 +1,88 @@ +cmake_minimum_required(VERSION 2.8.3) +project(p3dx_description) + +## 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 COMPONENTS + roscpp + rospy + urdf +) + +## System dependencies are found with CMake's conventions +# find_package(Boost REQUIRED COMPONENTS system) + + +## Uncomment this if the package has a setup.py. This macro ensures +## modules and global scripts declared therein get installed +## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html +# catkin_python_setup() + +####################################### +## Declare ROS messages and services ## +####################################### + +## Generate messages in the 'msg' folder +# add_message_files( +# FILES +# Message1.msg +# Message2.msg +# ) + +## Generate services in the 'srv' folder +# add_service_files( +# FILES +# Service1.srv +# Service2.srv +# ) + +## Generate added messages and services with any dependencies listed here +# generate_messages( +# DEPENDENCIES +# std_msgs # Or other packages containing msgs +# ) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if you package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( +# INCLUDE_DIRS include +# LIBRARIES p3dx_description +# CATKIN_DEPENDS roscpp rospy urdf +# DEPENDS system_lib +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +# include_directories(include) +include_directories( + ${catkin_INCLUDE_DIRS} +) + +## Declare a cpp library +# add_library(p3dx_description +# src/${PROJECT_NAME}/p3dx_description.cpp +# ) + +## Declare a cpp executable +# add_executable(p3dx_description src/main.cpp) + +## Add cmake target dependencies of the executable/library +## as an example, message headers may need to be generated before nodes +# add_dependencies(p3dx_description_node p3dx_description_generate_messages_cpp) + +## Specify libraries to link a library or executable target against +# target_link_libraries(p3dx_description_node +# ${catkin_LIBRARIES} +# ) diff --git a/src/p3dx_description/launch/p3dx_description.launch b/src/p3dx_description/launch/p3dx_description.launch new file mode 100644 index 0000000..1a21de9 --- /dev/null +++ b/src/p3dx_description/launch/p3dx_description.launch @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/p3dx_description/launch/rviz_p3dx.launch b/src/p3dx_description/launch/rviz_p3dx.launch new file mode 100644 index 0000000..69ebf9d --- /dev/null +++ b/src/p3dx_description/launch/rviz_p3dx.launch @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/p3dx_description/launch/rviz_p3dx_ugv1.launch b/src/p3dx_description/launch/rviz_p3dx_ugv1.launch new file mode 100644 index 0000000..66d4cba --- /dev/null +++ b/src/p3dx_description/launch/rviz_p3dx_ugv1.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/p3dx_description/meshes/Coordinates b/src/p3dx_description/meshes/Coordinates new file mode 100644 index 0000000..6fba9d2 --- /dev/null +++ b/src/p3dx_description/meshes/Coordinates @@ -0,0 +1,20 @@ +========================================= +Location Coordinates (x,y,z) +========================================= + +Chassis : -0.045 0 0.148 +Top : -0.045 0 0.234 + +Swivel : -0.185 0 0.055 +Center Hubcap : -0.211 0 0.037 +Center Wheel : -0.211 0 0.038 + +Right Hubcap : 0 0.158 0.091 +Right Wheel : 0 0.158 0.091 + +Left Hubcap : 0 -0.158 0.091 +Left Wheel : 0 -0.158 0.091 + +Front Sonar : -0.2 0 0.209 +Back Sonar : 0.109 0 0.209 + diff --git a/src/p3dx_description/meshes/back_rim.stl b/src/p3dx_description/meshes/back_rim.stl new file mode 100644 index 0000000..09587a5 Binary files /dev/null and b/src/p3dx_description/meshes/back_rim.stl differ diff --git a/src/p3dx_description/meshes/back_sonar.stl b/src/p3dx_description/meshes/back_sonar.stl new file mode 100644 index 0000000..82b9ce0 Binary files /dev/null and b/src/p3dx_description/meshes/back_sonar.stl differ diff --git a/src/p3dx_description/meshes/center_hubcap.stl b/src/p3dx_description/meshes/center_hubcap.stl new file mode 100644 index 0000000..c9400f7 Binary files /dev/null and b/src/p3dx_description/meshes/center_hubcap.stl differ diff --git a/src/p3dx_description/meshes/center_wheel.stl b/src/p3dx_description/meshes/center_wheel.stl new file mode 100644 index 0000000..c8b857d Binary files /dev/null and b/src/p3dx_description/meshes/center_wheel.stl differ diff --git a/src/p3dx_description/meshes/chassis.stl b/src/p3dx_description/meshes/chassis.stl new file mode 100644 index 0000000..13aa2cf Binary files /dev/null and b/src/p3dx_description/meshes/chassis.stl differ diff --git a/src/p3dx_description/meshes/front_rim.stl b/src/p3dx_description/meshes/front_rim.stl new file mode 100644 index 0000000..c3074d5 Binary files /dev/null and b/src/p3dx_description/meshes/front_rim.stl differ diff --git a/src/p3dx_description/meshes/front_sonar.stl b/src/p3dx_description/meshes/front_sonar.stl new file mode 100644 index 0000000..9153bc5 Binary files /dev/null and b/src/p3dx_description/meshes/front_sonar.stl differ diff --git a/src/p3dx_description/meshes/left_hubcap.stl b/src/p3dx_description/meshes/left_hubcap.stl new file mode 100644 index 0000000..01bd2f9 Binary files /dev/null and b/src/p3dx_description/meshes/left_hubcap.stl differ diff --git a/src/p3dx_description/meshes/left_wheel.stl b/src/p3dx_description/meshes/left_wheel.stl new file mode 100644 index 0000000..31137e2 Binary files /dev/null and b/src/p3dx_description/meshes/left_wheel.stl differ diff --git a/src/p3dx_description/meshes/lms100.dae b/src/p3dx_description/meshes/lms100.dae new file mode 100644 index 0000000..bc65151 --- /dev/null +++ b/src/p3dx_description/meshes/lms100.dae @@ -0,0 +1,253 @@ + + + + + Blender User + Blender 2.64.0 r51232 + + 2013-03-22T08:19:53 + 2013-03-22T08:19:53 + + Z_UP + + + + + + + 49.13434 + 1.777778 + 0.1 + 100 + + + + + + + + + + 1 1 1 + 1 + 0 + 0.00111109 + + + + + 0.000999987 + 0 + 1 + 1 + 1 + 1 + 1 + 2 + 0 + 1 + 1 + 1 + 1 + 1 + 0 + 2880 + 2 + 30.002 + 1.000799 + 0.04999995 + 29.99998 + 1 + 2 + 0 + 0 + 1 + 1 + 1 + 1 + 8192 + 1 + 1 + 0 + 1 + 1 + 1 + 3 + 0 + 0 + 0 + 0 + 45 + 0 + 1 + 1 + 1 + 3 + 0.15 + 75 + 1 + 1 + 0 + 1 + 1 + 0 + + + + + + + + + + + + 0 0 0 1 + + + 0 0 0 1 + + + 0.020312 0.020312 0.020312 1 + + + 0.25 0.25 0.25 1 + + + 12 + + + 1 + + + + + + 1 + + + + 1 + + + + + + + 0 0 0 1 + + + 0 0 0 1 + + + 0.695112 0.695112 0.695112 1 + + + 0.0625 0.0625 0.0625 1 + + + 0 + + + 1 + + + + + + 1 + + + + 1 + + + + + + + + + + + + + + + -0.02213996 0.005949974 -0.004869997 -0.02213996 0.005949974 0.004869997 -0.02164 0.009949982 -0.004999995 -0.02164 0.009949982 -0.005999982 -0.02164 0.009949982 0.004999995 -0.02164 0.009949982 0.005999982 -0.02149999 0.009949982 -0.006499946 -0.02149999 0.009949982 0.006499946 -0.02113997 0.009949982 -0.006869971 -0.02113997 0.009949982 0.006869971 -0.02063995 0.005949974 0.006999969 -0.02063995 0.009949982 -0.006999969 -0.02063995 0.009949982 0.006999969 -0.01979994 0.009949982 -0.006999969 -0.01979994 0.005949974 -0.006999969 -0.01979994 0.005949974 0.006999969 -0.01979994 0.009949982 0.006999969 -0.01838999 0.005949974 0.01014 -0.02063995 0.005949974 -0.006999969 -0.02113997 0.005949974 0.006869971 -0.02113997 0.005949974 -0.006869971 -0.02149999 0.005949974 0.006499946 -0.02149999 0.005949974 -0.006499946 -0.02164 0.005949974 0.005999982 -0.02164 0.005949974 0.004999995 -0.02164 0.005949974 -0.004999995 -0.02164 0.005949974 -0.005999982 -0.01920998 0.01990997 0.004999995 -0.01920998 0.01990997 -0.004999995 -0.005279958 0.02695 -0.01798999 -0.009719967 0.02695 -0.01595997 -0.01014 0.02695 -0.01576995 -0.01365 0.02695 -0.01273 -0.01416999 0.02695 -0.01227998 -0.01655995 0.02695 -0.008569955 -0.01705998 0.02695 -0.007789969 -0.01822996 0.02695 -0.003779947 -0.01855999 0.02695 -0.00266999 -0.01855999 0.02695 0.00127995 -0.01855999 0.02695 0.00266999 -0.01750999 0.02695 0.006229996 -0.01705998 0.02695 0.007789969 -0.01516997 0.02695 0.01071995 -0.01416999 0.02695 0.01227998 -0.01170998 0.02695 0.01440995 -0.01014 0.02695 0.01576995 -0.007389962 0.02695 0.01703 -0.005279958 0.02695 0.01798999 -0.002529978 0.02695 0.01838999 0 0.02695 0.01874995 0.002529978 0.02695 0.01838999 0.005279958 0.02695 0.01798999 0.007389962 0.02695 0.01703 0.01014 0.02695 0.01576995 0.01170998 0.02695 0.01440995 0.01416999 0.02695 0.01227998 0.01516997 0.02695 0.01071995 0.01705998 0.02695 0.007789969 0.01750999 0.02695 0.006229996 0.01855999 0.02695 0.00266999 0.01855999 0.02695 0.00127995 0.01855999 0.02695 -0.00266999 0.01822996 0.02695 -0.003779947 0.01705998 0.02695 -0.007789969 0.01655995 0.02695 -0.008569955 0.01416999 0.02695 -0.01227998 0.01365 0.02695 -0.01273 0.01014 0.02695 -0.01576995 0.009719967 0.02695 -0.01595997 0.005279958 0.02695 -0.01798999 0.005049943 0.02695 -0.01801997 -0.005049943 0.02695 -0.01801997 0 0.02695 -0.01874995 -0.01885998 0.02594995 0.001289963 -0.01850998 0.02594995 -0.003849983 -0.02039998 0.009949982 -0.004999995 -0.02039998 0.009949982 0.004999995 -0.01848 0.02594995 0.003999948 -0.01836997 0.02572995 0.004629969 -0.01840996 0.02588999 0.004329979 -0.01838999 0.02579998 0.004489958 -0.01835 0.02544999 0.004859983 -0.01838999 0.02494996 0.004999995 -0.01835995 0.02517998 0.004969954 -0.02164 0.02494996 0.004999995 -0.02164 0.02544999 0.004869997 -0.02188998 0.02537995 0.004869997 -0.02206999 0.02519994 0.004869997 -0.02213996 0.02494996 0.004869997 -0.02164 0.02581995 0.004499971 -0.02206999 0.02569997 0.004499971 -0.02238994 0.02537995 0.004499971 -0.02249997 0.02494996 0.004499971 -0.02164 0.02594995 0.003999948 -0.02213996 0.02581995 0.003999948 -0.02263998 0.02494996 0.003999948 -0.02249997 0.02544999 0.003999948 -0.02213996 0.02581995 -0.003999948 -0.02249997 0.02544999 -0.003999948 -0.02263998 0.02494996 -0.003999948 -0.02206999 0.02569997 -0.004499971 -0.02188998 0.02537995 -0.004869997 -0.02238994 0.02537995 -0.004499971 -0.02249997 0.02494996 -0.004499971 -0.02206999 0.02519994 -0.004869997 -0.02213996 0.02494996 -0.004869997 -0.01838999 0.02494996 -0.004999995 -0.02164 0.02494996 -0.004999995 -0.01835 0.02555996 -0.004789948 -0.01835995 0.02526998 -0.004949986 -0.01835 0.02543997 -0.00484997 -0.01836997 0.02577996 -0.004559993 -0.02164 0.02544999 -0.004869997 -0.02164 0.02581995 -0.004499971 -0.01848 0.02594995 -0.003999948 -0.02164 0.02594995 -0.003999948 -0.01841998 0.02590996 -0.004269957 -0.02001994 0.01871997 -0.004999995 -0.01986998 0.01879996 -0.004999995 -0.02025997 0.01844996 -0.004999995 -0.02039998 0.01794999 -0.004999995 -0.02037996 0.01813995 -0.004999995 -0.02039998 0.01794999 0.004999995 -0.02033996 0.01826995 0.004999995 -0.01993995 0.01877999 0.004999995 -0.01936 0.01894998 0.004999995 -0.01962 0.01892 0.004999995 -0.01879996 0.01894998 0.006679952 -0.01845997 0.01894998 0.007699966 -0.01936 0.01894998 -0.004999995 -0.01971 0.01888996 -0.004999995 -0.01845997 0.01894998 -0.007699966 -0.01668 0.01894998 -0.01102995 -0.01141995 0.01894998 -0.01641994 -7.8e-4 0.01894998 -0.01997995 0 0.01894998 -0.01993995 0.002989947 0.01894998 -0.01976996 0.01315999 0.01894998 -0.01505994 0.01454997 0.01894998 -0.01358997 0.01576 0.01894998 -0.01230996 0.01990997 0.01894998 0.001369953 0.01990997 0.01894998 -0.001889944 0.01919996 0.01894998 0.005609989 0.01779997 0.01894998 0.009119987 0.00792998 0.01894998 0.01826995 0.01008999 0.01894998 0.01726996 -0.007959961 0.01894998 0.01832997 -0.004529953 0.01894998 0.01947999 -0.01668 0.01894998 0.01102995 -0.01892 0.01881998 0.007889986 -0.02024996 0.01843994 0.004999995 -0.02017998 0.01855999 0.004999995 -0.00812 0.01894998 -0.01827996 0.006659984 0.01894998 -0.01885998 0.01576 0.01894998 0.01230996 0.002989947 0.01894998 0.01976996 0.002719998 0.01894998 0.01978999 -0.01141995 0.01894998 0.01641994 -0.01256996 0.01894998 0.01545 -0.01767998 0.01894998 -0.009159982 -0.01892 0.01881998 -0.007889986 -0.01937997 0.01794999 -0.008079946 -0.01830995 0.01794999 -0.01009994 -0.01925998 0.01844996 -0.008029997 -0.01458996 0.01894998 -0.01362997 -0.01709997 0.01881998 -0.01130998 -0.01750999 0.01794999 -0.01159 -0.0151 0.01794999 -0.01457995 -0.01739996 0.01844996 -0.01150995 -0.01431 0.01894998 -0.01397997 -0.01466 0.01881998 -0.01432996 -0.01501995 0.01794999 -0.01467996 -0.01491999 0.01844996 -0.01457995 -0.01034998 0.01894998 -0.01701998 -0.008319973 0.01881998 -0.01872998 -0.01169997 0.01881998 -0.01682996 -0.01198995 0.01794999 -0.01723998 -0.01190996 0.01844996 -0.01712995 -8.2e-4 0.01794999 -0.02098 -0.004759967 0.01794999 -0.02044999 -0.004729986 0.01844996 -0.02031999 -0.005689978 0.01794999 -0.02013999 -0.01073998 0.01794999 -0.01794999 -0.008529961 0.01794999 -0.01918995 -0.008469998 0.01844996 -0.01906996 -2.5e-4 0.01794999 -0.02094995 -8.2e-4 0.01844996 -0.02085 -8.1e-4 0.01881998 -0.02047997 -0.005379974 0.01894998 -0.01919996 -0.004649996 0.01881998 -0.01996999 -0.004529953 0.01894998 -0.01947999 0.005379974 0.01894998 -0.01917999 0.006829977 0.01881998 -0.01932996 0.003069996 0.01881998 -0.02026998 0.003139972 0.01794999 -0.02075999 0.003119945 0.01844996 -0.02063 0.01381999 0.01794999 -0.01580995 0.01059997 0.01794999 -0.01813 0.01052999 0.01844996 -0.01800996 0.01034998 0.01794999 -0.01824998 0.005209982 0.01794999 -0.02024996 0.006989955 0.01794999 -0.01979994 0.006949961 0.01844996 -0.01966995 0.01469999 0.01794999 -0.01488 0.01372998 0.01844996 -0.01570999 0.01348996 0.01881998 -0.01542997 0.01008999 0.01894998 -0.01726996 0.01034998 0.01881998 -0.01769995 0.01036995 0.01894998 -0.01705998 0.01774996 0.01894998 -0.009199976 0.01823997 0.01881998 -0.009349942 0.01615995 0.01881998 -0.01261997 0.01655 0.01794999 -0.01291996 0.01644998 0.01844996 -0.01283997 0.02090996 0.01794999 -0.00198996 0.02023994 0.01794999 -0.005469977 0.02002996 0.01844996 -0.005849957 0.02015995 0.01794999 -0.005889952 0.01807999 0.01794999 -0.01052999 0.01868999 0.01794999 -0.009579956 0.01857 0.01844996 -0.009519994 0.02090996 0.01794999 0 0.02076995 0.01844996 -0.001969993 0.02041 0.01881998 -0.001939952 0.01919996 0.01894998 -0.005609989 0.01967996 0.01881998 -0.00575 0.01949995 0.01894998 -0.004049956 0.01990997 0.01894998 0.001889944 0.02041 0.01881998 0.001939952 0.02090996 0.01794999 0.00198996 0.02023994 0.01794999 0.005469977 0.02076995 0.01844996 0.001969993 0.01876997 0.01894998 0.006669998 0.01967996 0.01881998 0.00575 0.02015995 0.01794999 0.005889952 0.02002996 0.01844996 0.005849957 0.01627999 0.01894998 0.0115 0.01615995 0.01881998 0.01261997 0.01823997 0.01881998 0.009349942 0.01868999 0.01794999 0.009579956 0.01857 0.01844996 0.009519994 0.01059997 0.01794999 0.01813 0.01381999 0.01794999 0.01580995 0.01372998 0.01844996 0.01570999 0.01469999 0.01794999 0.01488 0.01807999 0.01794999 0.01052999 0.01655 0.01794999 0.01291996 0.01644998 0.01844996 0.01283997 0.01034998 0.01794999 0.01824998 0.01052999 0.01844996 0.01800996 0.01034998 0.01881998 0.01769995 0.01315999 0.01894998 0.01505994 0.01348996 0.01881998 0.01542997 0.01258999 0.01894998 0.01546996 0.006659984 0.01894998 0.01885998 0.003069996 0.01881998 0.02026998 0.006829977 0.01881998 0.01932996 0.006989955 0.01794999 0.01979994 0.006949961 0.01844996 0.01966995 -0.004759967 0.01794999 0.02044999 -8.2e-4 0.01794999 0.02098 -8.2e-4 0.01844996 0.02085 -2.5e-4 0.01794999 0.02094995 0.005209982 0.01794999 0.02024996 0.003139972 0.01794999 0.02075999 0.003119945 0.01844996 0.02063 -0.005689978 0.01794999 0.02013999 -0.004729986 0.01844996 0.02031999 -0.004649996 0.01881998 0.01996999 -7.8e-4 0.01894998 0.01997995 -8.1e-4 0.01881998 0.02047997 -0.002709984 0.01894998 0.01972997 -0.00812 0.01894998 0.01827996 -0.01169997 0.01881998 0.01682996 -0.008319973 0.01881998 0.01872998 -0.008529961 0.01794999 0.01918995 -0.008469998 0.01844996 0.01906996 -0.01750999 0.01794999 0.01159 -0.0151 0.01794999 0.01457995 -0.01491999 0.01844996 0.01457995 -0.01501995 0.01794999 0.01467996 -0.01073998 0.01794999 0.01794999 -0.01198995 0.01794999 0.01723998 -0.01190996 0.01844996 0.01712995 -0.01937997 0.01794999 0.008079946 -0.01830995 0.01794999 0.01009994 -0.01925998 0.01844996 0.008029997 -0.01739996 0.01844996 0.01150995 -0.01709997 0.01881998 0.01130998 -0.01431 0.01894998 0.01397997 -0.01466 0.01881998 0.01432996 -0.01629996 0.01894998 0.0115 -0.01014 0.03504997 -0.01576995 -0.005279958 0.03504997 0.01798999 0 0.03504997 0.01874995 0.005279958 0.03504997 0.01798999 0.01014 0.03504997 0.01576995 0.01416999 0.03504997 0.01227998 0.01705998 0.03504997 0.007789969 0.01855999 0.03504997 0.00266999 0.01855999 0.03504997 -0.00266999 -0.01014 0.03504997 0.01576995 -0.01416999 0.03504997 0.01227998 -0.01705998 0.03504997 0.007789969 -0.01855999 0.03504997 0.00266999 -0.01855999 0.03504997 -0.00266999 -0.01705998 0.03504997 -0.007789969 -0.01416999 0.03504997 -0.01227998 -0.005279958 0.03504997 -0.01798999 0 0.03504997 -0.01874995 0.005279958 0.03504997 -0.01798999 0.01014 0.03504997 -0.01576995 0.01416999 0.03504997 -0.01227998 0.01705998 0.03504997 -0.007789969 0.001609981 0.03494995 -0.01717996 -0.003309965 0.03504997 -0.01692998 -0.003309965 0.03494995 -0.01692998 0.001759946 0.03494995 -0.01713997 0.001969993 0.03494995 -0.01708996 0.001609981 0.03504997 -0.01717996 0.004629969 0.03494995 -0.01644998 0.006399989 0.03494995 -0.01601999 0.007199943 0.03494995 -0.01555997 0.007989943 0.03494995 -0.0151 0.006399989 0.03504997 -0.01601999 0.009659945 0.03494995 -0.01413995 0.01066994 0.03494995 -0.01354998 0.01066994 0.03504997 -0.01354998 0.01512998 0.03494995 -0.007909953 0.01104998 0.03494995 -0.01314997 0.01406997 0.03504997 -0.009979963 0.01406997 0.03494995 -0.009979963 0.01695996 0.03494995 -0.002209961 0.01631999 0.03494995 -0.005589962 0.01631999 0.03504997 -0.005589962 0.01652997 0.03494995 -0.004479944 -0.007969975 0.03494995 -0.01529997 -0.007969975 0.03504997 -0.01529997 -0.009269952 0.03494995 -0.01454997 -0.01002997 0.03494995 0.01388996 -0.01088994 0.03494995 0.01314997 -0.01299995 0.03494995 0.01133996 -0.01299995 0.03504997 0.01133996 -0.01378995 0.03494995 0.01010996 -0.01567995 0.03494995 0.007189989 -0.01567995 0.03504997 0.007189989 -0.01626998 0.03494995 0.005199968 -0.01706999 0.03494995 0.002459943 -0.01706999 0.03494995 0.002019941 -0.01706999 0.03494995 9.7e-4 -0.01706999 0.03494995 6.9e-4 -0.01706999 0.03504997 0.002459943 -0.01706999 0.03494995 -0.002209961 -0.01706999 0.03494995 -0.002459943 -0.01706999 0.03504997 -0.002459943 -0.01647996 0.03494995 -0.004479944 -0.01567995 0.03494995 -0.007189989 -0.01567995 0.03504997 -0.007189989 -0.01521998 0.03494995 -0.007909953 -0.01299995 0.03504997 -0.01133996 -0.01299995 0.03494995 -0.01133996 -0.01002997 0.03494995 -0.01388996 -0.01088994 0.03494995 -0.01314997 -0.009269952 0.03504997 -0.01454997 -0.009269952 0.03494995 0.01454997 -0.009269952 0.03504997 0.01454997 0.01718997 0.03494995 9.7e-4 0.01699 0.03494995 0.002019941 0.01638996 0.03494995 0.005199968 0.01631999 0.03494995 0.005589962 0.01631999 0.03504997 0.005589962 0.01104998 0.03494995 0.01314997 0.01406997 0.03494995 0.009979963 0.01406997 0.03504997 0.009979963 0.01394999 0.03494995 0.01010996 0.01066994 0.03494995 0.01354998 0.009659945 0.03494995 0.01413995 0.01066994 0.03504997 0.01354998 0.007199943 0.03494995 0.01555997 0.006399989 0.03494995 0.01601999 0.006399989 0.03504997 0.01601999 0.004629969 0.03494995 0.01644998 0.001969993 0.03494995 0.01708996 0.001759946 0.03494995 0.01713997 0.001609981 0.03494995 0.01717996 0.001609981 0.03504997 0.01717996 -0.003309965 0.03494995 0.01692998 -0.007969975 0.03504997 0.01529997 -0.007969975 0.03494995 0.01529997 -0.003309965 0.03504997 0.01692998 0.01722997 0.03504997 7.5e-4 0.01722997 0.03494995 7.5e-4 0.01722997 0.03494995 -7.5e-4 0.01722997 0.03504997 -7.5e-4 -0.02063995 0.005949974 0.006999969 -0.02213996 0.005949974 0.004869997 -0.02213996 0.005949974 -0.004869997 -0.02263998 0.005949974 -0.003999948 -0.02263998 0.005949974 0 -0.02263998 0.005949974 0.003999948 -0.02249997 0.005949974 -0.004499971 -0.02249997 0.005949974 0.004499971 -0.01838999 0.005949974 -0.01014 -0.01510995 0.005949974 -0.01458996 -0.01510995 0.005949974 0.01458996 -0.01077997 0.005949974 -0.01801997 -0.01077997 0.005949974 0.01801997 -0.005709946 0.005949974 -0.02020996 -0.005709946 0.005949974 0.02020996 -2.5e-4 0.005949974 -0.02099996 -2.5e-4 0.005949974 0.02099996 0 0.005949974 -0.02096998 0 0.005949974 0.02096998 0.005239963 0.005949974 -0.02033996 0.005239963 0.005949974 0.02033996 0.01036 0.005949974 -0.01826995 0.01036 0.005949974 0.01826995 0.01475995 0.005949974 -0.01493996 0.01475995 0.005949974 0.01493996 0.01814997 0.005949974 -0.01056998 0.01814997 0.005949974 0.01056998 0.02026998 0.005949974 -0.005479991 0.02099996 0.005949974 0 0.02026998 0.005949974 0.005479991 -0.02499997 -0.03504997 -0.023 -0.02499997 -0.03504997 0.023 -0.02472996 -0.03504997 -0.02399998 -0.02472996 -0.03504997 0.02399998 -0.02399998 -0.03504997 -0.02472996 -0.02399998 -0.03504997 0.02472996 -0.02363997 0.003949999 -0.02164 -0.02363997 0.003949999 0.02164 -0.02363997 0.00544995 -0.02164 -0.02363997 0.00544995 0.02164 -0.02357 0.005699992 -0.02164 -0.02357 0.005699992 0.02164 -0.02338999 0.005879998 -0.02164 -0.02338999 0.005879998 0.02164 -0.02336996 0.003959953 0.02263998 -0.02336996 0.00544995 -0.02263998 -0.02336996 0.00544995 0.02263998 -0.02336996 0.003959953 -0.02263998 -0.02331 0.005699992 -0.02260994 -0.02331 0.005699992 0.02260994 -0.02314996 0.005879998 -0.02250999 -0.02314996 0.005879998 0.02250999 -0.02313995 0.005949974 -0.02164 -0.02313995 0.005949974 0 -0.02313995 0.005949974 0.02164 -0.023 -0.03504997 -0.02499997 -0.023 -0.03504997 0.02499997 -0.02293998 0.005949974 -0.02238994 -0.02293998 0.005949974 0.02238994 0 -0.03504997 0 -0.02263998 0.003959953 0.02336996 -0.02263998 0.003959953 -0.02336996 -0.02263998 0.00544995 -0.02336996 -0.02263998 0.00544995 0.02336996 -0.02260994 0.005699992 -0.02331 -0.02260994 0.005699992 0.02331 -0.02250999 0.005879998 -0.02314996 -0.02250999 0.005879998 0.02314996 0 0.005949974 -0.02313995 -0.02164 0.005949974 -0.02313995 -0.02238994 0.005949974 -0.02293998 -0.02238994 0.005949974 0.02293998 -0.02164 0.003949999 -0.02363997 -0.02164 0.003949999 0.02363997 -0.02164 0.00544995 -0.02363997 -0.02164 0.00544995 0.02363997 -0.02164 0.005699992 -0.02357 -0.02164 0.005699992 0.02357 -0.02164 0.005879998 -0.02338999 -0.02164 0.005879998 0.02338999 -0.02164 0.005949974 0.02313995 -0.005709946 0.005949974 -0.02020996 -0.01077997 0.005949974 -0.01801997 -0.01510995 0.005949974 -0.01458996 -0.01838999 0.005949974 -0.01014 -0.02213996 0.005949974 -0.004869997 0 0.005949974 0.02313995 0.02164 0.003949999 -0.02363997 0.02164 0.003949999 0.02363997 0.02164 0.00544995 -0.02363997 0.02164 0.00544995 0.02363997 0.02164 0.005699992 -0.02357 0.02164 0.005699992 0.02357 0.02164 0.005879998 -0.02338999 0.02164 0.005879998 0.02338999 0.02164 0.005949974 -0.02313995 0.02164 0.005949974 0.02313995 0.02238994 0.005949974 -0.02293998 0.02238994 0.005949974 0.02293998 0.02250999 0.005879998 -0.02314996 0.02250999 0.005879998 0.02314996 0.02260994 0.005699992 -0.02331 0.02260994 0.005699992 0.02331 0.02263998 0.003959953 -0.02336996 0.02263998 0.003959953 0.02336996 0.02263998 0.00544995 -0.02336996 0.02263998 0.00544995 0.02336996 0.02293998 0.005949974 -0.02238994 0.02293998 0.005949974 0.02238994 0.023 -0.03504997 -0.02499997 0.023 -0.03504997 0.02499997 0.02313995 0.005949974 -0.02164 0.02313995 0.005949974 0 0.02313995 0.005949974 0.02164 0.02314996 0.005879998 -0.02250999 0.02314996 0.005879998 0.02250999 0.02331 0.005699992 -0.02260994 0.02331 0.005699992 0.02260994 0.02336996 0.003959953 -0.02263998 0.02336996 0.003959953 0.02263998 0.02336996 0.00544995 -0.02263998 0.02336996 0.00544995 0.02263998 0.02338999 0.005879998 -0.02164 0.02338999 0.005879998 0.02164 0.02357 0.005699992 -0.02164 0.02357 0.005699992 0.02164 0.02363997 0.003949999 -0.02164 0.02363997 0.003949999 0.02164 0.02363997 0.00544995 -0.02164 0.02363997 0.00544995 0.02164 0.02399998 -0.03504997 -0.02472996 0.02399998 -0.03504997 0.02472996 0.02472996 -0.03504997 -0.02399998 0.02472996 -0.03504997 0.02399998 0.02499997 -0.03504997 -0.023 0.02499997 -0.03504997 0.023 0 0.03504997 0 -0.02213996 0.005949974 0.004869997 -0.02063995 0.005949974 0.006999969 -0.01979994 0.005949974 0.006999969 -0.01838999 0.005949974 0.01014 -0.02113997 0.005949974 0.006869971 -0.02149999 0.005949974 0.006499946 -0.02164 0.005949974 0.005999982 -0.02164 0.005949974 0.004999995 -0.02263998 0.005949974 -0.003999948 -0.02263998 0.005949974 0.003999948 -0.02249997 0.005949974 -0.004499971 -0.02249997 0.005949974 0.004499971 -0.01838999 0.005949974 -0.01014 -0.01510995 0.005949974 -0.01458996 -0.01510995 0.005949974 0.01458996 -0.01077997 0.005949974 -0.01801997 -0.01077997 0.005949974 0.01801997 -0.005709946 0.005949974 -0.02020996 -0.005709946 0.005949974 0.02020996 -2.5e-4 0.005949974 -0.02099996 -2.5e-4 0.005949974 0.02099996 0 0.005949974 -0.02096998 0 0.005949974 0.02096998 0.005239963 0.005949974 -0.02033996 0.005239963 0.005949974 0.02033996 0.01036 0.005949974 -0.01826995 0.01036 0.005949974 0.01826995 0.01475995 0.005949974 -0.01493996 0.01475995 0.005949974 0.01493996 0.01814997 0.005949974 -0.01056998 0.01814997 0.005949974 0.01056998 0.02026998 0.005949974 -0.005479991 0.02099996 0.005949974 0 0.02026998 0.005949974 0.005479991 -0.005709946 0.005949974 -0.02020996 -0.01077997 0.005949974 -0.01801997 -0.01510995 0.005949974 -0.01458996 -0.01838999 0.005949974 -0.01014 -0.01979994 0.005949974 0.006999969 -0.01838999 0.005949974 0.01014 -0.02113997 0.005949974 0.006869971 -0.02149999 0.005949974 0.006499946 -0.02164 0.005949974 0.005999982 -0.02164 0.005949974 0.004999995 -0.02263998 0.005949974 -0.003999948 -0.02263998 0.005949974 0.003999948 -0.02249997 0.005949974 -0.004499971 -0.02249997 0.005949974 0.004499971 -0.01838999 0.005949974 -0.01014 -0.01510995 0.005949974 -0.01458996 -0.01510995 0.005949974 0.01458996 -0.01077997 0.005949974 -0.01801997 -0.01077997 0.005949974 0.01801997 -0.005709946 0.005949974 -0.02020996 -0.005709946 0.005949974 0.02020996 -2.5e-4 0.005949974 -0.02099996 -2.5e-4 0.005949974 0.02099996 0 0.005949974 -0.02096998 0 0.005949974 0.02096998 0.005239963 0.005949974 -0.02033996 0.005239963 0.005949974 0.02033996 0.01036 0.005949974 -0.01826995 0.01036 0.005949974 0.01826995 0.01475995 0.005949974 -0.01493996 0.01475995 0.005949974 0.01493996 0.01814997 0.005949974 -0.01056998 0.01814997 0.005949974 0.01056998 0.02026998 0.005949974 -0.005479991 0.02099996 0.005949974 0 0.02026998 0.005949974 0.005479991 -0.005709946 0.005949974 -0.02020996 -0.01077997 0.005949974 -0.01801997 -0.01510995 0.005949974 -0.01458996 -0.01838999 0.005949974 -0.01014 -0.02063995 0.005949974 0.006999969 -0.02213996 0.005949974 0.004869997 -0.02213996 0.005949974 -0.004869997 -0.01979994 0.005949974 0.006999969 -0.01838999 0.005949974 0.01014 -0.02113997 0.005949974 0.006869971 -0.02149999 0.005949974 0.006499946 -0.02164 0.005949974 0.005999982 -0.02164 0.005949974 0.004999995 -0.02263998 0.005949974 -0.003999948 -0.02263998 0.005949974 0.003999948 -0.02249997 0.005949974 -0.004499971 -0.02249997 0.005949974 0.004499971 -0.01838999 0.005949974 -0.01014 -0.01510995 0.005949974 -0.01458996 -0.01510995 0.005949974 0.01458996 -0.01077997 0.005949974 -0.01801997 -0.01077997 0.005949974 0.01801997 -0.005709946 0.005949974 -0.02020996 -0.005709946 0.005949974 0.02020996 -2.5e-4 0.005949974 -0.02099996 -2.5e-4 0.005949974 0.02099996 0 0.005949974 -0.02096998 0 0.005949974 0.02096998 0.005239963 0.005949974 -0.02033996 0.005239963 0.005949974 0.02033996 0.01036 0.005949974 -0.01826995 0.01036 0.005949974 0.01826995 0.01475995 0.005949974 -0.01493996 0.01475995 0.005949974 0.01493996 0.01814997 0.005949974 -0.01056998 0.01814997 0.005949974 0.01056998 0.02026998 0.005949974 -0.005479991 0.02099996 0.005949974 0 0.02026998 0.005949974 0.005479991 -0.005709946 0.005949974 -0.02020996 -0.01077997 0.005949974 -0.01801997 -0.01510995 0.005949974 -0.01458996 -0.01838999 0.005949974 -0.01014 -0.00945729 0.003627836 -0.001710772 0 -0.01554995 0.02431994 0 0.005949974 0 + + + + + + + + + + 0 -1 0 0 -1 0 -0.9492978 0 -0.3143782 -0.9492978 0 0.3143782 -0.7785766 0.001171708 0.6275485 -0.7808654 0.001171231 0.6246982 -0.6209343 -0.001221954 0.7838616 -0.6453004 -0.01542252 0.7637733 -0.3964945 -0.0151537 0.9179121 -0.4893132 0.006718158 0.8720822 -0.4938785 0.006718337 0.8695049 -0.1431924 -0.008457064 0.9896588 -0.316222 0.006060898 0.9486659 -0.3172233 0.0060606 0.9483315 0.2392156 0.007879972 0.9709345 0.119358 -0.01385879 0.9927546 0.0559594 0.00282979 0.9984291 0.1191433 0.00413686 0.9928685 0.05255794 0.004160761 0.9986092 -0.1333157 -0.004680752 0.9910625 0.2450903 0.007883667 0.9694681 0.3747907 -0.01294112 0.9270192 0.4188861 0.001862525 0.9080369 0.4327281 0.001863181 0.9015226 0.6034716 -0.002766609 0.7973797 0.5845207 -0.01302987 0.8112742 0.7900453 -0.01468151 0.6128727 0.7272006 0.007067918 0.6863886 0.7263449 0.007068157 0.6872941 0.9823358 0.002611696 0.1871086 0.9289886 -0.004128932 0.3700852 0.9230861 -0.009820222 0.3844679 0.8414472 0.006709396 0.5402976 0.8421885 0.006709873 0.5391413 0.9819628 0.002612411 0.1890563 0.9911401 -0.01446169 0.1320315 0.9999719 0.007499694 0 0.9999719 0.007499694 0 0.9911401 -0.01446169 -0.1320315 0.9819628 0.002612411 -0.1890563 0.9823358 0.002611696 -0.1871086 0.9231205 -0.004674613 -0.3844823 0.9289375 -0.01127177 -0.3700649 0.7900453 -0.01468151 -0.6128727 0.8421885 0.006709873 -0.5391413 0.8414472 0.006709396 -0.5402976 0.4327281 0.001863181 -0.9015226 0.5845689 -0.002225697 -0.8113411 0.6034404 -0.0105375 -0.7973385 0.7263449 0.007068157 -0.6872941 0.7272006 0.007067918 -0.6863886 0.4188861 0.001862525 -0.9080369 0.3747907 -0.01294112 -0.9270192 0.2450903 0.007883667 -0.9694681 0.2392156 0.007879972 -0.9709345 0.119358 -0.01385879 -0.9927546 0.0559594 0.00282979 -0.9984291 0.1191433 0.00413686 -0.9928685 0.05255794 0.004160761 -0.9986092 -0.1431956 -0.005152344 -0.989681 -0.1333114 -0.009266734 -0.9910309 -0.3964945 -0.0151537 -0.9179121 -0.3172233 0.0060606 -0.9483315 -0.316222 0.006060898 -0.9486659 -0.7808654 0.001171231 -0.6246982 -0.6453768 -8.88654e-4 -0.7638639 -0.6208926 -0.01165908 -0.783809 -0.4938785 0.006718337 -0.8695049 -0.4893132 0.006718158 -0.8720822 -0.7785766 0.001171708 -0.6275485 -0.8049004 -0.01266139 -0.5932749 -0.881016 0.007450222 -0.4730277 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 -0.9471516 0.1680965 0.2732169 -0.407418 0.1514139 -0.9006023 -0.9422059 0.2770094 -0.1884511 -0.9113164 0.1482697 -0.3840813 -0.9315509 0.1626105 -0.3252239 -0.7991091 -0.3146805 -0.5122509 -0.9081746 0.2506373 -0.3352608 -0.9111543 0.1456485 -0.3854666 -0.928664 0.2243673 -0.2953684 -0.925579 0.2859641 -0.2480482 -0.9177774 0.2868903 0.2745518 -0.9178981 0.2856691 0.2754201 -0.9143468 0.1813663 0.3620446 -0.9384292 0.1466302 0.31281 -0.9311535 0.1683419 0.3234411 -0.901751 0.1467134 0.4065961 -0.9103941 0.1680585 0.3780726 -0.912325 0.3225979 0.2521777 -0.9188216 0.2869244 0.2710005 -0.9848498 0.1048805 0.138097 -0.9578264 0.2873474 0 -0.9559739 0.2861407 -0.06509518 -0.9987523 -0.04993659 0 -0.9210147 0.2770513 -0.2738146 -0.4861897 0.1523008 -0.8604789 -0.4091901 0.1777053 -0.8949773 -0.3149025 0.1457877 -0.9378605 -0.1278769 0.1498839 -0.9803991 -0.309273 0.1512408 -0.9388697 -0.141013 0.1688628 -0.9755002 -0.1303948 0.1630746 -0.977959 -0.4837509 0.1474936 -0.8626881 -0.636475 0.163087 -0.7538581 -0.645197 0.1696269 -0.744948 -0.7708169 0.1599442 -0.6166515 -0.6459589 0.159875 -0.746443 -0.7711567 0.1450923 -0.6198915 -0.8274903 0.1763324 -0.533073 -0.8709936 0.1562899 -0.4657721 -0.9149418 0.1555567 -0.3724025 -0.7441748 0.5367867 -0.3975726 -0.9384292 0.1466302 -0.3128098 -0.9364062 0.1603595 0.3121352 -0.8722791 0.1474033 0.4662632 -0.8271023 0.1767897 0.5335236 -0.7664864 0.1686882 0.6197121 -0.8297607 0.1690638 0.5318973 -0.7716946 0.1450895 0.6192225 -0.6450954 0.1696101 0.7450398 -0.6363618 0.1663306 0.7532449 -0.64563 0.1662972 0.7453235 -0.6361207 0.1630551 0.754164 -0.4856274 0.1477051 0.8615968 -0.4099487 0.177209 0.8947284 -0.2937462 0.1736751 0.9399735 -0.4077602 0.1746891 0.8962228 -0.3145152 0.1452308 0.9380769 -0.1418845 0.1683772 0.9754577 -0.1341822 0.1666406 0.976845 -0.1389042 0.1666364 0.9761855 -0.1267469 0.1627997 0.9784843 0.1395421 0.1371724 0.980669 0.05338537 0.1733645 0.9834097 0.07274723 0.1735997 0.9821257 0.1416881 0.1761806 0.9741073 0.2381073 0.1455035 0.9602779 0.4082419 0.1680009 0.8972816 0.4154286 0.1666471 0.8942303 0.4107152 0.1666655 0.8964015 0.4143497 0.165222 0.894995 0.6486326 0.1363442 0.7487897 0.575868 0.1693211 0.7998164 0.575499 0.1693159 0.8000832 0.6442187 0.1772168 0.7440273 0.7189208 0.1454344 0.6797072 0.8300612 0.16697 0.5320899 0.8296917 0.1670521 0.5326398 0.8285282 0.1670665 0.5344434 0.8312138 0.1651425 0.5308593 0.9521918 0.1337416 0.2746708 0.9171259 0.1644181 0.3631072 0.914055 0.1643574 0.3707966 0.9438654 0.1778166 0.2783871 0.9717582 0.1459009 0.1854698 0.9860588 0.1663975 0 0.9860587 0.1663975 0 0.9860587 0.1663975 0 0.9860587 0.1663975 0 0.9500489 0.1327823 -0.2824464 0.9697747 0.1601643 -0.1840775 0.9693279 0.1601721 -0.1864089 0.9447124 0.1775989 -0.2756393 0.830715 0.1654286 -0.5315507 0.8288937 0.166745 -0.533977 0.7189707 0.1454441 -0.6796524 0.6466634 0.1530798 -0.747257 0.717962 0.1537514 -0.6788895 0.6443232 0.1772074 -0.743939 0.5763537 0.1462174 -0.8040131 0.4070715 0.1568021 -0.8998366 0.5925795 0.1567866 -0.7901059 0.4147536 0.1656929 -0.8947209 0.4098841 0.1681987 -0.8964955 0.2399455 0.1457665 -0.9597803 0.1279237 0.1474865 -0.9807565 0.2369926 0.1489789 -0.9600207 0.1408129 0.1768286 -0.9741167 0.05614864 0.1468989 -0.9875566 0.05065917 0.1469421 -0.987847 -0.1424711 -3.79589e-4 -0.9897989 -0.129338 0 -0.9916005 -0.4158082 0 -0.9094523 -0.4154945 -2.07829e-4 -0.9095956 -0.4121701 0 -0.911107 -0.6546844 0 -0.7559022 -0.6546447 -3.01789e-5 -0.7559368 -0.6543759 0 -0.7561693 -0.840663 0 -0.5415588 -0.8408741 2.12565e-4 -0.5412307 -0.8418785 0 -0.5396671 -0.9599732 0 -0.280092 -0.9596633 -5.69179e-4 -0.2811512 -0.9585365 0 -0.2849697 -1 0 0 -1 0 0 -1 0 0 -0.9591508 0 0.2828954 -0.9596631 -8.33003e-4 0.2811512 -0.9608235 0 0.2771607 -0.8403387 0 0.5420618 -0.840874 -4.25545e-4 0.5412307 -0.8418794 0 0.5396656 -0.6545795 0 0.7559933 -0.6546447 -3.46783e-5 0.7559368 -0.6547469 0 0.7558482 -0.4165412 0 0.9091168 -0.4154945 4.29833e-4 0.9095956 -0.4141279 0 0.9102187 -0.1439396 0 0.9895865 -0.142471 5.09058e-4 0.9897989 -0.1408738 0 0.9900277 0.1408738 0 0.9900277 0.142471 5.09058e-4 0.9897989 0.1439396 0 0.9895865 0.4141279 0 0.9102187 0.4154945 4.29833e-4 0.9095956 0.4165412 0 0.9091168 0.6547469 0 0.7558482 0.6546447 -3.46783e-5 0.7559368 0.6545795 0 0.7559933 0.8418794 0 0.5396656 0.840874 -4.25545e-4 0.5412307 0.8403387 0 0.5420618 0.9608235 0 0.2771607 0.9596631 -8.33003e-4 0.2811512 0.9591508 0 0.2828954 1 0 0 1 0 0 1 0 0 0.9585365 0 -0.2849697 0.9596633 -5.69179e-4 -0.2811512 0.9599732 0 -0.280092 0.8418785 0 -0.5396671 0.8408741 2.12565e-4 -0.5412307 0.840663 0 -0.5415588 0.6543759 0 -0.7561693 0.6546447 -3.01789e-5 -0.7559368 0.6546844 0 -0.7559022 0.4121701 0 -0.911107 0.4154945 -2.07829e-4 -0.9095956 0.4158082 0 -0.9094523 0.129338 0 -0.9916005 0.1424711 -3.79589e-4 -0.9897989 0.1430675 0 -0.9897129 -0.1430675 0 -0.9897129 -1 0 0 -1 0 0 -1 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0.9838701 0.1788842 -0.007730364 0.9677938 0.2516258 -0.008649408 0.7070808 0.7070799 0.006879746 0.8947982 0.4464178 0.006871819 0.8719238 0.4895934 0.002814829 0.377206 0.9261251 -0.008792817 0.2516237 0.9677851 0 0.1293374 0.9916006 -0.9629649 0 0.269627 -0.9629649 0 0.269627 -0.251012 0.07028329 0.965429 -0.1845505 0.1845505 0.9653404 -0.07028359 0.2510112 0.9654293 -0.1942211 0.6936423 0.6936414 -0.1935422 0.6935194 0.6939541 -0.5112335 0.5112336 0.690855 -0.5112314 0.5112344 0.690856 -0.6932809 0.1941184 0.6940315 -0.7049736 0.1803423 0.6859219 -0.2607492 0.9343423 0.2429284 -0.243086 0.9349478 0.2584215 -0.682882 0.6828859 0.2594976 -0.6944488 0.6756823 0.2473751 -0.9403539 0.2405559 0.2405565 -0.9297617 0.2603295 0.2603303 -0.2516335 0.9678226 0 -0.2516335 0.9678226 0 -0.7167247 0.6973562 0 -0.7167247 0.6973562 0 -0.962965 0.2696263 0 -0.962965 0.2696263 0 -0.7167251 0 -0.6973558 -0.9629649 0 -0.269627 -0.9629649 0 -0.269627 -0.07028359 0.2510112 -0.9654293 -0.1845506 0.1845506 -0.9653404 -0.2440263 0.938564 -0.2440261 -0.2595868 0.9301772 -0.2595866 -0.6923445 0.673635 -0.2586021 -0.6852509 0.685255 -0.2466917 -0.9343009 0.2616005 -0.2421712 -0.9350127 0.2391895 -0.2618005 -0.1936007 0.6937291 -0.6937282 -0.1941202 0.693282 -0.6940299 -0.5112318 0.5112348 -0.6908552 -0.5112326 0.5112326 -0.6908563 -0.6994224 0.1789222 -0.6919503 -0.7027144 0.1967598 -0.6837237 -0.251012 0.07028329 -0.965429 0 0.1543763 -0.9880121 -0.009795784 0.2516214 -0.9677761 -0.007334709 0.722306 -0.6915347 0.00679636 0.4472005 -0.8944079 0.006780803 0.5067117 -0.8620889 -0.009076535 0.9677828 -0.2516229 0 0.9892032 -0.1465499 -0.2263051 0.7072249 0.6697902 0.3015977 0.696307 0.6513029 0.7167264 0.6973544 0 0.5183387 0.69911 -0.4925142 0.03862148 0.6995103 -0.7135781 -0.1644762 0.9669772 0.1946862 -0.1248043 0.9671578 0.2214269 0.01370066 0.9675313 0.2523798 0.06004744 0.9683741 0.2421693 0.1849305 0.9670732 0.1748434 0.1059339 0.9677575 -0.2285243 -0.1261059 0.966584 -0.2231875 -0.199501 0.9668129 -0.1596003 -0.6712515 0.704275 -0.2311238 -0.4654791 0.8727707 -0.1469718 -0.4844728 0.8612704 -0.1532949 -0.8913083 0.3450198 -0.2941612 -0.915989 0.251125 -0.3128905 -0.944593 0.09943693 -0.3128201 -0.9346077 0.1752427 0.3095133 -0.9163941 0.251105 0.3117182 -0.8494461 0.4497035 0.2760577 -0.6587777 0.7186641 0.2225626 -0.11454 0.9926847 0.03817999 -0.2079164 0.9745261 0.08408081 -0.2403051 0.9673867 0.08010166 -0.2239108 0.9672326 0.119688 -0.2239329 0.9672339 -0.1196353 -0.2369856 0.9674997 -0.08821576 -0.168695 0.984063 -0.05623167 -0.220901 0.9681158 -0.1181289 -0.195109 0.9681603 -0.1568376 -0.1642051 0.9670629 -0.194489 -0.1243403 0.9671458 -0.2217399 -0.03328311 0.9677709 -0.249623 0.01294058 0.9675522 -0.2523397 0.01371669 0.9672559 -0.2534325 0.01418453 0.9682756 -0.2494817 0.05979275 0.9683793 -0.2422114 0.1485582 0.966945 -0.2072386 0.1849181 0.9670735 -0.1748546 0.1827625 0.9676989 -0.173657 0.181624 0.9682638 -0.1716915 0.2103747 0.9683087 -0.1346127 0.2516335 0.9678226 0 0.2516335 0.9678226 0 0.2516335 0.9678227 0 0.2469634 0.9678903 -0.04687726 0.2482241 0.9675434 0.04737603 0.2343087 0.9675045 0.09504997 0.2367252 0.9670455 0.09372389 0.21423 0.9671535 0.1368191 0.1064419 0.9675605 0.2291214 0.1058055 0.9677801 0.2284879 0.1058276 0.9677543 0.2285876 0.1467888 0.9679301 0.2038734 -0.0766099 0.966454 0.245148 -0.08143335 0.9670985 0.2410164 -0.07958346 0.9681548 0.2373665 -0.03413015 0.9680389 0.2484672 -0.1947117 0.9681448 0.1574264 -0.2211804 0.9681038 0.1177042 -0.6276769 0.7031698 0.3340269 -0.6718416 0.7042246 0.2295574 -0.8316648 0.4851421 0.270131 -0.224141 0.7071188 -0.6706294 -0.08158397 0.9665949 -0.242978 -0.08118349 0.9673035 -0.240277 -0.230294 0.6945442 -0.6815959 -0.09658795 0.6949279 -0.7125629 -0.1300739 0.2494957 -0.9596003 0.05087167 0.2513077 -0.9665695 0.3019366 0.6962896 -0.6511644 0.06135189 0.9674767 -0.2454073 0.1061488 0.9675673 -0.2292293 0.3024179 0.6942894 -0.653074 0.4201316 0.6941274 -0.584531 0.5638182 0.2583763 -0.7844429 0.7015674 0.2590524 -0.6638488 0.657499 0.7065963 -0.2615662 0.6635753 0.6994388 -0.2654304 0.7016292 0.6998641 -0.133816 0.5189352 0.6991608 0.4918134 0.2101477 0.9683169 0.1349092 0.1812267 0.9682484 0.1721977 0.5147917 0.7040795 0.4891439 0.4141255 0.7046437 0.5761747 0.562515 0.2665852 0.7826297 0.4170309 0.2669032 0.8688198 0.03983807 0.6995611 0.7134614 0.01843094 0.9683725 0.2488275 0.01364505 0.9676027 0.2521088 0.03827118 0.7060714 0.7071057 -0.09523808 0.7051784 0.7026044 -0.1298174 0.2567928 0.9577082 -0.305629 0.2567279 0.916887 -0.4603919 0.7019324 0.5434429 -0.1641054 0.967066 0.194558 -0.164548 0.966937 0.1948249 -0.463243 0.6961148 0.5484799 -0.5580259 0.6967077 0.4507831 -0.8506854 0.2602313 -0.4567428 -0.2229626 0.9675791 -0.1186526 -0.6337479 0.6961472 -0.3372576 -0.6271286 0.7031058 -0.3351895 -0.8501825 0.2659004 -0.454408 -0.8554773 0.2506282 -0.4531491 -0.7517282 0.2706233 -0.6013882 -0.1978173 0.9671215 -0.159826 -0.5579887 0.6967101 -0.4508255 -0.5582559 0.6964031 -0.4509689 -0.7490752 0.2696682 -0.6051161 -0.7513393 0.2621917 -0.6055946 -0.1644515 0.9669765 -0.1947106 -0.4595423 0.7019816 -0.5440982 -0.464033 0.6961706 -0.5477408 -0.6238481 0.261821 -0.7363854 -0.621176 0.2712791 -0.7352197 -0.1242595 0.9673138 -0.221051 -0.3465486 0.7069951 -0.6164916 -0.3499536 0.7017597 -0.6205367 -0.4731478 0.2687683 -0.8389843 -0.4767771 0.2609524 -0.839397 -0.1288474 0.2567702 -0.9578452 -0.305629 0.2567279 -0.9168869 -0.3062461 0.2581284 -0.9162877 -0.3065935 0.2567667 -0.916554 -0.4726419 0.2588881 -0.8423696 0.05413478 0.2532923 -0.965874 0.05391412 0.2545722 -0.9655498 0.03948223 0.7060217 -0.7070888 -0.09333491 0.7052802 -0.7027577 -0.03303414 0.9680098 -0.2487279 -0.07829689 0.9681807 -0.2376884 0.06135183 0.9674766 -0.2454078 0.1740778 0.696309 -0.6963121 0.1739403 0.6986982 -0.6939493 0.2341818 0.2688215 -0.9342879 0.2314112 0.2534631 -0.9392579 0.5634199 0.2665578 -0.7819878 0.4170309 0.2669032 -0.8688198 0.4046592 0.2732187 -0.8726983 0.4044461 0.2603067 -0.8767347 0.2365246 0.2621741 -0.9355859 0.7046238 0.2473371 -0.6650787 0.7013934 0.2572429 -0.6647355 0.5154538 0.7040323 -0.488514 0.415661 0.7047259 -0.5749672 0.1455301 0.9686573 -0.2013059 0.15098 0.9678227 -0.2013067 0.2147524 0.9670686 -0.1366009 0.5968894 0.7068039 -0.3796725 0.6017773 0.7001448 -0.3842673 0.8154708 0.2526968 -0.5207222 0.8161497 0.2468252 -0.5224721 0.9629638 0.2696306 0 0.9449788 0.2718722 -0.1819358 0.9482918 0.2608299 -0.18086 0.9482879 0.261008 -0.1806234 0.8967889 0.2617092 -0.3567605 0.8974719 0.258296 -0.3575298 0.8130294 0.2577725 -0.5220504 0.9629638 0.2696306 0 0.9629638 0.2696306 0 0.7167264 0.6973544 0 0.70467 0.6965711 -0.1350152 0.2486808 0.9674128 -0.04764741 0.2481271 0.9675516 -0.04771661 0.9482879 0.261008 0.1806234 0.2469177 0.9678809 0.04730957 0.7014893 0.6998912 0.1344058 0.7047534 0.6966033 0.1344119 0.9482918 0.2608299 0.18086 0.9449788 0.2718721 0.1819358 0.2322279 0.9682156 0.09289127 0.6569463 0.7066604 0.2627788 0.6640112 0.699507 0.2641569 0.8976452 0.2582861 0.3571012 0.8966205 0.2616998 0.3571906 0.2123748 0.9678058 0.1350885 0.6024934 0.7000937 0.3832371 0.59627 0.7067469 0.3807505 0.8154708 0.2526969 0.5207222 0.8130294 0.2577725 0.5220504 0.5647161 0.2584066 0.7837867 0.7015674 0.2590524 0.6638488 0.7013934 0.2572429 0.6647355 0.7046238 0.2473371 0.6650787 0.8161497 0.2468252 0.5224721 0.4044461 0.2603067 0.8767347 0.4046592 0.2732187 0.8726983 0.3027438 0.6943063 0.6529051 0.4217932 0.6940296 0.5834496 0.1488554 0.9671839 0.2059057 0.1488695 0.9669557 0.2069647 0.06135171 0.9674767 0.2454074 0.1735082 0.6987219 0.6940336 0.1745008 0.6963297 0.6961856 0.2341818 0.2688215 0.9342879 0.2365246 0.2621741 0.9355859 -0.1291 0.2495277 0.9597235 0.05087167 0.2513077 0.9665695 0.05391412 0.2545722 0.9655498 0.05413478 0.2532923 0.965874 0.2314112 0.2534631 0.9392579 -0.3065935 0.2567667 0.916554 -0.3062461 0.2581284 0.9162877 -0.2280214 0.6946619 0.6822397 -0.09468263 0.6948394 0.7129049 -0.03354847 0.9669889 0.2526004 -0.03234249 0.9677872 0.2496837 -0.1255912 0.9665973 0.22342 -0.3491178 0.7017115 0.6210619 -0.3474251 0.7069473 0.616053 -0.4731478 0.2687683 0.8389843 -0.4726419 0.2588881 0.8423696 -0.8506854 0.2602313 0.4567428 -0.7513393 0.2621915 0.6055946 -0.7490752 0.2696682 0.6051161 -0.7517282 0.2706233 0.6013882 -0.6221522 0.2713071 0.7343835 -0.6228598 0.2618451 0.7372128 -0.4767771 0.2609524 0.839397 -0.8554773 0.2506282 0.4531491 -0.8501825 0.2659004 0.454408 -0.6330834 0.6962109 0.3383722 -0.5582225 0.6964006 0.4510145 -0.1946848 0.9681715 0.1572951 -0.1992351 0.9668231 0.15987 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0.2576645 0 -0.9662344 -0.05074721 0 -0.9987115 -0.05074721 0 -0.9987115 -0.3301701 0 -0.9439214 -0.3301701 0 -0.9439214 0.2314149 -0.04166501 -0.9719626 0.2337992 -0.0328713 -0.9717291 -0.2353472 -0.01319801 0.9718218 0.2360719 0 -0.9717356 0.498471 0 -0.8669065 0.5025548 0.05025458 -0.8630836 0.4977039 -0.0518344 -0.8657968 0.5000953 0.04980254 -0.8645372 0.5044022 0 -0.8634689 0.7249996 0 -0.6887493 0.7241208 -0.006897449 -0.6896386 0.8897777 0 -0.4563943 0.8898923 -0.008304476 -0.4560952 0.8900858 0 -0.4557931 0.7240293 0 -0.6897691 -0.9833266 0 0.1818479 -0.9818185 -0.044227 0.1845983 0.9825241 -0.002599418 -0.1861173 0.9825702 0 -0.1858918 0.6556872 0 0.7550326 -0.6556872 0 0.7550326 -0.6515577 -0.04579263 0.7572157 -0.6516571 -0.04426085 0.7572213 -0.6510875 0 0.7590027 -0.8414006 0 0.540412 -0.8395078 -0.03620713 0.54214 -0.8394931 0 0.5433704 -0.9587494 0 0.2842525 -0.9582376 0.04984301 0.2815961 -0.9599216 0 0.2802686 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -0.9598937 0 -0.2803642 -0.9588532 0.03467482 -0.281777 -0.9590831 0 -0.2831244 -0.8426965 0 -0.5383889 0.8393291 -0.04166615 0.5420246 0.8395044 0 0.5433529 0.6522963 0 0.757964 0.6490944 0.0781871 0.7566791 0.6515577 0.04579263 0.7572157 0.8899229 0 0.4561109 0.9838697 0 0.1788867 0.9821668 0.01870387 0.187079 0.9826549 -0.003704786 0.1854068 0.9822553 -0.03267395 0.1846804 0.9842713 0 0.1766641 0.8899229 0 0.4561109 0.7249996 0 0.6887493 0.7241208 -0.006897449 0.6896386 0.7232667 0.02902907 0.6899583 0.7348049 0 0.6782786 0.5044022 0 0.8634689 0.4990119 0.0604375 0.864485 0.5005733 0.02391499 0.8653637 0.498471 0 0.8669065 0.2360719 0 0.9717356 0.2353472 0.01319825 0.9718218 0.2337992 -0.03287124 0.9717291 0.2314148 -0.04166501 0.9719625 0.2576645 0 0.9662344 -0.05074721 0 0.9987115 -0.05074721 0 0.9987115 -0.3301701 0 0.9439214 0.3301701 0 -0.9439214 0 -1 0 0 -1 0 0 -1 0 0 0.03485059 -0.9993925 0.9993925 0.03485059 0 1 0 0 0 0 -1 -0.260666 0 0.9654291 -0.9654291 0 -0.260666 -0.9654291 0 -0.260666 -0.260666 0 -0.9654291 -0.9645484 0.04270619 -0.2604277 -0.9646556 0.04270696 -0.2600302 0.9654291 0 -0.260666 0.2604277 0.04270619 -0.9645484 0.7071068 0 0.7071068 0.2689354 0.9604846 -0.07171601 0.2758985 0.9581687 -0.07611 0.2031767 0.95783 -0.2031767 0.2031767 0.95783 -0.2031767 0.07389479 0.9579936 -0.2771059 0.07417577 0.9603113 -0.2688869 0.6940287 0.6940234 -0.1914564 0.6821739 0.707958 -0.1828504 0.4946855 0.7145437 -0.4946855 0.4946855 0.7145437 -0.4946855 0.1876068 0.7087336 -0.6800739 0.1862189 0.6947355 -0.694741 0.9324051 0.2610736 -0.2499225 0.9336825 0.2543331 -0.2520944 0.6852533 0.2466892 -0.6852533 0.6852534 0.2466892 -0.6852534 0.2503941 0.2542446 -0.9341641 0.2516342 0.2609541 -0.9319781 0 0 0 0 0.7071041 -0.7071095 0 0.7071041 -0.7071095 0 0.2696301 -0.9629639 0 0.2696301 -0.9629639 0.2696297 0.9629641 0 0.2696297 0.9629641 0 0.2696297 0.9629641 0 0.7071095 0.7071041 0 0.7071095 0.7071041 0 0.9629639 0.2696301 0 0.9629639 0.2696301 0 -0.07611 0.9581687 -0.2758985 -0.2031767 0.95783 -0.2031767 -0.2031767 0.95783 -0.2031767 -0.2771059 0.9579936 -0.07389479 -0.2688869 0.9603113 -0.07417577 -0.1914564 0.6940234 -0.6940287 -0.1828504 0.7079579 -0.6821739 -0.4946855 0.7145437 -0.4946855 -0.4946855 0.7145437 -0.4946855 -0.6800737 0.7087335 -0.1876068 -0.694741 0.6947355 -0.1862189 -0.2499225 0.2610736 -0.9324051 -0.2520944 0.2543331 -0.9336825 -0.6852533 0.2466892 -0.6852533 -0.6852534 0.2466892 -0.6852534 -0.9341641 0.2542446 -0.2503941 -0.9319781 0.2609541 -0.2516342 0.07171601 0.9604846 0.2689354 0.07611 0.9581687 0.2758985 0.2031767 0.95783 0.2031767 0.2031767 0.95783 0.2031767 0.2771059 0.9579936 0.07389479 0.2688869 0.9603113 0.07417577 0.1914564 0.6940234 0.6940287 0.1828504 0.7079579 0.6821739 0.4946855 0.7145437 0.4946855 0.4946855 0.7145437 0.4946855 0.6800737 0.7087335 0.1876068 0.694741 0.6947355 0.1862189 0.2499225 0.2610736 0.9324051 0.2520944 0.2543331 0.9336825 0.6852533 0.2466892 0.6852533 0.6852534 0.2466892 0.6852534 0.9341641 0.2542446 0.2503941 0.9319781 0.2609541 0.2516342 -0.2696297 0.9629641 0 -0.2696297 0.9629641 0 -0.2696297 0.9629641 0 -0.7071095 0.7071041 0 -0.7071095 0.7071041 0 -0.9629639 0.2696301 0 -0.9629639 0.2696301 0 0 0.9629641 0.2696297 0 0.9629641 0.2696297 0 0.9629641 0.2696297 0 0.7071041 0.7071095 0 0.7071041 0.7071095 0 0.2696301 0.9629639 0 0.2696301 0.9629639 -0.2689354 0.9604846 0.07171601 -0.2758985 0.9581687 0.07611 -0.2031767 0.95783 0.2031767 -0.2031767 0.95783 0.2031767 -0.07389479 0.9579936 0.2771059 -0.07417577 0.9603113 0.2688869 -0.6940287 0.6940234 0.1914564 -0.6821739 0.707958 0.1828504 -0.4946855 0.7145437 0.4946855 -0.4946855 0.7145437 0.4946855 -0.1876068 0.7087336 0.6800739 -0.1862189 0.6947355 0.694741 -0.9324051 0.2610736 0.2499225 -0.9336825 0.2543331 0.2520944 -0.6852533 0.2466892 0.6852533 -0.6852534 0.2466892 0.6852534 -0.2503941 0.2542446 0.9341641 -0.2516342 0.2609541 0.9319781 -0.9629639 0 -0.2696301 -0.9629639 0 -0.2696301 -0.7167251 0 -0.6973558 -0.7167237 -2.52567e-7 -0.6973572 -0.2516344 0 -0.9678224 -0.2516335 0 -0.9678226 -0.2516344 0 -0.9678224 -0.2516344 0 0.9678224 -0.2516344 0 0.9678224 -0.7167251 0 0.6973558 -0.7167251 0 0.6973558 -0.9629639 0 0.2696301 -0.9629639 0 0.2696301 -1 0 0 -1 0 0 0 0 1 0 0 -1 0 0 -1 -1 0 0 -1 0 0 -0.9122474 0 0.4096398 -0.8835567 -0.01679629 -0.4680228 -0.957763 0.01149314 -0.2873293 -0.957763 0.01149314 0.2873293 -0.8835567 -0.01679629 0.4680228 -0.9086417 0.007449328 0.4175103 -0.881016 0.007450222 0.4730277 -0.8049004 -0.01266139 0.5932749 -0.9122221 0.007446944 -0.4096284 -0.901296 0 -0.4332039 0 0 1 0 0 1 0 0 -1 0 0 -1 0 0 -1 -0.9190827 0.28875 -0.2681613 -0.9068856 0.3034356 -0.292379 -0.9189138 0.2091057 0.3344731 0.9175001 0.1444488 -0.3705781 0.8302804 0.1654177 -0.5322325 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 -0.2516344 0 0.9678224 0.002348303 0.6348381 0.7726417 -0.7167251 0 0.6973558 -0.7167251 0 0.6973558 -0.2516344 0 0.9678224 -0.2516344 0 0.9678224 -0.2516344 0 -0.9678224 -0.2516344 0 -0.9678224 -0.7167251 0 -0.6973558 -0.004324674 0.7071006 -0.7070997 0.003669202 0.9127396 -0.4085254 0.2344187 0.967514 -0.09468168 -0.7256583 0.6450302 -0.2394912 -0.3975354 0.9086532 0.1277299 0.2290577 0.9690912 -0.09162318 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 0 0 0 0 0 0 0.03485059 -0.9993925 0.9993925 0.03485059 0 -0.9993925 0.03485059 0 -0.9993925 0.03485059 0 0 0 1 0 0 1 1 0 0 0 0 -1 -1 0 0 -1 0 0 -0.7071068 0 0.7071068 -0.7071068 0 0.7071068 -0.260666 0 0.9654291 -0.9654291 0 0.260666 -0.9654291 0 0.260666 -0.9646556 0.04270696 0.2600302 -0.9645484 0.04270619 0.2604277 -0.706249 0.04924374 0.7062489 -0.7062489 0.04924374 0.7062489 -0.2604277 0.04270619 0.9645484 -0.2600302 0.04270696 0.9646556 -0.7071068 0 -0.7071068 -0.7071068 0 -0.7071068 -0.260666 0 -0.9654291 -0.2600301 0.04270696 -0.9646555 -0.2604277 0.04270619 -0.9645484 -0.7062489 0.04924374 -0.706249 -0.7062489 0.04924374 -0.7062489 0.260666 0 -0.9654291 0.7071068 0 -0.7071068 0.7071068 0 -0.7071068 0.260666 0 -0.9654291 0.9654291 0 -0.260666 0.9646556 0.04270696 -0.2600302 0.9645484 0.04270619 -0.2604277 0.706249 0.04924374 -0.7062489 0.7062489 0.04924374 -0.7062489 0.2600302 0.04270696 -0.9646556 0.2604278 0.04270619 0.9645484 0.2600301 0.04270696 0.9646556 0.9645479 0.04271709 0.2604277 0.964656 0.04269605 0.2600303 0.7062489 0.04924374 0.7062489 0.706249 0.04924374 0.7062489 0.7071068 0 0.7071068 0.9654291 0 0.260666 0.9654291 0 0.260666 0.260666 0 0.9654291 0.260666 0 0.9654291 0 0 0 0 0 0 -1.5404e-7 1 -6.36081e-7 3.24032e-7 1 5.61656e-7 6.54708e-7 1 0 -6.48629e-7 1 0 -5.82531e-7 1 2.98564e-7 4.26935e-7 1 4.96095e-7 -3.27791e-7 1 5.66667e-7 6.28108e-7 1 1.84581e-7 -1.5404e-7 1 6.36081e-7 5.49908e-7 1 -3.55121e-7 5.49908e-7 1 3.55121e-7 -4.74061e-7 1 -4.51486e-7 0 1 6.53629e-7 2.16121e-7 1 -6.17868e-7 3.24032e-7 1 -5.61656e-7 -5.82531e-7 1 -2.98564e-7 -4.74061e-7 1 4.51486e-7 4.26935e-7 1 -4.96095e-7 -3.27791e-7 1 -5.66667e-7 -6.43363e-7 1 1.20963e-7 2.16121e-7 1 6.17868e-7 6.28108e-7 1 -1.84581e-7 -6.43363e-7 1 -1.20963e-7 0 1 -6.53629e-7 0 0.9629641 -0.2696297 0 0.9629641 -0.2696297 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.1872387 -0.9823144 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.1364855 -0.9817008 -0.1327975 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.08765232 -0.9373711 -0.3371237 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.1734797 -0.9848374 0 0 0 0 0 0 0 0 0 0 -0.1734797 -0.9848374 0 0 0 0 0 0 0 0 0.9629641 -0.2696297 0 0 0 -0.07171601 0.9604846 -0.2689354 -0.08764123 -0.9899891 0.1106374 0.07545632 -0.9970984 0.01005166 -0.165484 -0.9851234 -0.04633498 0.06710433 -0.9963871 -0.05205571 -0.01855289 -0.9915714 -0.1282264 -0.1596735 -0.9861569 0.0447086 0.01166564 -0.9952132 0.09702873 0.1506127 0.98234 0.1110134 0.01357448 -0.9934884 -0.1131218 0 0 0 -0.1199531 -0.9858954 0.1167114 0.0334047 -0.9960209 0.08262425 0.07395762 -0.9967855 -0.03080356 -0.1550459 -0.986953 0.04341232 -0.04902708 -0.9923275 0.1135011 -0.05939245 -0.9717465 0.2284322 0.01359909 -0.9934894 -0.1131098 0 0 0 -0.1297165 -0.9869306 0.09561127 0.05006933 -0.9965522 0.06615769 0.07658731 -0.9970107 -0.01020228 -0.1044685 -0.9857454 -0.1318801 0.1044685 0.9857454 0.1318801 0 -0.9662557 0.2575849 -0.01562213 -0.9940313 0.1079711 -0.1443563 -0.9795069 -0.1404551 0.03801149 -0.9948446 -0.09401881 0.06233876 -0.9968829 0.04835891 -0.05876457 -0.9889584 -0.136044 -0.05089199 -0.9793348 0.195738 0.01164436 -0.9952126 0.09703755 -0.1872387 -0.9823144 0 0.05545455 -0.995769 -0.0732733 -0.1144365 -0.9871711 0.1113438 0.07075601 -0.9970582 0.02947002 -0.1506127 -0.98234 -0.1110134 0.05876457 0.9889584 0.136044 -0.1603716 -0.9844262 0.07201397 -0.01855289 -0.9915714 -0.1282265 0 0.03485065 0.9993925 0 0.03485059 0.9993926 0 0.03485053 0.9993925 0 0.03485059 0.9993926 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 -0.1707559 -0.9841526 -0.04781168 0.070692 0.9597275 0.2718927 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1790391 0.9805517 0.08039653 -0.1790391 -0.9805517 -0.08039653 0 -0.9156407 -0.4019977 + + + + + + + + + + + + + + + 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 4 4 4 4 4 4 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +

376 0 371 0 375 0 325 1 326 1 329 1 161 2 75 2 120 2 122 3 76 3 284 3 277 4 404 4 278 4 278 5 404 5 280 5 280 6 404 6 406 6 280 7 406 7 282 7 408 8 275 8 406 8 406 9 275 9 281 9 406 10 281 10 282 10 410 11 259 11 408 11 408 12 259 12 266 12 408 13 266 13 275 13 414 14 263 14 264 14 414 15 264 15 412 15 412 16 264 16 262 16 412 17 262 17 410 17 410 18 262 18 260 18 410 19 260 19 259 19 263 20 414 20 257 20 257 21 414 21 416 21 257 22 416 22 248 22 248 23 416 23 241 23 241 24 416 24 418 24 241 25 418 25 242 25 420 26 246 26 418 26 418 27 246 27 244 27 418 28 244 28 242 28 230 29 234 29 423 29 423 30 234 30 239 30 423 31 239 31 420 31 420 32 239 32 245 32 420 33 245 33 246 33 230 34 423 34 229 34 229 35 423 35 422 35 229 36 422 36 221 36 221 37 422 37 214 37 214 38 422 38 421 38 214 39 421 39 215 39 215 40 421 40 217 40 217 41 421 41 419 41 217 42 419 42 219 42 417 43 212 43 419 43 419 44 212 44 218 44 419 45 218 45 219 45 199 46 197 46 415 46 415 47 197 47 196 47 415 48 196 48 417 48 417 49 196 49 203 49 417 50 203 50 212 50 199 51 415 51 201 51 201 52 415 52 413 52 201 53 413 53 200 53 200 54 413 54 194 54 194 55 413 55 411 55 194 56 411 56 185 56 185 57 411 57 409 57 185 58 409 58 178 58 178 59 409 59 407 59 178 60 407 60 179 60 405 61 183 61 407 61 407 62 183 62 181 62 407 63 181 63 179 63 167 64 171 64 403 64 403 65 171 65 176 65 403 66 176 66 405 66 405 67 176 67 182 67 405 68 182 68 183 68 167 69 403 69 166 69 166 70 403 70 402 70 166 71 402 71 162 71 84 72 76 72 122 72 122 73 123 73 84 73 84 74 123 74 150 74 84 75 150 75 151 75 151 76 124 76 84 76 126 77 125 77 84 77 84 78 125 78 27 78 84 79 27 79 82 79 118 80 117 80 107 80 107 81 106 81 28 81 120 82 107 82 121 82 121 83 107 83 119 83 118 84 107 84 130 84 130 85 107 85 28 85 130 86 28 86 129 86 41 87 40 87 127 87 31 88 30 88 173 88 114 89 74 89 36 89 28 90 106 90 34 90 108 91 35 91 110 91 110 92 35 92 34 92 110 93 34 93 109 93 109 94 34 94 106 94 108 95 111 95 35 95 36 96 116 96 114 96 78 97 40 97 80 97 80 98 40 98 79 98 40 99 81 99 83 99 125 100 127 100 27 100 27 101 127 101 40 101 27 102 40 102 82 102 82 103 40 103 83 103 79 104 40 104 77 104 77 105 40 105 39 105 77 106 39 106 73 106 73 107 39 107 38 107 73 108 38 108 74 108 74 109 38 109 37 109 74 110 37 110 36 110 173 111 30 111 152 111 152 112 30 112 29 112 152 113 29 113 188 113 188 114 29 114 71 114 188 115 71 115 190 115 190 116 71 116 72 116 190 117 72 117 134 117 173 118 133 118 31 118 31 119 133 119 169 119 31 120 169 120 32 120 32 121 169 121 164 121 32 122 164 122 33 122 33 123 164 123 132 123 33 124 132 124 34 124 34 125 132 125 159 125 34 126 159 126 28 126 28 127 159 127 131 127 28 128 131 128 129 128 127 129 128 129 41 129 41 130 128 130 148 130 41 131 148 131 42 131 42 132 148 132 291 132 42 133 291 133 43 133 43 134 291 134 289 134 43 135 289 135 44 135 44 136 289 136 158 136 44 137 158 137 45 137 158 138 157 138 45 138 45 139 157 139 272 139 45 140 272 140 46 140 46 141 272 141 146 141 46 142 146 142 47 142 47 143 146 143 147 143 47 144 147 144 48 144 48 145 147 145 271 145 48 146 271 146 49 146 49 147 271 147 269 147 49 148 269 148 50 148 269 149 156 149 50 149 50 150 156 150 155 150 50 151 155 151 51 151 51 152 155 152 254 152 51 153 254 153 52 153 52 154 254 154 144 154 52 155 144 155 53 155 53 156 144 156 145 156 53 157 145 157 54 157 145 158 253 158 54 158 54 159 253 159 251 159 54 160 251 160 55 160 55 161 251 161 154 161 55 162 154 162 56 162 56 163 154 163 236 163 56 164 236 164 57 164 57 165 236 165 143 165 57 166 143 166 58 166 143 167 232 167 58 167 58 168 232 168 142 168 58 169 142 169 59 169 59 170 142 170 227 170 59 171 227 171 60 171 60 172 227 172 140 172 60 173 140 173 61 173 61 174 140 174 141 174 61 175 141 175 62 175 141 176 226 176 62 176 62 177 226 177 224 177 62 178 224 178 63 178 64 179 209 179 139 179 64 180 139 180 65 180 65 181 139 181 138 181 65 182 138 182 66 182 66 183 138 183 137 183 66 184 137 184 67 184 67 185 137 185 208 185 67 186 208 186 68 186 208 187 206 187 68 187 68 188 206 188 153 188 68 189 153 189 69 189 69 190 153 190 191 190 69 191 191 191 70 191 70 192 191 192 136 192 70 193 136 193 72 193 72 194 136 194 135 194 72 195 135 195 134 195 71 196 308 196 309 196 71 197 29 197 308 197 308 198 29 198 30 198 308 199 30 199 292 199 30 200 31 200 292 200 292 201 31 201 32 201 292 202 32 202 307 202 32 203 33 203 307 203 307 204 33 204 34 204 307 205 34 205 306 205 34 206 35 206 306 206 306 207 35 207 36 207 306 208 36 208 305 208 36 209 37 209 305 209 305 210 37 210 38 210 305 211 38 211 304 211 38 212 39 212 304 212 304 213 39 213 40 213 304 214 40 214 303 214 40 215 41 215 303 215 303 216 41 216 42 216 303 217 42 217 302 217 42 218 43 218 302 218 302 219 43 219 44 219 302 220 44 220 301 220 44 221 45 221 301 221 301 222 45 222 46 222 301 223 46 223 293 223 46 224 47 224 293 224 293 225 47 225 48 225 293 226 48 226 294 226 48 227 49 227 294 227 294 228 49 228 50 228 294 229 50 229 295 229 50 230 51 230 295 230 295 231 51 231 52 231 295 232 52 232 296 232 52 233 53 233 296 233 296 234 53 234 54 234 296 235 54 235 297 235 54 236 55 236 297 236 297 237 55 237 56 237 297 238 56 238 298 238 56 239 57 239 298 239 298 240 57 240 58 240 298 241 58 241 299 241 58 242 59 242 299 242 299 243 59 243 60 243 299 244 60 244 300 244 60 245 61 245 300 245 300 246 61 246 62 246 300 247 62 247 313 247 62 248 63 248 313 248 313 249 63 249 64 249 313 250 64 250 312 250 64 251 65 251 312 251 312 252 65 252 66 252 312 253 66 253 311 253 66 254 67 254 311 254 311 255 67 255 68 255 311 256 68 256 310 256 68 257 69 257 310 257 310 258 69 258 70 258 310 259 70 259 309 259 309 260 70 260 72 260 309 261 72 261 71 261 399 262 95 262 398 262 398 263 95 263 99 263 398 264 99 264 397 264 93 265 77 265 73 265 93 266 73 266 115 266 115 267 73 267 74 267 115 268 74 268 114 268 77 269 93 269 79 269 79 270 93 270 89 270 85 271 78 271 89 271 89 272 78 272 80 272 89 273 80 273 79 273 81 274 85 274 83 274 83 275 85 275 84 275 83 276 84 276 82 276 95 277 399 277 401 277 95 278 401 278 92 278 84 279 87 279 88 279 86 280 87 280 84 280 85 281 86 281 84 281 85 282 89 282 86 282 86 283 89 283 90 283 86 284 90 284 87 284 87 285 90 285 91 285 87 286 91 286 88 286 88 287 91 287 92 287 89 288 93 288 90 288 90 289 93 289 94 289 90 290 94 290 91 290 91 291 94 291 96 291 91 292 96 292 92 292 92 293 96 293 95 293 93 294 115 294 97 294 93 295 97 295 94 295 94 296 97 296 98 296 94 297 98 297 96 297 96 298 98 298 99 298 96 299 99 299 95 299 105 300 400 300 103 300 103 301 400 301 397 301 103 302 397 302 99 302 101 303 112 303 107 303 101 304 107 304 104 304 115 305 113 305 97 305 97 306 113 306 100 306 97 307 100 307 98 307 98 308 100 308 102 308 98 309 102 309 99 309 99 310 102 310 103 310 113 311 112 311 100 311 100 312 112 312 101 312 100 313 101 313 102 313 102 314 101 314 104 314 102 315 104 315 103 315 103 316 104 316 105 316 105 317 104 317 107 317 106 318 107 318 109 318 109 319 107 319 112 319 111 320 108 320 112 320 112 321 108 321 110 321 112 322 110 322 109 322 116 323 113 323 115 323 116 324 115 324 114 324 268 325 274 325 276 325 250 326 256 326 258 326 223 327 228 327 231 327 205 328 211 328 213 328 187 329 193 329 195 329 158 330 289 330 290 330 272 331 157 331 273 331 156 332 269 332 270 332 254 333 155 333 255 333 154 334 251 334 252 334 153 335 206 335 207 335 173 336 152 336 174 336 164 337 169 337 170 337 163 338 117 338 160 338 160 339 117 339 118 339 160 340 118 340 130 340 119 341 163 341 121 341 121 342 163 342 161 342 121 343 161 343 120 343 122 344 284 344 123 344 123 345 284 345 286 345 123 346 286 346 150 346 149 347 124 347 151 347 125 348 126 348 127 348 127 349 126 349 149 349 127 350 149 350 128 350 128 351 149 351 148 351 159 352 160 352 131 352 131 353 160 353 130 353 131 354 130 354 129 354 159 355 132 355 165 355 165 356 132 356 164 356 169 357 133 357 175 357 175 358 133 358 173 358 190 359 134 359 187 359 187 360 134 360 135 360 187 361 135 361 193 361 193 362 135 362 136 362 193 363 136 363 191 363 208 364 137 364 205 364 205 365 137 365 138 365 205 366 138 366 211 366 211 367 138 367 139 367 211 368 139 368 209 368 227 369 228 369 140 369 140 370 228 370 223 370 140 371 223 371 141 371 141 372 223 372 226 372 227 373 142 373 233 373 233 374 142 374 232 374 232 375 143 375 238 375 238 376 143 376 236 376 254 377 256 377 144 377 144 378 256 378 250 378 144 379 250 379 145 379 145 380 250 380 253 380 272 381 274 381 146 381 146 382 274 382 268 382 146 383 268 383 147 383 147 384 268 384 271 384 291 385 148 385 288 385 288 386 148 386 149 386 288 387 149 387 286 387 286 388 149 388 151 388 286 389 151 389 150 389 180 390 184 390 174 390 152 391 188 391 174 391 174 392 188 392 189 392 174 393 189 393 180 393 180 394 189 394 186 394 180 395 186 395 178 395 178 396 186 396 185 396 198 397 202 397 192 397 191 398 153 398 192 398 192 399 153 399 207 399 192 400 207 400 198 400 198 401 207 401 204 401 198 402 204 402 196 402 196 403 204 403 203 403 216 404 220 404 210 404 210 405 225 405 216 405 216 406 225 406 222 406 243 407 247 407 237 407 236 408 154 408 237 408 237 409 154 409 252 409 237 410 252 410 243 410 243 411 252 411 249 411 243 412 249 412 241 412 241 413 249 413 248 413 261 414 265 414 255 414 155 415 156 415 255 415 255 416 156 416 270 416 255 417 270 417 261 417 261 418 270 418 267 418 261 419 267 419 259 419 259 420 267 420 266 420 279 421 283 421 273 421 157 422 158 422 273 422 273 423 158 423 290 423 273 424 290 424 279 424 279 425 290 425 287 425 168 426 166 426 162 426 159 427 165 427 160 427 160 428 165 428 168 428 160 429 168 429 163 429 163 430 168 430 162 430 163 431 162 431 161 431 172 432 171 432 167 432 164 433 170 433 165 433 165 434 170 434 172 434 165 435 172 435 168 435 168 436 172 436 167 436 168 437 167 437 166 437 169 438 175 438 170 438 170 439 175 439 177 439 170 440 177 440 172 440 172 441 177 441 176 441 172 442 176 442 171 442 173 443 174 443 175 443 175 444 174 444 184 444 175 445 184 445 177 445 177 446 184 446 182 446 177 447 182 447 176 447 178 448 179 448 180 448 180 449 179 449 181 449 180 450 181 450 184 450 184 451 181 451 183 451 184 452 183 452 182 452 194 453 185 453 195 453 195 454 185 454 186 454 195 455 186 455 187 455 187 456 186 456 189 456 187 457 189 457 190 457 190 458 189 458 188 458 191 459 192 459 193 459 193 460 192 460 202 460 193 461 202 461 195 461 195 462 202 462 200 462 195 463 200 463 194 463 196 464 197 464 198 464 198 465 197 465 199 465 198 466 199 466 202 466 202 467 199 467 201 467 202 468 201 468 200 468 212 469 203 469 213 469 213 470 203 470 204 470 213 471 204 471 205 471 205 472 204 472 207 472 205 473 207 473 208 473 208 474 207 474 206 474 209 475 210 475 211 475 211 476 210 476 220 476 211 477 220 477 213 477 213 478 220 478 218 478 213 479 218 479 212 479 221 480 214 480 222 480 222 481 214 481 215 481 222 482 215 482 216 482 216 483 215 483 217 483 216 484 217 484 220 484 220 485 217 485 219 485 220 486 219 486 218 486 229 487 221 487 231 487 231 488 221 488 222 488 231 489 222 489 223 489 223 490 222 490 225 490 223 491 225 491 226 491 226 492 225 492 224 492 235 493 234 493 230 493 227 494 233 494 228 494 228 495 233 495 235 495 228 496 235 496 231 496 231 497 235 497 230 497 231 498 230 498 229 498 232 499 238 499 233 499 233 500 238 500 240 500 233 501 240 501 235 501 235 502 240 502 239 502 235 503 239 503 234 503 236 504 237 504 238 504 238 505 237 505 247 505 238 506 247 506 240 506 240 507 247 507 245 507 240 508 245 508 239 508 241 509 242 509 243 509 243 510 242 510 244 510 243 511 244 511 247 511 247 512 244 512 246 512 247 513 246 513 245 513 257 514 248 514 258 514 258 515 248 515 249 515 258 516 249 516 250 516 250 517 249 517 252 517 250 518 252 518 253 518 253 519 252 519 251 519 254 520 255 520 256 520 256 521 255 521 265 521 256 522 265 522 258 522 258 523 265 523 263 523 258 524 263 524 257 524 259 525 260 525 261 525 261 526 260 526 262 526 261 527 262 527 265 527 265 528 262 528 264 528 265 529 264 529 263 529 275 530 266 530 276 530 276 531 266 531 267 531 276 532 267 532 268 532 268 533 267 533 270 533 268 534 270 534 271 534 271 535 270 535 269 535 272 536 273 536 274 536 274 537 273 537 283 537 274 538 283 538 276 538 276 539 283 539 281 539 276 540 281 540 275 540 285 541 277 541 287 541 287 542 277 542 278 542 287 543 278 543 279 543 279 544 278 544 280 544 279 545 280 545 283 545 283 546 280 546 282 546 283 547 282 547 281 547 284 548 285 548 286 548 286 549 285 549 287 549 286 550 287 550 288 550 288 551 287 551 290 551 288 552 290 552 291 552 291 553 290 553 289 553 301 554 293 554 389 554 308 555 292 555 363 555 363 556 292 556 307 556 389 557 293 557 385 557 385 558 293 558 294 558 385 559 294 559 380 559 380 560 294 560 295 560 380 561 295 561 377 561 377 562 295 562 296 562 377 563 296 563 373 563 373 564 296 564 297 564 373 565 297 565 370 565 370 566 297 566 298 566 370 567 298 567 390 567 390 568 298 568 299 568 390 569 299 569 393 569 393 570 299 570 300 570 393 571 300 571 313 571 389 572 387 572 301 572 301 573 387 573 365 573 301 574 365 574 302 574 302 575 365 575 342 575 302 576 342 576 303 576 303 577 342 577 345 577 303 578 345 578 304 578 304 579 345 579 351 579 304 580 351 580 305 580 305 581 351 581 354 581 305 582 354 582 306 582 306 583 354 583 357 583 306 584 357 584 307 584 307 585 357 585 359 585 307 586 359 586 363 586 363 587 337 587 308 587 308 588 337 588 315 588 308 589 315 589 309 589 309 590 315 590 319 590 309 591 319 591 310 591 310 592 319 592 324 592 310 593 324 593 311 593 311 594 324 594 327 594 311 595 327 595 312 595 312 596 327 596 330 596 312 597 330 597 313 597 313 598 330 598 334 598 313 599 334 599 393 599 317 600 314 600 319 600 314 601 315 601 319 601 314 602 316 602 315 602 316 603 337 603 315 603 316 604 336 604 337 604 317 605 319 605 318 605 319 606 320 606 318 606 319 607 320 607 324 607 324 608 321 608 320 608 324 609 322 609 321 609 322 610 324 610 323 610 324 611 325 611 323 611 324 612 327 612 325 612 325 613 327 613 326 613 327 614 329 614 326 614 327 615 330 615 329 615 333 616 328 616 334 616 328 617 330 617 334 617 328 618 331 618 330 618 331 619 329 619 330 619 392 620 393 620 332 620 332 621 393 621 334 621 332 622 335 622 334 622 335 623 333 623 334 623 361 624 338 624 363 624 364 625 365 625 339 625 365 626 340 626 339 626 365 627 342 627 340 627 340 628 342 628 341 628 342 629 343 629 341 629 342 630 345 630 343 630 343 631 345 631 344 631 345 632 346 632 344 632 345 633 351 633 346 633 346 634 351 634 347 634 351 635 348 635 347 635 351 636 349 636 348 636 349 637 351 637 350 637 351 638 352 638 350 638 351 639 354 639 352 639 352 640 354 640 353 640 354 641 355 641 353 641 354 642 357 642 355 642 355 643 357 643 356 643 357 644 358 644 356 644 357 645 358 645 359 645 359 646 358 646 360 646 359 647 360 647 363 647 363 648 360 648 362 648 363 649 362 649 361 649 372 650 370 650 373 650 390 651 366 651 391 651 366 652 390 652 367 652 390 653 368 653 367 653 390 654 370 654 368 654 370 655 369 655 368 655 370 656 372 656 369 656 375 657 371 657 377 657 371 658 373 658 377 658 371 659 374 659 373 659 374 660 372 660 373 660 375 661 377 661 376 661 377 662 378 662 376 662 377 663 380 663 378 663 378 664 380 664 379 664 380 665 381 665 379 665 380 666 385 666 381 666 385 667 382 667 381 667 385 668 383 668 382 668 383 669 385 669 384 669 385 670 386 670 384 670 385 671 389 671 386 671 389 672 388 672 386 672 389 673 388 673 387 673 559 708 557 708 593 708 595 708 6 787 26 787 3 787 6 788 22 788 26 788 8 789 22 789 6 789 8 790 20 790 22 790 11 791 20 791 8 791 11 792 18 792 20 792 25 793 0 793 2 793 1 794 24 794 4 794 9 795 19 795 10 795 7 796 19 796 9 796 7 797 21 797 19 797 5 798 21 798 7 798 5 799 23 799 21 799 23 800 4 800 24 800 5 801 4 801 23 801 10 802 15 802 12 802 18 803 13 803 14 803 11 804 13 804 18 804 3 805 25 805 2 805 26 806 25 806 3 806 16 807 15 807 17 807 162 808 13 808 161 808 161 809 13 809 75 809 284 810 76 810 16 810 284 811 16 811 285 811 285 812 16 812 17 812 285 813 17 813 277 813 277 814 17 814 404 814 162 815 402 815 14 815 162 816 14 816 13 816 4 817 76 817 84 817 84 818 124 818 126 818 107 819 117 819 119 819 75 820 2 820 120 820 120 821 2 821 107 821 35 822 111 822 36 822 36 823 111 823 116 823 78 824 81 824 40 824 63 825 224 825 209 825 63 826 209 826 64 826 75 827 13 827 11 827 2 828 75 828 3 828 3 829 75 829 11 829 3 830 11 830 6 830 6 831 11 831 8 831 12 832 15 832 16 832 16 833 76 833 12 833 12 834 76 834 4 834 12 835 4 835 9 835 9 836 4 836 5 836 9 837 5 837 7 837 9 838 10 838 12 838 85 839 81 839 78 839 92 840 401 840 1 840 92 841 1 841 88 841 88 842 1 842 4 842 88 843 4 843 84 843 105 844 107 844 2 844 2 845 0 845 105 845 105 846 0 846 400 846 111 847 112 847 113 847 111 848 113 848 116 848 209 849 224 849 225 849 163 850 119 850 117 850 126 851 124 851 149 851 210 852 209 852 225 852 550 859 548 859 407 859 409 859 544 860 543 860 402 860 403 860 545 868 534 868 570 868 581 868 423 869 420 869 561 869 564 869 590 919 588 919 552 919 554 919 558 920 556 920 415 920 417 920 530 921 385 921 380 921 530 922 337 922 363 922 530 923 354 923 351 923 530 924 390 924 393 924 530 925 334 925 330 925 530 926 363 926 359 926 530 927 327 927 324 927 530 928 357 928 354 928 530 929 324 929 319 929 530 930 345 930 342 930 530 931 359 931 357 931 530 932 377 932 373 932 530 933 319 933 315 933 389 934 530 934 387 934 530 935 365 935 387 935 530 936 373 936 370 936 530 937 330 937 327 937 365 938 530 938 342 938 530 939 380 939 377 939 530 940 393 940 334 940 337 941 530 941 315 941 530 942 351 942 345 942 390 943 530 943 370 943 530 944 389 944 385 944 395 947 574 947 538 947 531 947 414 948 412 948 553 948 555 948 1 949 401 949 542 949 531 949 536 950 535 950 19 950 21 950 560 951 558 951 417 951 419 951 541 952 539 952 397 952 400 952 25 953 26 953 644 953 535 954 532 954 10 954 19 954 476 955 477 955 567 955 566 955 422 956 423 956 564 956 563 956 406 957 404 957 545 957 547 957 552 958 550 958 409 958 411 958 416 959 414 959 555 959 557 959 531 960 538 960 24 960 1 960 537 961 536 961 21 961 23 961 562 962 560 962 419 962 421 962 401 963 399 963 540 963 542 963 408 964 406 964 547 964 549 964 554 965 552 965 411 965 413 965 400 966 0 966 479 966 541 966 533 967 534 967 17 967 15 967 418 968 416 968 557 968 559 968 23 969 24 969 538 969 537 969 475 970 476 970 566 970 565 970 421 971 422 971 563 971 562 971 546 972 544 972 403 972 405 972 404 973 17 973 534 973 545 973 410 974 408 974 549 974 551 974 556 975 554 975 413 975 415 975 532 976 533 976 15 976 10 976 420 977 418 977 559 977 561 977 409 978 475 978 565 978 550 978 477 979 478 979 568 979 567 979 548 980 546 980 405 980 407 980 412 981 410 981 551 981 553 981 587 982 585 982 624 982 626 982 605 983 608 983 569 983 394 983 602 984 603 984 642 984 641 984 621 985 619 985 580 985 582 985 598 986 599 986 638 986 637 986 595 987 593 987 632 987 634 987 581 988 570 988 609 988 620 988 573 989 572 989 536 989 537 989 562 990 563 990 599 990 598 990 582 991 580 991 544 991 546 991 566 992 567 992 603 992 602 992 394 993 569 993 533 993 532 993 551 994 549 994 585 994 587 994 396 995 577 995 541 995 479 995 592 996 590 996 554 996 556 996 561 997 559 997 595 997 597 997 537 998 538 998 574 998 573 998 584 999 582 999 546 999 548 999 571 1000 394 1000 532 1000 535 1000 553 1001 551 1001 587 1001 589 1001 594 1002 592 1002 556 1002 558 1002 564 1003 561 1003 597 1003 600 1003 580 1004 579 1004 543 1004 544 1004 565 1005 566 1005 602 1005 601 1005 569 1006 570 1006 534 1006 533 1006 586 1007 584 1007 548 1007 550 1007 555 1008 553 1008 589 1008 591 1008 550 1009 565 1009 601 1009 586 1009 596 1010 594 1010 558 1010 560 1010 577 1011 575 1011 539 1011 541 1011 644 1012 22 1012 20 1012 563 1013 564 1013 600 1013 599 1013 547 1014 545 1014 581 1014 583 1014 567 1015 568 1015 604 1015 603 1015 572 1016 571 1016 535 1016 536 1016 588 1017 586 1017 550 1017 552 1017 531 1018 542 1018 578 1018 395 1018 557 1019 555 1019 591 1019 593 1019 598 1020 596 1020 560 1020 562 1020 542 1021 540 1021 576 1021 578 1021 549 1022 547 1022 583 1022 585 1022 607 1023 616 1023 577 1023 396 1023 631 1024 629 1024 590 1024 592 1024 597 1025 595 1025 634 1025 636 1025 623 1026 621 1026 582 1026 584 1026 610 1027 605 1027 394 1027 571 1027 589 1028 587 1028 626 1028 628 1028 573 1029 574 1029 613 1029 612 1029 633 1030 631 1030 592 1030 594 1030 611 1031 610 1031 571 1031 572 1031 600 1032 597 1032 636 1032 639 1032 619 1033 618 1033 579 1033 580 1033 601 1034 602 1034 641 1034 640 1034 608 1035 609 1035 570 1035 569 1035 625 1036 623 1036 584 1036 586 1036 591 1037 589 1037 628 1037 630 1037 612 1038 611 1038 572 1038 573 1038 586 1039 601 1039 640 1039 625 1039 635 1040 633 1040 594 1040 596 1040 616 1041 614 1041 575 1041 577 1041 599 1042 600 1042 639 1042 638 1042 583 1043 581 1043 620 1043 622 1043 603 1044 604 1044 643 1044 642 1044 627 1045 625 1045 586 1045 588 1045 607 1046 25 1046 644 1046 395 1047 578 1047 617 1047 606 1047 593 1048 591 1048 630 1048 632 1048 637 1049 635 1049 596 1049 598 1049 578 1050 576 1050 615 1050 617 1050 585 1051 583 1051 622 1051 624 1051 606 1052 613 1052 574 1052 395 1052 629 1053 627 1053 588 1053 590 1053 396 1054 25 1054 607 1054 644 1055 615 1055 398 1055 398 1056 615 1056 576 1056 614 1057 398 1057 575 1057 398 1058 540 1058 399 1058 644 1059 398 1059 614 1059 398 1060 576 1060 540 1060 539 1061 398 1061 397 1061 575 1063 398 1063 539 1063 622 1065 620 1065 644 1065 638 1066 639 1066 644 1066 644 1067 614 1067 616 1067 644 1068 633 1068 635 1068 625 1069 644 1069 640 1069 644 1070 611 1070 612 1070 630 1071 628 1071 644 1071 642 1072 643 1072 644 1072 644 1073 625 1073 627 1073 479 1074 25 1074 396 1074 606 1075 617 1075 644 1075 632 1076 630 1076 644 1076 644 1077 635 1077 637 1077 617 1078 615 1078 644 1078 624 1079 622 1079 644 1079 644 1080 613 1080 606 1080 644 1081 627 1081 629 1081 0 1082 25 1082 479 1082 620 1083 609 1083 644 1083 634 1084 632 1084 644 1084 637 1085 638 1085 644 1085 644 1086 619 1086 621 1086 641 1087 642 1087 644 1087 644 1088 608 1088 605 1088 626 1089 624 1089 644 1089 644 1090 616 1090 607 1090 644 1091 629 1091 631 1091 636 1092 634 1092 644 1092 644 1093 621 1093 623 1093 644 1094 605 1094 610 1094 628 1095 626 1095 644 1095 612 1096 613 1096 644 1096 644 1097 631 1097 633 1097 644 1098 610 1098 611 1098 639 1099 636 1099 644 1099 644 1100 618 1100 619 1100 640 1101 641 1101 644 1101 644 1102 609 1102 608 1102 644 1103 623 1103 625 1103 26 1128 22 1128 644 1128 644 1129 18 1129 20 1129 543 1130 14 1130 402 1130 478 1131 14 1131 568 1131 568 1132 14 1132 604 1132 579 1133 14 1133 543 1133 604 1134 14 1134 643 1134 618 1135 14 1135 579 1135 643 1136 14 1136 644 1136 644 1137 14 1137 618 1137 18 1138 14 1138 644 1138

+
+ + + + 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 +

453 674 526 674 528 674 453 675 503 675 524 675 453 676 449 676 503 676 503 677 449 677 466 677 529 678 528 678 520 678 523 679 521 679 522 679 483 680 481 680 468 680 467 681 469 681 457 681 430 682 432 682 439 682 439 683 441 683 430 683 466 684 456 684 468 684 426 685 424 685 441 685 441 686 424 686 430 686 520 687 514 687 522 687 497 688 524 688 503 688 498 689 515 689 500 689 505 690 516 690 501 690 501 691 516 691 508 691 501 692 508 692 491 692 491 693 508 693 493 693 491 694 493 694 489 694 489 695 493 695 487 695 516 696 518 696 508 696 508 697 518 697 510 697 508 698 510 698 493 698 493 699 510 699 495 699 493 700 495 700 487 700 487 701 495 701 485 701 518 702 522 702 510 702 510 703 522 703 514 703 510 704 514 704 495 704 495 705 514 705 499 705 495 706 499 706 485 706 485 707 499 707 483 707 472 709 487 709 485 709 472 710 485 710 470 710 470 711 485 711 483 711 470 712 483 712 468 712 506 713 507 713 517 713 516 714 505 714 506 714 506 715 517 715 516 715 516 716 517 716 519 716 516 717 519 717 518 717 518 718 519 718 523 718 518 719 523 719 522 719 464 720 472 720 460 720 464 721 460 721 451 721 451 722 460 722 444 722 451 723 444 723 446 723 446 724 444 724 436 724 472 725 470 725 460 725 460 726 470 726 458 726 460 727 458 727 444 727 444 728 458 728 442 728 444 729 442 729 436 729 436 730 442 730 434 730 470 731 468 731 458 731 458 732 468 732 456 732 458 733 456 733 442 733 442 734 456 734 439 734 442 735 439 735 434 735 434 736 439 736 432 736 490 737 488 737 492 737 492 738 488 738 494 738 492 739 494 739 502 739 502 740 494 740 509 740 502 741 509 741 507 741 507 742 509 742 517 742 488 743 486 743 494 743 494 744 486 744 496 744 494 745 496 745 509 745 509 746 496 746 511 746 509 747 511 747 517 747 517 748 511 748 519 748 486 749 484 749 496 749 496 750 484 750 500 750 496 751 500 751 511 751 511 752 500 752 515 752 511 753 515 753 519 753 519 754 515 754 523 754 447 755 446 755 436 755 437 756 448 756 447 756 447 757 436 757 437 757 437 758 436 758 434 758 437 759 434 759 435 759 435 760 434 760 432 760 435 761 432 761 433 761 480 762 474 762 473 762 488 763 490 763 480 763 480 764 473 764 488 764 488 765 473 765 471 765 488 766 471 766 486 766 486 767 471 767 469 767 486 768 469 768 484 768 448 769 437 769 452 769 452 770 437 770 445 770 452 771 445 771 465 771 465 772 445 772 461 772 465 773 461 773 474 773 474 774 461 774 473 774 437 775 435 775 445 775 445 776 435 776 443 776 445 777 443 777 461 777 461 778 443 778 459 778 461 779 459 779 473 779 473 780 459 780 471 780 435 781 433 781 443 781 443 782 433 782 440 782 443 783 440 783 459 783 459 784 440 784 457 784 459 785 457 785 471 785 471 786 457 786 469 786 529 853 527 853 453 853 450 854 429 854 453 854 528 855 529 855 453 855 429 856 427 856 453 856 525 857 504 857 453 857 504 858 450 858 453 858 453 861 425 861 424 861 453 862 428 862 449 862 453 863 426 863 428 863 453 864 424 864 426 864 527 865 525 865 453 865 453 866 524 866 526 866 427 867 425 867 453 867 503 870 466 870 481 870 529 871 520 871 521 871 424 872 425 872 431 872 424 873 431 873 430 873 469 874 467 874 484 874 484 875 467 875 482 875 522 876 521 876 520 876 468 877 481 877 466 877 432 878 430 878 433 878 433 879 430 879 431 879 440 880 438 880 457 880 457 881 438 881 454 881 457 882 454 882 467 882 438 883 440 883 431 883 431 884 440 884 433 884 438 885 431 885 425 885 438 886 425 886 427 886 438 887 427 887 454 887 454 888 427 888 429 888 454 889 429 889 450 889 454 890 450 890 467 890 456 891 455 891 439 891 439 892 455 892 441 892 455 893 456 893 466 893 455 894 466 894 449 894 455 895 449 895 428 895 455 896 428 896 441 896 441 897 428 897 426 897 481 898 483 898 499 898 514 899 512 899 499 899 499 900 512 900 497 900 499 901 497 901 481 901 512 902 514 902 520 902 512 903 520 903 528 903 512 904 528 904 526 904 512 905 526 905 497 905 497 906 526 906 524 906 497 907 503 907 481 907 525 908 498 908 504 908 504 909 498 909 482 909 529 910 521 910 527 910 527 911 521 911 513 911 498 912 525 912 527 912 498 913 527 913 513 913 498 914 513 914 515 914 515 915 513 915 523 915 523 916 513 916 521 916 498 917 500 917 482 917 482 918 500 918 484 918 462 945 489 945 487 945 462 946 487 946 472 946 472 1062 463 1062 462 1062 463 1064 472 1064 464 1064 645 1104 450 1104 504 1104 504 1105 482 1105 645 1105 482 1106 467 1106 645 1106 467 1107 450 1107 645 1107 646 1108 452 1108 465 1108 489 1109 462 1109 646 1109 646 1110 506 1110 505 1110 646 1111 465 1111 474 1111 463 1112 464 1112 646 1112 447 1113 448 1113 646 1113 646 1114 492 1114 502 1114 646 1115 490 1115 492 1115 646 1116 502 1116 507 1116 646 1117 448 1117 452 1117 646 1118 507 1118 506 1118 446 1119 447 1119 646 1119 462 1120 463 1120 646 1120 501 1121 491 1121 646 1121 505 1122 501 1122 646 1122 451 1123 446 1123 646 1123 646 1124 480 1124 490 1124 646 1125 474 1125 480 1125 491 1126 489 1126 646 1126 464 1127 451 1127 646 1127

+
+
+ 1 +
+
+ + + + 7.481132 -6.50764 5.343665 + 0 0 1 46.69194 + 0 1 0 0.619768 + 1 0 0 63.5593 + 1 1 1 + + + + 4.076245 1.005454 5.903862 + 0 0 1 106.9363 + 0 1 0 3.163707 + 1 0 0 37.26105 + 1 1 1 + + + + 0 0 0 + 0 0 1 0 + 0 1 0 0 + 1 0 0 90.00001 + 1 1 1 + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/src/p3dx_description/meshes/right_hubcap.stl b/src/p3dx_description/meshes/right_hubcap.stl new file mode 100644 index 0000000..ac3f36f Binary files /dev/null and b/src/p3dx_description/meshes/right_hubcap.stl differ diff --git a/src/p3dx_description/meshes/right_wheel.stl b/src/p3dx_description/meshes/right_wheel.stl new file mode 100644 index 0000000..c518c0e Binary files /dev/null and b/src/p3dx_description/meshes/right_wheel.stl differ diff --git a/src/p3dx_description/meshes/swivel.stl b/src/p3dx_description/meshes/swivel.stl new file mode 100644 index 0000000..03797a2 Binary files /dev/null and b/src/p3dx_description/meshes/swivel.stl differ diff --git a/src/p3dx_description/meshes/top.stl b/src/p3dx_description/meshes/top.stl new file mode 100644 index 0000000..302ed5f Binary files /dev/null and b/src/p3dx_description/meshes/top.stl differ diff --git a/src/p3dx_description/package.xml b/src/p3dx_description/package.xml new file mode 100644 index 0000000..8d04c2a --- /dev/null +++ b/src/p3dx_description/package.xml @@ -0,0 +1,20 @@ + + + p3dx_description + 0.1.0 + + A Pioneer 3DX description for Gazebo. First working version + + + Rafael Berkvens + GPLv3 + https://github.com/RafBerkvens/ua_ros_p3dx + + catkin + roscpp + rospy + urdf + roscpp + rospy + urdf + \ No newline at end of file diff --git a/src/p3dx_description/urdf/materials.xacro b/src/p3dx_description/urdf/materials.xacro new file mode 100644 index 0000000..d382342 --- /dev/null +++ b/src/p3dx_description/urdf/materials.xacro @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/p3dx_description/urdf/pioneer3dx.gazebo b/src/p3dx_description/urdf/pioneer3dx.gazebo new file mode 100644 index 0000000..c6c4d07 --- /dev/null +++ b/src/p3dx_description/urdf/pioneer3dx.gazebo @@ -0,0 +1,135 @@ + + + + + + + + + + + + + /${ns} + + + + + + Gazebo/Red + + + + + Gazebo/Black + + + + + Gazebo/Grey + + + + + Gazebo/Grey + + + + + Gazebo/Black + 10.0 + 10.0 + 1000000.0 + 1.0 + + + + + + + + + + + true + 100 + base_right_wheel_joint + base_left_wheel_joint + 0.39 + 0.15 + 5 + cmd_vel + odom + odom + base_link + + + + + + + true + 100.0 + base_link + ${ns}/base_pose_ground_truth + 0.01 + map + + 0 0 0 + 0 0 0 + + + + + + + 0 0 0 0 0 0 + false + 50 + + + + 360 + 1 + -1.570796 + 1.570796 + + + + 0.10 + 30.0 + 0.01 + + + gaussian + + 0.0 + 0.01 + + + + ${ns}/laser/scan + lms100 + + + + + diff --git a/src/p3dx_description/urdf/pioneer3dx.xacro b/src/p3dx_description/urdf/pioneer3dx.xacro new file mode 100644 index 0000000..789ea0a --- /dev/null +++ b/src/p3dx_description/urdf/pioneer3dx.xacro @@ -0,0 +1,262 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/p3dx_description/urdf/pioneer3dx.xml b/src/p3dx_description/urdf/pioneer3dx.xml new file mode 100644 index 0000000..5bb5137 --- /dev/null +++ b/src/p3dx_description/urdf/pioneer3dx.xml @@ -0,0 +1,470 @@ + + + + + + + + + + + /p3dx + + + + Gazebo/Red + + + Gazebo/Black + + + Gazebo/Grey + + + Gazebo/Grey + + + Gazebo/Black + 10.0 + 10.0 + 1000000.0 + 1.0 + + + + + + + true + 100 + base_right_wheel_joint + base_left_wheel_joint + 0.39 + 0.15 + 5 + cmd_vel + odom + odom + base_link + + + + + true + 100.0 + base_link + p3dx/base_pose_ground_truth + 0.01 + map + + 0 0 0 + 0 0 0 + + + + + 0 0 0 0 0 0 + false + 50 + + + + 360 + 1 + -1.570796 + 1.570796 + + + + 0.10 + 30.0 + 0.01 + + + gaussian + + 0.0 + 0.01 + + + + p3dx/laser/scan + lms100 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pr2_mechanism_model/SimpleTransmission + + + EffortJointInterface + 75.0676691729 + + + + Gazebo/Yellow + + + Gazebo/Black + 0.5 + 50.0 + 100000000.0 + 1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pr2_mechanism_model/SimpleTransmission + + + EffortJointInterface + -75.0676691729 + + + + Gazebo/Yellow + + + Gazebo/Black + 0.5 + 50.0 + 100000000.0 + 1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/p3dx_description/urdf/pioneer3dx_fixed_joints.xml b/src/p3dx_description/urdf/pioneer3dx_fixed_joints.xml new file mode 100644 index 0000000..6e14699 --- /dev/null +++ b/src/p3dx_description/urdf/pioneer3dx_fixed_joints.xml @@ -0,0 +1,470 @@ + + + + + + + + + + + /p3dx + + + + Gazebo/Red + + + Gazebo/Black + + + Gazebo/Grey + + + Gazebo/Grey + + + Gazebo/Black + 10.0 + 10.0 + 1000000.0 + 1.0 + + + + + + + true + 100 + base_right_wheel_joint + base_left_wheel_joint + 0.39 + 0.15 + 5 + cmd_vel + odom + odom + base_link + + + + + true + 100.0 + base_link + p3dx/base_pose_ground_truth + 0.01 + map + + 0 0 0 + 0 0 0 + + + + + 0 0 0 0 0 0 + false + 50 + + + + 360 + 1 + -1.570796 + 1.570796 + + + + 0.10 + 30.0 + 0.01 + + + gaussian + + 0.0 + 0.01 + + + + p3dx/laser/scan + lms100 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pr2_mechanism_model/SimpleTransmission + + + EffortJointInterface + 75.0676691729 + + + + Gazebo/Yellow + + + Gazebo/Black + 0.5 + 50.0 + 100000000.0 + 1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pr2_mechanism_model/SimpleTransmission + + + EffortJointInterface + -75.0676691729 + + + + Gazebo/Yellow + + + Gazebo/Black + 0.5 + 50.0 + 100000000.0 + 1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/p3dx_description/urdf/pioneer3dx_wheel.xacro b/src/p3dx_description/urdf/pioneer3dx_wheel.xacro new file mode 100644 index 0000000..fd65e8a --- /dev/null +++ b/src/p3dx_description/urdf/pioneer3dx_wheel.xacro @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pr2_mechanism_model/SimpleTransmission + + + EffortJointInterface + ${reflect * 624/35 * 80/19} + + + + + Gazebo/Yellow + + + + Gazebo/Black + 0.5 + 50.0 + 100000000.0 + 1.0 + + + + + + diff --git a/src/p3dx_navigation/CMakeLists.txt b/src/p3dx_navigation/CMakeLists.txt new file mode 100644 index 0000000..055d75b --- /dev/null +++ b/src/p3dx_navigation/CMakeLists.txt @@ -0,0 +1,202 @@ +cmake_minimum_required(VERSION 3.0.2) +project(p3dx_navigation) + +## Compile as C++11, supported in ROS Kinetic and newer +# add_compile_options(-std=c++11) + +## 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) + +## System dependencies are found with CMake's conventions +# find_package(Boost REQUIRED COMPONENTS system) + + +## Uncomment this if the package has a setup.py. This macro ensures +## modules and global scripts declared therein get installed +## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html +# catkin_python_setup() + +################################################ +## Declare ROS messages, services and actions ## +################################################ + +## To declare and build messages, services or actions from within this +## package, follow these steps: +## * Let MSG_DEP_SET be the set of packages whose message types you use in +## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). +## * In the file package.xml: +## * add a build_depend tag for "message_generation" +## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET +## * If MSG_DEP_SET isn't empty the following dependency has been pulled in +## but can be declared for certainty nonetheless: +## * add a exec_depend tag for "message_runtime" +## * In this file (CMakeLists.txt): +## * add "message_generation" and every package in MSG_DEP_SET to +## find_package(catkin REQUIRED COMPONENTS ...) +## * add "message_runtime" and every package in MSG_DEP_SET to +## catkin_package(CATKIN_DEPENDS ...) +## * uncomment the add_*_files sections below as needed +## and list every .msg/.srv/.action file to be processed +## * uncomment the generate_messages entry below +## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) + +## Generate messages in the 'msg' folder +# add_message_files( +# FILES +# Message1.msg +# Message2.msg +# ) + +## Generate services in the 'srv' folder +# add_service_files( +# FILES +# Service1.srv +# Service2.srv +# ) + +## Generate actions in the 'action' folder +# add_action_files( +# FILES +# Action1.action +# Action2.action +# ) + +## Generate added messages and services with any dependencies listed here +# generate_messages( +# DEPENDENCIES +# std_msgs # Or other packages containing msgs +# ) + +################################################ +## Declare ROS dynamic reconfigure parameters ## +################################################ + +## To declare and build dynamic reconfigure parameters within this +## package, follow these steps: +## * In the file package.xml: +## * add a build_depend and a exec_depend tag for "dynamic_reconfigure" +## * In this file (CMakeLists.txt): +## * add "dynamic_reconfigure" to +## find_package(catkin REQUIRED COMPONENTS ...) +## * uncomment the "generate_dynamic_reconfigure_options" section below +## and list every .cfg file to be processed + +## Generate dynamic reconfigure parameters in the 'cfg' folder +# generate_dynamic_reconfigure_options( +# cfg/DynReconf1.cfg +# cfg/DynReconf2.cfg +# ) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if your package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( +# INCLUDE_DIRS include +# LIBRARIES p3dx_navigation +# CATKIN_DEPENDS other_catkin_pkg +# DEPENDS system_lib +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +include_directories( +# include +# ${catkin_INCLUDE_DIRS} +) + +## Declare a C++ library +# add_library(${PROJECT_NAME} +# src/${PROJECT_NAME}/p3dx_navigation.cpp +# ) + +## Add cmake target dependencies of the library +## as an example, code may need to be generated before libraries +## either from message generation or dynamic reconfigure +# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Declare a C++ executable +## With catkin_make all packages are built within a single CMake context +## The recommended prefix ensures that target names across packages don't collide +# add_executable(${PROJECT_NAME}_node src/p3dx_navigation_node.cpp) + +## Rename C++ executable without prefix +## The above recommended prefix causes long target names, the following renames the +## target back to the shorter version for ease of user use +## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" +# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "") + +## Add cmake target dependencies of the executable +## same as for the library above +# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Specify libraries to link a library or executable target against +# target_link_libraries(${PROJECT_NAME}_node +# ${catkin_LIBRARIES} +# ) + +############# +## Install ## +############# + +# all install targets should use catkin DESTINATION variables +# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html + +## Mark executable scripts (Python etc.) for installation +## in contrast to setup.py, you can choose the destination +# catkin_install_python(PROGRAMS +# scripts/my_python_script +# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark executables for installation +## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html +# install(TARGETS ${PROJECT_NAME}_node +# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark libraries for installation +## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html +# install(TARGETS ${PROJECT_NAME} +# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} +# ) + +## Mark cpp header files for installation +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +# FILES_MATCHING PATTERN "*.h" +# PATTERN ".svn" EXCLUDE +# ) + +## Mark other files for installation (e.g. launch and bag files, etc.) +# install(FILES +# # myfile1 +# # myfile2 +# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +# ) + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test_p3dx_navigation.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) diff --git a/src/p3dx_navigation/launch/amcl.launch b/src/p3dx_navigation/launch/amcl.launch new file mode 100644 index 0000000..7c28b88 --- /dev/null +++ b/src/p3dx_navigation/launch/amcl.launch @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/p3dx_navigation/launch/move_base.launch b/src/p3dx_navigation/launch/move_base.launch new file mode 100644 index 0000000..27917be --- /dev/null +++ b/src/p3dx_navigation/launch/move_base.launch @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/p3dx_navigation/launch/p3dx_navigation.launch b/src/p3dx_navigation/launch/p3dx_navigation.launch new file mode 100644 index 0000000..32921f8 --- /dev/null +++ b/src/p3dx_navigation/launch/p3dx_navigation.launch @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/p3dx_navigation/package.xml b/src/p3dx_navigation/package.xml new file mode 100644 index 0000000..fce0301 --- /dev/null +++ b/src/p3dx_navigation/package.xml @@ -0,0 +1,59 @@ + + + p3dx_navigation + 0.0.0 + The p3dx_navigation package + + + + + ryken + + + + + + TODO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + catkin + + + + + + + + diff --git a/src/p3dx_navigation/param/base_local_planner_params.yaml b/src/p3dx_navigation/param/base_local_planner_params.yaml new file mode 100644 index 0000000..2c5896e --- /dev/null +++ b/src/p3dx_navigation/param/base_local_planner_params.yaml @@ -0,0 +1,26 @@ +TrajectoryPlannerROS: + +# Robot Configuration Parameters + max_vel_x: 0.18 + min_vel_x: 0.08 + + max_vel_theta: 1.0 + min_vel_theta: -1.0 + min_in_place_vel_theta: 1.0 + + acc_lim_x: 1.0 + acc_lim_y: 0.0 + acc_lim_theta: 0.6 + +# Goal Tolerance Parameters + xy_goal_tolerance: 0.10 + yaw_goal_tolerance: 0.05 + +# Differential-drive robot configuration + holonomic_robot: false + +# Forward Simulation Parameters + sim_time: 0.8 + vx_samples: 18 + vtheta_samples: 20 + sim_granularity: 0.05 diff --git a/src/p3dx_navigation/param/costmap_common_params_waffle_pi.yaml b/src/p3dx_navigation/param/costmap_common_params_waffle_pi.yaml new file mode 100644 index 0000000..3d5a6d7 --- /dev/null +++ b/src/p3dx_navigation/param/costmap_common_params_waffle_pi.yaml @@ -0,0 +1,12 @@ +obstacle_range: 3.0 +raytrace_range: 3.5 + +footprint: [[-0.205, -0.155], [-0.205, 0.155], [0.077, 0.155], [0.077, -0.155]] +#robot_radius: 0.17 + +inflation_radius: 1.0 +cost_scaling_factor: 3.0 + +map_type: costmap +observation_sources: scan +scan: {sensor_frame: base_scan, data_type: LaserScan, topic: scan, marking: true, clearing: true} diff --git a/src/p3dx_navigation/param/dwa_local_planner_params_waffle_pi.yaml b/src/p3dx_navigation/param/dwa_local_planner_params_waffle_pi.yaml new file mode 100644 index 0000000..b89997f --- /dev/null +++ b/src/p3dx_navigation/param/dwa_local_planner_params_waffle_pi.yaml @@ -0,0 +1,47 @@ +DWAPlannerROS: + +# Robot Configuration Parameters + max_vel_x: 0.26 + min_vel_x: -0.26 + + max_vel_y: 0.0 + min_vel_y: 0.0 + +# The velocity when robot is moving in a straight line + max_vel_trans: 0.26 + min_vel_trans: 0.13 + + max_vel_theta: 1.82 + min_vel_theta: 0.9 + + acc_lim_x: 2.5 + acc_lim_y: 0.0 + acc_lim_theta: 3.2 + +# Goal Tolerance Parametes + xy_goal_tolerance: 0.05 + yaw_goal_tolerance: 0.17 + latch_xy_goal_tolerance: false + +# Forward Simulation Parameters + sim_time: 2.0 + vx_samples: 20 + vy_samples: 0 + vth_samples: 40 + controller_frequency: 10.0 + +# Trajectory Scoring Parameters + path_distance_bias: 32.0 + goal_distance_bias: 20.0 + occdist_scale: 0.02 + forward_point_distance: 0.325 + stop_time_buffer: 0.2 + scaling_speed: 0.25 + max_scaling_factor: 0.2 + +# Oscillation Prevention Parameters + oscillation_reset_dist: 0.05 + +# Debugging + publish_traj_pc : true + publish_cost_grid_pc: true diff --git a/src/p3dx_navigation/param/global_costmap_params.yaml b/src/p3dx_navigation/param/global_costmap_params.yaml new file mode 100644 index 0000000..c6bafdf --- /dev/null +++ b/src/p3dx_navigation/param/global_costmap_params.yaml @@ -0,0 +1,10 @@ +global_costmap: + global_frame: map + robot_base_frame: base_link + + update_frequency: 10.0 + publish_frequency: 10.0 + transform_tolerance: 0.5 + + static_map: true + diff --git a/src/p3dx_navigation/param/local_costmap_params.yaml b/src/p3dx_navigation/param/local_costmap_params.yaml new file mode 100644 index 0000000..682392d --- /dev/null +++ b/src/p3dx_navigation/param/local_costmap_params.yaml @@ -0,0 +1,14 @@ +local_costmap: + global_frame: odom + robot_base_frame: base_link + + update_frequency: 10.0 + publish_frequency: 10.0 + transform_tolerance: 0.5 + + static_map: false + rolling_window: true + width: 3 + height: 3 + resolution: 0.05 + diff --git a/src/p3dx_navigation/param/move_base_params.yaml b/src/p3dx_navigation/param/move_base_params.yaml new file mode 100644 index 0000000..f042cd6 --- /dev/null +++ b/src/p3dx_navigation/param/move_base_params.yaml @@ -0,0 +1,9 @@ +shutdown_costmaps: false +controller_frequency: 10.0 +planner_patience: 5.0 +controller_patience: 15.0 +conservative_reset_dist: 3.0 +planner_frequency: 5.0 +oscillation_timeout: 10.0 +oscillation_distance: 0.2 + diff --git a/src/p3dx_navigation/rviz/p3dx_navigation.rviz b/src/p3dx_navigation/rviz/p3dx_navigation.rviz new file mode 100644 index 0000000..a5f6f42 --- /dev/null +++ b/src/p3dx_navigation/rviz/p3dx_navigation.rviz @@ -0,0 +1,426 @@ +Panels: + - Class: rviz/Displays + Help Height: 0 + Name: Displays + Property Tree Widget: + Expanded: + - /TF1/Frames1 + - /TF1/Tree1 + - /Global Map1/Costmap1 + - /Global Map1/Planner1 + - /Local Map1/Polygon1 + - /Local Map1/Costmap1 + - /Local Map1/Planner1 + Splitter Ratio: 0.5 + Tree Height: 231 + - Class: rviz/Selection + Name: Selection + - Class: rviz/Tool Properties + Expanded: + - /2D Pose Estimate1 + - /2D Nav Goal1 + - /Waypoints1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz/Time + Name: Time + SyncMode: 0 + SyncSource: LaserScan + - Class: rviz/Tool Properties + Expanded: + - /Waypoints1 + Name: Tool Properties + Splitter Ratio: 0.5 + - Class: waypoints/waypointPanel + Name: waypointPanel + - Class: waypoints/waypointPanel + Name: waypointPanel + - Class: waypoints/waypointPanel + Name: waypointPanel +Preferences: + PromptSaveOnExit: true +Toolbars: + toolButtonStyle: 2 +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 42 + Reference Frame: + Value: true + - Class: rviz/TF + Enabled: false + Filter (blacklist): "" + Filter (whitelist): "" + Frame Timeout: 15 + Frames: + All Enabled: false + Marker Alpha: 1 + Marker Scale: 1 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: false + Tree: + {} + Update Interval: 0 + Value: false + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/LaserScan + Color: 0; 255; 0 + Color Transformer: FlatColor + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: LaserScan + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.030000001192092896 + Style: Flat Squares + Topic: /scan + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: true + - Alpha: 0.699999988079071 + Class: rviz/Map + Color Scheme: map + Draw Behind: false + Enabled: true + Name: Map + Topic: /map + Unreliable: false + Use Timestamp: false + Value: true + - Alpha: 1 + Buffer Length: 1 + Class: rviz/Path + Color: 0; 0; 0 + Enabled: true + Head Diameter: 0.30000001192092896 + Head Length: 0.20000000298023224 + Length: 0.30000001192092896 + Line Style: Lines + Line Width: 0.029999999329447746 + Name: Planner Plan + Offset: + X: 0 + Y: 0 + Z: 0 + Pose Color: 255; 85; 255 + Pose Style: None + Queue Size: 10 + Radius: 0.029999999329447746 + Shaft Diameter: 0.10000000149011612 + Shaft Length: 0.10000000149011612 + Topic: /move_base/NavfnROS/plan + Unreliable: false + Value: true + - Class: rviz/Group + Displays: + - Alpha: 0.699999988079071 + Class: rviz/Map + Color Scheme: costmap + Draw Behind: true + Enabled: true + Name: Costmap + Topic: /move_base/global_costmap/costmap + Unreliable: false + Use Timestamp: false + Value: true + - Alpha: 1 + Buffer Length: 1 + Class: rviz/Path + Color: 255; 0; 0 + Enabled: true + Head Diameter: 0.30000001192092896 + Head Length: 0.20000000298023224 + Length: 0.30000001192092896 + Line Style: Lines + Line Width: 0.029999999329447746 + Name: Planner + Offset: + X: 0 + Y: 0 + Z: 0 + Pose Color: 255; 85; 255 + Pose Style: None + Queue Size: 10 + Radius: 0.029999999329447746 + Shaft Diameter: 0.10000000149011612 + Shaft Length: 0.10000000149011612 + Topic: /move_base/DWAPlannerROS/global_plan + Unreliable: false + Value: true + Enabled: true + Name: Global Map + - Class: rviz/Group + Displays: + - Alpha: 1 + Class: rviz/Polygon + Color: 0; 0; 0 + Enabled: true + Name: Polygon + Queue Size: 10 + Topic: /move_base/local_costmap/footprint + Unreliable: false + Value: true + - Alpha: 0.699999988079071 + Class: rviz/Map + Color Scheme: costmap + Draw Behind: false + Enabled: true + Name: Costmap + Topic: /move_base/local_costmap/costmap + Unreliable: false + Use Timestamp: false + Value: true + - Alpha: 1 + Buffer Length: 1 + Class: rviz/Path + Color: 255; 255; 0 + Enabled: true + Head Diameter: 0.30000001192092896 + Head Length: 0.20000000298023224 + Length: 0.30000001192092896 + Line Style: Lines + Line Width: 0.029999999329447746 + Name: Planner + Offset: + X: 0 + Y: 0 + Z: 0 + Pose Color: 255; 85; 255 + Pose Style: None + Queue Size: 10 + Radius: 0.029999999329447746 + Shaft Diameter: 0.10000000149011612 + Shaft Length: 0.10000000149011612 + Topic: /move_base/DWAPlannerROS/local_plan + Unreliable: false + Value: true + Enabled: true + Name: Local Map + - Alpha: 1 + Arrow Length: 0.05000000074505806 + Axes Length: 0.30000001192092896 + Axes Radius: 0.009999999776482582 + Class: rviz/PoseArray + Color: 0; 192; 0 + Enabled: true + Head Length: 0.07000000029802322 + Head Radius: 0.029999999329447746 + Name: Amcl Particles + Queue Size: 10 + Shaft Length: 0.23000000417232513 + Shaft Radius: 0.009999999776482582 + Shape: Arrow (Flat) + Topic: /particlecloud + Unreliable: false + Value: true + - Alpha: 1 + Axes Length: 1 + Axes Radius: 0.10000000149011612 + Class: rviz/Pose + Color: 255; 25; 0 + Enabled: true + Head Length: 0.30000001192092896 + Head Radius: 0.10000000149011612 + Name: Goal + Queue Size: 10 + Shaft Length: 0.5 + Shaft Radius: 0.05000000074505806 + Shape: Arrow + Topic: /move_base_simple/goal + Unreliable: false + Value: true + - Alpha: 1 + Axes Length: 1 + Axes Radius: 0.10000000149011612 + Class: rviz/PoseWithCovariance + Color: 255; 25; 0 + Covariance: + Orientation: + Alpha: 0.5 + Color: 255; 255; 127 + Color Style: Unique + Frame: Local + Offset: 1 + Scale: 1 + Value: true + Position: + Alpha: 0.30000001192092896 + Color: 204; 51; 204 + Scale: 1 + Value: true + Value: true + Enabled: true + Head Length: 0.30000001192092896 + Head Radius: 0.10000000149011612 + Name: PoseWithCovariance + Queue Size: 10 + Shaft Length: 1 + Shaft Radius: 0.05000000074505806 + Shape: Arrow + Topic: /amcl_pose + Unreliable: false + Value: true + - Alpha: 1 + Arrow Length: 0.30000001192092896 + Axes Length: 0.30000001192092896 + Axes Radius: 0.009999999776482582 + Class: rviz/PoseArray + Color: 255; 25; 0 + Enabled: true + Head Length: 0.07000000029802322 + Head Radius: 0.029999999329447746 + Name: PoseArray + Queue Size: 10 + Shaft Length: 0.23000000417232513 + Shaft Radius: 0.009999999776482582 + Shape: Arrow (Flat) + Topic: /particlecloud + Unreliable: false + Value: true + - Alpha: 0.699999988079071 + Class: rviz/Map + Color Scheme: map + Draw Behind: false + Enabled: true + Name: Map + Topic: /move_base/local_costmap/costmap + Unreliable: false + Use Timestamp: false + Value: true + - Class: rviz/Image + Enabled: false + Image Topic: /astra/rgb/image_raw + Max Value: 1 + Median window: 5 + Min Value: 0 + Name: Image + Normalize Range: true + Queue Size: 2 + Transport Hint: compressed + Unreliable: false + Value: false + - Class: rviz/Image + Enabled: true + Image Topic: /darknet_ros/detection_image + Max Value: 1 + Median window: 5 + Min Value: 0 + Name: Image + Normalize Range: true + Queue Size: 2 + Transport Hint: raw + Unreliable: false + Value: true + - Alpha: 1 + Axes Length: 1 + Axes Radius: 0.10000000149011612 + Class: rviz/Pose + Color: 255; 25; 0 + Enabled: true + Head Length: 0.30000001192092896 + Head Radius: 0.10000000149011612 + Name: Pose + Queue Size: 10 + Shaft Length: 1 + Shaft Radius: 0.05000000074505806 + Shape: Arrow + Topic: /move_base_simple/goal + Unreliable: false + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Default Light: true + Fixed Frame: map + Frame Rate: 30 + Name: root + Tools: + - Class: rviz/MoveCamera + - Class: rviz/Interact + Hide Inactive Objects: true + - Class: rviz/Select + - Class: rviz/SetInitialPose + Theta std deviation: 0.2617993950843811 + Topic: /initialpose + X std deviation: 0.5 + Y std deviation: 0.5 + - Class: rviz/SetGoal + Topic: /move_base_simple/goal + - Class: rviz/Measure + - Class: waypoints/Waypoints + Topic: waypoint + Value: true + Views: + Current: + Angle: -1.5307965278625488 + Class: rviz/TopDownOrtho + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Scale: 70.76335906982422 + Target Frame: + X: -0.1558832973241806 + Y: 1.6944838762283325 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 1016 + Hide Left Dock: false + Hide Right Dock: true + Image: + collapsed: false + QMainWindow State: 000000ff00000000fd00000004000000000000021f0000039efc0200000010fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d00000124000000c900fffffffb0000000a0049006d0061006700650000000119000000ef0000001600fffffffb0000000a0049006d0061006700650100000167000000a00000001600fffffffb0000000a0049006d00610067006500000001130000008e0000000000000000fb0000000a0049006d00610067006501000001e1000000bf0000000000000000fb0000000a0049006d00610067006500000001a5000000ca0000000000000000fb0000000a0049006d00610067006501000002a6000001350000000000000000fb0000001e0054006f006f006c002000500072006f0070006500720074006900650073000000032e000000ad0000005c00fffffffb0000000a0049006d00610067006501000002a10000013a0000000000000000fb0000001a0077006100790070006f0069006e007400500061006e0065006c0000000369000000720000001600fffffffb0000001a0077006100790070006f0069006e007400500061006e0065006c0000000254000001870000001600fffffffb0000001a0077006100790070006f0069006e007400500061006e0065006c010000020d000001ce0000001600ffffff000000010000010f0000039efc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d0000039e000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004a00000003efc0100000002fb0000000800540069006d00650000000000000004a00000041800fffffffb0000000800540069006d00650100000000000004500000000000000000000002450000039e00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: true + Width: 1130 + X: 72 + Y: 27 + waypointPanel: + collapsed: false diff --git a/src/p3dx_slam/CMakeLists.txt b/src/p3dx_slam/CMakeLists.txt new file mode 100644 index 0000000..3d0b2a8 --- /dev/null +++ b/src/p3dx_slam/CMakeLists.txt @@ -0,0 +1,202 @@ +cmake_minimum_required(VERSION 3.0.2) +project(p3dx_slam) + +## Compile as C++11, supported in ROS Kinetic and newer +# add_compile_options(-std=c++11) + +## 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) + +## System dependencies are found with CMake's conventions +# find_package(Boost REQUIRED COMPONENTS system) + + +## Uncomment this if the package has a setup.py. This macro ensures +## modules and global scripts declared therein get installed +## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html +# catkin_python_setup() + +################################################ +## Declare ROS messages, services and actions ## +################################################ + +## To declare and build messages, services or actions from within this +## package, follow these steps: +## * Let MSG_DEP_SET be the set of packages whose message types you use in +## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...). +## * In the file package.xml: +## * add a build_depend tag for "message_generation" +## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET +## * If MSG_DEP_SET isn't empty the following dependency has been pulled in +## but can be declared for certainty nonetheless: +## * add a exec_depend tag for "message_runtime" +## * In this file (CMakeLists.txt): +## * add "message_generation" and every package in MSG_DEP_SET to +## find_package(catkin REQUIRED COMPONENTS ...) +## * add "message_runtime" and every package in MSG_DEP_SET to +## catkin_package(CATKIN_DEPENDS ...) +## * uncomment the add_*_files sections below as needed +## and list every .msg/.srv/.action file to be processed +## * uncomment the generate_messages entry below +## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...) + +## Generate messages in the 'msg' folder +# add_message_files( +# FILES +# Message1.msg +# Message2.msg +# ) + +## Generate services in the 'srv' folder +# add_service_files( +# FILES +# Service1.srv +# Service2.srv +# ) + +## Generate actions in the 'action' folder +# add_action_files( +# FILES +# Action1.action +# Action2.action +# ) + +## Generate added messages and services with any dependencies listed here +# generate_messages( +# DEPENDENCIES +# std_msgs # Or other packages containing msgs +# ) + +################################################ +## Declare ROS dynamic reconfigure parameters ## +################################################ + +## To declare and build dynamic reconfigure parameters within this +## package, follow these steps: +## * In the file package.xml: +## * add a build_depend and a exec_depend tag for "dynamic_reconfigure" +## * In this file (CMakeLists.txt): +## * add "dynamic_reconfigure" to +## find_package(catkin REQUIRED COMPONENTS ...) +## * uncomment the "generate_dynamic_reconfigure_options" section below +## and list every .cfg file to be processed + +## Generate dynamic reconfigure parameters in the 'cfg' folder +# generate_dynamic_reconfigure_options( +# cfg/DynReconf1.cfg +# cfg/DynReconf2.cfg +# ) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if your package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( +# INCLUDE_DIRS include +# LIBRARIES p3dx_slam +# CATKIN_DEPENDS other_catkin_pkg +# DEPENDS system_lib +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +include_directories( +# include +# ${catkin_INCLUDE_DIRS} +) + +## Declare a C++ library +# add_library(${PROJECT_NAME} +# src/${PROJECT_NAME}/p3dx_slam.cpp +# ) + +## Add cmake target dependencies of the library +## as an example, code may need to be generated before libraries +## either from message generation or dynamic reconfigure +# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Declare a C++ executable +## With catkin_make all packages are built within a single CMake context +## The recommended prefix ensures that target names across packages don't collide +# add_executable(${PROJECT_NAME}_node src/p3dx_slam_node.cpp) + +## Rename C++ executable without prefix +## The above recommended prefix causes long target names, the following renames the +## target back to the shorter version for ease of user use +## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" +# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "") + +## Add cmake target dependencies of the executable +## same as for the library above +# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Specify libraries to link a library or executable target against +# target_link_libraries(${PROJECT_NAME}_node +# ${catkin_LIBRARIES} +# ) + +############# +## Install ## +############# + +# all install targets should use catkin DESTINATION variables +# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html + +## Mark executable scripts (Python etc.) for installation +## in contrast to setup.py, you can choose the destination +# catkin_install_python(PROGRAMS +# scripts/my_python_script +# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark executables for installation +## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html +# install(TARGETS ${PROJECT_NAME}_node +# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark libraries for installation +## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html +# install(TARGETS ${PROJECT_NAME} +# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} +# ) + +## Mark cpp header files for installation +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +# FILES_MATCHING PATTERN "*.h" +# PATTERN ".svn" EXCLUDE +# ) + +## Mark other files for installation (e.g. launch and bag files, etc.) +# install(FILES +# # myfile1 +# # myfile2 +# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +# ) + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test_p3dx_slam.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) diff --git a/src/p3dx_slam/config/gmapping_params.yaml b/src/p3dx_slam/config/gmapping_params.yaml new file mode 100644 index 0000000..666f46d --- /dev/null +++ b/src/p3dx_slam/config/gmapping_params.yaml @@ -0,0 +1,29 @@ +map_update_interval: 2.0 +maxUrange: 20.0 +sigma: 0.05 +kernelSize: 1 +lstep: 0.05 +astep: 0.05 +iterations: 5 +lsigma: 0.075 +ogain: 3.0 +lskip: 0 +minimumScore: 50 +srr: 0.1 +srt: 0.2 +str: 0.1 +stt: 0.2 +linearUpdate: 1.0 +angularUpdate: 0.2 +temporalUpdate: 0.5 +resampleThreshold: 0.5 +particles: 100 +xmin: -10.0 +ymin: -10.0 +xmax: 10.0 +ymax: 10.0 +delta: 0.05 +llsamplerange: 0.01 +llsamplestep: 0.01 +lasamplerange: 0.005 +lasamplestep: 0.005 \ No newline at end of file diff --git a/src/p3dx_slam/launch/p3dx_gmapping.launch b/src/p3dx_slam/launch/p3dx_gmapping.launch new file mode 100644 index 0000000..58b3c59 --- /dev/null +++ b/src/p3dx_slam/launch/p3dx_gmapping.launch @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/src/p3dx_slam/launch/p3dx_slam.launch b/src/p3dx_slam/launch/p3dx_slam.launch new file mode 100644 index 0000000..44aa7ac --- /dev/null +++ b/src/p3dx_slam/launch/p3dx_slam.launch @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/p3dx_slam/package.xml b/src/p3dx_slam/package.xml new file mode 100644 index 0000000..ed88361 --- /dev/null +++ b/src/p3dx_slam/package.xml @@ -0,0 +1,59 @@ + + + p3dx_slam + 0.0.0 + The p3dx_slam package + + + + + ryken + + + + + + TODO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + catkin + + + + + + + + diff --git a/src/p3dx_slam/rviz/p3dx_gmapping.rviz b/src/p3dx_slam/rviz/p3dx_gmapping.rviz new file mode 100644 index 0000000..e02a759 --- /dev/null +++ b/src/p3dx_slam/rviz/p3dx_gmapping.rviz @@ -0,0 +1,266 @@ +Panels: + - Class: rviz/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /RobotModel1 + - /RobotModel1/Status1 + - /TF1/Frames1 + Splitter Ratio: 0.594406008720398 + Tree Height: 204 + - Class: rviz/Selection + Name: Selection + - Class: rviz/Tool Properties + Expanded: + - /2D Pose Estimate1 + - /2D Nav Goal1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz/Time + Name: Time + SyncMode: 0 + SyncSource: LaserScan +Preferences: + PromptSaveOnExit: true +Toolbars: + toolButtonStyle: 2 +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 100 + Reference Frame: map + Value: true + - Alpha: 1 + Class: rviz/RobotModel + Collision Enabled: false + Enabled: true + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + base_link: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + center_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + center_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + front_sonar: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + lms100: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_left_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_left_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_right_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_right_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + swivel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + top_plate: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Name: RobotModel + Robot Description: robot_description + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + - Class: rviz/TF + Enabled: false + Filter (blacklist): "" + Filter (whitelist): "" + Frame Timeout: 15 + Frames: + All Enabled: true + Marker Alpha: 1 + Marker Scale: 1 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: true + Tree: + {} + Update Interval: 0 + Value: false + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/LaserScan + Color: 0; 255; 0 + Color Transformer: FlatColor + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: LaserScan + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.030000001192092896 + Style: Flat Squares + Topic: /scan + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: true + - Class: rviz/Image + Enabled: true + Image Topic: /astra/rgb/image_raw + Max Value: 1 + Median window: 5 + Min Value: 0 + Name: Image + Normalize Range: true + Queue Size: 2 + Transport Hint: compressed + Unreliable: false + Value: true + - Alpha: 0.699999988079071 + Class: rviz/Map + Color Scheme: map + Draw Behind: false + Enabled: true + Name: Map + Topic: /map + Unreliable: false + Use Timestamp: false + Value: true + - Class: rviz/Image + Enabled: true + Image Topic: /astra/depth_registered/image + Max Value: 1 + Median window: 5 + Min Value: 0 + Name: Image + Normalize Range: true + Queue Size: 2 + Transport Hint: raw + Unreliable: false + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Default Light: true + Fixed Frame: map + Frame Rate: 30 + Name: root + Tools: + - Class: rviz/Interact + Hide Inactive Objects: true + - Class: rviz/MoveCamera + - Class: rviz/Select + - Class: rviz/FocusCamera + - Class: rviz/Measure + - Class: rviz/SetInitialPose + Theta std deviation: 0.2617993950843811 + Topic: /initialpose + X std deviation: 0.5 + Y std deviation: 0.5 + - Class: rviz/SetGoal + Topic: /move_base_simple/goal + - Class: rviz/PublishPoint + Single click: true + Topic: /clicked_point + Value: true + Views: + Current: + Angle: -1.5707963705062866 + Class: rviz/TopDownOrtho + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Scale: -42.45056915283203 + Target Frame: map + X: 0 + Y: 0 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 1016 + Hide Left Dock: false + Hide Right Dock: true + Image: + collapsed: false + QMainWindow State: 000000ff00000000fd0000000400000000000002e30000035afc020000000afb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d00000157000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000a0049006d006100670065010000019a000000f00000001600fffffffb0000000a0049006d0061006700650100000290000001070000001600ffffff000000010000010f0000035cfc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a0056006900650077007300000000430000035c000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004ff0000003efc0100000002fb0000000800540069006d00650100000000000004ff000003bc00fffffffb0000000800540069006d00650100000000000004500000000000000000000002160000035a00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: true + Width: 1279 + X: 72 + Y: 27 diff --git a/src/rgbd_launch/.travis.yml b/src/rgbd_launch/.travis.yml new file mode 100644 index 0000000..eda6351 --- /dev/null +++ b/src/rgbd_launch/.travis.yml @@ -0,0 +1,31 @@ +# This config file for Travis CI utilizes ros-industrial/industrial_ci package. +# For more info for the package, see https://github.com/ros-industrial/industrial_ci/blob/master/README.rst +sudo: required +dist: trusty +services: + - docker +language: generic +compiler: + - gcc +notifications: + email: + on_success: always + on_failure: always + recipients: + - gm130s@gmail.com +env: + matrix: + - ROS_DISTRO="indigo" ROS_REPOSITORY_PATH=http://packages.ros.org/ros/ubuntu USE_DEB=true + - ROS_DISTRO="indigo" ROS_REPOSITORY_PATH=http://packages.ros.org/ros-shadow-fixed/ubuntu USE_DEB=true + - ROS_DISTRO="indigo" PRERELEASE=true PRERELEASE_DOWNSTREAM_DEPTH=1 + - ROS_DISTRO="jade" ROS_REPOSITORY_PATH=http://packages.ros.org/ros/ubuntu USE_DEB=true + - ROS_DISTRO="jade" ROS_REPOSITORY_PATH=http://packages.ros.org/ros-shadow-fixed/ubuntu USE_DEB=true + - ROS_DISTRO="jade" PRERELEASE=true PRERELEASE_DOWNSTREAM_DEPTH=1 +matrix: + allow_failures: + # Run docker-based ROS prerelease test http://wiki.ros.org/bloom/Tutorials/PrereleaseTest Because we might not want to run prerelease test for all PRs, it's omitted from pass-fail criteria. + - env: ROS_DISTRO="indigo" PRERELEASE=true PRERELEASE_DOWNSTREAM_DEPTH=1 + - env: ROS_DISTRO="jade" PRERELEASE=true PRERELEASE_DOWNSTREAM_DEPTH=1 +install: + - git clone https://github.com/ros-industrial/industrial_ci.git .ci_config && source .ci_config/travis.sh +# - source ./travis.sh # Enable this when you have a package-local script diff --git a/src/rgbd_launch/CHANGELOG.rst b/src/rgbd_launch/CHANGELOG.rst new file mode 100644 index 0000000..4b86251 --- /dev/null +++ b/src/rgbd_launch/CHANGELOG.rst @@ -0,0 +1,44 @@ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Changelog for package rgbd_launch +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +2.1.3 (2016-09-10) +------------------ +* [feat] add prefix to nodelet name `#28 `_ +* [maintenance] Enable rostest `#29 `_, `#31 `_ +* Contributors: Isaac I.Y. Saito, Kentaro Wada, Yuki Furuta + +2.1.2 (2016-05-07) +------------------ +* [feat] depth_registered_filtered injection `#25 `_ +* [sys] [Travis CI] Update config to using industrial_ci with Prerelease Test. `#23 `_ +* Contributors: Jonathan Bohren, Isaac I.Y. Saito + +2.1.1 (2015-11-16) +------------------ +* 1st ROS Jade release +* [feat] Add convert_metric nodes to depth_registered.launch.xml (`#13 `_ from kbogert/hydro-devel) +* [feat] Add the metric nodes to output a depth image +* [fix] Merge pull request `#1 `_ from piyushk/piyush/kbogert-depth-registered-metric + fixed rect convert metric to conform to both s/w and h/w pipelines. fixe... +* Contributors: Kenneth Bogert, Piyush Khandelwal + +2.1.0 (2014-05-05) +------------------ +* Revert "Add machine parameter". closes `#5 `_ +* Contributors: Piyush Khandelwal + +2.0.1 (2013-09-06) +------------------ +* Merge pull request `#2 `_ - added machine parameter to launch nodelet manager on a remote machine. +* Merge pull request `#1 `_ - added debayer_processing argument + +2.0.0 (2013-08-19) +------------------ +* explicit s/w and h/w processing chains with flags to enable/disable +* marked and moved all launch files as internal +* added a script to serve as an upgrade notice for ROS Hydro. This notice should be removed for ROS Indigo +* fixed cloud processing when device registration is enabled +* added tf prefix resolution to kinect_frames +* Migrated from openni_launch v1.9.1 and removed all openni specific files + diff --git a/src/rgbd_launch/CMakeLists.txt b/src/rgbd_launch/CMakeLists.txt new file mode 100644 index 0000000..63299c1 --- /dev/null +++ b/src/rgbd_launch/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 2.8.3) +project(rgbd_launch) + +find_package(catkin) + +catkin_package() + +install(DIRECTORY launch + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/ +) + +install(PROGRAMS scripts/hydro-upgrade-notice + DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}/ +) + +if(CATKIN_ENABLE_TESTING) + find_package(roslaunch REQUIRED) + find_package(rostest REQUIRED) + roslaunch_add_file_check(launch) + roslaunch_add_file_check(test) + add_rostest(test/camera.test) +endif() diff --git a/src/rgbd_launch/launch/includes/depth.launch.xml b/src/rgbd_launch/launch/includes/depth.launch.xml new file mode 100644 index 0000000..2ec709e --- /dev/null +++ b/src/rgbd_launch/launch/includes/depth.launch.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rgbd_launch/launch/includes/depth_registered.launch.xml b/src/rgbd_launch/launch/includes/depth_registered.launch.xml new file mode 100644 index 0000000..43c21b8 --- /dev/null +++ b/src/rgbd_launch/launch/includes/depth_registered.launch.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rgbd_launch/launch/includes/disparity.launch.xml b/src/rgbd_launch/launch/includes/disparity.launch.xml new file mode 100644 index 0000000..36e5b65 --- /dev/null +++ b/src/rgbd_launch/launch/includes/disparity.launch.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rgbd_launch/launch/includes/disparity_registered.launch.xml b/src/rgbd_launch/launch/includes/disparity_registered.launch.xml new file mode 100644 index 0000000..1e48b8f --- /dev/null +++ b/src/rgbd_launch/launch/includes/disparity_registered.launch.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rgbd_launch/launch/includes/ir.launch.xml b/src/rgbd_launch/launch/includes/ir.launch.xml new file mode 100644 index 0000000..eba2492 --- /dev/null +++ b/src/rgbd_launch/launch/includes/ir.launch.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + diff --git a/src/rgbd_launch/launch/includes/manager.launch.xml b/src/rgbd_launch/launch/includes/manager.launch.xml new file mode 100644 index 0000000..b5efacb --- /dev/null +++ b/src/rgbd_launch/launch/includes/manager.launch.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rgbd_launch/launch/includes/processing.launch.xml b/src/rgbd_launch/launch/includes/processing.launch.xml new file mode 100644 index 0000000..2ae46a4 --- /dev/null +++ b/src/rgbd_launch/launch/includes/processing.launch.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rgbd_launch/launch/includes/rgb.launch.xml b/src/rgbd_launch/launch/includes/rgb.launch.xml new file mode 100644 index 0000000..7920d8b --- /dev/null +++ b/src/rgbd_launch/launch/includes/rgb.launch.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rgbd_launch/launch/kinect_frames.launch b/src/rgbd_launch/launch/kinect_frames.launch new file mode 100644 index 0000000..4d5b966 --- /dev/null +++ b/src/rgbd_launch/launch/kinect_frames.launch @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/src/rgbd_launch/package.xml b/src/rgbd_launch/package.xml new file mode 100644 index 0000000..1de2343 --- /dev/null +++ b/src/rgbd_launch/package.xml @@ -0,0 +1,31 @@ + + rgbd_launch + 2.1.3 + + Launch files to open an RGBD device and load all nodelets to + convert raw depth/RGB/IR streams to depth images, disparity images, + and (registered) point clouds. + + Patrick Mihelich and others + Piyush Khandelwal + BSD + + http://www.ros.org/wiki/rgbd_launch + https://github.com/ros-drivers/rgbd_launch + https://github.com/ros-drivers/rgbd_launch/issues + + catkin + + depth_image_proc + image_proc + nodelet + tf + + depth_image_proc + image_proc + nodelet + tf + + rostest + + diff --git a/src/rgbd_launch/scripts/hydro-upgrade-notice b/src/rgbd_launch/scripts/hydro-upgrade-notice new file mode 100644 index 0000000..8e48fe5 --- /dev/null +++ b/src/rgbd_launch/scripts/hydro-upgrade-notice @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +import rospy +import sys + +if __name__ == '__main__': + rospy.init_node('kinect_frames') + name = rospy.get_param('~name') + from_pkg = rospy.get_param('~from_pkg', 'openni_launch') + to_pkg = rospy.get_param('~to_pkg', 'rgbd_launch') + from_pkg_path = rospy.get_param('~from_pkg_path') + to_pkg_path = rospy.get_param('~to_pkg_path') + + rospy.logfatal(name + ' has moved to ' + to_pkg + '! ' + + 'Replace \"$(find ' + from_pkg + ')/' + from_pkg_path + '\" ' + + 'with \"$(find ' + to_pkg + ')/' + to_pkg_path + '\". ' + + 'This notice will be removed in ROS Indigo') + + sys.exit(0) diff --git a/src/rgbd_launch/test/camera.test b/src/rgbd_launch/test/camera.test new file mode 100644 index 0000000..d673d1c --- /dev/null +++ b/src/rgbd_launch/test/camera.test @@ -0,0 +1,6 @@ + + + + + diff --git a/src/rgbd_launch/test/camera_for_test.launch b/src/rgbd_launch/test/camera_for_test.launch new file mode 100644 index 0000000..b0da3c9 --- /dev/null +++ b/src/rgbd_launch/test/camera_for_test.launch @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/rgbd_launch/test/test_rgbd_launch.py b/src/rgbd_launch/test/test_rgbd_launch.py new file mode 100644 index 0000000..d24d944 --- /dev/null +++ b/src/rgbd_launch/test/test_rgbd_launch.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +#*********************************************************** +#* Software License Agreement (BSD License) +#* +#* Copyright (c) 2009, Willow Garage, Inc. +#* 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 Willow Garage 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 OWNER 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. +#*********************************************************** +# Author: Yuki Furuta + +import tf +import rospy +from unittest import TestCase + + +class TestRGBDLaunch(TestCase): + def testKinectFrames(self): + tfListener = tf.TransformListener() + try: + tfListener.waitForTransform("camera_depth_optical_frame", + "camera_rgb_optical_frame", + rospy.Time(), rospy.Duration(20)) + except Exception as e: + self.fail(str(e)) + try: + trans = tfListener.lookupTransform("camera_depth_optical_frame", + "camera_rgb_optical_frame", + rospy.Time()) + self.assertIsNotNone(trans) + except Exception as e: + self.fail(str(e)) + +if __name__ == '__main__': + rospy.init_node("test_kinect_frames") + import rostest + rostest.rosrun("rgbd_launch", "test_kinect_frames", TestRGBDLaunch) diff --git a/src/robot/CMakeLists.txt b/src/robot/CMakeLists.txt new file mode 100644 index 0000000..70139b2 --- /dev/null +++ b/src/robot/CMakeLists.txt @@ -0,0 +1,120 @@ +cmake_minimum_required(VERSION 2.8.3) +project(robot) + +## 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 COMPONENTS + rosaria + p3dx_description +# tsbot_drivers + robot_state_publisher + estop + urg_node +# mynt_eye_ros_wrapper +) + +################################### +## catkin specific configuration ## +################################### +## The catkin_package macro generates cmake config files for your package +## Declare things to be passed to dependent projects +## INCLUDE_DIRS: uncomment this if you package contains header files +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( +# INCLUDE_DIRS include +# LIBRARIES random_walk + CATKIN_DEPENDS rosaria p3dx_description robot_state_publisher estop urg_node # mynt_eye_ros_wrapper tsbot_drivers +# DEPENDS traxbot_stingbot +) + +########### +## Build ## +########### + +## Specify additional locations of header files +## Your package locations should be listed before other locations +# include_directories(include) +#include_directories( +# include ${catkin_INCLUDE_DIRS} +#) + +## Declare a C++ library +# add_library(random_walk +# src/${PROJECT_NAME}/random_walk.cpp +# ) +#add_library(tsbot_drivers +# src/tsbot_drivers.cpp +#) + +## Add cmake target dependencies of the library +## as an example, code may need to be generated before libraries +## either from message generation or dynamic reconfigure +# add_dependencies(random_walk ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Declare a C++ executable +#add_executable(traxbot src/traxbot.cpp src/tsbot_drivers.cpp) + +## Add cmake target dependencies of the executable +## same as for the library above +# add_dependencies(random_walk_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) + +## Specify libraries to link a library or executable target against +# target_link_libraries(random_walk_node +# ${catkin_LIBRARIES} +# ) +#target_link_libraries(traxbot ${catkin_LIBRARIES}) + +############# +## Install ## +############# + +# all install targets should use catkin DESTINATION variables +# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html + +## Mark executable scripts (Python etc.) for installation +## in contrast to setup.py, you can choose the destination +# install(PROGRAMS +# scripts/my_python_script +# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark executables and/or libraries for installation +# install(TARGETS random_walk random_walk_node +# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} +# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +# ) + +## Mark cpp header files for installation +# install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +# FILES_MATCHING PATTERN "*.h" +# PATTERN ".svn" EXCLUDE +# ) + +## Mark other files for installation (e.g. launch and bag files, etc.) +install(FILES + robot.launch + mynteye_stereo_camera.launch + hokuyo_LRF.launch + platform.launch + sensors.launch + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +) + +############# +## Testing ## +############# + +## Add gtest based cpp test target and link libraries +# catkin_add_gtest(${PROJECT_NAME}-test test/test_random_walk.cpp) +# if(TARGET ${PROJECT_NAME}-test) +# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) +# endif() + +## Add folders to be run by python nosetests +# catkin_add_nosetests(test) + diff --git a/src/robot/launch/d435_intel_realsense_camera.launch b/src/robot/launch/d435_intel_realsense_camera.launch new file mode 100644 index 0000000..4f544f7 --- /dev/null +++ b/src/robot/launch/d435_intel_realsense_camera.launch @@ -0,0 +1,76 @@ + + + + + + + + + + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/robot/launch/hokuyo_LRF.launch b/src/robot/launch/hokuyo_LRF.launch new file mode 100644 index 0000000..3b215d4 --- /dev/null +++ b/src/robot/launch/hokuyo_LRF.launch @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/robot/launch/intel_realsense_camera.launch b/src/robot/launch/intel_realsense_camera.launch new file mode 100644 index 0000000..d9ee49f --- /dev/null +++ b/src/robot/launch/intel_realsense_camera.launch @@ -0,0 +1,76 @@ + + + + + + + + + + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/robot/launch/mynteye_stereo_camera.launch b/src/robot/launch/mynteye_stereo_camera.launch new file mode 100644 index 0000000..d83c231 --- /dev/null +++ b/src/robot/launch/mynteye_stereo_camera.launch @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + #target_frame: laser # Leave disabled to output scan in pointcloud frame + transform_tolerance: 0.01 + min_height: 0.0 + max_height: 2.0 + + angle_min: -1.5707963 # -M_PI/180.0 * 90 deg. + angle_max: 1.5707963 # M_PI/180.0 * 90 deg + angle_increment: 0.00614355896702 # M_PI/180.0 * 0.352 deg. (equal to Hokuyo URG-04LX) + scan_time: 0.1 + range_min: 0.45 + range_max: 5.0 + use_inf: true + inf_epsilon: 1.0 + + # Concurrency level, affects number of pointclouds queued for processing and number of threads used + # 0 : Detect number of cores + # 1 : Single threaded + # 2->inf : Parallelism level + concurrency_level: 1 + + + + + diff --git a/src/robot/launch/orbbec_astra_camera.launch b/src/robot/launch/orbbec_astra_camera.launch new file mode 100644 index 0000000..cf4cf01 --- /dev/null +++ b/src/robot/launch/orbbec_astra_camera.launch @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/robot/launch/platform.launch b/src/robot/launch/platform.launch new file mode 100644 index 0000000..3a89b70 --- /dev/null +++ b/src/robot/launch/platform.launch @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/robot/launch/robot.launch b/src/robot/launch/robot.launch new file mode 100644 index 0000000..35913bf --- /dev/null +++ b/src/robot/launch/robot.launch @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/robot/launch/sensors.launch b/src/robot/launch/sensors.launch new file mode 100644 index 0000000..bd29b04 --- /dev/null +++ b/src/robot/launch/sensors.launch @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/robot/package.xml b/src/robot/package.xml new file mode 100644 index 0000000..bfc862a --- /dev/null +++ b/src/robot/package.xml @@ -0,0 +1,55 @@ + + + + robot + 1.0.0 + +This package contains launch files for the mobile robot platforms and sensors owned by the Mobile Robotics Lab, at Institute of Systems and Robotics - University of Coimbra. + + + + Rui P. Rocha + + + + + LGPLv3 + + + + + + + + + + + Rui P. Rocha + + + + + + + + + + + + + catkin + rosaria + p3dx_description + + robot_state_publisher + estop + urg_node + + + + + + + + + diff --git a/src/robot/rviz_configs/nav_p3dx.rviz b/src/robot/rviz_configs/nav_p3dx.rviz new file mode 100644 index 0000000..0be832f --- /dev/null +++ b/src/robot/rviz_configs/nav_p3dx.rviz @@ -0,0 +1,360 @@ +Panels: + - Class: rviz/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + Splitter Ratio: 0.5 + Tree Height: 377 + - Class: rviz/Selection + Name: Selection + - Class: rviz/Tool Properties + Expanded: + - /2D Pose Estimate1 + - /2D Nav Goal1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz/Time + Experimental: false + Name: Time + SyncMode: 0 + SyncSource: LaserScan +Preferences: + PromptSaveOnExit: true +Toolbars: + toolButtonStyle: 2 +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 5 + Class: rviz/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 32 + Y: 15 + Z: 0 + Plane: XY + Plane Cell Count: 20 + Reference Frame: + Value: true + - Alpha: 1 + Class: rviz/RobotModel + Collision Enabled: false + Enabled: true + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + base_link: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + center_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + center_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + front_sonar: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + lms100: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_left_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_left_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_right_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_right_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + swivel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + top_plate: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Name: Pionner 3-DX robot + Robot Description: robot_description + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/LaserScan + Color: 237; 212; 0 + Color Transformer: FlatColor + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: LaserScan + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.019999999552965164 + Style: Flat Squares + Topic: /scan + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: true + - Class: rviz/TF + Enabled: true + Frame Timeout: 15 + Frames: + All Enabled: false + base_link: + Value: false + center_hubcap: + Value: false + center_wheel: + Value: false + front_sonar: + Value: false + laser: + Value: true + lms100: + Value: false + map: + Value: true + odom: + Value: true + p3dx_left_hubcap: + Value: false + p3dx_left_wheel: + Value: false + p3dx_right_hubcap: + Value: false + p3dx_right_wheel: + Value: false + sonar: + Value: false + swivel: + Value: false + top_plate: + Value: false + Marker Alpha: 1 + Marker Scale: 1 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: true + Tree: + map: + odom: + base_link: + front_sonar: + {} + laser: + {} + lms100: + {} + p3dx_left_wheel: + p3dx_left_hubcap: + {} + p3dx_right_wheel: + p3dx_right_hubcap: + {} + sonar: + {} + swivel: + center_wheel: + center_hubcap: + {} + top_plate: + {} + Update Interval: 0 + Value: true + - Alpha: 0.699999988079071 + Class: rviz/Map + Color Scheme: map + Draw Behind: false + Enabled: true + Name: Map + Topic: /map + Unreliable: false + Use Timestamp: false + Value: true + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/PointCloud2 + Color: 255; 255; 255 + Color Transformer: RGB8 + Decay Time: 0 + Enabled: false + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: PointCloud2 + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.009999999776482582 + Style: Flat Squares + Topic: /astra/depth_registered/points + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: false + - Alpha: 1 + Arrow Length: 0.30000001192092896 + Axes Length: 0.30000001192092896 + Axes Radius: 0.009999999776482582 + Class: rviz/PoseArray + Color: 255; 25; 0 + Enabled: true + Head Length: 0.07000000029802322 + Head Radius: 0.029999999329447746 + Name: AMCL particle cloud + Queue Size: 10 + Shaft Length: 0.23000000417232513 + Shaft Radius: 0.009999999776482582 + Shape: Arrow (Flat) + Topic: /particlecloud + Unreliable: false + Value: true + - Alpha: 0.699999988079071 + Class: rviz/Map + Color Scheme: map + Draw Behind: false + Enabled: false + Name: Local cost map + Topic: /move_base/local_costmap/costmap + Unreliable: false + Use Timestamp: false + Value: false + - Alpha: 0.699999988079071 + Class: rviz/Map + Color Scheme: map + Draw Behind: false + Enabled: false + Name: Global cost map + Topic: /move_base/global_costmap/costmap + Unreliable: false + Use Timestamp: false + Value: false + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Default Light: true + Fixed Frame: map + Frame Rate: 30 + Name: root + Tools: + - Class: rviz/Interact + Hide Inactive Objects: true + - Class: rviz/MoveCamera + - Class: rviz/Select + - Class: rviz/FocusCamera + - Class: rviz/Measure + - Class: rviz/SetInitialPose + Theta std deviation: 0.2617993950843811 + Topic: /initialpose + X std deviation: 0.5 + Y std deviation: 0.5 + - Class: rviz/SetGoal + Topic: /move_base_simple/goal + - Class: rviz/PublishPoint + Single click: true + Topic: /clicked_point + Value: true + Views: + Current: + Class: rviz/Orbit + Distance: 11.610610961914062 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Field of View: 0.7853981852531433 + Focal Point: + X: 6.945462226867676 + Y: 3.3342180252075195 + Z: 0.3235793113708496 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 1.5697963237762451 + Target Frame: map + Yaw: 4.7235798835754395 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 674 + Hide Left Dock: false + Hide Right Dock: true + QMainWindow State: 000000ff00000000fd00000004000000000000015600000204fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d00000204000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000208fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d00000208000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000004670000003efc0100000002fb0000000800540069006d0065010000000000000467000002eb00fffffffb0000000800540069006d006501000000000000045000000000000000000000030b0000020400000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: true + Width: 1127 + X: 235 + Y: 27 diff --git a/src/robot/rviz_configs/p3dx.rviz b/src/robot/rviz_configs/p3dx.rviz new file mode 100644 index 0000000..0eb874b --- /dev/null +++ b/src/robot/rviz_configs/p3dx.rviz @@ -0,0 +1,472 @@ +Panels: + - Class: rviz/Displays + Help Height: 0 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + Splitter Ratio: 0.6705882549285889 + Tree Height: 225 + - Class: rviz/Selection + Name: Selection + - Class: rviz/Tool Properties + Expanded: + - /2D Pose Estimate1 + - /2D Nav Goal1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz/Time + Name: Time + SyncMode: 0 + SyncSource: LaserScan +Preferences: + PromptSaveOnExit: true +Toolbars: + toolButtonStyle: 2 +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 5 + Class: rviz/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 32 + Y: 15 + Z: 0 + Plane: XY + Plane Cell Count: 20 + Reference Frame: + Value: true + - Alpha: 1 + Class: rviz/RobotModel + Collision Enabled: false + Enabled: true + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + base_link: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + center_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + center_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + front_sonar: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + lms100: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_left_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_left_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_right_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_right_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + swivel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + top_plate: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Name: Pionner 3-DX robot + Robot Description: robot_description + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/LaserScan + Color: 239; 41; 41 + Color Transformer: FlatColor + Decay Time: 0 + Enabled: false + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: Hokuyo LaserScan + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.019999999552965164 + Style: Flat Squares + Topic: /hokuyo/scan + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: false + - Class: rviz/TF + Enabled: true + Filter (blacklist): "" + Filter (whitelist): "" + Frame Timeout: 15 + Frames: + All Enabled: false + astra_depth_frame: + Value: true + astra_depth_optical_frame: + Value: false + astra_link: + Value: true + astra_rgb_frame: + Value: false + astra_rgb_optical_frame: + Value: false + base_link: + Value: false + center_hubcap: + Value: false + center_wheel: + Value: false + front_sonar: + Value: false + laser: + Value: true + lms100: + Value: false + odom: + Value: false + p3dx_left_hubcap: + Value: false + p3dx_left_wheel: + Value: false + p3dx_right_hubcap: + Value: false + p3dx_right_wheel: + Value: false + sonar: + Value: false + swivel: + Value: false + top_plate: + Value: true + Marker Alpha: 1 + Marker Scale: 1 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: true + Tree: + odom: + base_link: + astra_link: + astra_depth_frame: + astra_depth_optical_frame: + {} + astra_rgb_frame: + astra_rgb_optical_frame: + {} + front_sonar: + {} + laser: + {} + lms100: + {} + p3dx_left_wheel: + p3dx_left_hubcap: + {} + p3dx_right_wheel: + p3dx_right_hubcap: + {} + sonar: + {} + swivel: + center_wheel: + center_hubcap: + {} + top_plate: + {} + Update Interval: 0 + Value: true + - Alpha: 0.699999988079071 + Class: rviz/Map + Color Scheme: map + Draw Behind: false + Enabled: false + Name: Map + Topic: /map + Unreliable: false + Use Timestamp: false + Value: false + - Class: rviz/Camera + Enabled: true + Image Rendering: background and overlay + Image Topic: /astra/rgb/image_raw + Name: Orbbec Astra RGB image + Overlay Alpha: 0.5 + Queue Size: 2 + Transport Hint: raw + Unreliable: false + Value: true + Visibility: + Astra virtual LaserScan: true + Grid: true + Hokuyo LaserScan: true + LaserScan: true + Map: true + Orbbec Astra point cloud: true + Pionner 3-DX robot: true + Realsense RGB image: true + Realsense point cloud: true + TF: true + Value: true + Zoom Factor: 1 + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/PointCloud2 + Color: 255; 255; 255 + Color Transformer: RGB8 + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: Orbbec Astra point cloud + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.009999999776482582 + Style: Flat Squares + Topic: /astra/depth_registered/points_throttled + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: true + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/LaserScan + Color: 115; 210; 22 + Color Transformer: FlatColor + Decay Time: 0 + Enabled: false + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: Astra virtual LaserScan + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.019999999552965164 + Style: Flat Squares + Topic: /astra/scan + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: false + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/LaserScan + Color: 252; 233; 79 + Color Transformer: FlatColor + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: LaserScan + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.019999999552965164 + Style: Flat Squares + Topic: /scan + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: true + - Class: rviz/Camera + Enabled: false + Image Rendering: overlay + Image Topic: /realsense/color/image_raw + Name: Realsense RGB image + Overlay Alpha: 0.5 + Queue Size: 2 + Transport Hint: raw + Unreliable: false + Value: false + Visibility: + Astra virtual LaserScan: true + Grid: true + Hokuyo LaserScan: true + LaserScan: true + Map: true + Orbbec Astra RGB image: true + Orbbec Astra point cloud: true + Pionner 3-DX robot: true + Realsense point cloud: true + TF: true + Value: false + Zoom Factor: 1 + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/PointCloud2 + Color: 255; 255; 255 + Color Transformer: RGB8 + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: Realsense point cloud + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.009999999776482582 + Style: Flat Squares + Topic: /realsense/depth/color/points_throttled + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: true + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Default Light: true + Fixed Frame: base_link + Frame Rate: 30 + Name: root + Tools: + - Class: rviz/Interact + Hide Inactive Objects: true + - Class: rviz/MoveCamera + - Class: rviz/Select + - Class: rviz/FocusCamera + - Class: rviz/Measure + - Class: rviz/SetInitialPose + Theta std deviation: 0.2617993950843811 + Topic: /initialpose + X std deviation: 0.5 + Y std deviation: 0.5 + - Class: rviz/SetGoal + Topic: /move_base_simple/goal + - Class: rviz/PublishPoint + Single click: true + Topic: /clicked_point + Value: true + Views: + Current: + Class: rviz/Orbit + Distance: 4.7533278465271 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Field of View: 0.7853981852531433 + Focal Point: + X: 1.1790642738342285 + Y: 0.18087533116340637 + Z: 0.8980374932289124 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.4047970473766327 + Target Frame: base_link + Yaw: 2.600405216217041 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 691 + Hide Left Dock: false + Hide Right Dock: true + Orbbec Astra RGB image: + collapsed: false + QMainWindow State: 000000ff00000000fd00000004000000000000015700000215fc020000000ffb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d0000011e000000c900fffffffb0000002c004f00720062006200650063002000410073007400720061002000520047004200200069006d0061006700650100000161000000f10000001600fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb0000000c00430061006d0065007200610000000287000000c20000000000000000fb0000000c00430061006d0065007200610000000286000000c30000000000000000fb0000000c00430061006d0065007200610000000286000000c30000000000000000fb0000000c00430061006d0065007200610000000286000000c30000000000000000fb0000000a0049006d0061006700650000000286000000c30000000000000000fb00000026005200650061006c00730065006e00730065002000520047004200200069006d0061006700650000000191000000ce0000001600ffffff000000010000010f00000231fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d00000231000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000738000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e100000197000000030000048a0000003efc0100000002fb0000000800540069006d006501000000000000048a000003bc00fffffffb0000000800540069006d006501000000000000045000000000000000000000032d0000021500000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Realsense RGB image: + collapsed: false + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: true + Width: 1162 + X: 125 + Y: 27 diff --git a/src/robot/rviz_configs/slam_p3dx.rviz b/src/robot/rviz_configs/slam_p3dx.rviz new file mode 100644 index 0000000..0996483 --- /dev/null +++ b/src/robot/rviz_configs/slam_p3dx.rviz @@ -0,0 +1,338 @@ +Panels: + - Class: rviz/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Grid1 + Splitter Ratio: 0.6823529601097107 + Tree Height: 370 + - Class: rviz/Selection + Name: Selection + - Class: rviz/Tool Properties + Expanded: + - /2D Pose Estimate1 + - /2D Nav Goal1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz/Time + Experimental: false + Name: Time + SyncMode: 0 + SyncSource: LaserScan +Preferences: + PromptSaveOnExit: true +Toolbars: + toolButtonStyle: 2 +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 5 + Class: rviz/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 32 + Y: 15 + Z: 0 + Plane: XY + Plane Cell Count: 20 + Reference Frame: + Value: true + - Alpha: 1 + Class: rviz/RobotModel + Collision Enabled: false + Enabled: true + Links: + All Links Enabled: true + Expand Joint Details: false + Expand Link Details: false + Expand Tree: false + Link Tree Style: Links in Alphabetic Order + base_link: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + center_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + center_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + front_sonar: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + lms100: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_left_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_left_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_right_hubcap: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + p3dx_right_wheel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + swivel: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + top_plate: + Alpha: 1 + Show Axes: false + Show Trail: false + Value: true + Name: Pionner 3-DX robot + Robot Description: robot_description + TF Prefix: "" + Update Interval: 0 + Value: true + Visual Enabled: true + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/LaserScan + Color: 237; 212; 0 + Color Transformer: FlatColor + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: LaserScan + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.019999999552965164 + Style: Flat Squares + Topic: /scan + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: true + - Class: rviz/TF + Enabled: true + Frame Timeout: 15 + Frames: + All Enabled: false + astra_depth_frame: + Value: false + astra_depth_optical_frame: + Value: false + astra_link: + Value: true + astra_rgb_frame: + Value: false + astra_rgb_optical_frame: + Value: false + base_link: + Value: false + center_hubcap: + Value: false + center_wheel: + Value: false + front_sonar: + Value: false + laser: + Value: true + lms100: + Value: false + odom: + Value: true + p3dx_left_hubcap: + Value: false + p3dx_left_wheel: + Value: false + p3dx_right_hubcap: + Value: false + p3dx_right_wheel: + Value: false + sonar: + Value: false + swivel: + Value: false + top_plate: + Value: false + Marker Alpha: 1 + Marker Scale: 1 + Name: TF + Show Arrows: true + Show Axes: true + Show Names: true + Tree: + odom: + base_link: + astra_link: + astra_depth_frame: + astra_depth_optical_frame: + {} + astra_rgb_frame: + astra_rgb_optical_frame: + {} + front_sonar: + {} + laser: + {} + lms100: + {} + p3dx_left_wheel: + p3dx_left_hubcap: + {} + p3dx_right_wheel: + p3dx_right_hubcap: + {} + sonar: + {} + swivel: + center_wheel: + center_hubcap: + {} + top_plate: + {} + Update Interval: 0 + Value: true + - Alpha: 0.699999988079071 + Class: rviz/Map + Color Scheme: map + Draw Behind: false + Enabled: true + Name: Map + Topic: /map + Unreliable: false + Use Timestamp: false + Value: true + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/PointCloud2 + Color: 255; 255; 255 + Color Transformer: RGB8 + Decay Time: 0 + Enabled: false + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: Astra Orbbec PointCloud2 + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.009999999776482582 + Style: Flat Squares + Topic: /astra/depth_registered/points + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: false + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Default Light: true + Fixed Frame: base_link + Frame Rate: 30 + Name: root + Tools: + - Class: rviz/Interact + Hide Inactive Objects: true + - Class: rviz/MoveCamera + - Class: rviz/Select + - Class: rviz/FocusCamera + - Class: rviz/Measure + - Class: rviz/SetInitialPose + Theta std deviation: 0.2617993950843811 + Topic: /initialpose + X std deviation: 0.5 + Y std deviation: 0.5 + - Class: rviz/SetGoal + Topic: /move_base_simple/goal + - Class: rviz/PublishPoint + Single click: true + Topic: /clicked_point + Value: true + Views: + Current: + Class: rviz/Orbit + Distance: 7.424437522888184 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Field of View: 0.7853981852531433 + Focal Point: + X: 1.3798636198043823 + Y: 0.451846718788147 + Z: 0.28588008880615234 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.5297970771789551 + Target Frame: base_link + Yaw: 2.6685807704925537 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 667 + Hide Left Dock: false + Hide Right Dock: true + QMainWindow State: 000000ff00000000fd000000040000000000000156000001fdfc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d000001fd000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000231fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073000000003d00000231000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e100000197000000030000035f0000003efc0100000002fb0000000800540069006d006501000000000000035f000002eb00fffffffb0000000800540069006d0065010000000000000450000000000000000000000203000001fd00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: true + Width: 863 + X: 503 + Y: 27 diff --git a/src/ros_astra_camera/.gitignore b/src/ros_astra_camera/.gitignore new file mode 100644 index 0000000..dbe9c82 --- /dev/null +++ b/src/ros_astra_camera/.gitignore @@ -0,0 +1 @@ +.vscode/ \ No newline at end of file diff --git a/src/ros_astra_camera/56-orbbec-usb.rules b/src/ros_astra_camera/56-orbbec-usb.rules new file mode 100644 index 0000000..0f6a761 --- /dev/null +++ b/src/ros_astra_camera/56-orbbec-usb.rules @@ -0,0 +1,63 @@ +SUBSYSTEM=="usb", ATTR{idProduct}=="0401", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra" +SUBSYSTEM=="usb", ATTR{idProduct}=="0402", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_s" +SUBSYSTEM=="usb", ATTR{idProduct}=="0403", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_pro" +SUBSYSTEM=="usb", ATTR{idProduct}=="0404", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_mini" +SUBSYSTEM=="usb", ATTR{idProduct}=="0407", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra_mini_s" +SUBSYSTEM=="usb", ATTR{idProduct}=="0501", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0502", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0504", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0505", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0508", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0509", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="050a", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="050b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="050c", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="050d", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="050e", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="050f", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0510", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0511", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0512", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0513", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0514", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0515", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0516", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0517", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0518", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0519", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="051a", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="051b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="051c", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="051d", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="051e", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="051f", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0520", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="0604", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0605", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="super" +SUBSYSTEM=="usb", ATTR{idProduct}=="0606", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="luna" +SUBSYSTEM=="usb", ATTR{idProduct}=="0607", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="ado" +SUBSYSTEM=="usb", ATTR{idProduct}=="0608", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra d-u" +SUBSYSTEM=="usb", ATTR{idProduct}=="0609", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="p2" +SUBSYSTEM=="usb", ATTR{idProduct}=="060a", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="alien" +SUBSYSTEM=="usb", ATTR{idProduct}=="060b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="deeyea" +SUBSYSTEM=="usb", ATTR{idProduct}=="060c", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astrauvc" +SUBSYSTEM=="usb", ATTR{idProduct}=="060d", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astra pro plus" +SUBSYSTEM=="usb", ATTR{idProduct}=="060e", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="060f", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0610", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0611", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0612", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0613", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0614", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0615", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0616", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0617", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0618", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0619", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="061a", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="061b", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="061c", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="061d", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="061e", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="061f", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" +SUBSYSTEM=="usb", ATTR{idProduct}=="0620", ATTR{idVendor}=="2bc5", MODE:="0666", OWNER:="root", GROUP:="video", SYMLINK+="astradepth" \ No newline at end of file diff --git a/src/ros_astra_camera/CHANGELOG.rst b/src/ros_astra_camera/CHANGELOG.rst new file mode 100644 index 0000000..e4e37ca --- /dev/null +++ b/src/ros_astra_camera/CHANGELOG.rst @@ -0,0 +1,63 @@ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Changelog for package astra_camera +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +0.3.0 (2019-08-08) +------------ +* Add UVC support +* Add OPENNI2 include files under include folder +* Add more video modes +* Add useful services to control cameras +* Support Stereo S, Embedded S, and Stereo S U3 +* Merge astra_launch package +* 56-orbbec-usb.rules now includes uvc support +* CMakeLists.txt changes accordingly +* Update README +* Contributors: Chi-Ju Wu, Nan Xu, dandedrick, coxep + +0.2.2 (2018-03-22) +----------- +* Add launchfile info and reformat nicely +* Publish projector/camera_info (fixes disparity img) +* modify gcc optimizate problem +* Contributors: Chan Jun Shern, Martin Günther, Mikael Arguedas, Tim + +0.2.1 (2018-02-12) +----------- +* 1,patch for catkin_make -j1 in docker 2,patch for x64 use x86 in docker 3,arm/arm64 use no-filter library +* Contributors: Tim + +0.2.0 (2018-01-25) +------------------ +* add support for astra mini s +* Contributors: Tim Liu + +0.1.5 (2016-05-27) +------------------ +* add dependency on generated messages to avoid race condition at build time +* switching to libusb-1.0 +* Contributors: Tully Foote + +0.1.4 (2016-05-27) +------------------ +* add libusb-dev as a build dependency +* Contributors: Tully Foote + +0.1.3 (2016-05-26) +------------------ +* Adding build dependency on libudev-dev +* Contributors: Tully Foote + +0.1.2 (2016-05-26) +------------------ +* add git as a dependency +* Contributors: Tully Foote + +0.1.1 (2016-05-26) +------------------ +* removing dependency which was internalilzed +* Contributors: Tully Foote + +0.1.0 (2016-05-26) +------------------ +* Initial release of ROS driver for Astra camera +* Contributors: Ernesto Corbellini, Len Zhong, Tim, Tully Foote, ob-tim-liu diff --git a/src/ros_astra_camera/CMakeLists.txt b/src/ros_astra_camera/CMakeLists.txt new file mode 100644 index 0000000..7f94ace --- /dev/null +++ b/src/ros_astra_camera/CMakeLists.txt @@ -0,0 +1,195 @@ +cmake_minimum_required(VERSION 2.8.3) +project(astra_camera) + +find_package(catkin REQUIRED camera_info_manager dynamic_reconfigure image_transport nodelet sensor_msgs roscpp message_generation) + +find_package(Boost REQUIRED COMPONENTS system thread) + +find_package(libuvc REQUIRED) + +#MACHINE = $(shell uname -m) +execute_process(COMMAND uname -m OUTPUT_VARIABLE MACHINES ) +execute_process(COMMAND getconf LONG_BIT OUTPUT_VARIABLE MACHINES_BIT ) +MESSAGE(STATUS "ORRBEC Machine : ${MACHINES}") +MESSAGE(STATUS "ORRBEC Machine Bits : ${MACHINES_BIT}") +IF ( (${MACHINES} MATCHES "x86_64") AND (${MACHINES_BIT} MATCHES "64") ) + set(HOST_PLATFORM "x64") +# for schroot enviroment +ELSEIF ( (${MACHINES} MATCHES "x86_64") AND (${MACHINES_BIT} MATCHES "32") ) + set(HOST_PLATFORM "x86") +ELSEIF ( ${MACHINES} MATCHES "x86" ) +ELSEIF ( ${MACHINES} MATCHES "x86" ) + set(HOST_PLATFORM "x86") +ELSEIF ( ${MACHINES} MATCHES "i686" ) + set(HOST_PLATFORM "x86") +ELSEIF ( ${MACHINES} MATCHES "i386" ) + set(HOST_PLATFORM "x86") +ELSEIF ( ${MACHINES} MATCHES "arm" ) + set(HOST_PLATFORM "arm") +ELSEIF ( (${MACHINES} MATCHES "aarch64") AND (${MACHINES_BIT} MATCHES "64") ) + set(HOST_PLATFORM "arm64") +ELSEIF ( (${MACHINES} MATCHES "aarch64") AND (${MACHINES_BIT} MATCHES "32") ) + set(HOST_PLATFORM "arm") +ENDIF () + +message(STATUS "ORRBEC : ${HOST_PLATFORM}") +message(STATUS "libuvc ${libuvc_VERSION_MAJOR}.${libuvc_VERSION_MINOR}.${libuvc_VERSION_PATCH}") + +generate_dynamic_reconfigure_options(cfg/Astra.cfg cfg/UVCCamera.cfg) + +add_service_files( + FILES + GetSerial.srv + GetDeviceType.srv + GetIRGain.srv + GetCameraInfo.srv + GetUVCExposure.srv + GetIRExposure.srv + GetUVCGain.srv + GetUVCWhiteBalance.srv + SetUVCWhiteBalance.srv + SetUVCGain.srv + SetIRExposure.srv + SetIRGain.srv + SetIRFlood.srv + SetLaser.srv + SetLDP.srv + SetUVCExposure.srv + ResetIRGain.srv + ResetIRExposure.srv + SwitchIRCamera.srv +) + +generate_messages( + DEPENDENCIES + std_msgs sensor_msgs +) + +catkin_package( + INCLUDE_DIRS include + LIBRARIES astra_wrapper + CATKIN_DEPENDS camera_info_manager dynamic_reconfigure image_transport nodelet sensor_msgs roscpp message_runtime + #DEPENDS libastra +) + +add_definitions(-Dlibuvc_VERSION_MAJOR=${libuvc_VERSION_MAJOR}) +add_definitions(-Dlibuvc_VERSION_MINOR=${libuvc_VERSION_MINOR}) +add_definitions(-Dlibuvc_VERSION_PATCH=${libuvc_VERSION_PATCH}) + +set(ORBBEC_OPENNI2_REDIST "${CMAKE_CURRENT_SOURCE_DIR}/include/openni2_redist/${HOST_PLATFORM}") +link_directories(${ORBBEC_OPENNI2_REDIST} + ${catkin_LINK_DIRS} + ) + +#MESSAGE(STATUS "ORRBEC : ${ORBBEC_OPENNI2_REDIST}") + +include_directories(include + ${catkin_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR}/include/openni2 + ${libuvc_INCLUDE_DIRS} + ) + + +add_library(astra_wrapper + src/astra_convert.cpp + src/astra_device.cpp + src/astra_device_info.cpp + src/astra_timer_filter.cpp + src/astra_frame_listener.cpp + src/astra_device_manager.cpp + src/astra_exception.cpp + src/astra_video_mode.cpp + src/astra_device_type.cpp +) +target_link_libraries(astra_wrapper ${catkin_LIBRARIES} -lOpenNI2 -L${ORBBEC_OPENNI2_REDIST} + ${Boost_LIBRARIES} ) +add_dependencies(astra_wrapper ${PROJECT_NAME}_gencfg ${PROJECT_NAME}_generate_messages_cpp) + +add_library(astra_driver_lib + src/astra_driver.cpp + src/astra_device_type.cpp +) +target_link_libraries(astra_driver_lib astra_wrapper ${catkin_LIBRARIES} ${Boost_LIBRARIES} ) +add_dependencies(astra_driver_lib ${PROJECT_NAME}_gencfg ${PROJECT_NAME}_generate_messages_cpp) + +add_library(astra_camera_nodelet + ros/astra_camera_nodelet.cpp +) +target_link_libraries(astra_camera_nodelet astra_driver_lib ${catkin_LIBRARIES} ${Boost_LIBRARIES} ) +add_dependencies(astra_camera_nodelet ${PROJECT_NAME}_gencfg ${PROJECT_NAME}_generate_messages_cpp) + +add_executable(astra_camera_node + ros/astra_camera_node.cpp +) +target_link_libraries(astra_camera_node astra_driver_lib ${catkin_LIBRARIES} ${Boost_LIBRARIES} ) +add_dependencies(astra_camera_node ${PROJECT_NAME}_gencfg ${PROJECT_NAME}_generate_messages_cpp) + +add_executable(astra_list_devices + src/list_devices.cpp +) +target_link_libraries(astra_list_devices astra_wrapper) + +add_executable(astra_test_wrapper test/test_wrapper.cpp ) +target_link_libraries(astra_test_wrapper astra_wrapper ${Boost_LIBRARIES}) +if (UNIX AND NOT APPLE) + add_executable(astra_usb_reset src/usb_reset.c) + set(ADDITIONAL_EXECUTABLES "astra_usb_reset") +endif() + +add_executable(camera_node src/libuvc_camera/main.cpp + src/libuvc_camera/camera_driver.cpp + src/astra_device_type.cpp) +target_link_libraries(camera_node ${libuvc_LIBRARIES} ${Boost_LIBRARIES} ${catkin_LIBRARIES}) +add_dependencies(camera_node ${PROJECT_NAME}_gencfg ${PROJECT_NAME}_generate_messages_cpp) + +add_library(libuvc_camera_nodelet src/libuvc_camera/nodelet.cpp + src/libuvc_camera/camera_driver.cpp + src/astra_device_type.cpp) +target_link_libraries(libuvc_camera_nodelet ${libuvc_LIBRARIES} ${Boost_LIBRARIES} ${catkin_LIBRARIES}) +add_dependencies(libuvc_camera_nodelet ${PROJECT_NAME}_gencfg ${PROJECT_NAME}_generate_messages_cpp) + +install(TARGETS astra_wrapper astra_camera_nodelet astra_camera_node astra_list_devices astra_driver_lib ${ADDITIONAL_EXECUTABLES} + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} + ) + +install(FILES include/openni2_redist/${HOST_PLATFORM}/libOpenNI2.so + DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}/ +) + +install(DIRECTORY include/openni2_redist/${HOST_PLATFORM}/OpenNI2 + DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}/ +) + +#install(DIRECTORY include/${PROJECT_NAME}/ +# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +#) + +# add xml file +install(FILES astra_nodelets.xml + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +) + +install(FILES 56-orbbec-usb.rules + DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}/${PROJECT_NAME} +) + +install(DIRECTORY scripts + DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}/${PROJECT_NAME} +) + +install(FILES 56-orbbec-usb.rules + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +) + +install(DIRECTORY scripts + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} +) + +install(TARGETS camera_node libuvc_camera_nodelet + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) diff --git a/src/ros_astra_camera/LICENSE b/src/ros_astra_camera/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/src/ros_astra_camera/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/ros_astra_camera/README.md b/src/ros_astra_camera/README.md new file mode 100644 index 0000000..342fd4d --- /dev/null +++ b/src/ros_astra_camera/README.md @@ -0,0 +1,141 @@ +# astra_camera + +A ROS driver for Orbbec 3D cameras. + +## Install + +This package supports ROS Kinetic and Melodic. + +1. Install [ROS](http://wiki.ros.org/ROS/Installation). + +2. Install dependences + ```sh + sudo apt install ros-$ROS_DISTRO-rgbd-launch ros-$ROS_DISTRO-libuvc ros-$ROS_DISTRO-libuvc-camera ros-$ROS_DISTRO-libuvc-ros + ``` + +3. Create a [ROS Workspace](http://wiki.ros.org/ROS/Tutorials/InstallingandConfiguringROSEnvironment)(if you don't have one) + ```sh + mkdir -p ~/catkin_ws/src + cd ~/catkin_ws/ + catkin_make + source devel/setup.bash + ``` + +4. Pull the repository into your ROS workspace + ```sh + cd ~/catkin_ws/src + git clone https://github.com/orbbec/ros_astra_camera + ``` + +5. Create astra udev rule + ```sh + roscd astra_camera + ./scripts/create_udev_rules + ``` + +6. Go to catkin workspace and compile astra_camera + ```sh + cd ~/catkin_ws + catkin_make --pkg astra_camera + ``` + +### Filter Enable (To be deprecated: recommend to try master branch at first) + +Astra driver provides normal and filtering methods. With filter driver, we can get more precise depth data but it would cost more computing resources. If the program will be executed on embedded systems, we suggest to use normal method. You can use `-DFILTER=ON / OFF` to change the method as below. + +`catkin_make --pkg astra_camera -DFILTER=OFF` + +## Run astra_camera + +If you didn't add `source $YOUR_WORKSPACE/devel/setup.bash` to your `.bashrc`, remember to source it when open a new terminal :) + +### Examples + +#### Use Astra + +`roslaunch astra_camera astra.launch` + +#### Use Astra Stereo S (w/ UVC) + +`roslaunch astra_camera stereo_s.launch` + +You can use **rviz** or **image_view** to verify the outputs. + +## Important Topics + +* `*/image_raw`: depth/rgb/ir raw images + * If showing IR image is required, it would be more visible to normalize it from 16bit to 8bit (0 to 255) +* `*/image_rect_raw`: images rectified by intrinsic/extrinsic parameters +* `*/camera_info`: camera intrinsic/extrinsic parameters +* `/camera/depth/points`: point cloud without color information +* `/camera/depth_registered/points`: xyzrgb point cloud (Currently, RGB-D regestration supports default resolution only) + +## Useful Services + +This package provides multiple [ros services](http://wiki.ros.org/Services) for users to get useful information and set up devices. To know more about using these services, please check [this tutorial](http://wiki.ros.org/rosservice). + +* `/camera/get_device_type`: return a string containing astra device type +* `/camera/get_ir_exposure`: get exposure value of ir camera +* `/camera/get_ir_gain`: get gain value of ir camera +* `/camera/get_serial`: get serial number +* `/camera/get_uvc_exposure`: get exposure value of rgb camera +* `/camera/get_uvc_gain`: get gain value of rgb camera +* `/camera/get_uvc_white_balance`: get white balance value of rgb camera +* `/camera/reset_ir_exposure`: reset ir exposure to default value +* `/camera/reset_ir_gain`: reset ir gain to default value +* `/camera/set_ir_exposure`: set ir exposure to specific value +* `/camera/set_ir_gain`: set ir gain to specific value +* `/camera/set_laser`: turn on (**true**) or turn off (**false**) laser +* `/camera/set_ldp`: turn on (**true**) or turn off (**false**) ldp +* `/camera/set_uvc_exposure`: set uvc exposure. (set **0** indicating auto mode) +* `/camera/set_uvc_gain`: set uvc gain +* `/camera/set_uvc_white_balance`: set uvc white balance (set **0** indicating auto mode) +* `/camera/set_ir_flood`: turn on (**true**) or turn off (**false**) ir flood +* `/camera/switch_ir_camera`: while using stereo_s/stereo_s_u3, you can switch (left/right) ir camera + +### Examples + +After launching an astra camera, you can get ir exposure by the following command +1. ir exposure + ```sh + rosservice call /camera/get_ir_exposure + ``` + Next, you can change this value in this way + ```sh + rosservice call /camera/set_ir_exposure "{exposure: 50}" # Press tab to autocomplete + ``` + +2. turn on/off laser + ```sh + rosservice call /camera/set_laser "{enable: true}" # turn on + rosservice call /camera/set_laser "{enable: false}" # turn off + ``` + +3. switch ir + ```sh + rosservice call /camera/switch_ir_camera "camera: 'left'" # left + rosservice call /camera/switch_ir_camera "camera: 'right'" # right + ``` + +For the other services, the usage is same as the above example. + +## Multiple Cameras + +To launch multiple cameras, you could modify `multi_astra.launch` to match your setting. The important settings are `device_x_id`(serial number of your devices), `3d_sensor`(name of launch file), and `has_uvc_serial`(does your camera's uvc have serial number). + +If you received **USB Buffer Error**, you could try to increase your USBFS buffer size by the following command. +```sh +echo 64 > /sys/module/usbcore/parameters/usbfs_memory_mb # or maybe 128 +``` + +## License + +Copyright 2019 Orbbec Ltd. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at + +[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + +*Other names and brands may be claimed as the property of others* diff --git a/src/ros_astra_camera/astra_nodelets.xml b/src/ros_astra_camera/astra_nodelets.xml new file mode 100644 index 0000000..db477e3 --- /dev/null +++ b/src/ros_astra_camera/astra_nodelets.xml @@ -0,0 +1,17 @@ + + + + + Astra camera driver nodelet. + + + + + + UVC camera driver nodelet. + + + + diff --git a/src/ros_astra_camera/cfg/Astra.cfg b/src/ros_astra_camera/cfg/Astra.cfg new file mode 100644 index 0000000..c246eb6 --- /dev/null +++ b/src/ros_astra_camera/cfg/Astra.cfg @@ -0,0 +1,59 @@ +#!/usr/bin/env python + +PACKAGE='astra_camera' + +from dynamic_reconfigure.parameter_generator_catkin import * + +gen = ParameterGenerator() + +# TODO Only offer modes supported by known hardware +output_mode_enum = gen.enum([ gen.const( "SXGA_30Hz", int_t, 1, "1280x1024@30Hz"), + gen.const( "SXGA_15Hz", int_t, 2, "1280x1024@15Hz"), + gen.const( "XGA_30Hz", int_t, 3, "1280x720@30Hz"), + gen.const( "XGA_15Hz", int_t, 4, "1280x720@15Hz"), + gen.const( "VGA_30Hz", int_t, 5, "640x480@30Hz"), + gen.const( "VGA_25Hz", int_t, 6, "640x480@25Hz"), + gen.const( "QVGA_25Hz", int_t, 7, "320x240@25Hz"), + gen.const( "QVGA_30Hz", int_t, 8, "320x240@30Hz"), + gen.const( "QVGA_60Hz", int_t, 9, "320x240@60Hz"), + gen.const( "QQVGA_25Hz", int_t, 10, "160x120@25Hz"), + gen.const( "QQVGA_30Hz", int_t, 11, "160x120@30Hz"), + gen.const( "QQVGA_60Hz", int_t, 12, "160x120@60Hz"), + gen.const("640400_30Hz", int_t, 13, "640x400@30Hz"), + gen.const("320200_30Hz", int_t, 14, "320x200@30Hz"), + gen.const("1280800_7Hz", int_t, 15, "1280x800@7Hz"), + gen.const("1280800_30Hz", int_t, 16, "1280x800@30Hz"), + gen.const("640400_60Hz", int_t, 17, "640x400@60Hz")], + "output mode") + +video_stream_enum = gen.enum([ gen.const( "RGB", bool_t, True, "RGB video stream preferred"), + gen.const( "IR", bool_t, False, "IR video stream preferred")], + "preferred video stream mode") + +gen.add("rgb_preferred", bool_t, 0, "Preferred camera stream", True, edit_method = video_stream_enum) + +gen.add("ir_mode", int_t, 0, "Video mode for IR camera", 5, 1, 17, edit_method = output_mode_enum) +gen.add("color_mode", int_t, 0, "Video mode for color camera", 5, 1, 17, edit_method = output_mode_enum) +gen.add("depth_mode", int_t, 0, "Video mode for depth camera", 5, 1, 17, edit_method = output_mode_enum) + +gen.add("depth_registration", bool_t, 0, "Depth data registration", True) +gen.add("color_depth_synchronization", bool_t, 0, "Synchronization of color and depth camera", False) +gen.add("auto_exposure", bool_t, 0, "Auto-Exposure", True) +gen.add("auto_white_balance", bool_t, 0, "Auto-White-Balance", True) + +gen.add("data_skip", int_t, 0, "Skip N images for every image published (rgb/depth/depth_registered/ir)", 0, 0, 10) + +gen.add("ir_time_offset", double_t, 0, "ir image time offset in seconds", -0.033, -1.0, 1.0 ); +gen.add("color_time_offset", double_t, 0, "color image time offset in seconds", -0.033, -1.0, 1.0 ); +gen.add("depth_time_offset", double_t, 0, "depth image time offset in seconds", -0.033, -1.0, 1.0 ); + +gen.add("depth_ir_offset_x", double_t, 0, "X offset between IR and depth images", 5.0, -20.0, 20.0) +gen.add("depth_ir_offset_y", double_t, 0, "Y offset between IR and depth images", 4.0, -20.0, 20.0) + +gen.add("z_offset_mm", int_t, 0, "Z offset in mm", 0, -200, 200) +gen.add("z_scaling", double_t, 0, "Scaling factor for depth values", 1.0, 0.5, 1.5) + +gen.add("use_device_time", bool_t, 0, "Use internal timer of OpenNI device", True) + +exit(gen.generate(PACKAGE, "Astra", "Astra")) + diff --git a/src/ros_astra_camera/cfg/UVCCamera.cfg b/src/ros_astra_camera/cfg/UVCCamera.cfg new file mode 100644 index 0000000..7c73e90 --- /dev/null +++ b/src/ros_astra_camera/cfg/UVCCamera.cfg @@ -0,0 +1,191 @@ +#! /usr/bin/env python2 +# Derived from camera1394 cfg + +from dynamic_reconfigure.parameter_generator_catkin import * + +RECONFIGURE_CLOSE = 3 # Parameters that need a sensor to be stopped completely when changed +RECONFIGURE_STOP = 1 # Parameters that need a sensor to stop streaming when changed +RECONFIGURE_RUNNING = 0 # Parameters that can be changed while a sensor is streaming + +gen = ParameterGenerator() + +# Name, Type, Reconfiguration level, Description, Default, Min, Max + +gen.add("vendor", str_t, RECONFIGURE_CLOSE, + "Vendor ID, hex digits (use camera of any vendor if null).", + "") + +gen.add("product", str_t, RECONFIGURE_CLOSE, + "Product ID, hex digits (use camera of any model if null).", + "") + +gen.add("serial", str_t, RECONFIGURE_CLOSE, + "Serial number, arbitrary string (use camera of any serial number if null).", + "") + +gen.add("index", int_t, RECONFIGURE_CLOSE, + "Index into the list of cameras that match the above parameters.", + 0, 0) + +gen.add("width", int_t, RECONFIGURE_CLOSE, + "Image width.", 640, 0) + +gen.add("height", int_t, RECONFIGURE_CLOSE, + "Image height.", 480, 0) + +video_modes = gen.enum([gen.const("uncompressed", str_t, "uncompressed", "Use any uncompressed format"), + gen.const("compressed", str_t, "compressed", "User any compressed format"), + gen.const("yuyv", str_t, "yuyv", "YUYV"), + gen.const("uyvy", str_t, "uyvy", "UYVY"), + gen.const("rgb", str_t, "rgb", "RGB"), + gen.const("bgr", str_t, "bgr", "BGR"), + gen.const("mjpeg", str_t, "mjpeg", "MJPEG"), + gen.const("gray8", str_t, "gray8", "gray8")], + "Video stream format") + +gen.add("video_mode", str_t, RECONFIGURE_CLOSE, + "Format of video stream from camera.", "uncompressed", + edit_method = video_modes) + +gen.add("frame_rate", double_t, RECONFIGURE_CLOSE, + "Camera speed, frames per second.", 15.0, 0.1, 1000.0) + +timestamp_methods = gen.enum([gen.const("PubTime", str_t, "pub", "Time of publication"), + gen.const("FrameStartTime", str_t, "start", "Time when raw frame capture began"), + gen.const("FrameStopTime", str_t, "stop", "Time when raw frame capture ended"), + gen.const("HostReceiptTime", str_t, "hostrcpt", "Time when camera-to-host transfer completed")], + "Methods for determining the timestamp") + +gen.add("timestamp_method", str_t, RECONFIGURE_CLOSE, + "Method for determining the timestamp.", "start", + edit_method = timestamp_methods) + +gen.add("frame_id", str_t, RECONFIGURE_RUNNING, + "ROS tf frame of reference, resolved with tf_prefix unless absolute.", + "camera") + +gen.add("camera_info_url", str_t, RECONFIGURE_RUNNING, + "Path to camera calibration file.", "") + +# Camera Terminal controls + +scanning_modes = gen.enum([gen.const("Interlaced", int_t, 0, ""), + gen.const("Progressive", int_t, 1, "")], + "Scanning modes") + +gen.add("scanning_mode", int_t, RECONFIGURE_RUNNING, + "Scanning mode.", 0, 0, 1, + edit_method = scanning_modes) + +auto_exposure_modes = gen.enum([gen.const("Manual", int_t, 0, "Manual exposure, manual iris"), + gen.const("Auto", int_t, 1, "Auto exposure, auto iris"), + gen.const("Shutter_Priority", int_t, 2, "manual exposure, auto iris"), + gen.const("Aperture_Priority", int_t, 3, "auto exposure, manual iris")], + "Auto-exposure modes") + +gen.add("auto_exposure", int_t, RECONFIGURE_RUNNING, + "Auto exposure mode.", + 3, 0, 3, edit_method = auto_exposure_modes) + +gen.add("auto_exposure_priority", int_t, RECONFIGURE_RUNNING, + "In auto mode or shutter priority mode, allow the device to vary frame rate.", + 0, 0, 1) + +gen.add("exposure_absolute", double_t, RECONFIGURE_RUNNING, + "Length of exposure, seconds.", 0., 0.0001, 10.0) + +# TODO: relative exposure time + +gen.add("iris_absolute", double_t, RECONFIGURE_RUNNING, + "Aperture, f.", 0., 0., 655.35) + +# TODO: relative iris + +gen.add("auto_focus", bool_t, RECONFIGURE_RUNNING, + "Maintain focus automatically.", True) + +gen.add("focus_absolute", int_t, RECONFIGURE_RUNNING, + "Absolute focal distance, millimeters.", 0, 0, 65536) + +# TODO: relative focus + +# TODO: zoom + +gen.add("pan_absolute", int_t, RECONFIGURE_RUNNING, + "Pan (clockwise), arc seconds.", 0, -180*3600, 180*3600) + +gen.add("tilt_absolute", int_t, RECONFIGURE_RUNNING, + "Tilt (up), arc seconds.", 0, -180*3600, 180*3600) + +# TODO: relative pan/tilt + +gen.add("roll_absolute", int_t, RECONFIGURE_RUNNING, + "Roll (clockwise), degrees.", 0, -180, 180) + +# TODO: relative roll + +gen.add("privacy", bool_t, RECONFIGURE_RUNNING, + "Image capture disabled.", False) + +# Processing Unit controls + +gen.add("backlight_compensation", int_t, RECONFIGURE_RUNNING, + "Backlight compensation, device-dependent (zero for none, increasing compensation above zero).", + 0, 0, 65536) + + +gen.add("brightness", int_t, RECONFIGURE_RUNNING, + "Brightness, device dependent.", 0, -32768, 32767) + +gen.add("contrast", int_t, RECONFIGURE_RUNNING, + "Contrast, device dependent.", 0, -32768, 32767) + +gen.add("gain", int_t, RECONFIGURE_RUNNING, + "Gain, device dependent.", 0, 0, 65536) + +power_line_frequency_modes = gen.enum([gen.const("Disabled", int_t, 0, "Disabled"), + gen.const("Freq_50", int_t, 1, "50 Hz"), + gen.const("Freq_60", int_t, 1, "60 Hz")], + "Power line frequency modes") + +gen.add("power_line_frequency", int_t, RECONFIGURE_RUNNING, + "Power line frequency anti-flicker processing.", + 0, 0, 2, + edit_method = power_line_frequency_modes) + +gen.add("auto_hue", bool_t, RECONFIGURE_RUNNING, + "Automatic hue control.", False) + +gen.add("hue", double_t, RECONFIGURE_RUNNING, + "Hue, degrees.", 0., -180., 180.) + +gen.add("saturation", int_t, RECONFIGURE_RUNNING, + "Saturation, device dependent (zero for grayscale).", 0, 0, 65536) + +gen.add("sharpness", int_t, RECONFIGURE_RUNNING, + "Image sharpness, device dependent.", + 0, 0, 65536) + +# TODO: check range definition +gen.add("gamma", double_t, RECONFIGURE_RUNNING, + "Gamma.", 1.0, 0.01, 5.0) + +gen.add("auto_white_balance", bool_t, RECONFIGURE_RUNNING, + "Automatic white balance.", False) + +gen.add("white_balance_temperature", int_t, RECONFIGURE_RUNNING, + "White balance temperature, degrees.", 0, 0, 65536) + +gen.add("white_balance_BU", double_t, RECONFIGURE_RUNNING, + "Blue or U component of white balance, device-dependent.", + 0, 0, 65536) + +gen.add("white_balance_RV", double_t, RECONFIGURE_RUNNING, + "Red or V component of white balance, device-dependent.", + 0, 0, 65536) + +# TODO: digital multiplier {,limit} + +# TODO: analog video standard, analog video lock + +exit(gen.generate('libuvc_camera', "libuvc_camera", "UVCCamera")) diff --git a/src/ros_astra_camera/include/astra_camera/astra_convert.h b/src/ros_astra_camera/include/astra_camera/astra_convert.h new file mode 100644 index 0000000..fde16cb --- /dev/null +++ b/src/ros_astra_camera/include/astra_camera/astra_convert.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + + +#ifndef ASTRA_CONVERT_H_ +#define ASTRA_CONVERT_H_ + +#include "astra_camera/astra_device_info.h" +#include "astra_camera/astra_video_mode.h" + +#include "openni2/OpenNI.h" + +#include + +namespace astra_wrapper +{ + +const AstraDeviceInfo astra_convert(const openni::DeviceInfo* pInfo); + +const AstraVideoMode astra_convert(const openni::VideoMode& input); +const openni::VideoMode astra_convert(const AstraVideoMode& input); + +const std::vector astra_convert(const openni::Array& input); +} + +#endif diff --git a/src/ros_astra_camera/include/astra_camera/astra_device.h b/src/ros_astra_camera/include/astra_camera/astra_device.h new file mode 100644 index 0000000..43da2e7 --- /dev/null +++ b/src/ros_astra_camera/include/astra_camera/astra_device.h @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#ifndef ASTRA_DEVICE_H +#define ASTRA_DEVICE_H + +#include "astra_camera/astra_video_mode.h" + +#include "astra_camera/astra_exception.h" +#include "astra_camera/astra_device_type.h" + +#include + +#include +#include +#include +#include + +#include + +#include +#include + +namespace openni +{ +class Device; +class DeviceInfo; +class VideoStream; +class SensorInfo; +} + +namespace astra_wrapper +{ + +typedef boost::function FrameCallbackFunction; + +class AstraFrameListener; + +class AstraDevice +{ +public: + AstraDevice(const std::string& device_URI); + virtual ~AstraDevice(); + + const std::string getUri() const; + const std::string getVendor() const; + const std::string getName() const; + uint16_t getUsbVendorId() const; + uint16_t getUsbProductId() const; + + const std::string getStringID() const; + + bool isValid() const; + + bool hasIRSensor() const; + bool hasColorSensor() const; + bool hasDepthSensor() const; + + void startIRStream(); + void startColorStream(); + void startDepthStream(); + + void stopAllStreams(); + + void stopIRStream(); + void stopColorStream(); + void stopDepthStream(); + + bool isIRStreamStarted(); + bool isColorStreamStarted(); + bool isDepthStreamStarted(); + + bool isImageRegistrationModeSupported() const; + void setImageRegistrationMode(bool enabled); + void setDepthColorSync(bool enabled); + + const AstraVideoMode getIRVideoMode(); + const AstraVideoMode getColorVideoMode(); + const AstraVideoMode getDepthVideoMode(); + + const std::vector& getSupportedIRVideoModes() const; + const std::vector& getSupportedColorVideoModes() const; + const std::vector& getSupportedDepthVideoModes() const; + + bool isIRVideoModeSupported(const AstraVideoMode& video_mode) const; + bool isColorVideoModeSupported(const AstraVideoMode& video_mode) const; + bool isDepthVideoModeSupported(const AstraVideoMode& video_mode) const; + + void setIRVideoMode(const AstraVideoMode& video_mode); + void setColorVideoMode(const AstraVideoMode& video_mode); + void setDepthVideoMode(const AstraVideoMode& video_mode); + + void setIRFrameCallback(FrameCallbackFunction callback); + void setColorFrameCallback(FrameCallbackFunction callback); + void setDepthFrameCallback(FrameCallbackFunction callback); + + float getIRFocalLength (int output_y_resolution) const; + float getColorFocalLength (int output_y_resolution) const; + float getDepthFocalLength (int output_y_resolution) const; + float getBaseline () const; + OBCameraParams getCameraParams() const; + bool isCameraParamsValid(); + char* getSerialNumber(); + char* getDeviceType(); + OB_DEVICE_NO getDeviceTypeNo(); + int getIRGain() const; + int getIRExposure() const; + + void setCameraParams(OBCameraParams param); + void setIRGain(int gain); + void setIRExposure(int exposure); + void setLaser(bool enable); + void setIRFlood(bool enable); + void setLDP(bool enable); + + void switchIRCamera(int cam); + + void setAutoExposure(bool enable); + void setAutoWhiteBalance(bool enable); + + bool getAutoExposure() const; + bool getAutoWhiteBalance() const; + + void setUseDeviceTimer(bool enable); + +protected: + void shutdown(); + + boost::shared_ptr getIRVideoStream() const; + boost::shared_ptr getColorVideoStream() const; + boost::shared_ptr getDepthVideoStream() const; + + boost::shared_ptr openni_device_; + boost::shared_ptr device_info_; + + boost::shared_ptr ir_frame_listener; + boost::shared_ptr color_frame_listener; + boost::shared_ptr depth_frame_listener; + + mutable boost::shared_ptr ir_video_stream_; + mutable boost::shared_ptr color_video_stream_; + mutable boost::shared_ptr depth_video_stream_; + + mutable std::vector ir_video_modes_; + mutable std::vector color_video_modes_; + mutable std::vector depth_video_modes_; + + bool ir_video_started_; + bool color_video_started_; + bool depth_video_started_; + + bool image_registration_activated_; + + bool use_device_time_; + + OBCameraParams m_CamParams; + bool m_ParamsValid; + char serial_number[12]; + char device_type[32]; + OB_DEVICE_NO device_type_no; +}; + +std::ostream& operator << (std::ostream& stream, const AstraDevice& device); + +} + +#endif /* OPENNI_DEVICE_H */ diff --git a/src/ros_astra_camera/include/astra_camera/astra_device_info.h b/src/ros_astra_camera/include/astra_camera/astra_device_info.h new file mode 100644 index 0000000..a63a1b5 --- /dev/null +++ b/src/ros_astra_camera/include/astra_camera/astra_device_info.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#ifndef ASTRA_DEVICE_INFO_H_ +#define ASTRA_DEVICE_INFO_H_ + +#include + +#include + +namespace astra_wrapper +{ + +struct AstraDeviceInfo +{ + std::string uri_; + std::string vendor_; + std::string name_; + uint16_t vendor_id_; + uint16_t product_id_; +}; + +std::ostream& operator << (std::ostream& stream, const AstraDeviceInfo& device_info); + +} + +#endif /* DRIVER_H_ */ diff --git a/src/ros_astra_camera/include/astra_camera/astra_device_manager.h b/src/ros_astra_camera/include/astra_camera/astra_device_manager.h new file mode 100644 index 0000000..75bc658 --- /dev/null +++ b/src/ros_astra_camera/include/astra_camera/astra_device_manager.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#ifndef ASTRA_DEVICE_MANAGER_H_ +#define ASTRA_DEVICE_MANAGER_H_ + +#include "astra_camera/astra_device_info.h" + +#include + +#include +#include +#include + +namespace astra_wrapper +{ + +class AstraDeviceListener; +class AstraDevice; + +class AstraDeviceManager +{ +public: + AstraDeviceManager(); + virtual ~AstraDeviceManager(); + + static boost::shared_ptr getSingelton(); + + boost::shared_ptr > getConnectedDeviceInfos() const; + boost::shared_ptr > getConnectedDeviceURIs() const; + std::size_t getNumOfConnectedDevices() const; + + boost::shared_ptr getAnyDevice(); + boost::shared_ptr getDevice(const std::string& device_URI); + + std::string getSerial(const std::string& device_URI) const; + +protected: + boost::shared_ptr device_listener_; + + static boost::shared_ptr singelton_; +}; + + +std::ostream& operator <<(std::ostream& stream, const AstraDeviceManager& device_manager); + +} + +#endif diff --git a/src/ros_astra_camera/include/astra_camera/astra_device_type.h b/src/ros_astra_camera/include/astra_camera/astra_device_type.h new file mode 100644 index 0000000..d2b10e9 --- /dev/null +++ b/src/ros_astra_camera/include/astra_camera/astra_device_type.h @@ -0,0 +1,20 @@ +#ifndef ASTRA_DEVICE_TYPE_H +#define ASTRA_DEVICE_TYPE_H + +#define OB_STEREO_S "Orbbec Canglong" +#define OB_EMBEDDED_S "Astra SL1000S_U3" +#define OB_STEREO_S_U3 "Astra SV1301S_U3" +#define OB_ASTRA_PRO "Orbbec Astra Pro" + +typedef enum +{ + OB_ASTRA_NO, + OB_STEREO_S_NO, + OB_EMBEDDED_S_NO, + OB_STEREO_S_U3_NO, + OB_ASTRA_PRO_NO +} OB_DEVICE_NO; + +bool astraWithUVC(OB_DEVICE_NO id); + +#endif \ No newline at end of file diff --git a/src/ros_astra_camera/include/astra_camera/astra_driver.h b/src/ros_astra_camera/include/astra_camera/astra_driver.h new file mode 100644 index 0000000..00c1033 --- /dev/null +++ b/src/ros_astra_camera/include/astra_camera/astra_driver.h @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#ifndef ASTRA_DRIVER_H +#define ASTRA_DRIVER_H + +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include +#include + +#include "astra_camera/astra_device_manager.h" +#include "astra_camera/astra_device.h" +#include "astra_camera/astra_video_mode.h" +#include "astra_camera/GetSerial.h" +#include "astra_camera/GetDeviceType.h" +#include "astra_camera/GetIRGain.h" +#include "astra_camera/SetIRGain.h" +#include "astra_camera/GetIRExposure.h" +#include "astra_camera/SetIRExposure.h" +#include "astra_camera/SetLaser.h" +#include "astra_camera/SetLDP.h" +#include "astra_camera/ResetIRGain.h" +#include "astra_camera/ResetIRExposure.h" +#include "astra_camera/GetCameraInfo.h" +#include "astra_camera/SetIRFlood.h" +#include "astra_camera/SwitchIRCamera.h" +#include + +#include + +namespace astra_wrapper +{ + +class AstraDriver +{ +public: + AstraDriver(ros::NodeHandle& n, ros::NodeHandle& pnh) ; + ~AstraDriver(); + +private: + typedef astra_camera::AstraConfig Config; + typedef dynamic_reconfigure::Server ReconfigureServer; + + void newIRFrameCallback(sensor_msgs::ImagePtr image); + void newColorFrameCallback(sensor_msgs::ImagePtr image); + void newDepthFrameCallback(sensor_msgs::ImagePtr image); + + // Methods to get calibration parameters for the various cameras + sensor_msgs::CameraInfoPtr getDefaultCameraInfo(int width, int height, double f) const; + sensor_msgs::CameraInfoPtr getColorCameraInfo(int width, int height, ros::Time time) const; + sensor_msgs::CameraInfoPtr getIRCameraInfo(int width, int height, ros::Time time) const; + sensor_msgs::CameraInfoPtr getDepthCameraInfo(int width, int height, ros::Time time) const; + sensor_msgs::CameraInfoPtr getProjectorCameraInfo(int width, int height, ros::Time time) const; + sensor_msgs::CameraInfo convertAstraCameraInfo(OBCameraParams p, ros::Time time) const; + + void readConfigFromParameterServer(); + + // resolves non-URI device IDs to URIs, e.g. '#1' is resolved to the URI of the first device + std::string resolveDeviceURI(const std::string& device_id); + void initDevice(); + + void advertiseROSTopics(); + + void imageConnectCb(); + void depthConnectCb(); + + bool getSerialCb(astra_camera::GetSerialRequest& req, astra_camera::GetSerialResponse& res); + bool getDeviceTypeCb(astra_camera::GetDeviceTypeRequest& req, astra_camera::GetDeviceTypeResponse& res); + bool getIRGainCb(astra_camera::GetIRGainRequest& req, astra_camera::GetIRGainResponse& res); + bool setIRGainCb(astra_camera::SetIRGainRequest& req, astra_camera::SetIRGainResponse& res); + bool getIRExposureCb(astra_camera::GetIRExposureRequest& req, astra_camera::GetIRExposureResponse& res); + bool setIRExposureCb(astra_camera::SetIRExposureRequest& req, astra_camera::SetIRExposureResponse& res); + bool setLaserCb(astra_camera::SetLaserRequest& req, astra_camera::SetLaserResponse& res); + bool resetIRGainCb(astra_camera::ResetIRGainRequest& req, astra_camera::ResetIRGainResponse& res); + bool resetIRExposureCb(astra_camera::ResetIRExposureRequest& req, astra_camera::ResetIRExposureResponse& res); + bool getCameraInfoCb(astra_camera::GetCameraInfoRequest& req, astra_camera::GetCameraInfoResponse& res); + bool setIRFloodCb(astra_camera::SetIRFloodRequest& req, astra_camera::SetIRFloodResponse& res); + bool switchIRCameraCb(astra_camera::SwitchIRCameraRequest& req, astra_camera::SwitchIRCameraResponse& res); + bool setLDPCb(astra_camera::SetLDPRequest& req, astra_camera::SetLDPResponse& res); + + void configCb(Config &config, uint32_t level); + + void applyConfigToOpenNIDevice(); + + void genVideoModeTableMap(); + int lookupVideoModeFromDynConfig(int mode_nr, AstraVideoMode& video_mode); + + sensor_msgs::ImageConstPtr rawToFloatingPointConversion(sensor_msgs::ImageConstPtr raw_image); + + void setIRVideoMode(const AstraVideoMode& ir_video_mode); + void setColorVideoMode(const AstraVideoMode& color_video_mode); + void setDepthVideoMode(const AstraVideoMode& depth_video_mode); + + ros::NodeHandle& nh_; + ros::NodeHandle& pnh_; + + boost::shared_ptr device_manager_; + boost::shared_ptr device_; + + std::string device_id_; + + /** \brief get_serial server*/ + ros::ServiceServer get_camera_info; + ros::ServiceServer get_serial_server; + ros::ServiceServer get_device_type_server; + ros::ServiceServer get_ir_gain_server; + ros::ServiceServer set_ir_gain_server; + ros::ServiceServer get_ir_exposure_server; + ros::ServiceServer set_ir_exposure_server; + ros::ServiceServer set_ir_flood_server; + ros::ServiceServer set_laser_server; + ros::ServiceServer set_ldp_server; + ros::ServiceServer reset_ir_gain_server; + ros::ServiceServer reset_ir_exposure_server; + ros::ServiceServer switch_ir_camera; + + /** \brief reconfigure server*/ + boost::shared_ptr reconfigure_server_; + bool config_init_; + + std::set alreadyOpen; + boost::mutex connect_mutex_; + // published topics + image_transport::CameraPublisher pub_color_; + image_transport::CameraPublisher pub_depth_; + image_transport::CameraPublisher pub_depth_raw_; + image_transport::CameraPublisher pub_ir_; + ros::Publisher pub_projector_info_; + + /** \brief Camera info manager objects. */ + boost::shared_ptr color_info_manager_, ir_info_manager_; + + AstraVideoMode ir_video_mode_; + AstraVideoMode color_video_mode_; + AstraVideoMode depth_video_mode_; + + std::string ir_frame_id_; + std::string color_frame_id_; + std::string depth_frame_id_ ; + + std::string color_info_url_, ir_info_url_; + + bool color_depth_synchronization_; + bool depth_registration_; + + std::map video_modes_lookup_; + + // dynamic reconfigure config + double depth_ir_offset_x_; + double depth_ir_offset_y_; + int z_offset_mm_; + double z_scaling_; + + ros::Duration ir_time_offset_; + ros::Duration color_time_offset_; + ros::Duration depth_time_offset_; + + int data_skip_; + + int data_skip_ir_counter_; + int data_skip_color_counter_; + int data_skip_depth_counter_; + + bool rgb_preferred_; + + bool auto_exposure_; + bool auto_white_balance_; + + bool ir_subscribers_; + bool color_subscribers_; + bool depth_subscribers_; + bool depth_raw_subscribers_; + bool projector_info_subscribers_; + + bool use_device_time_; + + Config old_config_; + int uvc_flip_; +}; + +} + +#endif diff --git a/src/ros_astra_camera/include/astra_camera/astra_exception.h b/src/ros_astra_camera/include/astra_camera/astra_exception.h new file mode 100644 index 0000000..e5857df --- /dev/null +++ b/src/ros_astra_camera/include/astra_camera/astra_exception.h @@ -0,0 +1,91 @@ +/* + * Software License Agreement (BSD License) + * + * Copyright (c) 2011, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * Tim Liu + * + * 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 Willow Garage, Inc. 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 OWNER 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. + * + */ +#ifndef __ASTRA_EXCEPTION__ +#define __ASTRA_EXCEPTION__ + +#include +#include +#include +#include + +#if defined _WIN32 && defined _MSC_VER +# define __PRETTY_FUNCTION__ __FUNCTION__ +#endif +#define THROW_OPENNI_EXCEPTION(format,...) throwOpenNIException( __PRETTY_FUNCTION__, __FILE__, __LINE__, format , ##__VA_ARGS__ ) + +namespace astra_wrapper +{ +/** + * @brief General exception class + * @author Suat Gedikli + * @date 02.january 2011 + */ +class AstraException : public std::exception +{ +public: + AstraException(const std::string& function_name, + const std::string& file_name, + unsigned line_number, + const std::string& message); + + virtual ~AstraException() throw(); + AstraException & operator=(const AstraException& exception); + virtual const char* what() const throw(); + + const std::string& getFunctionName() const; + const std::string& getFileName() const; + unsigned getLineNumber() const; + +protected: + std::string function_name_; + std::string file_name_; + unsigned line_number_; + std::string message_; + std::string message_long_; +}; + +inline void throwOpenNIException(const char* function, const char* file, unsigned line, const char* format, ...) +{ + static char msg[1024]; + va_list args; + va_start(args, format); + vsprintf(msg, format, args); + throw AstraException(function, file, line, msg); +} +} // namespace astra_camera +#endif diff --git a/src/ros_astra_camera/include/astra_camera/astra_frame_listener.h b/src/ros_astra_camera/include/astra_camera/astra_frame_listener.h new file mode 100644 index 0000000..7a1cb55 --- /dev/null +++ b/src/ros_astra_camera/include/astra_camera/astra_frame_listener.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#ifndef ASTRA_FRAME_LISTENER_H_ +#define ASTRA_FRAME_LISTENER_H_ + +#include "astra_camera/astra_device.h" + +#include + +#include + +#include "openni2/OpenNI.h" + +namespace astra_wrapper +{ + +class AstraTimerFilter; + +class AstraFrameListener : public openni::VideoStream::NewFrameListener +{ +public: + AstraFrameListener(); + + virtual ~AstraFrameListener() + { }; + + void onNewFrame(openni::VideoStream& stream); + + void setCallback(FrameCallbackFunction& callback) + { + callback_ = callback; + } + + void setUseDeviceTimer(bool enable); + +private: + openni::VideoFrameRef m_frame; + + FrameCallbackFunction callback_; + + bool user_device_timer_; + boost::shared_ptr timer_filter_; + + double prev_time_stamp_; +}; + +} + +#endif diff --git a/src/ros_astra_camera/include/astra_camera/astra_timer_filter.h b/src/ros_astra_camera/include/astra_camera/astra_timer_filter.h new file mode 100644 index 0000000..d3b4cb7 --- /dev/null +++ b/src/ros_astra_camera/include/astra_camera/astra_timer_filter.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#ifndef ASTRA_TIME_FILTER_H_ +#define ASTRA_TIME_FILTER_H_ + +#include + +#include "openni2/OpenNI.h" + +namespace astra_wrapper +{ + +class AstraTimerFilter +{ +public: + AstraTimerFilter(std::size_t filter_len); + virtual ~AstraTimerFilter(); + + void addSample(double sample); + + double getMedian(); + double getMovingAvg(); + + void clear(); + +private: + std::size_t filter_len_; + + std::deque buffer_; +}; + +} + +#endif diff --git a/src/ros_astra_camera/include/astra_camera/astra_video_mode.h b/src/ros_astra_camera/include/astra_camera/astra_video_mode.h new file mode 100644 index 0000000..21998aa --- /dev/null +++ b/src/ros_astra_camera/include/astra_camera/astra_video_mode.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#ifndef ASTRA_VIDEO_MODE_H_ +#define ASTRA_VIDEO_MODE_H_ + +#include +#include + +namespace astra_wrapper +{ + +// copied from OniEnums.h +typedef enum +{ + // Depth + PIXEL_FORMAT_DEPTH_1_MM = 100, + PIXEL_FORMAT_DEPTH_100_UM = 101, + PIXEL_FORMAT_SHIFT_9_2 = 102, + PIXEL_FORMAT_SHIFT_9_3 = 103, + + // Color + PIXEL_FORMAT_RGB888 = 200, + PIXEL_FORMAT_YUV422 = 201, + PIXEL_FORMAT_GRAY8 = 202, + PIXEL_FORMAT_GRAY16 = 203, + PIXEL_FORMAT_JPEG = 204, +} PixelFormat; + +struct AstraVideoMode +{ + std::size_t x_resolution_; + std::size_t y_resolution_; + double frame_rate_; + PixelFormat pixel_format_; +}; + +std::ostream& operator << (std::ostream& stream, const AstraVideoMode& video_mode); + +bool operator==(const AstraVideoMode& video_mode_a, const AstraVideoMode& video_mode_b); +bool operator!=(const AstraVideoMode& video_mode_a, const AstraVideoMode& video_mode_b); + +} + +#endif diff --git a/src/ros_astra_camera/include/libuvc_camera/camera_driver.h b/src/ros_astra_camera/include/libuvc_camera/camera_driver.h new file mode 100644 index 0000000..9481255 --- /dev/null +++ b/src/ros_astra_camera/include/libuvc_camera/camera_driver.h @@ -0,0 +1,113 @@ +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace libuvc_camera { + +class CameraDriver { +public: + CameraDriver(ros::NodeHandle nh, ros::NodeHandle priv_nh); + ~CameraDriver(); + + bool Start(); + void Stop(); + +private: + enum State { + kInitial = 0, + kStopped = 1, + kRunning = 2, + }; + + // Flags controlling whether the sensor needs to be stopped (or reopened) when changing settings + static const int kReconfigureClose = 3; // Need to close and reopen sensor to change this setting + static const int kReconfigureStop = 1; // Need to stop the stream before changing this setting + static const int kReconfigureRunning = 0; // We can change this setting without stopping the stream + + void OpenCamera(UVCCameraConfig &new_config); + void CloseCamera(); + + // Accept a reconfigure request from a client + void ReconfigureCallback(UVCCameraConfig &config, uint32_t level); + enum uvc_frame_format GetVideoMode(std::string vmode); + // Accept changes in values of automatically updated controls + void AutoControlsCallback(enum uvc_status_class status_class, + int event, + int selector, + enum uvc_status_attribute status_attribute, + void *data, size_t data_len); + static void AutoControlsCallbackAdapter(enum uvc_status_class status_class, + int event, + int selector, + enum uvc_status_attribute status_attribute, + void *data, size_t data_len, + void *ptr); + // Accept a new image frame from the camera + void ImageCallback(uvc_frame_t *frame); + static void ImageCallbackAdapter(uvc_frame_t *frame, void *ptr); + bool getUVCExposureCb(astra_camera::GetUVCExposureRequest& req, astra_camera::GetUVCExposureResponse& res); + bool setUVCExposureCb(astra_camera::SetUVCExposureRequest& req, astra_camera::SetUVCExposureResponse& res); + bool getUVCGainCb(astra_camera::GetUVCGainRequest& req, astra_camera::GetUVCGainResponse& res); + bool setUVCGainCb(astra_camera::SetUVCGainRequest& req, astra_camera::SetUVCGainResponse& res); + bool getUVCWhiteBalanceCb(astra_camera::GetUVCWhiteBalanceRequest& req, astra_camera::GetUVCWhiteBalanceResponse& res); + bool setUVCWhiteBalanceCb(astra_camera::SetUVCWhiteBalanceRequest& req, astra_camera::SetUVCWhiteBalanceResponse& res); + + ros::NodeHandle nh_, priv_nh_; + + State state_; + boost::recursive_mutex mutex_; + + uvc_context_t *ctx_; + uvc_device_t *dev_; + uvc_device_handle_t *devh_; + uvc_frame_t *rgb_frame_; + + image_transport::ImageTransport it_; + image_transport::CameraPublisher cam_pub_; + + dynamic_reconfigure::Server config_server_; + UVCCameraConfig config_; + bool config_changed_; + + camera_info_manager::CameraInfoManager cinfo_manager_; + std::string ns; + std::string ns_no_slash; + + ros::ServiceServer get_uvc_exposure_server; + ros::ServiceServer set_uvc_exposure_server; + ros::ServiceServer get_uvc_gain_server; + ros::ServiceServer set_uvc_gain_server; + ros::ServiceServer get_uvc_white_balance_server; + ros::ServiceServer set_uvc_white_balance_server; + + ros::ServiceClient device_type_client; + ros::ServiceClient camera_info_client; + + bool device_type_init_; + bool camera_info_init_; + std::string device_type_; + sensor_msgs::CameraInfo camera_info_; + int uvc_flip_; + OB_DEVICE_NO device_type_no_; + bool camera_info_valid_; +}; + +}; diff --git a/src/ros_astra_camera/include/openni2/Android-Arm/OniPlatformAndroid-Arm.h b/src/ros_astra_camera/include/openni2/Android-Arm/OniPlatformAndroid-Arm.h new file mode 100644 index 0000000..b4cf2cc --- /dev/null +++ b/src/ros_astra_camera/include/openni2/Android-Arm/OniPlatformAndroid-Arm.h @@ -0,0 +1,43 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIPLATFORMANDROID_ARM_H +#define ONIPLATFORMANDROID_ARM_H + +// Start with Linux-x86, and override what's different +#include "../Linux-x86/OniPlatformLinux-x86.h" + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#undef ONI_PLATFORM +#undef ONI_PLATFORM_STRING + +#define ONI_PLATFORM ONI_PLATFORM_ANDROID_ARM +#define ONI_PLATFORM_STRING "Android-Arm" + +#ifdef HAVE_ANDROID_OS + #define ONI_PLATFORM_ANDROID_OS + + #undef ONI_PLATFORM_STRING + #define ONI_PLATFORM_STRING "AndroidOS-Arm" +#endif + +#endif // ONIPLATFORMANDROID_ARM_H diff --git a/src/ros_astra_camera/include/openni2/Driver/OniDriverAPI.h b/src/ros_astra_camera/include/openni2/Driver/OniDriverAPI.h new file mode 100644 index 0000000..e5a3f76 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/Driver/OniDriverAPI.h @@ -0,0 +1,393 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIDRIVERAPI_H +#define ONIDRIVERAPI_H + +#include "OniPlatform.h" +#include "OniCTypes.h" +#include "OniCProperties.h" +#include "OniDriverTypes.h" +#include + +namespace oni { namespace driver { + +class DeviceBase; +class StreamBase; + +typedef void (ONI_CALLBACK_TYPE* DeviceConnectedCallback)(const OniDeviceInfo*, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* DeviceDisconnectedCallback)(const OniDeviceInfo*, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* DeviceStateChangedCallback)(const OniDeviceInfo* deviceId, int errorState, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* NewFrameCallback)(StreamBase* streamId, OniFrame*, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* PropertyChangedCallback)(void* sender, int propertyId, const void* data, int dataSize, void* pCookie); + +class StreamServices : public OniStreamServices +{ +public: + int getDefaultRequiredFrameSize() + { + return OniStreamServices::getDefaultRequiredFrameSize(streamServices); + } + + OniFrame* acquireFrame() + { + return OniStreamServices::acquireFrame(streamServices); + } + + void addFrameRef(OniFrame* pFrame) + { + OniStreamServices::addFrameRef(streamServices, pFrame); + } + + void releaseFrame(OniFrame* pFrame) + { + OniStreamServices::releaseFrame(streamServices, pFrame); + } +}; + +class StreamBase +{ +public: + StreamBase() : m_newFrameCallback(NULL), m_propertyChangedCallback(NULL) {} + virtual ~StreamBase() {} + + virtual void setServices(StreamServices* pStreamServices) { m_pServices = pStreamServices; } + + virtual OniStatus setProperty(int /*propertyId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniStatus getProperty(int /*propertyId*/, void* /*data*/, int* /*pDataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isPropertySupported(int /*propertyId*/) {return FALSE;} + virtual OniStatus invoke(int /*commandId*/, void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isCommandSupported(int /*commandId*/) {return FALSE;} + + virtual int getRequiredFrameSize() { return getServices().getDefaultRequiredFrameSize(); } + + virtual OniStatus start() = 0; + virtual void stop() = 0; + + virtual void setNewFrameCallback(NewFrameCallback handler, void* pCookie) { m_newFrameCallback = handler; m_newFrameCallbackCookie = pCookie; } + virtual void setPropertyChangedCallback(PropertyChangedCallback handler, void* pCookie) { m_propertyChangedCallback = handler; m_propertyChangedCookie = pCookie; } + + virtual void notifyAllProperties() { return; } + + virtual OniStatus convertDepthToColorCoordinates(StreamBase* /*colorStream*/, int /*depthX*/, int /*depthY*/, OniDepthPixel /*depthZ*/, int* /*pColorX*/, int* /*pColorY*/) { return ONI_STATUS_NOT_SUPPORTED; } + + virtual OniStatus convertC2DCoordinates(int /*depthX*/, int /*depthY*/, OniDepthPixel /*depthZ*/, int* /*pColorX*/, int* /*pColorY*/) { return ONI_STATUS_NOT_SUPPORTED; } + + virtual OniStatus convertD2CCoordinates(int /*depthX*/, int /*depthY*/, OniDepthPixel /*depthZ*/, int* /*pColorX*/, int* /*pColorY*/) { return ONI_STATUS_NOT_SUPPORTED; } +protected: + void raiseNewFrame(OniFrame* pFrame) { (*m_newFrameCallback)(this, pFrame, m_newFrameCallbackCookie); } + void raisePropertyChanged(int propertyId, const void* data, int dataSize) { (*m_propertyChangedCallback)(this, propertyId, data, dataSize, m_propertyChangedCookie); } + + StreamServices& getServices() { return *m_pServices; } + +private: + StreamServices* m_pServices; + NewFrameCallback m_newFrameCallback; + void* m_newFrameCallbackCookie; + PropertyChangedCallback m_propertyChangedCallback; + void* m_propertyChangedCookie; +}; + +class DeviceBase +{ +public: + DeviceBase() {} + virtual ~DeviceBase() {} + + virtual OniStatus getSensorInfoList(OniSensorInfo** pSensorInfos, int* numSensors) = 0; + + virtual StreamBase* createStream(OniSensorType) = 0; + virtual void destroyStream(StreamBase* pStream) = 0; + + virtual OniStatus setProperty(int /*propertyId*/, const void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniStatus getProperty(int /*propertyId*/, void* /*data*/, int* /*pDataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isPropertySupported(int /*propertyId*/) {return FALSE;} + virtual OniStatus invoke(int /*commandId*/, void* /*data*/, int /*dataSize*/) {return ONI_STATUS_NOT_IMPLEMENTED;} + virtual OniBool isCommandSupported(int /*commandId*/) {return FALSE;} + virtual OniStatus tryManualTrigger() {return ONI_STATUS_OK;} + + virtual void setPropertyChangedCallback(PropertyChangedCallback handler, void* pCookie) { m_propertyChangedCallback = handler; m_propertyChangedCookie = pCookie; } + virtual void notifyAllProperties() { return; } + + virtual OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode) { return (mode == ONI_IMAGE_REGISTRATION_OFF); } + +protected: + void raisePropertyChanged(int propertyId, const void* data, int dataSize) { (*m_propertyChangedCallback)(this, propertyId, data, dataSize, m_propertyChangedCookie); } + +private: + PropertyChangedCallback m_propertyChangedCallback; + void* m_propertyChangedCookie; +}; + +class DriverServices +{ +public: + DriverServices(OniDriverServices* pDriverServices) : m_pDriverServices(pDriverServices) {} + + void errorLoggerAppend(const char* format, ...) + { + va_list args; + va_start(args, format); + m_pDriverServices->errorLoggerAppend(m_pDriverServices->driverServices, format, args); + va_end(args); + } + + void errorLoggerClear() + { + m_pDriverServices->errorLoggerClear(m_pDriverServices->driverServices); + } + + void log(int severity, const char* file, int line, const char* mask, const char* message) + { + m_pDriverServices->log(m_pDriverServices->driverServices, severity, file, line, mask, message); + } + +private: + OniDriverServices* m_pDriverServices; +}; + +class DriverBase +{ +public: + DriverBase(OniDriverServices* pDriverServices) : m_services(pDriverServices) + {} + + virtual ~DriverBase() {} + + virtual OniStatus initialize(DeviceConnectedCallback connectedCallback, DeviceDisconnectedCallback disconnectedCallback, DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) + { + m_deviceConnectedEvent = connectedCallback; + m_deviceDisconnectedEvent = disconnectedCallback; + m_deviceStateChangedEvent = deviceStateChangedCallback; + m_pCookie = pCookie; + return ONI_STATUS_OK; + } + + virtual DeviceBase* deviceOpen(const char* uri, const char* mode) = 0; + virtual void deviceClose(DeviceBase* pDevice) = 0; + + virtual void shutdown() = 0; + + virtual OniStatus tryDevice(const char* /*uri*/) { return ONI_STATUS_ERROR;} + + virtual void* enableFrameSync(StreamBase** /*pStreams*/, int /*streamCount*/) { return NULL; } + virtual void disableFrameSync(void* /*frameSyncGroup*/) {} + +protected: + void deviceConnected(const OniDeviceInfo* pInfo) { (m_deviceConnectedEvent)(pInfo, m_pCookie); } + void deviceDisconnected(const OniDeviceInfo* pInfo) { (m_deviceDisconnectedEvent)(pInfo, m_pCookie); } + void deviceStateChanged(const OniDeviceInfo* pInfo, int errorState) { (m_deviceStateChangedEvent)(pInfo, errorState, m_pCookie); } + + DriverServices& getServices() { return m_services; } + +private: + DeviceConnectedCallback m_deviceConnectedEvent; + DeviceDisconnectedCallback m_deviceDisconnectedEvent; + DeviceStateChangedCallback m_deviceStateChangedEvent; + void* m_pCookie; + + DriverServices m_services; +}; + +}} // oni::driver + +#define ONI_EXPORT_DRIVER(DriverClass) \ + \ +oni::driver::DriverBase* g_pDriver = NULL; \ + \ +/* As Driver */ \ +ONI_C_API_EXPORT void oniDriverCreate(OniDriverServices* driverServices) { \ + g_pDriver = XN_NEW(DriverClass, driverServices); \ +} \ +ONI_C_API_EXPORT void oniDriverDestroy() \ +{ \ + g_pDriver->shutdown(); \ + XN_DELETE(g_pDriver); g_pDriver = NULL; \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverInitialize(oni::driver::DeviceConnectedCallback deviceConnectedCallback, \ + oni::driver::DeviceDisconnectedCallback deviceDisconnectedCallback, \ + oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, \ + void* pCookie) \ +{ \ + return g_pDriver->initialize(deviceConnectedCallback, deviceDisconnectedCallback, deviceStateChangedCallback, pCookie); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverTryDevice(const char* uri) \ +{ \ + return g_pDriver->tryDevice(uri); \ +} \ + \ +/* As Device */ \ +ONI_C_API_EXPORT oni::driver::DeviceBase* oniDriverDeviceOpen(const char* uri, const char* mode) \ +{ \ + return g_pDriver->deviceOpen(uri, mode); \ +} \ +ONI_C_API_EXPORT void oniDriverDeviceClose(oni::driver::DeviceBase* pDevice) \ +{ \ + g_pDriver->deviceClose(pDevice); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceGetSensorInfoList(oni::driver::DeviceBase* pDevice, OniSensorInfo** pSensorInfos, \ + int* numSensors) \ +{ \ + return pDevice->getSensorInfoList(pSensorInfos, numSensors); \ +} \ + \ +ONI_C_API_EXPORT oni::driver::StreamBase* oniDriverDeviceCreateStream(oni::driver::DeviceBase* pDevice, \ + OniSensorType sensorType) \ +{ \ + return pDevice->createStream(sensorType); \ +} \ + \ +ONI_C_API_EXPORT void oniDriverDeviceDestroyStream(oni::driver::DeviceBase* pDevice, oni::driver::StreamBase* pStream) \ +{ \ + return pDevice->destroyStream(pStream); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceSetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ + const void* data, int dataSize) \ +{ \ + return pDevice->setProperty(propertyId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceGetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ + void* data, int* pDataSize) \ +{ \ + return pDevice->getProperty(propertyId, data, pDataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverDeviceIsPropertySupported(oni::driver::DeviceBase* pDevice, int propertyId) \ +{ \ + return pDevice->isPropertySupported(propertyId); \ +} \ +ONI_C_API_EXPORT void oniDriverDeviceSetPropertyChangedCallback(oni::driver::DeviceBase* pDevice, \ + oni::driver::PropertyChangedCallback handler, void* pCookie) \ +{ \ + pDevice->setPropertyChangedCallback(handler, pCookie); \ +} \ +ONI_C_API_EXPORT void oniDriverDeviceNotifyAllProperties(oni::driver::DeviceBase* pDevice) \ +{ \ + pDevice->notifyAllProperties(); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceInvoke(oni::driver::DeviceBase* pDevice, int commandId, \ + void* data, int dataSize) \ +{ \ + return pDevice->invoke(commandId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverDeviceIsCommandSupported(oni::driver::DeviceBase* pDevice, int commandId) \ +{ \ + return pDevice->isCommandSupported(commandId); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverDeviceTryManualTrigger(oni::driver::DeviceBase* pDevice) \ +{ \ + return pDevice->tryManualTrigger(); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverDeviceIsImageRegistrationModeSupported(oni::driver::DeviceBase* pDevice, \ + OniImageRegistrationMode mode) \ +{ \ + return pDevice->isImageRegistrationModeSupported(mode); \ +} \ + \ +/* As Stream */ \ +ONI_C_API_EXPORT void oniDriverStreamSetServices(oni::driver::StreamBase* pStream, OniStreamServices* pServices) \ +{ \ + pStream->setServices((oni::driver::StreamServices*)pServices); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamSetProperty(oni::driver::StreamBase* pStream, int propertyId, \ + const void* data, int dataSize) \ +{ \ + return pStream->setProperty(propertyId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverStreamGetProperty(oni::driver::StreamBase* pStream, int propertyId, void* data, \ + int* pDataSize) \ +{ \ + return pStream->getProperty(propertyId, data, pDataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverStreamIsPropertySupported(oni::driver::StreamBase* pStream, int propertyId) \ +{ \ + return pStream->isPropertySupported(propertyId); \ +} \ +ONI_C_API_EXPORT void oniDriverStreamSetPropertyChangedCallback(oni::driver::StreamBase* pStream, \ + oni::driver::PropertyChangedCallback handler, void* pCookie) \ +{ \ + pStream->setPropertyChangedCallback(handler, pCookie); \ +} \ +ONI_C_API_EXPORT void oniDriverStreamNotifyAllProperties(oni::driver::StreamBase* pStream) \ +{ \ + pStream->notifyAllProperties(); \ +} \ +ONI_C_API_EXPORT OniStatus oniDriverStreamInvoke(oni::driver::StreamBase* pStream, int commandId, \ + void* data, int dataSize) \ +{ \ + return pStream->invoke(commandId, data, dataSize); \ +} \ +ONI_C_API_EXPORT OniBool oniDriverStreamIsCommandSupported(oni::driver::StreamBase* pStream, int commandId) \ +{ \ + return pStream->isCommandSupported(commandId); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamStart(oni::driver::StreamBase* pStream) \ +{ \ + return pStream->start(); \ +} \ +ONI_C_API_EXPORT void oniDriverStreamStop(oni::driver::StreamBase* pStream) \ +{ \ + pStream->stop(); \ +} \ + \ +ONI_C_API_EXPORT int oniDriverStreamGetRequiredFrameSize(oni::driver::StreamBase* pStream) \ +{ \ + return pStream->getRequiredFrameSize(); \ +} \ + \ +ONI_C_API_EXPORT void oniDriverStreamSetNewFrameCallback(oni::driver::StreamBase* pStream, \ + oni::driver::NewFrameCallback handler, void* pCookie) \ +{ \ + pStream->setNewFrameCallback(handler, pCookie); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamConvertDepthToColorCoordinates(oni::driver::StreamBase* pDepthStream, \ + oni::driver::StreamBase* pColorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY) \ +{ \ + return pDepthStream->convertDepthToColorCoordinates(pColorStream, depthX, depthY, depthZ, pColorX, pColorY); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamConvertC2DCoordinates(oni::driver::StreamBase* pDepthStream, \ + int colorX, int colorY, OniDepthPixel depthZ, int* pDepthX, int* pDepthY) \ +{ \ + return pDepthStream->convertC2DCoordinates(colorX, colorY, depthZ, pDepthX, pDepthY); \ +} \ + \ +ONI_C_API_EXPORT OniStatus oniDriverStreamConvertD2CCoordinates(oni::driver::StreamBase* pDepthStream, \ + int colorX, int colorY, OniDepthPixel depthZ, int* pDepthX, int* pDepthY) \ +{ \ + return pDepthStream->convertD2CCoordinates(colorX, colorY, depthZ, pDepthX, pDepthY); \ +} \ + \ +ONI_C_API_EXPORT void* oniDriverEnableFrameSync(oni::driver::StreamBase** pStreams, int streamCount) \ +{ \ + return g_pDriver->enableFrameSync(pStreams, streamCount); \ +} \ + \ +ONI_C_API_EXPORT void oniDriverDisableFrameSync(void* frameSyncGroup) \ +{ \ + return g_pDriver->disableFrameSync(frameSyncGroup); \ +} \ + +#endif // ONIDRIVERAPI_H diff --git a/src/ros_astra_camera/include/openni2/Driver/OniDriverTypes.h b/src/ros_astra_camera/include/openni2/Driver/OniDriverTypes.h new file mode 100644 index 0000000..e8a9402 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/Driver/OniDriverTypes.h @@ -0,0 +1,54 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIDRIVERTYPES_H +#define ONIDRIVERTYPES_H + +#include +#include + +#define ONI_STREAM_PROPERTY_PRIVATE_BASE XN_MAX_UINT16 + +typedef struct +{ + int dataSize; + void* data; +} OniGeneralBuffer; + +/////// DriverServices +struct OniDriverServices +{ + void* driverServices; + void (ONI_CALLBACK_TYPE* errorLoggerAppend)(void* driverServices, const char* format, va_list args); + void (ONI_CALLBACK_TYPE* errorLoggerClear)(void* driverServices); + void (ONI_CALLBACK_TYPE* log)(void* driverServices, int severity, const char* file, int line, const char* mask, const char* message); +}; + +struct OniStreamServices +{ + void* streamServices; + int (ONI_CALLBACK_TYPE* getDefaultRequiredFrameSize)(void* streamServices); + OniFrame* (ONI_CALLBACK_TYPE* acquireFrame)(void* streamServices); // returns a frame with size corresponding to getRequiredFrameSize() + void (ONI_CALLBACK_TYPE* addFrameRef)(void* streamServices, OniFrame* pframe); + void (ONI_CALLBACK_TYPE* releaseFrame)(void* streamServices, OniFrame* pframe); +}; + + +#endif // ONIDRIVERTYPES_H diff --git a/src/ros_astra_camera/include/openni2/KinectProperties.h b/src/ros_astra_camera/include/openni2/KinectProperties.h new file mode 100644 index 0000000..0999cb9 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/KinectProperties.h @@ -0,0 +1,104 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef KINECTPROPERTIES_H +#define KINECTPROPERTIES_H + +#include + +/* + * private properties of Microsoft Kinect devices. + * + * @remarks + * properties structure is 0x045eXXYY (045e = Microsoft's USB vendor ID) + * where XX is range and YY is code. + * range values: + * 00 - common stream properties + * 10 - depth stream properties + * 20 - color stream properties + * E0 - device commands + * F0 - device properties + */ +enum +{ + KINECT_PROPERTY_BASE = 0x045e0000, + + /*******************************************************************/ + /* Common stream properties (00-) */ + /*******************************************************************/ + + /*******************************************************************/ + /* Depth stream properties (10-) */ + /*******************************************************************/ + + /** OniBool, set and get. + * Maps to Near Mode in Kinect SDK. + * Also maps to XN_STREAM_PROPERTY_CLOSE_RANGE in PS1080.h. + */ + KINECT_DEPTH_PROPERTY_CLOSE_RANGE = KINECT_PROPERTY_BASE + 0x1001, + + /*******************************************************************/ + /* Color stream properties (20-) */ + /*******************************************************************/ + + /*******************************************************************/ + /* Device commands (E0-) */ + /*******************************************************************/ + + /*******************************************************************/ + /* Device properties (F0-) */ + /*******************************************************************/ + + /* 3D sensing properties (F0-) */ + + /** OniBool, set and get. + * Maps to !NuiGetForceInfraredEmitterOff in Kinect SDK. + * Also maps to XN_MODULE_PROPERTY_EMITTER_STATE. + */ + KINECT_DEVICE_PROPERTY_EMITTER_STATE = KINECT_PROPERTY_BASE + 0xF001, + + /* Non- 3D sensing bonus properties (F8) */ + + /** long, set and get. + * Maps to NuiCameraElevationGetAngle and NuiCameraElevationSetAngle in Kinect SDK. + */ + KINECT_DEVICE_PROPERTY_CAMERA_ELEVATION = KINECT_PROPERTY_BASE + 0xF801, + + /** KinectVector3f, get only. + * Maps to NuiAccelerometerGetCurrentReading. + */ + KINECT_DEVICE_PROPERTY_ACCELEROMETER = KINECT_PROPERTY_BASE + 0xF802, + + /** String, get only. + * Maps to NuiAudioArrayId. + * Useful to find the mic array on the sensor when developing audio-enabled applications. + */ + KINECT_DEVICE_PROPERTY_AUDIO_ARRAY_ID = KINECT_PROPERTY_BASE + 0xF803, + +}; + +typedef struct +{ + float x; + float y; + float z; +} KinectVector3f; + +#endif // KINECTPROPERTIES_H diff --git a/src/ros_astra_camera/include/openni2/Linux-Arm/OniPlatformLinux-Arm.h b/src/ros_astra_camera/include/openni2/Linux-Arm/OniPlatformLinux-Arm.h new file mode 100644 index 0000000..be1f4da --- /dev/null +++ b/src/ros_astra_camera/include/openni2/Linux-Arm/OniPlatformLinux-Arm.h @@ -0,0 +1,36 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIPLATFORMLINUX_ARM_H +#define ONIPLATFORMLINUX_ARM_H + +// Start with Linux-x86, and override what's different +#include "../Linux-x86/OniPlatformLinux-x86.h" + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#undef ONI_PLATFORM +#undef ONI_PLATFORM_STRING +#define ONI_PLATFORM ONI_PLATFORM_LINUX_ARM +#define ONI_PLATFORM_STRING "Linux-Arm" + +#endif // ONIPLATFORMLINUX_ARM_H + diff --git a/src/ros_astra_camera/include/openni2/Linux-x86/OniPlatformLinux-x86.h b/src/ros_astra_camera/include/openni2/Linux-x86/OniPlatformLinux-x86.h new file mode 100644 index 0000000..0e75f1c --- /dev/null +++ b/src/ros_astra_camera/include/openni2/Linux-x86/OniPlatformLinux-x86.h @@ -0,0 +1,102 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIPLATFORMLINUX_X86_H +#define ONIPLATFORMLINUX_X86_H + +//--------------------------------------------------------------------------- +// Prerequisites +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#define ONI_PLATFORM ONI_PLATFORM_LINUX_X86 +#define ONI_PLATFORM_STRING "Linux-x86" + +//--------------------------------------------------------------------------- +// Platform Capabilities +//--------------------------------------------------------------------------- +#define ONI_PLATFORM_ENDIAN_TYPE ONI_PLATFORM_IS_LITTLE_ENDIAN + +#define ONI_PLATFORM_SUPPORTS_DYNAMIC_LIBS 1 + +//--------------------------------------------------------------------------- +// Memory +//--------------------------------------------------------------------------- +/** The default memory alignment. */ +#define ONI_DEFAULT_MEM_ALIGN 16 + +/** The thread static declarator (using TLS). */ +#define ONI_THREAD_STATIC __thread + +//--------------------------------------------------------------------------- +// Files +//--------------------------------------------------------------------------- +/** The maximum allowed file path size (in bytes). */ +#define ONI_FILE_MAX_PATH 256 + +//--------------------------------------------------------------------------- +// Call back +//--------------------------------------------------------------------------- +/** The std call type. */ +#define ONI_STDCALL __stdcall + +/** The call back calling convention. */ +#define ONI_CALLBACK_TYPE + +/** The C and C++ calling convension. */ +#define ONI_C_DECL + +//--------------------------------------------------------------------------- +// Macros +//--------------------------------------------------------------------------- +/** Returns the date and time at compile time. */ +#define ONI_TIMESTAMP __DATE__ " " __TIME__ + +/** Converts n into a pre-processor string. */ +#define ONI_STRINGIFY(n) ONI_STRINGIFY_HELPER(n) +#define ONI_STRINGIFY_HELPER(n) #n + +//--------------------------------------------------------------------------- +// API Export/Import Macros +//--------------------------------------------------------------------------- +/** Indicates an exported shared library function. */ +#define ONI_API_EXPORT __attribute__ ((visibility("default"))) + +/** Indicates an imported shared library function. */ +#define ONI_API_IMPORT + +/** Indicates a deprecated function */ +#define ONI_API_DEPRECATED(msg) __attribute__((warning("This function is deprecated: " msg))) + +#endif // ONIPLATFORMLINUX_X86_H + diff --git a/src/ros_astra_camera/include/openni2/MacOSX/OniPlatformMacOSX.h b/src/ros_astra_camera/include/openni2/MacOSX/OniPlatformMacOSX.h new file mode 100644 index 0000000..4de813a --- /dev/null +++ b/src/ros_astra_camera/include/openni2/MacOSX/OniPlatformMacOSX.h @@ -0,0 +1,57 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIPLATFORMMACOSX_H +#define ONIPLATFORMMACOSX_H + +// Start with Linux-x86, and override what's different +#include "../Linux-x86/OniPlatformLinux-x86.h" + +#include + +#undef ONI_PLATFORM +#undef ONI_PLATFORM_STRING +#define ONI_PLATFORM ONI_PLATFORM_MACOSX +#define ONI_PLATFORM_STRING "MacOSX" + +#include "TargetConditionals.h" +#if (TARGET_IPHONE_SIMULATOR == 1) || (TARGET_OS_IPHONE == 1) + #define ONI_PLATFORM_IOS + + #undef ONI_PLATFORM_STRING + #define ONI_PLATFORM_STRING "iOS" +#elif TARGET_OS_MAC + #ifdef XN_XCODE_BUILD + #define ONI_PLATFORM_MACOSX_XCODE + + #undef ONI_PLATFORM_STRING + #define ONI_PLATFORM_STRING "MacOSX-Xcode" + #endif +#endif + +#define ONI_PLATFORM_HAS_NO_TIMED_OPS +#define ONI_PLATFORM_HAS_NO_CLOCK_GETTIME +#define ONI_PLATFORM_HAS_NO_SCHED_PARAM +#define ONI_PLATFORM_HAS_BUILTIN_SEMUN + +#undef ONI_THREAD_STATIC +#define ONI_THREAD_STATIC + +#endif // ONIPLATFORMMACOSX_H diff --git a/src/ros_astra_camera/include/openni2/OniCAPI.h b/src/ros_astra_camera/include/openni2/OniCAPI.h new file mode 100644 index 0000000..a584021 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/OniCAPI.h @@ -0,0 +1,264 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONICAPI_H +#define ONICAPI_H + +#include "OniPlatform.h" +#include "OniCTypes.h" +#include "OniCProperties.h" +#include "OniVersion.h" + +/******************************************** General APIs */ + +/** Initialize OpenNI2. Use ONI_API_VERSION as the version. */ +ONI_C_API OniStatus oniInitialize(int apiVersion); +/** Shutdown OpenNI2 */ +ONI_C_API void oniShutdown(); + +/** + * Get the list of currently connected device. + * Each device is represented by its OniDeviceInfo. + * pDevices will be allocated inside. + */ +ONI_C_API OniStatus oniGetDeviceList(OniDeviceInfo** pDevices, int* pNumDevices); +/** Release previously allocated device list */ +ONI_C_API OniStatus oniReleaseDeviceList(OniDeviceInfo* pDevices); + +ONI_C_API OniStatus oniRegisterDeviceCallbacks(OniDeviceCallbacks* pCallbacks, void* pCookie, OniCallbackHandle* pHandle); +ONI_C_API void oniUnregisterDeviceCallbacks(OniCallbackHandle handle); + +/** Wait for any of the streams to have a new frame */ +ONI_C_API OniStatus oniWaitForAnyStream(OniStreamHandle* pStreams, int numStreams, int* pStreamIndex, int timeout); + +/** Get the current version of OpenNI2 */ +ONI_C_API OniVersion oniGetVersion(); + +/** Translate from format to number of bytes per pixel. Will return 0 for formats in which the number of bytes per pixel isn't fixed. */ +ONI_C_API int oniFormatBytesPerPixel(OniPixelFormat format); + +/** Get internal error */ +ONI_C_API const char* oniGetExtendedError(); + +/******************************************** Device APIs */ + +/** Open a device. Uri can be taken from the matching OniDeviceInfo. */ +ONI_C_API OniStatus oniDeviceOpen(const char* uri, OniDeviceHandle* pDevice); +/** Close a device */ +ONI_C_API OniStatus oniDeviceClose(OniDeviceHandle device); + +/** Get the possible configurations available for a specific source, or NULL if the source does not exist. */ +ONI_C_API const OniSensorInfo* oniDeviceGetSensorInfo(OniDeviceHandle device, OniSensorType sensorType); + +/** Get the OniDeviceInfo of a certain device. */ +ONI_C_API OniStatus oniDeviceGetInfo(OniDeviceHandle device, OniDeviceInfo* pInfo); + +/** Create a new stream in the device. The stream will originate from the source. */ +ONI_C_API OniStatus oniDeviceCreateStream(OniDeviceHandle device, OniSensorType sensorType, OniStreamHandle* pStream); + +ONI_C_API OniStatus oniDeviceEnableDepthColorSync(OniDeviceHandle device); +ONI_C_API void oniDeviceDisableDepthColorSync(OniDeviceHandle device); +ONI_C_API OniBool oniDeviceGetDepthColorSyncEnabled(OniDeviceHandle device); + +/** Set property in the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ +ONI_C_API OniStatus oniDeviceSetProperty(OniDeviceHandle device, int propertyId, const void* data, int dataSize); +/** Get property in the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ +ONI_C_API OniStatus oniDeviceGetProperty(OniDeviceHandle device, int propertyId, void* data, int* pDataSize); +/** Check if the property is supported by the device. Use the properties listed in OniTypes.h: ONI_DEVICE_PROPERTY_..., or specific ones supplied by the device. */ +ONI_C_API OniBool oniDeviceIsPropertySupported(OniDeviceHandle device, int propertyId); +/** Invoke an internal functionality of the device. */ +ONI_C_API OniStatus oniDeviceInvoke(OniDeviceHandle device, int commandId, void* data, int dataSize); +/** Check if a command is supported, for invoke */ +ONI_C_API OniBool oniDeviceIsCommandSupported(OniDeviceHandle device, int commandId); + +ONI_C_API OniBool oniDeviceIsImageRegistrationModeSupported(OniDeviceHandle device, OniImageRegistrationMode mode); + +/** @internal */ +ONI_C_API OniStatus oniDeviceOpenEx(const char* uri, const char* mode, OniDeviceHandle* pDevice); + +/******************************************** Stream APIs */ + +/** Destroy an existing stream */ +ONI_C_API void oniStreamDestroy(OniStreamHandle stream); + +/** Get the OniSensorInfo of the certain stream. */ +ONI_C_API const OniSensorInfo* oniStreamGetSensorInfo(OniStreamHandle stream); + +/** Start generating data from the stream. */ +ONI_C_API OniStatus oniStreamStart(OniStreamHandle stream); +/** Stop generating data from the stream. */ +ONI_C_API void oniStreamStop(OniStreamHandle stream); + +/** Get the next frame from the stream. This function is blocking until there is a new frame from the stream. For timeout, use oniWaitForStreams() first */ +ONI_C_API OniStatus oniStreamReadFrame(OniStreamHandle stream, OniFrame** pFrame); + +/** Register a callback to when the stream has a new frame. */ +ONI_C_API OniStatus oniStreamRegisterNewFrameCallback(OniStreamHandle stream, OniNewFrameCallback handler, void* pCookie, OniCallbackHandle* pHandle); +/** Unregister a previously registered callback to when the stream has a new frame. */ +ONI_C_API void oniStreamUnregisterNewFrameCallback(OniStreamHandle stream, OniCallbackHandle handle); + +/** Set property in the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ +ONI_C_API OniStatus oniStreamSetProperty(OniStreamHandle stream, int propertyId, const void* data, int dataSize); +/** Get property in the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ +ONI_C_API OniStatus oniStreamGetProperty(OniStreamHandle stream, int propertyId, void* data, int* pDataSize); +/** Check if the property is supported the stream. Use the properties listed in OniTypes.h: ONI_STREAM_PROPERTY_..., or specific ones supplied by the device for its streams. */ +ONI_C_API OniBool oniStreamIsPropertySupported(OniStreamHandle stream, int propertyId); +/** Invoke an internal functionality of the stream. */ +ONI_C_API OniStatus oniStreamInvoke(OniStreamHandle stream, int commandId, void* data, int dataSize); +/** Check if a command is supported, for invoke */ +ONI_C_API OniBool oniStreamIsCommandSupported(OniStreamHandle stream, int commandId); +/** Sets the stream buffer allocation functions. Note that this function may only be called while stream is not started. */ +ONI_C_API OniStatus oniStreamSetFrameBuffersAllocator(OniStreamHandle stream, OniFrameAllocBufferCallback alloc, OniFrameFreeBufferCallback free, void* pCookie); + +//// +/** Mark another user of the frame. */ +ONI_C_API void oniFrameAddRef(OniFrame* pFrame); +/** Mark that the frame is no longer needed. */ +ONI_C_API void oniFrameRelease(OniFrame* pFrame); + +/*add by xlj*/ +ONI_C_API void oniStreamfilter(OniStreamHandle stream, void* buf, int newVal, int maxSpeckleSize, int maxDiff); + +// ONI_C_API OniStatus oniConvertRealWorldToProjective(OniStreamHandle stream, OniFloatPoint3D* pRealWorldPoint, OniFloatPoint3D* pProjectivePoint); +// ONI_C_API OniStatus oniConvertProjectiveToRealWorld(OniStreamHandle stream, OniFloatPoint3D* pProjectivePoint, OniFloatPoint3D* pRealWorldPoint); + +/** + * Creates a recorder that records to a file. + * @param [in] fileName The name of the file that will contain the recording. + * @param [out] pRecorder Points to the handle to the newly created recorder. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniCreateRecorder(const char* fileName, OniRecorderHandle* pRecorder); + +/** + * Attaches a stream to a recorder. The amount of attached streams is virtually + * infinite. You cannot attach a stream after you have started a recording, if + * you do: an error will be returned by oniRecorderAttachStream. + * @param [in] recorder The handle to the recorder. + * @param [in] stream The handle to the stream. + * @param [in] allowLossyCompression Allows/denies lossy compression + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniRecorderAttachStream( + OniRecorderHandle recorder, + OniStreamHandle stream, + OniBool allowLossyCompression); + +/** + * Starts recording. There must be at least one stream attached to the recorder, + * if not: oniRecorderStart will return an error. + * @param[in] recorder The handle to the recorder. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniRecorderStart(OniRecorderHandle recorder); + +/** + * Stops recording. You can resume recording via oniRecorderStart. + * @param[in] recorder The handle to the recorder. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API void oniRecorderStop(OniRecorderHandle recorder); + +/** + * Stops recording if needed, and destroys a recorder. + * @param [in,out] recorder The handle to the recorder, the handle will be + * invalidated (nullified) when the function returns. + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniRecorderDestroy(OniRecorderHandle* pRecorder); + +ONI_C_API OniStatus oniCoordinateConverterDepthToWorld(OniStreamHandle depthStream, float depthX, float depthY, float depthZ, float* pWorldX, float* pWorldY, float* pWorldZ); + +ONI_C_API OniStatus oniCoordinateConverterWorldToDepth(OniStreamHandle depthStream, float worldX, float worldY, float worldZ, float* pDepthX, float* pDepthY, float* pDepthZ); + +ONI_C_API OniStatus oniCoordinateConverterDepthToColor(OniStreamHandle depthStream, OniStreamHandle colorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY); + +ONI_C_API OniStatus oniCoordinateConverterC2D(OniStreamHandle depthStream, int colorX, int colorY, OniDepthPixel depthZ, int* pDepthX, int* pDepthY); +ONI_C_API OniStatus oniCoordinateConverterD2C(OniStreamHandle depthStream, int colorX, int colorY, OniDepthPixel depthZ, int* pDepthX, int* pDepthY); +/******************************************** Log APIs */ + +/** + * Change the log output folder + + * @param const char * strOutputFolder [in] path to the desirebale folder + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogOutputFolder(const char* strOutputFolder); + +/** + * Get the current log file name + + * @param char * strFileName [out] hold the returned file name + * @param int nBufferSize [in] size of strFileName + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniGetLogFileName(char* strFileName, int nBufferSize); + +/** + * Set the Minimum severity for log produce + + * @param const char * strMask [in] Name of the logger + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogMinSeverity(int nMinSeverity); + +/** + * Configures if log entries will be printed to console. + + * @param OniBool bConsoleOutput [in] TRUE to print log entries to console, FALSE otherwise. + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogConsoleOutput(OniBool bConsoleOutput); + +/** + * Configures if log entries will be printed to a log file. + + * @param OniBool bFileOutput [in] TRUE to print log entries to the file, FALSE otherwise. + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogFileOutput(OniBool bFileOutput); + +#if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM +/** + * Configures if log entries will be printed to the Android log. + + * @param OniBool bAndroidOutput [in] TRUE to print log entries to the Android log, FALSE otherwise. + * + * @retval ONI_STATUS_OK Upon successful completion. + * @retval ONI_STATUS_ERROR Upon any kind of failure. + */ +ONI_C_API OniStatus oniSetLogAndroidOutput(OniBool bAndroidOutput); +#endif +#endif // ONICAPI_H diff --git a/src/ros_astra_camera/include/openni2/OniCEnums.h b/src/ros_astra_camera/include/openni2/OniCEnums.h new file mode 100644 index 0000000..c11fa52 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/OniCEnums.h @@ -0,0 +1,84 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONICENUMS_H +#define ONICENUMS_H + +/** Possible failure values */ +typedef enum +{ + ONI_STATUS_OK = 0, + ONI_STATUS_ERROR = 1, + ONI_STATUS_NOT_IMPLEMENTED = 2, + ONI_STATUS_NOT_SUPPORTED = 3, + ONI_STATUS_BAD_PARAMETER = 4, + ONI_STATUS_OUT_OF_FLOW = 5, + ONI_STATUS_NO_DEVICE = 6, + ONI_STATUS_TIME_OUT = 102, +} OniStatus; + +/** The source of the stream */ +typedef enum +{ + ONI_SENSOR_IR = 1, + ONI_SENSOR_COLOR = 2, + ONI_SENSOR_DEPTH = 3, + +} OniSensorType; + +/** All available formats of the output of a stream */ +typedef enum +{ + // Depth + ONI_PIXEL_FORMAT_DEPTH_1_MM = 100, + ONI_PIXEL_FORMAT_DEPTH_100_UM = 101, + ONI_PIXEL_FORMAT_SHIFT_9_2 = 102, + ONI_PIXEL_FORMAT_SHIFT_9_3 = 103, + + // Color + ONI_PIXEL_FORMAT_RGB888 = 200, + ONI_PIXEL_FORMAT_YUV422 = 201, + ONI_PIXEL_FORMAT_GRAY8 = 202, + ONI_PIXEL_FORMAT_GRAY16 = 203, + ONI_PIXEL_FORMAT_JPEG = 204, + ONI_PIXEL_FORMAT_YUYV = 205, +} OniPixelFormat; + +typedef enum +{ + ONI_DEVICE_STATE_OK = 0, + ONI_DEVICE_STATE_ERROR = 1, + ONI_DEVICE_STATE_NOT_READY = 2, + ONI_DEVICE_STATE_EOF = 3 +} OniDeviceState; + +typedef enum +{ + ONI_IMAGE_REGISTRATION_OFF = 0, + ONI_IMAGE_REGISTRATION_DEPTH_TO_COLOR = 1, +} OniImageRegistrationMode; + +enum +{ + ONI_TIMEOUT_NONE = 0, + ONI_TIMEOUT_FOREVER = -1, +}; + +#endif // ONICENUMS_H diff --git a/src/ros_astra_camera/include/openni2/OniCProperties.h b/src/ros_astra_camera/include/openni2/OniCProperties.h new file mode 100644 index 0000000..5bbf39d --- /dev/null +++ b/src/ros_astra_camera/include/openni2/OniCProperties.h @@ -0,0 +1,80 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONICPROPERTIES_H +#define ONICPROPERTIES_H + +// Device properties +enum +{ + ONI_DEVICE_PROPERTY_FIRMWARE_VERSION = 0, // By implementation + ONI_DEVICE_PROPERTY_DRIVER_VERSION = 1, // OniVersion + ONI_DEVICE_PROPERTY_HARDWARE_VERSION = 2, // int + ONI_DEVICE_PROPERTY_SERIAL_NUMBER = 3, // string + ONI_DEVICE_PROPERTY_ERROR_STATE = 4, // ?? + ONI_DEVICE_PROPERTY_IMAGE_REGISTRATION = 5, // OniImageRegistrationMode + + + //orbbec + OBEXTENSION_ID_IR_GAIN = 11, + OBEXTENSION_ID_IR_EXP, + OBEXTENSION_ID_LDP_EN, + OBEXTENSION_ID_CAM_PARAMS, + OBEXTENSION_ID_LASER_EN, + OBEXTENSION_ID_SERIALNUMBER, + OBEXTENSION_ID_DEVICETYPE, + OBEXTENSION_ID_UPDATE_FIRMWARE, + + + // Files + ONI_DEVICE_PROPERTY_PLAYBACK_SPEED = 100, // float + ONI_DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED = 101, // OniBool +}; + +// Stream properties +enum +{ + ONI_STREAM_PROPERTY_CROPPING = 0, // OniCropping* + ONI_STREAM_PROPERTY_HORIZONTAL_FOV = 1, // float: radians + ONI_STREAM_PROPERTY_VERTICAL_FOV = 2, // float: radians + ONI_STREAM_PROPERTY_VIDEO_MODE = 3, // OniVideoMode* + + ONI_STREAM_PROPERTY_MAX_VALUE = 4, // int + ONI_STREAM_PROPERTY_MIN_VALUE = 5, // int + + ONI_STREAM_PROPERTY_STRIDE = 6, // int + ONI_STREAM_PROPERTY_MIRRORING = 7, // OniBool + + ONI_STREAM_PROPERTY_NUMBER_OF_FRAMES = 8, // int + + // Camera + ONI_STREAM_PROPERTY_AUTO_WHITE_BALANCE = 100, // OniBool + ONI_STREAM_PROPERTY_AUTO_EXPOSURE = 101, // OniBool + ONI_STREAM_PROPERTY_EXPOSURE = 102, // int + ONI_STREAM_PROPERTY_GAIN = 103, // int +}; + +// Device commands (for Invoke) +enum +{ + ONI_DEVICE_COMMAND_SEEK = 1, // OniSeek +}; + +#endif // ONICPROPERTIES_H diff --git a/src/ros_astra_camera/include/openni2/OniCTypes.h b/src/ros_astra_camera/include/openni2/OniCTypes.h new file mode 100644 index 0000000..c7eee8a --- /dev/null +++ b/src/ros_astra_camera/include/openni2/OniCTypes.h @@ -0,0 +1,222 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONICTYPES_H +#define ONICTYPES_H + +#include "OniPlatform.h" +#include "OniCEnums.h" + +/** Basic types **/ +typedef int OniBool; + +#ifndef TRUE +#define TRUE 1 +#endif //TRUE +#ifndef FALSE +#define FALSE 0 +#endif //FALSE + +#define ONI_MAX_STR 256 +#define ONI_MAX_SENSORS 10 + +struct OniCallbackHandleImpl; +typedef struct OniCallbackHandleImpl* OniCallbackHandle; + +/** Holds an OpenNI version number, which consists of four separate numbers in the format: @c major.minor.maintenance.build. For example: 2.0.0.20. */ +typedef struct +{ + /** Major version number, incremented for major API restructuring. */ + int major; + /** Minor version number, incremented when significant new features added. */ + int minor; + /** Maintenance build number, incremented for new releases that primarily provide minor bug fixes. */ + int maintenance; + /** Build number. Incremented for each new API build. Generally not shown on the installer and download site. */ + int build; +} OniVersion; + +typedef int OniHardwareVersion; + +/** Description of the output: format and resolution */ +typedef struct +{ + OniPixelFormat pixelFormat; + int resolutionX; + int resolutionY; + int fps; +} OniVideoMode; + +/** List of supported video modes by a specific source */ +typedef struct +{ + OniSensorType sensorType; + int numSupportedVideoModes; + OniVideoMode *pSupportedVideoModes; +} OniSensorInfo; + +/** Basic description of a device */ +typedef struct +{ + char uri[ONI_MAX_STR]; + char vendor[ONI_MAX_STR]; + char name[ONI_MAX_STR]; + uint16_t usbVendorId; + uint16_t usbProductId; +} OniDeviceInfo; + +typedef struct OBCameraParams +{ + float l_intr_p[4];//[fx,fy,cx,cy] + float r_intr_p[4];//[fx,fy,cx,cy] + float r2l_r[9];//[r00,r01,r02;r10,r11,r12;r20,r21,r22] + float r2l_t[3];//[t1,t2,t3] + float l_k[5];//[k1,k2,p1,p2,k3] + float r_k[5]; + //int is_mirror; +}OBCameraParams; + +struct _OniDevice; +typedef struct _OniDevice* OniDeviceHandle; + +struct _OniStream; +typedef struct _OniStream* OniStreamHandle; + +struct _OniRecorder; +typedef struct _OniRecorder* OniRecorderHandle; + +/** All information of the current frame */ +typedef struct +{ + int dataSize; + void* data; + + OniSensorType sensorType; + uint64_t timestamp; + int frameIndex; + + int width; + int height; + + OniVideoMode videoMode; + OniBool croppingEnabled; + int cropOriginX; + int cropOriginY; + + int stride; +} OniFrame; + +typedef void (ONI_CALLBACK_TYPE* OniNewFrameCallback)(OniStreamHandle stream, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniGeneralCallback)(void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniDeviceInfoCallback)(const OniDeviceInfo* pInfo, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniDeviceStateCallback)(const OniDeviceInfo* pInfo, OniDeviceState deviceState, void* pCookie); + +typedef void* (ONI_CALLBACK_TYPE* OniFrameAllocBufferCallback)(int size, void* pCookie); +typedef void (ONI_CALLBACK_TYPE* OniFrameFreeBufferCallback)(void* data, void* pCookie); + +typedef struct +{ + OniDeviceInfoCallback deviceConnected; + OniDeviceInfoCallback deviceDisconnected; + OniDeviceStateCallback deviceStateChanged; +} OniDeviceCallbacks; + +typedef struct +{ + int enabled; + int originX; + int originY; + int width; + int height; +} OniCropping; + +// Pixel types +/** +Pixel type used to store depth images. +*/ +typedef uint16_t OniDepthPixel; +typedef uint16_t OniIRPixel; + +/** +Pixel type used to store 16-bit grayscale images +*/ +typedef uint16_t OniGrayscale16Pixel; + +/** +Pixel type used to store 8-bit grayscale/bayer images +*/ +typedef uint8_t OniGrayscale8Pixel; + +#pragma pack (push, 1) + +/** Holds the value of a single color image pixel in 24-bit RGB format. */ +typedef struct +{ + /* Red value of this pixel. */ + uint8_t r; + /* Green value of this pixel. */ + uint8_t g; + /* Blue value of this pixel. */ + uint8_t b; +} OniRGB888Pixel; + +/** + Holds the value of two pixels in YUV422 format (Luminance/Chrominance,16-bits/pixel). + The first pixel has the values y1, u, v. + The second pixel has the values y2, u, v. +*/ +typedef struct +{ + /** First chrominance value for two pixels, stored as blue luminance difference signal. */ + uint8_t u; + /** Overall luminance value of first pixel. */ + uint8_t y1; + /** Second chrominance value for two pixels, stored as red luminance difference signal. */ + uint8_t v; + /** Overall luminance value of second pixel. */ + uint8_t y2; +} OniYUV422DoublePixel; + +/** + Holds the value of two pixels in YUV422 format (Luminance/Chrominance,16-bits/pixel). + The first pixel has the values y1, u, v. + The second pixel has the values y2, u, v. +*/ +typedef struct +{ + /** Overall luminance value of first pixel. */ + uint8_t y1; + /** First chrominance value for two pixels, stored as blue luminance difference signal. */ + uint8_t u; + /** Overall luminance value of second pixel. */ + uint8_t y2; + /** Second chrominance value for two pixels, stored as red luminance difference signal. */ + uint8_t v; +} OniYUYVDoublePixel; + +#pragma pack (pop) + +typedef struct +{ + int frameIndex; + OniStreamHandle stream; +} OniSeek; + +#endif // ONICTYPES_H diff --git a/src/ros_astra_camera/include/openni2/OniEnums.h b/src/ros_astra_camera/include/openni2/OniEnums.h new file mode 100644 index 0000000..2d8e4ed --- /dev/null +++ b/src/ros_astra_camera/include/openni2/OniEnums.h @@ -0,0 +1,93 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIENUMS_H +#define ONIENUMS_H + +namespace openni +{ + +/** Possible failure values */ +typedef enum +{ + STATUS_OK = 0, + STATUS_ERROR = 1, + STATUS_NOT_IMPLEMENTED = 2, + STATUS_NOT_SUPPORTED = 3, + STATUS_BAD_PARAMETER = 4, + STATUS_OUT_OF_FLOW = 5, + STATUS_NO_DEVICE = 6, + STATUS_TIME_OUT = 102, +} Status; + +/** The source of the stream */ +typedef enum +{ + SENSOR_IR = 1, + SENSOR_COLOR = 2, + SENSOR_DEPTH = 3, + +} SensorType; + +/** All available formats of the output of a stream */ +typedef enum +{ + // Depth + PIXEL_FORMAT_DEPTH_1_MM = 100, + PIXEL_FORMAT_DEPTH_100_UM = 101, + PIXEL_FORMAT_SHIFT_9_2 = 102, + PIXEL_FORMAT_SHIFT_9_3 = 103, + + // Color + PIXEL_FORMAT_RGB888 = 200, + PIXEL_FORMAT_YUV422 = 201, + PIXEL_FORMAT_GRAY8 = 202, + PIXEL_FORMAT_GRAY16 = 203, + PIXEL_FORMAT_JPEG = 204, + PIXEL_FORMAT_YUYV = 205, +} PixelFormat; + +typedef enum +{ + DEVICE_STATE_OK = 0, + DEVICE_STATE_ERROR = 1, + DEVICE_STATE_NOT_READY = 2, + DEVICE_STATE_EOF = 3 +} DeviceState; + +typedef enum +{ + IMAGE_REGISTRATION_OFF = 0, + IMAGE_REGISTRATION_DEPTH_TO_COLOR = 1, +} ImageRegistrationMode; + +typedef enum +{ + PARAMS_REGISTRATION_OFF = 0, + PARAMS_REGISTRATION_DEPTH_TO_COLOR = 1, + PARAMS_REGISTRATION_USE_DISTORTION = 2, +} ParamsRegistrationMode; + +static const int TIMEOUT_NONE = 0; +static const int TIMEOUT_FOREVER = -1; + +} // namespace openni + +#endif // ONIENUMS_H diff --git a/src/ros_astra_camera/include/openni2/OniPlatform.h b/src/ros_astra_camera/include/openni2/OniPlatform.h new file mode 100644 index 0000000..b4d3950 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/OniPlatform.h @@ -0,0 +1,72 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIPLATFORM_H +#define ONIPLATFORM_H + +// Supported platforms +#define ONI_PLATFORM_WIN32 1 +#define ONI_PLATFORM_LINUX_X86 2 +#define ONI_PLATFORM_LINUX_ARM 3 +#define ONI_PLATFORM_MACOSX 4 +#define ONI_PLATFORM_ANDROID_ARM 5 + +#if (defined _WIN32) +# ifndef RC_INVOKED +# if _MSC_VER < 1300 +# error OpenNI Platform Abstraction Layer - Win32 - Microsoft Visual Studio version below 2003 (7.0) are not supported! +# endif +# endif +# include "Win32/OniPlatformWin32.h" +#elif defined (ANDROID) && (__arm__|| __aarch64__) +# include "Android-Arm/OniPlatformAndroid-Arm.h" +#elif (__linux__ && (__i386__ || __x86_64__)) +# include "Linux-x86/OniPlatformLinux-x86.h" +#elif (__linux__ && (__arm__ || __aarch64__)) +# include "Linux-Arm/OniPlatformLinux-Arm.h" +#elif _ARC +# include "ARC/OniPlaformARC.h" +#elif (__APPLE__) +# include "MacOSX/OniPlatformMacOSX.h" +#else +# error Xiron Platform Abstraction Layer - Unsupported Platform! +#endif + +#ifdef __cplusplus +# define ONI_C extern "C" +# define ONI_C_API_EXPORT ONI_C ONI_API_EXPORT +# define ONI_C_API_IMPORT ONI_C ONI_API_IMPORT +# define ONI_CPP_API_EXPORT ONI_API_EXPORT +# define ONI_CPP_API_IMPORT ONI_API_IMPORT +#else // __cplusplus +# define ONI_C_API_EXPORT ONI_API_EXPORT +# define ONI_C_API_IMPORT ONI_API_IMPORT +#endif // __cplusplus + +#ifdef OPENNI2_EXPORT +# define ONI_C_API ONI_C_API_EXPORT +# define ONI_CPP_API ONI_CPP_API_EXPORT +#else // OPENNI2_EXPORT +# define ONI_C_API ONI_C_API_IMPORT +# define ONI_CPP_API ONI_CPP_API_IMPORT +#endif // OPENNI2_EXPORT + + +#endif // ONIPLATFORM_H diff --git a/src/ros_astra_camera/include/openni2/OniProperties.h b/src/ros_astra_camera/include/openni2/OniProperties.h new file mode 100644 index 0000000..f3eb9f3 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/OniProperties.h @@ -0,0 +1,83 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIPROPERTIES_H +#define ONIPROPERTIES_H + +namespace openni +{ + +// Device properties +enum +{ + DEVICE_PROPERTY_FIRMWARE_VERSION = 0, // string + DEVICE_PROPERTY_DRIVER_VERSION = 1, // OniVersion + DEVICE_PROPERTY_HARDWARE_VERSION = 2, // int + DEVICE_PROPERTY_SERIAL_NUMBER = 3, // string + DEVICE_PROPERTY_ERROR_STATE = 4, // ?? + DEVICE_PROPERTY_IMAGE_REGISTRATION = 5, // OniImageRegistrationMode + + //orbbec + OBEXTENSION_ID_IR_GAIN = 11, + OBEXTENSION_ID_IR_EXP, + OBEXTENSION_ID_LDP_EN, + OBEXTENSION_ID_CAM_PARAMS, + OBEXTENSION_ID_LASER_EN, + OBEXTENSION_ID_SERIALNUMBER, + OBEXTENSION_ID_DEVICETYPE, + OBEXTENSION_ID_UPDATE_FIRMWARE, + // Files + DEVICE_PROPERTY_PLAYBACK_SPEED = 100, // float + DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED = 101, // OniBool +}; + +// Stream properties +enum +{ + STREAM_PROPERTY_CROPPING = 0, // OniCropping* + STREAM_PROPERTY_HORIZONTAL_FOV = 1, // float: radians + STREAM_PROPERTY_VERTICAL_FOV = 2, // float: radians + STREAM_PROPERTY_VIDEO_MODE = 3, // OniVideoMode* + + STREAM_PROPERTY_MAX_VALUE = 4, // int + STREAM_PROPERTY_MIN_VALUE = 5, // int + + STREAM_PROPERTY_STRIDE = 6, // int + STREAM_PROPERTY_MIRRORING = 7, // OniBool + + STREAM_PROPERTY_NUMBER_OF_FRAMES = 8, // int + + // Camera + STREAM_PROPERTY_AUTO_WHITE_BALANCE = 100, // OniBool + STREAM_PROPERTY_AUTO_EXPOSURE = 101, // OniBool + STREAM_PROPERTY_EXPOSURE = 102, // int + STREAM_PROPERTY_GAIN = 103, // int + + STREAM_PROPERTY_SOFTWARE_REGISTRATION = 0x2080FF42, // int +}; + +// Device commands (for Invoke) +enum +{ + DEVICE_COMMAND_SEEK = 1, // OniSeek +}; + +} // namespace openni +#endif // ONIPROPERTIES_H diff --git a/src/ros_astra_camera/include/openni2/OniTest.h b/src/ros_astra_camera/include/openni2/OniTest.h new file mode 100644 index 0000000..93ef767 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/OniTest.h @@ -0,0 +1,40 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONITEST_H +#define ONITEST_H + +#define TEST_DEVICE_NAME "Test" // use with device.open() to create a test device + +/** +* Additional commands for Test device streams +*/ +enum +{ + TEST_COMMAND_ISSUE_FRAME = 0xFFFF0001, // TestCommandIssueFrame +}; + +typedef struct TestCommandIssueFrame +{ + uint64_t timestamp; + void* data; +} TestCommandIssueFrame; + +#endif // ONITEST_H diff --git a/src/ros_astra_camera/include/openni2/OniVersion.h b/src/ros_astra_camera/include/openni2/OniVersion.h new file mode 100644 index 0000000..5c2e84e --- /dev/null +++ b/src/ros_astra_camera/include/openni2/OniVersion.h @@ -0,0 +1,48 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIVERSION_H +#define ONIVERSION_H + +#include "OniPlatform.h" + +#define ONI_VERSION_MAJOR 2 +#define ONI_VERSION_MINOR 3 +#define ONI_VERSION_MAINTENANCE 0 +#define ONI_VERSION_BUILD 50 + +/** OpenNI version (in brief string format): "Major.Minor.Maintenance (Build)" */ +#define ONI_BRIEF_VERSION_STRING \ + ONI_STRINGIFY(ONI_VERSION_MAJOR) "." \ + ONI_STRINGIFY(ONI_VERSION_MINOR) "." \ + ONI_STRINGIFY(ONI_VERSION_MAINTENANCE) \ + " (Build " ONI_STRINGIFY(ONI_VERSION_BUILD) ")" + +/** OpenNI version (in numeric format): (OpenNI major version * 100000000 + OpenNI minor version * 1000000 + OpenNI maintenance version * 10000 + OpenNI build version). */ +#define ONI_VERSION (ONI_VERSION_MAJOR*100000000 + ONI_VERSION_MINOR*1000000 + ONI_VERSION_MAINTENANCE*10000 + ONI_VERSION_BUILD) +#define ONI_CREATE_API_VERSION(major, minor) ((major)*1000 + (minor)) +#define ONI_API_VERSION ONI_CREATE_API_VERSION(ONI_VERSION_MAJOR, ONI_VERSION_MINOR) + +/** OpenNI version (in string format): "Major.Minor.Maintenance.Build-Platform (MMM DD YYYY HH:MM:SS)". */ +#define ONI_VERSION_STRING \ + ONI_BRIEF_VERSION_STRING "-" \ + ONI_PLATFORM_STRING " (" ONI_TIMESTAMP ")" + +#endif // ONIVERSION_H diff --git a/src/ros_astra_camera/include/openni2/OpenNI.h b/src/ros_astra_camera/include/openni2/OpenNI.h new file mode 100644 index 0000000..4e6477a --- /dev/null +++ b/src/ros_astra_camera/include/openni2/OpenNI.h @@ -0,0 +1,2804 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef OPENNI_H +#define OPENNI_H + +#include "OniPlatform.h" +#include "OniProperties.h" +#include "OniEnums.h" + +#include "OniCAPI.h" +#include "OniCProperties.h" +#include "OniCTypes.h" + +/** +openni is the namespace of the entire C++ API of OpenNI +*/ +namespace openni +{ + +/** Pixel type used to store depth images. */ +typedef uint16_t DepthPixel; + +/** Pixel type used to store IR images. */ +typedef uint16_t Grayscale16Pixel; + +// structs +/** Holds an OpenNI version number, which consists of four separate numbers in the format: @c major.minor.maintenance.build. For example: 2.0.0.20. */ +typedef struct +{ + /** Major version number, incremented for major API restructuring. */ + int major; + /** Minor version number, incremented when significant new features added. */ + int minor; + /** Maintenance build number, incremented for new releases that primarily provide minor bug fixes. */ + int maintenance; + /** Build number. Incremented for each new API build. Generally not shown on the installer and download site. */ + int build; +} Version; + +/** Holds the value of a single color image pixel in 24-bit RGB format. */ +typedef struct +{ + /* Red value of this pixel. */ + uint8_t r; + /* Green value of this pixel. */ + uint8_t g; + /* Blue value of this pixel. */ + uint8_t b; +} RGB888Pixel; + +/** + Holds the value of two pixels in YUV422 format (Luminance/Chrominance,16-bits/pixel). + The first pixel has the values y1, u, v. + The second pixel has the values y2, u, v. +*/ +typedef struct +{ + /** First chrominance value for two pixels, stored as blue luminance difference signal. */ + uint8_t u; + /** Overall luminance value of first pixel. */ + uint8_t y1; + /** Second chrominance value for two pixels, stored as red luminance difference signal. */ + uint8_t v; + /** Overall luminance value of second pixel. */ + uint8_t y2; +} YUV422DoublePixel; + +/** + Holds the value of two pixels in YUV422 format (Luminance/Chrominance,16-bits/pixel). + The first pixel has the values y1, u, v. + The second pixel has the values y2, u, v. +*/ +typedef struct +{ + /** Overall luminance value of first pixel. */ + uint8_t y1; + /** First chrominance value for two pixels, stored as blue luminance difference signal. */ + uint8_t u; + /** Overall luminance value of second pixel. */ + uint8_t y2; + /** Second chrominance value for two pixels, stored as red luminance difference signal. */ + uint8_t v; +} YUYVDoublePixel; + +/** This special URI can be passed to @ref Device::open() when the application has no concern for a specific device. */ +class _NullString +{ +public: + _NullString() {} + operator const char*() const { return NULL; } +}; + +static const _NullString ANY_DEVICE; + +/** +Provides a simple array class used throughout the API. Wraps a primitive array +of objects, holding the elements and their count. +*/ +template +class Array +{ +public: + /** + Default constructor. Creates an empty Array and sets the element count to zero. + */ + Array() : m_data(NULL), m_count(0), m_owner(false) {} + + /** + Constructor. Creates new Array from an existing primitive array of known size. + + @tparam [in] T Object type this Array will contain. + @param [in] data Pointer to a primitive array of objects of type T. + @param [in] count Number of elements in the primitive array pointed to by data. + */ + Array(const T* data, int count) : m_owner(false) { _setData(data, count); } + + /** + Destructor. Destroys the Array object. + */ + ~Array() + { + clear(); + } + + /** + Getter function for the Array size. + @returns Current number of elements in the Array. + */ + int getSize() const { return m_count; } + + /** + Implements the array indexing operator for the Array class. + */ + const T& operator[](int index) const {return m_data[index];} + + /** + @internal + Setter function for data. Causes this array to wrap an existing primitive array + of specified type. The optional data ownership flag controls whether the primitive + array this Array wraps will be destroyed when this Array is deconstructed. + @param [in] T Type of objects array will contain. + @param [in] data Pointer to first object in list. + @param [in] count Number of objects in list. + @param [in] isOwner Optional flag to indicate data ownership + */ + void _setData(const T* data, int count, bool isOwner = false) + { + clear(); + m_count = count; + m_owner = isOwner; + if (!isOwner) + { + m_data = data; + } + else + { + m_data = new T[count]; + memcpy((void*)m_data, data, count*sizeof(T)); + } + } + +private: + Array(const Array&); + Array& operator=(const Array&); + + void clear() + { + if (m_owner && m_data != NULL) + delete []m_data; + m_owner = false; + m_data = NULL; + m_count = 0; + } + + const T* m_data; + int m_count; + bool m_owner; +}; + +// Forward declaration of all +class SensorInfo; +class VideoStream; +class VideoFrameRef; +class Device; +class OpenNI; +class CameraSettings; +class PlaybackControl; + +/** +Encapsulates a group of settings for a @ref VideoStream. Settings stored include +frame rate, resolution, and pixel format. + +This class is used as an input for changing the settings of a @ref VideoStream, +as well as an output for reporting the current settings of that class. It is also used +by @ref SensorInfo to report available video modes of a stream. + +Recommended practice is to use @ref SensorInfo::getSupportedVideoModes() +to obtain a list of valid video modes, and then to use items from that list to pass +new settings to @ref VideoStream. This is much less likely to produce an +invalid video mode than instantiating and manually changing objects of this +class. +*/ +class VideoMode : private OniVideoMode +{ +public: + /** + Default constructor, creates an empty VideoMode object. Application programs should, in most + cases, use the copy constructor to copy an existing valid video mode. This is much less + error prone that creating and attempting to configure a new VideoMode from scratch. + */ + VideoMode() + {} + + /** + Copy constructor, creates a new VideoMode identical to an existing VideoMode. + + @param [in] other Existing VideoMode to copy. + */ + VideoMode(const VideoMode& other) + { + *this = other; + } + + /** + Assignment operator. Sets the pixel format, frame rate, and resolution of this + VideoMode to equal that of a different VideoMode. + + @param [in] other Existing VideoMode to copy settings from. + */ + VideoMode& operator=(const VideoMode& other) + { + setPixelFormat(other.getPixelFormat()); + setResolution(other.getResolutionX(), other.getResolutionY()); + setFps(other.getFps()); + + return *this; + } + + /** + Getter function for the pixel format of this VideoMode. + @returns Current pixel format setting of this VideoMode. + */ + PixelFormat getPixelFormat() const { return (PixelFormat)pixelFormat; } + + /** + Getter function for the X resolution of this VideoMode. + @returns Current horizontal resolution of this VideoMode, in pixels. + */ + int getResolutionX() const { return resolutionX; } + + /** + Getter function for the Y resolution of this VideoMode. + @returns Current vertical resolution of this VideoMode, in pixels. + */ + int getResolutionY() const {return resolutionY;} + + /** + Getter function for the frame rate of this VideoMode. + @returns Current frame rate, measured in frames per second. + */ + int getFps() const { return fps; } + + /** + Setter function for the pixel format of this VideoMode. Application use of this + function is not recommended. Instead, use @ref SensorInfo::getSupportedVideoModes() + to obtain a list of valid video modes. + @param [in] format Desired new pixel format for this VideoMode. + */ + void setPixelFormat(PixelFormat format) { this->pixelFormat = (OniPixelFormat)format; } + + /** + Setter function for the resolution of this VideoMode. Application use of this + function is not recommended. Instead, use @ref SensorInfo::getSupportedVideoModes() to + obtain a list of valid video modes. + @param [in] resolutionX Desired new horizontal resolution in pixels. + @param [in] resolutionY Desired new vertical resolution in pixels. + */ + void setResolution(int resolutionX, int resolutionY) + { + this->resolutionX = resolutionX; + this->resolutionY = resolutionY; + } + + /** + Setter function for the frame rate. Application use of this function is not recommended. + Instead, use @ref SensorInfo::getSupportedVideoModes() to obtain a list of valid + video modes. + @param [in] fps Desired new frame rate, measured in frames per second. + */ + void setFps(int fps) { this->fps = fps; } + + friend class SensorInfo; + friend class VideoStream; + friend class VideoFrameRef; +}; + +/** +The SensorInfo class encapsulates all info related to a specific sensor in a specific +device. +A @ref Device object holds a SensorInfo object for each sensor it contains. +A @ref VideoStream object holds one SensorInfo object, describing the sensor used to produce that stream. + +A given SensorInfo object will contain the type of the sensor (Depth, IR or Color), and +a list of all video modes that the sensor can support. Each available video mode will have a single +VideoMode object that can be queried to get the details of that mode. + +SensorInfo objects should be the only source of VideoMode objects for the vast majority of +application programs. + +Application programs will never directly instantiate objects of type SensorInfo. In fact, no +public constructors are provided. SensorInfo objects should be obtained either from a Device or @ref VideoStream, +and in turn be used to provide available video modes for that sensor. +*/ +class SensorInfo +{ +public: + /** + Provides the sensor type of the sensor this object is associated with. + @returns Type of the sensor. + */ + SensorType getSensorType() const { return (SensorType)m_pInfo->sensorType; } + + /** + Provides a list of video modes that this sensor can support. This function is the + recommended method to be used by applications to obtain @ref VideoMode objects. + + @returns Reference to an array of @ref VideoMode objects, one for each supported + video mode. + */ + const Array& getSupportedVideoModes() const { return m_videoModes; } + +private: + SensorInfo(const SensorInfo&); + SensorInfo& operator=(const SensorInfo&); + + SensorInfo() : m_pInfo(NULL), m_videoModes(NULL, 0) {} + + SensorInfo(const OniSensorInfo* pInfo) : m_pInfo(NULL), m_videoModes(NULL, 0) + { + _setInternal(pInfo); + } + + void _setInternal(const OniSensorInfo* pInfo) + { + m_pInfo = pInfo; + if (pInfo == NULL) + { + m_videoModes._setData(NULL, 0); + } + else + { + m_videoModes._setData(static_cast(pInfo->pSupportedVideoModes), pInfo->numSupportedVideoModes); + } + } + + const OniSensorInfo* m_pInfo; + Array m_videoModes; + + friend class VideoStream; + friend class Device; +}; + +/** +The DeviceInfo class encapsulates info related to a specific device. + +Applications will generally obtain objects of this type via calls to @ref OpenNI::enumerateDevices() or +@ref openni::Device::getDeviceInfo(), and then use the various accessor functions to obtain specific +information on that device. + +There should be no reason for application code to instantiate this object directly. +*/ +class DeviceInfo : private OniDeviceInfo +{ +public: + /** + Returns the device URI. URI can be used by @ref Device::open to open a specific device. + The URI string format is determined by the driver. + */ + const char* getUri() const { return uri; } + /** Returns a the vendor name for this device. */ + const char* getVendor() const { return vendor; } + /** Returns the device name for this device. */ + const char* getName() const { return name; } + /** Returns the USB VID code for this device. */ + uint16_t getUsbVendorId() const { return usbVendorId; } + /** Returns the USB PID code for this device. */ + uint16_t getUsbProductId() const { return usbProductId; } + + friend class Device; + friend class OpenNI; +}; + +/** +The @ref VideoFrameRef class encapsulates a single video frame - the output of a @ref VideoStream at a specific time. +The data contained will be a single frame of color, IR, or depth video, along with associated meta data. + +An object of type @ref VideoFrameRef does not actually hold the data of the frame, but only a reference to it. The +reference can be released by destroying the @ref VideoFrameRef object, or by calling the @ref release() method. The +actual data of the frame is freed when the last reference to it is released. + +The usual way to obtain @ref VideoFrameRef objects is by a call to @ref VideoStream.:readFrame(). + +All data references by a @ref VideoFrameRef is stored as a primitive array of pixels. Each pixel will be +of a type according to the configured pixel format (see @ref VideoMode). +*/ +class VideoFrameRef +{ +public: + /** + Default constructor. Creates a new empty @ref VideoFrameRef object. + This object will be invalid until initialized by a call to @ref VideoStream::readFrame(). + */ + VideoFrameRef() + { + m_pFrame = NULL; + } + + /** + Destroy this object and release the reference to the frame. + */ + ~VideoFrameRef() + { + release(); + } + + /** + Copy constructor. Creates a new @ref VideoFrameRef object. The newly created + object will reference the same frame current object references. + @param [in] other Another @ref VideoFrameRef object. + */ + VideoFrameRef(const VideoFrameRef& other) : m_pFrame(NULL) + { + _setFrame(other.m_pFrame); + } + + /** + Make this @ref VideoFrameRef object reference the same frame that the @c other frame references. + If this object referenced another frame before calling this method, the previous frame will be released. + @param [in] other Another @ref VideoFrameRef object. + */ + VideoFrameRef& operator=(const VideoFrameRef& other) + { + _setFrame(other.m_pFrame); + return *this; + } + + /** + Getter function for the size of the data contained by this object. Useful primarily + when allocating buffers. + @returns Current size of data pointed to by this object, measured in bytes. + */ + inline int getDataSize() const + { + return m_pFrame->dataSize; + } + + /** + Getter function for the array of data pointed to by this object. + @returns Pointer to the actual frame data array. Type of data + pointed to can be determined according to the pixel format (can be obtained by calling @ref getVideoMode()). + */ + inline const void* getData() const + { + return m_pFrame->data; + } + + /** + Getter function for the sensor type used to produce this frame. Used to determine whether + this is an IR, Color or Depth frame. See the @ref SensorType enumeration for all possible return + values from this function. + @returns The type of sensor used to produce this frame. + */ + inline SensorType getSensorType() const + { + return (SensorType)m_pFrame->sensorType; + } + + /** + Returns a reference to the @ref VideoMode object assigned to this frame. This object describes + the video mode the sensor was configured to when the frame was produced and can be used + to determine the pixel format and resolution of the data. It will also provide the frame rate + that the sensor was running at when it recorded this frame. + @returns Reference to the @ref VideoMode assigned to this frame. + */ + inline const VideoMode& getVideoMode() const + { + return static_cast(m_pFrame->videoMode); + } + + /** + Provides a timestamp for the frame. The 'zero' point for this stamp + is implementation specific, but all streams from the same device are guaranteed to use the same zero. + This value can therefore be used to compute time deltas between frames from the same device, + regardless of whether they are from the same stream. + @returns Timestamp of frame, measured in microseconds from an arbitrary zero + */ + inline uint64_t getTimestamp() const + { + return m_pFrame->timestamp; + } + + /** + Frames are provided sequential frame ID numbers by the sensor that produced them. If frame + synchronization has been enabled for a device via @ref Device::setDepthColorSyncEnabled(), then frame + numbers for corresponding frames of depth and color are guaranteed to match. + + If frame synchronization is not enabled, then there is no guarantee of matching frame indexes between + @ref VideoStream "VideoStreams". In the latter case, applications should use timestamps instead of frame indexes to + align frames in time. + @returns Index number for this frame. + */ + inline int getFrameIndex() const + { + return m_pFrame->frameIndex; + } + + /** + Gives the current width of this frame, measured in pixels. If cropping is enabled, this will be + the width of the cropping window. If cropping is not enabled, then this will simply be equal to + the X resolution of the @ref VideoMode used to produce this frame. + @returns Width of this frame in pixels. + */ + inline int getWidth() const + { + return m_pFrame->width; + } + + /** + Gives the current height of this frame, measured in pixels. If cropping is enabled, this will + be the length of the cropping window. If cropping is not enabled, then this will simply be equal + to the Y resolution of the @ref VideoMode used to produce this frame. + */ + inline int getHeight() const + { + return m_pFrame->height; + } + + /** + Indicates whether cropping was enabled when the frame was produced. + @return true if cropping is enabled, false otherwise + */ + inline bool getCroppingEnabled() const + { + return m_pFrame->croppingEnabled == TRUE; + } + + /** + Indicates the X coordinate of the upper left corner of the crop window. + @return Distance of crop origin from left side of image, in pixels. + */ + inline int getCropOriginX() const + { + return m_pFrame->cropOriginX; + } + + /** + Indicates the Y coordinate of the upper left corner of the crop window. + @return Distance of crop origin from top of image, in pixels. + */ + inline int getCropOriginY() const + { + return m_pFrame->cropOriginY; + } + + /** + Gives the length of one row of pixels, measured in bytes. Primarily useful + for indexing the array which contains the data. + @returns Stride of the array which contains the image for this frame, in bytes + */ + inline int getStrideInBytes() const + { + return m_pFrame->stride; + } + + /** + Check if this object references an actual frame. + */ + inline bool isValid() const + { + return m_pFrame != NULL; + } + + /** + Release the reference to the frame. Once this method is called, the object becomes invalid, and no method + should be called other than the assignment operator, or passing this object to a @ref VideoStream::readFrame() call. + */ + void release() + { + if (m_pFrame != NULL) + { + oniFrameRelease(m_pFrame); + m_pFrame = NULL; + } + } + + /** @internal */ + void _setFrame(OniFrame* pFrame) + { + setReference(pFrame); + if (pFrame != NULL) + { + oniFrameAddRef(pFrame); + } + } + + /** @internal */ + OniFrame* _getFrame() + { + return m_pFrame; + } + +private: + friend class VideoStream; + inline void setReference(OniFrame* pFrame) + { + // Initial - don't addref. This is the reference from OpenNI + release(); + m_pFrame = pFrame; + } + + OniFrame* m_pFrame; // const!!? +}; + +/** +The @ref VideoStream object encapsulates a single video stream from a device. Once created, it is used to start data flow +from the device, and to read individual frames of data. This is the central class used to obtain data in OpenNI. It +provides the ability to manually read data in a polling loop, as well as providing events and a Listener class that can be +used to implement event-driven data acquisition. + +Aside from the video data frames themselves, the class offers a number of functions used for obtaining information about a +@ref VideoStream. Field of view, available video modes, and minimum and maximum valid pixel values can all be obtained. + +In addition to obtaining data, the @ref VideoStream object is used to set all configuration properties that apply to a specific +stream (rather than to an entire device). In particular, it is used to control cropping, mirroring, and video modes. + +A pointer to a valid, initialized device that provides the desired stream type is required to create a stream. + +Several video streams can be created to stream data from the same sensor. This is useful if several components of an application +need to read frames separately. + +While some device might allow different streams +from the same sensor to have different configurations, most devices will have a single configuration for the sensor, +shared by all streams. +*/ +class VideoStream +{ +public: + /** + The @ref VideoStream::NewFrameListener class is provided to allow the implementation of event driven frame reading. To use + it, create a class that inherits from it and implement override the onNewFrame() method. Then, register + your created class with an active @ref VideoStream using the @ref VideoStream::addNewFrameListener() function. Once this is done, the + event handler function you implemented will be called whenever a new frame becomes available. You may call + @ref VideoStream::readFrame() from within the event handler. + */ + class NewFrameListener + { + public: + /** + Default constructor. + */ + NewFrameListener() : m_callbackHandle(NULL) + { + } + + virtual ~NewFrameListener() + { + } + + /** + Derived classes should implement this function to handle new frames. + */ + virtual void onNewFrame(VideoStream&) = 0; + + private: + friend class VideoStream; + + static void ONI_CALLBACK_TYPE callback(OniStreamHandle streamHandle, void* pCookie) + { + NewFrameListener* pListener = (NewFrameListener*)pCookie; + VideoStream stream; + stream._setHandle(streamHandle); + pListener->onNewFrame(stream); + stream._setHandle(NULL); + } + OniCallbackHandle m_callbackHandle; + }; + + class FrameAllocator + { + public: + virtual ~FrameAllocator() {} + virtual void* allocateFrameBuffer(int size) = 0; + virtual void freeFrameBuffer(void* data) = 0; + + private: + friend class VideoStream; + + static void* ONI_CALLBACK_TYPE allocateFrameBufferCallback(int size, void* pCookie) + { + FrameAllocator* pThis = (FrameAllocator*)pCookie; + return pThis->allocateFrameBuffer(size); + } + + static void ONI_CALLBACK_TYPE freeFrameBufferCallback(void* data, void* pCookie) + { + FrameAllocator* pThis = (FrameAllocator*)pCookie; + pThis->freeFrameBuffer(data); + } + }; + + /** + Default constructor. Creates a new, non-valid @ref VideoStream object. The object created will be invalid until its create() function + is called with a valid Device. + */ + VideoStream() : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(true) + {} + + /** + Handle constructor. Creates a VideoStream object based on the given initialized handle. + This object will not destroy the underlying handle when @ref destroy() or destructor is called + */ + explicit VideoStream(OniStreamHandle handle) : m_stream(NULL), m_sensorInfo(), m_pCameraSettings(NULL), m_isOwner(false) + { + _setHandle(handle); + } + + /** + Destructor. The destructor calls the destroy() function, but it is considered a best practice for applications to + call destroy() manually on any @ref VideoStream that they run create() on. + */ + ~VideoStream() + { + destroy(); + } + + /** + Checks to see if this object has been properly initialized and currently points to a valid stream. + @returns true if this object has been previously initialized, false otherwise. + */ + bool isValid() const + { + return m_stream != NULL; + } + + /** + Creates a stream of frames from a specific sensor type of a specific device. You must supply a reference to a + Device that supplies the sensor type requested. You can use @ref Device::hasSensor() to check whether a + given sensor is available on your target device before calling create(). + + @param [in] device A reference to the @ref Device you want to create the stream on. + @param [in] sensorType The type of sensor the stream should produce data from. + @returns Status code indicating success or failure for this operation. + */ + inline Status create(const Device& device, SensorType sensorType); + + /** + Destroy this stream. This function is currently called automatically by the destructor, but it is + considered a best practice for applications to manually call this function on any @ref VideoStream that they + call create() for. + */ + inline void destroy(); + + /** + Provides the @ref SensorInfo object associated with the sensor that is producing this @ref VideoStream. Note that + this function will return NULL if the stream has not yet been initialized with the create() function. + + @ref SensorInfo is useful primarily as a means of learning which video modes are valid for this VideoStream. + + @returns Reference to the SensorInfo object associated with the sensor providing this stream. + */ + const SensorInfo& getSensorInfo() const + { + return m_sensorInfo; + } + + ParamsRegistrationMode getSoftwareRegistratorMode(){ + + ParamsRegistrationMode mode; + Status rc = getProperty(STREAM_PROPERTY_SOFTWARE_REGISTRATION, &mode); + if (rc != STATUS_OK) + { + return PARAMS_REGISTRATION_OFF; + } + return mode; + } + + void setSoftwareRegistrator(ParamsRegistrationMode mode){ + setProperty(STREAM_PROPERTY_SOFTWARE_REGISTRATION, (int)mode); + } + + /** + Starts data generation from this video stream. + */ + Status start() + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamStart(m_stream); + } + + /** + Stops data generation from this video stream. + */ + void stop() + { + if (!isValid()) + { + return; + } + + oniStreamStop(m_stream); + } + + /** + Read the next frame from this video stream, delivered as a @ref VideoFrameRef. This is the primary + method for manually obtaining frames of video data. + If no new frame is available, the call will block until one is available. + To avoid blocking, use @ref VideoStream::Listener to implement an event driven architecture. Another + alternative is to use @ref OpenNI::waitForAnyStream() to wait for new frames from several streams. + + @param [out] pFrame Pointer to a @ref VideoFrameRef object to hold the reference to the new frame. + @returns Status code to indicated success or failure of this function. + */ + Status readFrame(VideoFrameRef* pFrame) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + OniFrame* pOniFrame; + Status rc = (Status)oniStreamReadFrame(m_stream, &pOniFrame); + + pFrame->setReference(pOniFrame); + return rc; + } + + /** + Adds a new Listener to receive this VideoStream onNewFrame event. See @ref VideoStream::NewFrameListener for + more information on implementing an event driven frame reading architecture. An instance of a listener can be added to only one source. + + @param [in] pListener Pointer to a @ref VideoStream::NewFrameListener object (or a derivative) that will respond to this event. + @returns Status code indicating success or failure of the operation. + */ + Status addNewFrameListener(NewFrameListener* pListener) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamRegisterNewFrameCallback(m_stream, pListener->callback, pListener, &pListener->m_callbackHandle); + } + + /** + Removes a Listener from this video stream list. The listener removed will no longer receive new frame events from this stream. + @param [in] pListener Pointer to the listener object to be removed. + */ + void removeNewFrameListener(NewFrameListener* pListener) + { + if (!isValid()) + { + return; + } + + oniStreamUnregisterNewFrameCallback(m_stream, pListener->m_callbackHandle); + pListener->m_callbackHandle = NULL; + } + + /** + Sets the frame buffers allocator for this video stream. + @param [in] pAllocator Pointer to the frame buffers allocator object. Pass NULL to return to default frame allocator. + @returns ONI_STATUS_OUT_OF_FLOW The frame buffers allocator cannot be set while stream is streaming. + */ + Status setFrameBuffersAllocator(FrameAllocator* pAllocator) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + if (pAllocator == NULL) + { + return (Status)oniStreamSetFrameBuffersAllocator(m_stream, NULL, NULL, NULL); + } + else + { + return (Status)oniStreamSetFrameBuffersAllocator(m_stream, pAllocator->allocateFrameBufferCallback, pAllocator->freeFrameBufferCallback, pAllocator); + } + } + + /** + @internal + Get an internal handle. This handle can be used via the C API. + */ + OniStreamHandle _getHandle() const + { + return m_stream; + } + + /** + Gets an object through which several camera settings can be configured. + @returns NULL if the stream doesn't support camera settings. + */ + CameraSettings* getCameraSettings() {return m_pCameraSettings;} + + /** + General function for obtaining the value of stream specific properties. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of the getProperty function very often. + + @param [in] propertyId The numerical ID of the property to be queried. + @param [out] data Place to store the value of the property. + @param [in,out] dataSize IN: Size of the buffer passed in the @c data argument. OUT: the actual written size. + @returns Status code indicating success or failure of this operation. + */ + Status getProperty(int propertyId, void* data, int* dataSize) const + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamGetProperty(m_stream, propertyId, data, dataSize); + } + + /** + General function for setting the value of stream specific properties. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of the setProperty function very often. + + @param [in] propertyId The numerical ID of the property to be set. + @param [in] data Place to store the data to be written to the property. + @param [in] dataSize Size of the data to be written to the property. + @returns Status code indicating success or failure of this operation. + */ + Status setProperty(int propertyId, const void* data, int dataSize) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamSetProperty(m_stream, propertyId, data, dataSize); + } + + /** + Get the current video mode information for this video stream. + This includes its resolution, fps and stream format. + + @returns Current video mode information for this video stream. + */ + VideoMode getVideoMode() const + { + VideoMode videoMode; + getProperty(STREAM_PROPERTY_VIDEO_MODE, static_cast(&videoMode)); + return videoMode; + } + + /** + Changes the current video mode of this stream. Recommended practice is to use @ref Device::getSensorInfo(), and + then @ref SensorInfo::getSupportedVideoModes() to obtain a list of valid video mode settings for this stream. Then, + pass a valid @ref VideoMode to @ref setVideoMode to ensure correct operation. + + @param [in] videoMode Desired new video mode for this stream. + returns Status code indicating success or failure of this operation. + */ + Status setVideoMode(const VideoMode& videoMode) + { + return setProperty(STREAM_PROPERTY_VIDEO_MODE, static_cast(videoMode)); + } + + /** + Provides the maximum possible value for pixels obtained by this stream. This is most useful for + getting the maximum possible value of depth streams. + @returns Maximum possible pixel value. + */ + int getMaxPixelValue() const + { + int maxValue; + Status rc = getProperty(STREAM_PROPERTY_MAX_VALUE, &maxValue); + if (rc != STATUS_OK) + { + return 0; + } + return maxValue; + } + + /** + Provides the smallest possible value for pixels obtains by this VideoStream. This is most useful + for getting the minimum possible value that will be reported by a depth stream. + @returns Minimum possible pixel value that can come from this stream. + */ + int getMinPixelValue() const + { + int minValue; + Status rc = getProperty(STREAM_PROPERTY_MIN_VALUE, &minValue); + if (rc != STATUS_OK) + { + return 0; + } + return minValue; + } + + /** + Checks whether this stream supports cropping. + @returns true if the stream supports cropping, false if it does not. + */ + bool isCroppingSupported() const + { + return isPropertySupported(STREAM_PROPERTY_CROPPING); + } + + /** + Obtains the current cropping settings for this stream. + @param [out] pOriginX X coordinate of the upper left corner of the cropping window + @param [out] pOriginY Y coordinate of the upper left corner of the cropping window + @param [out] pWidth Horizontal width of the cropping window, in pixels + @param [out] pHeight Vertical width of the cropping window, in pixels + returns true if cropping is currently enabled, false if it is not. + */ + bool getCropping(int* pOriginX, int* pOriginY, int* pWidth, int* pHeight) const + { + OniCropping cropping; + bool enabled = false; + + Status rc = getProperty(STREAM_PROPERTY_CROPPING, &cropping); + + if (rc == STATUS_OK) + { + *pOriginX = cropping.originX; + *pOriginY = cropping.originY; + *pWidth = cropping.width; + *pHeight = cropping.height; + enabled = (cropping.enabled == TRUE); + } + + return enabled; + } + + /** + Changes the cropping settings for this stream. You can use the @ref isCroppingSupported() + function to make sure cropping is supported before calling this function. + @param [in] originX New X coordinate of the upper left corner of the cropping window. + @param [in] originY New Y coordinate of the upper left corner of the cropping window. + @param [in] width New horizontal width for the cropping window, in pixels. + @param [in] height New vertical height for the cropping window, in pixels. + @returns Status code indicating success or failure of this operation. + */ + Status setCropping(int originX, int originY, int width, int height) + { + OniCropping cropping; + cropping.enabled = true; + cropping.originX = originX; + cropping.originY = originY; + cropping.width = width; + cropping.height = height; + return setProperty(STREAM_PROPERTY_CROPPING, cropping); + } + + /** + Disables cropping. + @returns Status code indicating success or failure of this operation. + */ + Status resetCropping() + { + OniCropping cropping; + cropping.enabled = false; + return setProperty(STREAM_PROPERTY_CROPPING, cropping); + } + + /** + Check whether mirroring is currently turned on for this stream. + @returns true if mirroring is currently enabled, false otherwise. + */ + bool getMirroringEnabled() const + { + OniBool enabled; + Status rc = getProperty(STREAM_PROPERTY_MIRRORING, &enabled); + if (rc != STATUS_OK) + { + return false; + } + return enabled == TRUE; + } + + /** + Enable or disable mirroring for this stream. + @param [in] isEnabled true to enable mirroring, false to disable it. + @returns Status code indicating the success or failure of this operation. + */ + Status setMirroringEnabled(bool isEnabled) + { + return setProperty(STREAM_PROPERTY_MIRRORING, isEnabled ? TRUE : FALSE); + } + + /** + Gets the horizontal field of view of frames received from this stream. + @returns Horizontal field of view, in radians. + */ + float getHorizontalFieldOfView() const + { + float horizontal = 0; + getProperty(STREAM_PROPERTY_HORIZONTAL_FOV, &horizontal); + return horizontal; + } + + /** + Gets the vertical field of view of frames received from this stream. + @returns Vertical field of view, in radians. + */ + float getVerticalFieldOfView() const + { + float vertical = 0; + getProperty(STREAM_PROPERTY_VERTICAL_FOV, &vertical); + return vertical; + } + + /** + Function for setting a value of a stream property using an arbitrary input type. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of this function very often. + @tparam [in] T Data type of the value to be passed to the property. + @param [in] propertyId The numerical ID of the property to be set. + @param [in] value Data to be sent to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status setProperty(int propertyId, const T& value) + { + return setProperty(propertyId, &value, sizeof(T)); + } + + /** + Function for getting the value from a property using an arbitrary output type. + There are convenience functions available for all commonly used properties, so it is not + expected that applications will make direct use of this function very often. + @tparam [in] T Data type of the value to be read. + @param [in] propertyId The numerical ID of the property to be read. + @param [in, out] value Pointer to a place to store the value read from the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status getProperty(int propertyId, T* value) const + { + int size = sizeof(T); + return getProperty(propertyId, value, &size); + } + + /** + Checks if a specific property is supported by the video stream. + @param [in] propertyId Property to be checked. + @returns true if the property is supported, false otherwise. + */ + bool isPropertySupported(int propertyId) const + { + if (!isValid()) + { + return false; + } + + return oniStreamIsPropertySupported(m_stream, propertyId) == TRUE; + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @param [in] commandId Numerical code of the property to be invoked. + @param [in] data Data to be passed to the property. + @param [in] dataSize size of the buffer passed in @c data. + @returns Status code indicating success or failure of this operation. + */ + Status invoke(int commandId, void* data, int dataSize) + { + if (!isValid()) + { + return STATUS_ERROR; + } + + return (Status)oniStreamInvoke(m_stream, commandId, data, dataSize); + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @tparam [in] T Type of data to be passed to the property. + @param [in] commandId Numerical code of the property to be invoked. + @param [in] value Data to be passed to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status invoke(int commandId, T& value) + { + return invoke(commandId, &value, sizeof(T)); + } + + /** + Checks if a specific command is supported by the video stream. + @param [in] commandId Command to be checked. + @returns true if the command is supported, false otherwise. + */ + bool isCommandSupported(int commandId) const + { + if (!isValid()) + { + return false; + } + + return (Status)oniStreamIsCommandSupported(m_stream, commandId) == TRUE; + } + + void filterSpeckles(void* buf, int newVal, int maxSpeckleSize, int maxDiff){ + oniStreamfilter(m_stream, buf, newVal, maxSpeckleSize, maxDiff); + } + +private: + friend class Device; + + void _setHandle(OniStreamHandle stream) + { + m_sensorInfo._setInternal(NULL); + m_stream = stream; + + if (stream != NULL) + { + m_sensorInfo._setInternal(oniStreamGetSensorInfo(m_stream)); + } + } + +private: + VideoStream(const VideoStream& other); + VideoStream& operator=(const VideoStream& other); + + OniStreamHandle m_stream; + SensorInfo m_sensorInfo; + CameraSettings* m_pCameraSettings; + bool m_isOwner; +}; + +/** +The Device object abstracts a specific device; either a single hardware device, or a file +device holding a recording from a hardware device. It offers the ability to connect to +the device, and obtain information about its configuration and the data streams it can offer. + +It provides the means to query and change all configuration parameters that apply to the +device as a whole. This includes enabling depth/color image registration and frame +synchronization. + +Devices are used when creating and initializing @ref VideoStream "VideoStreams" -- you will need a valid pointer to +a Device in order to use the VideoStream.create() function. This, along with configuration, is +the primary use of this class for application developers. + +Before devices can be created, @ref OpenNI::initialize() must have been run to make the device drivers +on the system available to the API. +*/ +class Device +{ +public: + /** + Default constructor. Creates a new empty Device object. This object will be invalid until it is initialized by + calling its open() function. + */ + Device() : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(true) + { + clearSensors(); + } + + /** + Handle constructor. Creates a Device object based on the given initialized handle. + This object will not destroy the underlying handle when @ref close() or destructor is called + */ + explicit Device(OniDeviceHandle handle) : m_pPlaybackControl(NULL), m_device(NULL), m_isOwner(false) + { + _setHandle(handle); + } + + /** + The destructor calls the @ref close() function, but it is considered a best practice for applications to + call @ref close() manually on any @ref Device that they run @ref open() on. + */ + ~Device() + { + if (m_device != NULL) + { + close(); + } + } + + /** + Opens a device. This can either open a device chosen arbitrarily from all devices + on the system, or open a specific device selected by passing this function the device URI. + + To open any device, simply pass the constant@ref ANY_DEVICE to this function. If multiple + devices are connected to the system, then one of them will be opened. This procedure is most + useful when it is known that exactly one device is (or can be) connected to the system. In that case, + requesting a list of all devices and iterating through it would be a waste of effort. + + If multiple devices are (or may be) connected to a system, then a URI will be required to select + a specific device to open. There are two ways to obtain a URI: from a DeviceConnected event, or + by calling @ref OpenNI::enumerateDevices(). + + In the case of a DeviceConnected event, the @ref OpenNI::Listener will be provided with a DeviceInfo object + as an argument to its @ref OpenNI::Listener::onDeviceConnected "onDeviceConnected()" function. + The DeviceInfo.getUri() function can then be used to obtain the URI. + + If the application is not using event handlers, then it can also call the static function + @ref OpenNI::enumerateDevices(). This will return an array of @ref DeviceInfo objects, one for each device + currently available to the system. The application can then iterate through this list and + select the desired device. The URI is again obtained via the @ref DeviceInfo::getUri() function. + + Standard codes of type Status are returned indicating whether opening was successful. + + @param [in] uri String containing the URI of the device to be opened, or @ref ANY_DEVICE. + @returns Status code with the outcome of the open operation. + + @remark For opening a recording file, pass the file path as a uri. + */ + inline Status open(const char* uri); + + /** + Closes the device. This properly closes any files or shuts down hardware, as appropriate. This + function is currently called by the destructor if not called manually by application code, but it + is considered a best practice to manually close any device that was opened. + */ + inline void close(); + + /** + Provides information about this device in the form of a DeviceInfo object. This object can + be used to access the URI of the device, as well as various USB descriptor strings that might + be useful to an application. + + Note that valid device info will not be available if this device has not yet been opened. If you are + trying to obtain a URI to open a device, use OpenNI::enumerateDevices() instead. + @returns DeviceInfo object for this Device + */ + const DeviceInfo& getDeviceInfo() const + { + return m_deviceInfo; + } + + /** + This function checks to see if one of the specific sensor types defined in @ref SensorType is + available on this device. This allows an application to, for example, query for the presence + of a depth sensor, or color sensor. + @param [in] sensorType of sensor to query for + @returns true if the Device supports the sensor queried, false otherwise. + */ + bool hasSensor(SensorType sensorType) + { + int i; + for (i = 0; (i < ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i) + { + if (m_aSensorInfo[i].getSensorType() == sensorType) + { + return true; + } + } + + if (i == ONI_MAX_SENSORS) + { + return false; + } + + const OniSensorInfo* pInfo = oniDeviceGetSensorInfo(m_device, (OniSensorType)sensorType); + + if (pInfo == NULL) + { + return false; + } + + m_aSensorInfo[i]._setInternal(pInfo); + + return true; + } + + /** + Get the @ref SensorInfo for a specific sensor type on this device. The @ref SensorInfo + is useful primarily for determining which video modes are supported by the sensor. + @param [in] sensorType of sensor to get information about. + @returns SensorInfo object corresponding to the sensor type specified, or NULL if such a sensor + is not available from this device. + */ + const SensorInfo* getSensorInfo(SensorType sensorType) + { + int i; + for (i = 0; (i < ONI_MAX_SENSORS) && (m_aSensorInfo[i].m_pInfo != NULL); ++i) + { + if (m_aSensorInfo[i].getSensorType() == sensorType) + { + return &m_aSensorInfo[i]; + } + } + + // not found. check to see we have additional space + if (i == ONI_MAX_SENSORS) + { + return NULL; + } + + const OniSensorInfo* pInfo = oniDeviceGetSensorInfo(m_device, (OniSensorType)sensorType); + if (pInfo == NULL) + { + return NULL; + } + + m_aSensorInfo[i]._setInternal(pInfo); + return &m_aSensorInfo[i]; + } + + /** + @internal + Get an internal handle. This handle can be used via the C API. + */ + OniDeviceHandle _getHandle() const + { + return m_device; + } + + /** + Gets an object through which playback of a file device can be controlled. + @returns NULL if this device is not a file device. + */ + PlaybackControl* getPlaybackControl() {return m_pPlaybackControl;} + + /** + Get the value of a general property of the device. + There are convenience functions for all the commonly used properties, such as + image registration and frame synchronization. It is expected for this reason + that this function will rarely be directly used by applications. + + @param [in] propertyId Numerical ID of the property you would like to check. + @param [out] data Place to store the value of the property. + @param [in,out] dataSize IN: Size of the buffer passed in the @c data argument. OUT: the actual written size. + @returns Status code indicating results of this operation. + */ + Status getProperty(int propertyId, void* data, int* dataSize) const + { + return (Status)oniDeviceGetProperty(m_device, propertyId, data, dataSize); + } + + /** + Sets the value of a general property of the device. + There are convenience functions for all the commonly used properties, such as + image registration and frame synchronization. It is expected for this reason + that this function will rarely be directly used by applications. + + @param [in] propertyId The numerical ID of the property to be set. + @param [in] data Place to store the data to be written to the property. + @param [in] dataSize Size of the data to be written to the property. + @returns Status code indicating results of this operation. + */ + Status setProperty(int propertyId, const void* data, int dataSize) + { + return (Status)oniDeviceSetProperty(m_device, propertyId, data, dataSize); + } + + void setGain(int gain) { + oniDeviceSetProperty(m_device, OBEXTENSION_ID_IR_GAIN, &gain, sizeof(gain)); + } + + int getGain() { + int value = 0; + int size = sizeof(value); + oniDeviceGetProperty(m_device, openni::OBEXTENSION_ID_IR_GAIN, (uint16_t *)&value, &size); + return value; + } + /** + Checks to see if this device can support registration of color video and depth video. + Image registration is used to properly superimpose two images from cameras located at different + points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about + registration. + @returns true if image registration is supported by this device, false otherwise. + */ + bool isImageRegistrationModeSupported(ImageRegistrationMode mode) const + { + return (oniDeviceIsImageRegistrationModeSupported(m_device, (OniImageRegistrationMode)mode) == TRUE); + } + + /** + Gets the current image registration mode of this device. + Image registration is used to properly superimpose two images from cameras located at different + points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about + registration. + @returns Current image registration mode. See @ref ImageRegistrationMode for possible return values. + */ + ImageRegistrationMode getImageRegistrationMode() const + { + ImageRegistrationMode mode; + Status rc = getProperty(DEVICE_PROPERTY_IMAGE_REGISTRATION, &mode); + if (rc != STATUS_OK) + { + return IMAGE_REGISTRATION_OFF; + } + return mode; + } + + /** + Sets the image registration on this device. + Image registration is used to properly superimpose two images from cameras located at different + points in space. Please see the OpenNi 2.0 Programmer's Guide for more information about + registration. + + See @ref ImageRegistrationMode for a list of valid settings to pass to this function. + + It is a good practice to first check if the mode is supported by calling @ref isImageRegistrationModeSupported(). + + @param [in] mode Desired new value for the image registration mode. + @returns Status code for the operation. + */ + Status setImageRegistrationMode(ImageRegistrationMode mode) + { + return setProperty(DEVICE_PROPERTY_IMAGE_REGISTRATION, mode); + } + + /** + Checks whether this Device object is currently connected to an actual file or hardware device. + @returns true if the Device is connected, false otherwise. + */ + bool isValid() const + { + return m_device != NULL; + } + + /** + Checks whether this device is a file device (i.e. a recording). + @returns true if this is a file device, false otherwise. + */ + bool isFile() const + { + return isPropertySupported(DEVICE_PROPERTY_PLAYBACK_SPEED) && + isPropertySupported(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED) && + isCommandSupported(DEVICE_COMMAND_SEEK); + } + + /** + Used to turn the depth/color frame synchronization feature on and off. When frame synchronization + is enabled, the device will deliver depth and image frames that are separated in time + by some maximum value. When disabled, the phase difference between depth and image frame + generation cannot be guaranteed. + @param [in] isEnabled Set to TRUE to enable synchronization, FALSE to disable it + @returns Status code indicating success or failure of this operation + */ + Status setDepthColorSyncEnabled(bool isEnabled) + { + Status rc = STATUS_OK; + + if (isEnabled) + { + rc = (Status)oniDeviceEnableDepthColorSync(m_device); + } + else + { + oniDeviceDisableDepthColorSync(m_device); + } + + return rc; + } + + bool getDepthColorSyncEnabled() + { + return oniDeviceGetDepthColorSyncEnabled(m_device) == TRUE; + } + + /** + Sets a property that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + + @tparam T Type of data to be passed to the property. + @param [in] propertyId The numerical ID of the property to be set. + @param [in] value Place to store the data to be written to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status setProperty(int propertyId, const T& value) + { + return setProperty(propertyId, &value, sizeof(T)); + } + + /** + Checks a property that provides an arbitrary data type as its output. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @tparam [in] T Data type of the value to be read. + @param [in] propertyId The numerical ID of the property to be read. + @param [in, out] value Pointer to a place to store the value read from the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status getProperty(int propertyId, T* value) const + { + int size = sizeof(T); + return getProperty(propertyId, value, &size); + } + + /** + Checks if a specific property is supported by the device. + @param [in] propertyId Property to be checked. + @returns true if the property is supported, false otherwise. + */ + bool isPropertySupported(int propertyId) const + { + return oniDeviceIsPropertySupported(m_device, propertyId) == TRUE; + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @param [in] commandId Numerical code of the property to be invoked. + @param [in] data Data to be passed to the property. + @param [in] dataSize size of the buffer passed in @c data. + @returns Status code indicating success or failure of this operation. + */ + Status invoke(int commandId, void* data, int dataSize) + { + return (Status)oniDeviceInvoke(m_device, commandId, data, dataSize); + } + + /** + Invokes a command that takes an arbitrary data type as its input. It is not expected that + application code will need this function frequently, as all commonly used properties have + higher level functions provided. + @tparam [in] T Type of data to be passed to the property. + @param [in] propertyId Numerical code of the property to be invoked. + @param [in] value Data to be passed to the property. + @returns Status code indicating success or failure of this operation. + */ + template + Status invoke(int propertyId, T& value) + { + return invoke(propertyId, &value, sizeof(T)); + } + + /** + Checks if a specific command is supported by the device. + @param [in] commandId Command to be checked. + @returns true if the command is supported, false otherwise. + */ + bool isCommandSupported(int commandId) const + { + return oniDeviceIsCommandSupported(m_device, commandId) == TRUE; + } + + /** @internal **/ + inline Status _openEx(const char* uri, const char* mode); + +private: + Device(const Device&); + Device& operator=(const Device&); + + void clearSensors() + { + for (int i = 0; i < ONI_MAX_SENSORS; ++i) + { + m_aSensorInfo[i]._setInternal(NULL); + } + } + + inline Status _setHandle(OniDeviceHandle deviceHandle); + +private: + PlaybackControl* m_pPlaybackControl; + + OniDeviceHandle m_device; + DeviceInfo m_deviceInfo; + SensorInfo m_aSensorInfo[ONI_MAX_SENSORS]; + + bool m_isOwner; +}; + +/** + * The PlaybackControl class provides access to a series of specific to playing back + * a recording from a file device. + * + * When playing a stream back from a recording instead of playing from a live device, + * it is possible to vary playback speed, change the current time location (ie + * fast forward / rewind / seek), specify whether the playback should be repeated at the end + * of the recording, and query the total size of the recording. + * + * Since none of these functions make sense in the context of a physical device, they are + * split out into a seperate playback control class. To use, simply create your file device, + * create a PlaybackControl, and then attach the PlaybackControl to the file device. + */ +class PlaybackControl +{ +public: + + /** + * Deconstructor. Destroys a PlaybackControl class. The deconstructor presently detaches + * from its recording automatically, but it is considered a best practice for applications to + * manually detach from any stream that was attached to. + */ + ~PlaybackControl() + { + detach(); + } + + /** + * Getter function for the current playback speed of this device. + * + * This value is expressed as a multiple of the speed the original + * recording was taken at. For example, if the original recording was at 30fps, and + * playback speed is set to 0.5, then the recording will play at 15fps. If playback speed + * is set to 2.0, then the recording would playback at 60fps. + * + * In addition, there are two "special" values. A playback speed of 0.0 indicates that the + * playback should occur as fast as the system is capable of returning frames. This is + * most useful when testing algorithms on large datasets, as it enables playback to be + * done at a much higher rate than would otherwise be possible. + * + * A value of -1 indicates that speed is "manual". In this mode, new frames will only + * become available when an application manually reads them. If used in a polling loop, + * this setting also enables systems to read and process frames limited only by + * available processing speeds. + * + * @returns Current playback speed of the device, measured as ratio of recording speed. + */ + float getSpeed() const + { + if (!isValid()) + { + return 0.0f; + } + float speed; + Status rc = m_pDevice->getProperty(DEVICE_PROPERTY_PLAYBACK_SPEED, &speed); + if (rc != STATUS_OK) + { + return 1.0f; + } + return speed; + } + /** + * Setter function for the playback speed of the device. For a full explanation of + * what this value means @see PlaybackControl::getSpeed(). + * + * @param [in] speed Desired new value of playback speed, as ratio of original recording. + * @returns Status code indicating success or failure of this operation. + */ + Status setSpeed(float speed) + { + if (!isValid()) + { + return STATUS_NO_DEVICE; + } + return m_pDevice->setProperty(DEVICE_PROPERTY_PLAYBACK_SPEED, speed); + } + + /** + * Gets the current repeat setting of the file device. + * + * @returns true if repeat is enabled, false if not enabled. + */ + bool getRepeatEnabled() const + { + if (!isValid()) + { + return false; + } + + OniBool repeat; + Status rc = m_pDevice->getProperty(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, &repeat); + if (rc != STATUS_OK) + { + return false; + } + + return repeat == TRUE; + } + + /** + * Changes the current repeat mode of the device. If repeat mode is turned on, then the recording will + * begin playback again at the beginning after the last frame is read. If turned off, no more frames + * will become available after last frame is read. + * + * @param [in] repeat New value for repeat -- true to enable, false to disable + * @returns Status code indicating success or failure of this operations. + */ + Status setRepeatEnabled(bool repeat) + { + if (!isValid()) + { + return STATUS_NO_DEVICE; + } + + return m_pDevice->setProperty(DEVICE_PROPERTY_PLAYBACK_REPEAT_ENABLED, repeat ? TRUE : FALSE); + } + + /** + * Seeks within a VideoStream to a given FrameID. Note that when this function is called on one + * stream, all other streams will also be changed to the corresponding place in the recording. The FrameIDs + * of different streams may not match, since FrameIDs may differ for streams that are not synchronized, but + * the recording will set all streams to the same moment in time. + * + * @param [in] stream Stream for which the frameIndex value is valid. + * @param [in] frameIndex Frame index to move playback to + * @returns Status code indicating success or failure of this operation + */ + Status seek(const VideoStream& stream, int frameIndex) + { + if (!isValid()) + { + return STATUS_NO_DEVICE; + } + OniSeek seek; + seek.frameIndex = frameIndex; + seek.stream = stream._getHandle(); + return m_pDevice->invoke(DEVICE_COMMAND_SEEK, seek); + } + + /** + * Provides the a count of frames that this recording contains for a given stream. This is useful + * both to determine the length of the recording, and to ensure that a valid Frame Index is set when using + * the @ref PlaybackControl::seek() function. + * + * @param [in] stream The video stream to count frames for + * @returns Number of frames in provided @ref VideoStream, or 0 if the stream is not part of the recording + */ + int getNumberOfFrames(const VideoStream& stream) const + { + int numOfFrames = -1; + Status rc = stream.getProperty(STREAM_PROPERTY_NUMBER_OF_FRAMES, &numOfFrames); + if (rc != STATUS_OK) + { + return 0; + } + return numOfFrames; + } + + bool isValid() const + { + return m_pDevice != NULL; + } +private: + Status attach(Device* device) + { + if (!device->isValid() || !device->isFile()) + { + return STATUS_ERROR; + } + + detach(); + m_pDevice = device; + + return STATUS_OK; + } + void detach() + { + m_pDevice = NULL; + } + + friend class Device; + PlaybackControl(Device* pDevice) : m_pDevice(NULL) + { + if (pDevice != NULL) + { + attach(pDevice); + } + } + + Device* m_pDevice; +}; + +class CameraSettings +{ +public: + // setters + Status setAutoExposureEnabled(bool enabled) + { + return setProperty(STREAM_PROPERTY_AUTO_EXPOSURE, enabled ? TRUE : FALSE); + } + Status setAutoWhiteBalanceEnabled(bool enabled) + { + return setProperty(STREAM_PROPERTY_AUTO_WHITE_BALANCE, enabled ? TRUE : FALSE); + } + + bool getAutoExposureEnabled() const + { + OniBool enabled = FALSE; + + Status rc = getProperty(STREAM_PROPERTY_AUTO_EXPOSURE, &enabled); + return rc == STATUS_OK && enabled == TRUE; + } + bool getAutoWhiteBalanceEnabled() const + { + OniBool enabled = FALSE; + + Status rc = getProperty(STREAM_PROPERTY_AUTO_WHITE_BALANCE, &enabled); + return rc == STATUS_OK && enabled == TRUE; + } + + Status setGain(int gain) + { + return setProperty(STREAM_PROPERTY_GAIN, gain); + } + Status setExposure(int exposure) + { + return setProperty(STREAM_PROPERTY_EXPOSURE, exposure); + } + int getGain() + { + int gain; + Status rc = getProperty(STREAM_PROPERTY_GAIN, &gain); + if (rc != STATUS_OK) + { + return 100; + } + return gain; + } + int getExposure() + { + int exposure; + Status rc = getProperty(STREAM_PROPERTY_EXPOSURE, &exposure); + if (rc != STATUS_OK) + { + return 0; + } + return exposure; + } + + bool isValid() const {return m_pStream != NULL;} +private: + template + Status getProperty(int propertyId, T* value) const + { + if (!isValid()) return STATUS_NOT_SUPPORTED; + + return m_pStream->getProperty(propertyId, value); + } + template + Status setProperty(int propertyId, const T& value) + { + if (!isValid()) return STATUS_NOT_SUPPORTED; + + return m_pStream->setProperty(propertyId, value); + } + + friend class VideoStream; + CameraSettings(VideoStream* pStream) + { + m_pStream = pStream; + } + + VideoStream* m_pStream; +}; + + +/** + * The OpenNI class is a static entry point to the library. It is used by every OpenNI 2.0 + * application to initialize the SDK and drivers to enable creation of valid device objects. + * + * It also defines a listener class and events that enable for event driven notification of + * device connection, device disconnection, and device configuration changes. + * + * In addition, it gives access to SDK version information and provides a function that allows + * you to wait for data to become available on any one of a list of streams (as opposed to + * waiting for data on one specific stream with functions provided by the VideoStream class) + * +*/ +class OpenNI +{ +public: + + /** + * The OpenNI::DeviceConnectedListener class provides a means of registering for, and responding to + * when a device is connected. + * + * onDeviceConnected is called whenever a new device is connected to the system (ie this event + * would be triggered when a new sensor is manually plugged into the host system running the + * application) + * + * To use this class, you should write a new class that inherits from it, and override the + * onDeviceConnected method. Once you instantiate your class, use the + * OpenNI::addDeviceConnectedListener() function to add your listener object to OpenNI's list of listeners. Your + * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceConnectedListener() + * function is also provided, if you want to have your class stop listening to these events for any + * reason. + */ + class DeviceConnectedListener + { + public: + DeviceConnectedListener() + { + m_deviceConnectedCallbacks.deviceConnected = deviceConnectedCallback; + m_deviceConnectedCallbacks.deviceDisconnected = NULL; + m_deviceConnectedCallbacks.deviceStateChanged = NULL; + m_deviceConnectedCallbacksHandle = NULL; + } + + virtual ~DeviceConnectedListener() + { + } + + /** + * Callback function for the onDeviceConnected event. This function will be + * called whenever this event occurs. When this happens, a pointer to the @ref DeviceInfo + * object for the newly connected device will be supplied. Note that once a + * device is removed, if it was opened by a @ref Device object, that object can no longer be + * used to access the device, even if it was reconnected. Once a device was reconnected, + * @ref Device::open() should be called again in order to use this device. + * + * If you wish to open the new device as it is connected, simply query the provided DeviceInfo + * object to obtain the URI of the device, and pass this URI to the Device.Open() function. + */ + virtual void onDeviceConnected(const DeviceInfo*) = 0; + private: + static void ONI_CALLBACK_TYPE deviceConnectedCallback(const OniDeviceInfo* pInfo, void* pCookie) + { + DeviceConnectedListener* pListener = (DeviceConnectedListener*)pCookie; + pListener->onDeviceConnected(static_cast(pInfo)); + } + + friend class OpenNI; + OniDeviceCallbacks m_deviceConnectedCallbacks; + OniCallbackHandle m_deviceConnectedCallbacksHandle; + + }; + /** + * The OpenNI::DeviceDisconnectedListener class provides a means of registering for, and responding to + * when a device is disconnected. + * + * onDeviceDisconnected is called when a device is removed from the system. Note that once a + * device is removed, if it was opened by a @ref Device object, that object can no longer be + * used to access the device, even if it was reconnected. Once a device was reconnected, + * @ref Device::open() should be called again in order to use this device. + * + * To use this class, you should write a new class that inherits from it, and override the + * onDeviceDisconnected method. Once you instantiate your class, use the + * OpenNI::addDeviceDisconnectedListener() function to add your listener object to OpenNI's list of listeners. Your + * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceDisconnectedListener() + * function is also provided, if you want to have your class stop listening to these events for any + * reason. + */ + class DeviceDisconnectedListener + { + public: + DeviceDisconnectedListener() + { + m_deviceDisconnectedCallbacks.deviceConnected = NULL; + m_deviceDisconnectedCallbacks.deviceDisconnected = deviceDisconnectedCallback; + m_deviceDisconnectedCallbacks.deviceStateChanged = NULL; + m_deviceDisconnectedCallbacksHandle = NULL; + } + + virtual ~DeviceDisconnectedListener() + { + } + + /** + * Callback function for the onDeviceDisconnected event. This function will be + * called whenever this event occurs. When this happens, a pointer to the DeviceInfo + * object for the newly disconnected device will be supplied. Note that once a + * device is removed, if it was opened by a @ref Device object, that object can no longer be + * used to access the device, even if it was reconnected. Once a device was reconnected, + * @ref Device::open() should be called again in order to use this device. + */ + virtual void onDeviceDisconnected(const DeviceInfo*) = 0; + private: + static void ONI_CALLBACK_TYPE deviceDisconnectedCallback(const OniDeviceInfo* pInfo, void* pCookie) + { + DeviceDisconnectedListener* pListener = (DeviceDisconnectedListener*)pCookie; + pListener->onDeviceDisconnected(static_cast(pInfo)); + } + + friend class OpenNI; + OniDeviceCallbacks m_deviceDisconnectedCallbacks; + OniCallbackHandle m_deviceDisconnectedCallbacksHandle; + }; + /** + * The OpenNI::DeviceStateChangedListener class provides a means of registering for, and responding to + * when a device's state is changed. + * + * onDeviceStateChanged is triggered whenever the state of a connected device is changed. + * + * To use this class, you should write a new class that inherits from it, and override the + * onDeviceStateChanged method. Once you instantiate your class, use the + * OpenNI::addDeviceStateChangedListener() function to add your listener object to OpenNI's list of listeners. Your + * handler function will then be called whenever the event occurs. A OpenNI::removeDeviceStateChangedListener() + * function is also provided, if you want to have your class stop listening to these events for any + * reason. + */ + class DeviceStateChangedListener + { + public: + DeviceStateChangedListener() + { + m_deviceStateChangedCallbacks.deviceConnected = NULL; + m_deviceStateChangedCallbacks.deviceDisconnected = NULL; + m_deviceStateChangedCallbacks.deviceStateChanged = deviceStateChangedCallback; + m_deviceStateChangedCallbacksHandle = NULL; + } + + virtual ~DeviceStateChangedListener() + { + } + + /** + * Callback function for the onDeviceStateChanged event. This function will be + * called whenever this event occurs. When this happens, a pointer to a DeviceInfo + * object for the affected device will be supplied, as well as the new DeviceState + * value of that device. + */ + virtual void onDeviceStateChanged(const DeviceInfo*, DeviceState) = 0; + private: + static void ONI_CALLBACK_TYPE deviceStateChangedCallback(const OniDeviceInfo* pInfo, OniDeviceState state, void* pCookie) + { + DeviceStateChangedListener* pListener = (DeviceStateChangedListener*)pCookie; + pListener->onDeviceStateChanged(static_cast(pInfo), DeviceState(state)); + } + + friend class OpenNI; + OniDeviceCallbacks m_deviceStateChangedCallbacks; + OniCallbackHandle m_deviceStateChangedCallbacksHandle; + }; + + /** + Initialize the library. + This will load all available drivers, and see which devices are available + It is forbidden to call any other method in OpenNI before calling @ref initialize(). + */ + static Status initialize() + { + return (Status)oniInitialize(ONI_API_VERSION); // provide version of API, to make sure proper struct sizes are used + } + + /** + Stop using the library. Unload all drivers, close all streams and devices. + Once @ref shutdown was called, no other calls to OpenNI is allowed. + */ + static void shutdown() + { + oniShutdown(); + } + + /** + * Returns the version of OpenNI + */ + static Version getVersion() + { + OniVersion oniVersion = oniGetVersion(); + Version version; + version.major = oniVersion.major; + version.minor = oniVersion.minor; + version.maintenance = oniVersion.maintenance; + version.build = oniVersion.build; + return version; + } + + /** + * Retrieves the calling thread's last extended error information. The last extended error information is maintained + * on a per-thread basis. Multiple threads do not overwrite each other's last extended error information. + * + * The extended error information is cleared on every call to an OpenNI method, so you should call this method + * immediately after a call to an OpenNI method which have failed. + */ + static const char* getExtendedError() + { + return oniGetExtendedError(); + } + + /** + Fills up an array of @ref DeviceInfo objects with devices that are available. + @param [in,out] deviceInfoList An array to be filled with devices. + */ + static void enumerateDevices(Array* deviceInfoList) + { + OniDeviceInfo* m_pDeviceInfos; + int m_deviceInfoCount; + oniGetDeviceList(&m_pDeviceInfos, &m_deviceInfoCount); + deviceInfoList->_setData((DeviceInfo*)m_pDeviceInfos, m_deviceInfoCount, true); + oniReleaseDeviceList(m_pDeviceInfos); + } + + /** + Wait for a new frame from any of the streams provided. The function blocks until any of the streams + has a new frame available, or the timeout has passed. + @param [in] pStreams An array of streams to wait for. + @param [in] streamCount The number of streams in @c pStreams + @param [out] pReadyStreamIndex The index of the first stream that has new frame available. + @param [in] timeout [Optional] A timeout before returning if no stream has new data. Default value is @ref TIMEOUT_FOREVER. + */ + static Status waitForAnyStream(VideoStream** pStreams, int streamCount, int* pReadyStreamIndex, int timeout = TIMEOUT_FOREVER) + { + static const int ONI_MAX_STREAMS = 50; + OniStreamHandle streams[ONI_MAX_STREAMS]; + + if (streamCount > ONI_MAX_STREAMS) + { + printf("Too many streams for wait: %d > %d\n", streamCount, ONI_MAX_STREAMS); + return STATUS_BAD_PARAMETER; + } + + *pReadyStreamIndex = -1; + for (int i = 0; i < streamCount; ++i) + { + if (pStreams[i] != NULL) + { + streams[i] = pStreams[i]->_getHandle(); + } + else + { + streams[i] = NULL; + } + } + Status rc = (Status)oniWaitForAnyStream(streams, streamCount, pReadyStreamIndex, timeout); + + return rc; + } + + /** + * Add a listener to the list of objects that receive the event when a device is connected. See the + * @ref OpenNI::DeviceConnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be added to the list + * @returns Status code indicating success or failure of this operation. + */ + static Status addDeviceConnectedListener(DeviceConnectedListener* pListener) + { + if (pListener->m_deviceConnectedCallbacksHandle != NULL) + { + return STATUS_ERROR; + } + return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceConnectedCallbacks, pListener, &pListener->m_deviceConnectedCallbacksHandle); + } + /** + * Add a listener to the list of objects that receive the event when a device is disconnected. See the + * @ref OpenNI::DeviceDisconnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be added to the list + * @returns Status code indicating success or failure of this operation. + */ + static Status addDeviceDisconnectedListener(DeviceDisconnectedListener* pListener) + { + if (pListener->m_deviceDisconnectedCallbacksHandle != NULL) + { + return STATUS_ERROR; + } + return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceDisconnectedCallbacks, pListener, &pListener->m_deviceDisconnectedCallbacksHandle); + } + /** + * Add a listener to the list of objects that receive the event when a device's state changes. See the + * @ref OpenNI::DeviceStateChangedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be added to the list + * @returns Status code indicating success or failure of this operation. + */ + static Status addDeviceStateChangedListener(DeviceStateChangedListener* pListener) + { + if (pListener->m_deviceStateChangedCallbacksHandle != NULL) + { + return STATUS_ERROR; + } + return (Status)oniRegisterDeviceCallbacks(&pListener->m_deviceStateChangedCallbacks, pListener, &pListener->m_deviceStateChangedCallbacksHandle); + } + /** + * Remove a listener from the list of objects that receive the event when a device is connected. See + * the @ref OpenNI::DeviceConnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be removed from the list + * @returns Status code indicating the success or failure of this operation. + */ + static void removeDeviceConnectedListener(DeviceConnectedListener* pListener) + { + oniUnregisterDeviceCallbacks(pListener->m_deviceConnectedCallbacksHandle); + pListener->m_deviceConnectedCallbacksHandle = NULL; + } + /** + * Remove a listener from the list of objects that receive the event when a device is disconnected. See + * the @ref OpenNI::DeviceDisconnectedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be removed from the list + * @returns Status code indicating the success or failure of this operation. + */ + static void removeDeviceDisconnectedListener(DeviceDisconnectedListener* pListener) + { + oniUnregisterDeviceCallbacks(pListener->m_deviceDisconnectedCallbacksHandle); + pListener->m_deviceDisconnectedCallbacksHandle = NULL; + } + /** + * Remove a listener from the list of objects that receive the event when a device's state changes. See + * the @ref OpenNI::DeviceStateChangedListener class for details on utilizing the events provided by OpenNI. + * + * @param pListener Pointer to the Listener to be removed from the list + * @returns Status code indicating the success or failure of this operation. + */ + static void removeDeviceStateChangedListener(DeviceStateChangedListener* pListener) + { + oniUnregisterDeviceCallbacks(pListener->m_deviceStateChangedCallbacksHandle); + pListener->m_deviceStateChangedCallbacksHandle = NULL; + } + + /** + * Change the log output folder + + * @param const char * strLogOutputFolder [in] log required folder + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogOutputFolder(const char *strLogOutputFolder) + { + return (Status)oniSetLogOutputFolder(strLogOutputFolder); + } + + /** + * Get current log file name + + * @param char * strFileName [out] returned file name buffer + * @param int nBufferSize [in] Buffer size + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status getLogFileName(char *strFileName, int nBufferSize) + { + return (Status)oniGetLogFileName(strFileName, nBufferSize); + } + + /** + * Set minimum severity for log produce + + * @param int nMinSeverity [in] Logger severity + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogMinSeverity(int nMinSeverity) + { + return(Status) oniSetLogMinSeverity(nMinSeverity); + } + + /** + * Configures if log entries will be printed to console. + + * @param const OniBool bConsoleOutput [in] TRUE to print log entries to console, FALSE otherwise. + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogConsoleOutput(bool bConsoleOutput) + { + return (Status)oniSetLogConsoleOutput(bConsoleOutput); + } + + /** + * Configures if log entries will be printed to file. + + * @param const OniBool bConsoleOutput [in] TRUE to print log entries to file, FALSE otherwise. + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + static Status setLogFileOutput(bool bFileOutput) + { + return (Status)oniSetLogFileOutput(bFileOutput); + } + + #if ONI_PLATFORM == ONI_PLATFORM_ANDROID_ARM + /** + * Configures if log entries will be printed to the Android log. + + * @param OniBool bAndroidOutput bAndroidOutput [in] TRUE to print log entries to the Android log, FALSE otherwise. + * + * @retval STATUS_OK Upon successful completion. + * @retval STATUS_ERROR Upon any kind of failure. + */ + + static Status setLogAndroidOutput(bool bAndroidOutput) + { + return (Status)oniSetLogAndroidOutput(bAndroidOutput); + } + #endif + +private: + OpenNI() + { + } +}; + +/** +The CoordinateConverter class converts points between the different coordinate systems. + +Depth and World coordinate systems + +OpenNI applications commonly use two different coordinate systems to represent depth. These two systems are referred to as Depth +and World representation. + +Depth coordinates are the native data representation. In this system, the frame is a map (two dimensional array), and each pixel is +assigned a depth value. This depth value represents the distance between the camera plane and whatever object is in the given +pixel. The X and Y coordinates are simply the location in the map, where the origin is the top-left corner of the field of view. + +World coordinates superimpose a more familiar 3D Cartesian coordinate system on the world, with the camera lens at the origin. +In this system, every point is specified by 3 points -- x, y and z. The x axis of this system is along a line that passes +through the infrared projector and CMOS imager of the camera. The y axis is parallel to the front face of the camera, and +perpendicular to the x axis (it will also be perpendicular to the ground if the camera is upright and level). The z axis +runs into the scene, perpendicular to both the x and y axis. From the perspective of the camera, an object moving from +left to right is moving along the increasing x axis. An object moving up is moving along the increasing y axis, and an object +moving away from the camera is moving along the increasing z axis. + +Mathematically, the Depth coordinate system is the projection of the scene on the CMOS. If the sensor's angular field of view and +resolution are known, then an angular size can be calculated for each pixel. This is how the conversion algorithms work. The +dependence of this calculation on FoV and resolution is the reason that a @ref VideoStream pointer must be provided to these +functions. The @ref VideoStream pointer is used to determine parameters for the specific points to be converted. + +Since Depth coordinates are a projective, the apparent size of objects in depth coordinates (measured in pixels) +will increase as an object moves closer to the sensor. The size of objects in the World coordinate system is independent of +distance from the sensor. + +Note that converting from Depth to World coordinates is relatively expensive computationally. It is generally not practical to convert +the entire raw depth map to World coordinates. A better approach is to have your computer vision algorithm work in Depth +coordinates for as long as possible, and only converting a few specific points to World coordinates right before output. + +Note that when converting from Depth to World or vice versa, the Z value remains the same. +*/ +class CoordinateConverter +{ +public: + /** + Converts a single point from the World coordinate system to the Depth coordinate system. + @param [in] depthStream Reference to an openni::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] worldX The X coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldY The Y coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldZ The Z coordinate of the point to be converted, measured in millimeters in World coordinates + @param [out] pDepthX Pointer to a place to store the X coordinate of the output value, measured in pixels with 0 at far left of image + @param [out] pDepthY Pointer to a place to store the Y coordinate of the output value, measured in pixels with 0 at top of image + @param [out] pDepthZ Pointer to a place to store the Z(depth) coordinate of the output value, measured in the @ref PixelFormat of depthStream + */ + static Status convertWorldToDepth(const VideoStream& depthStream, float worldX, float worldY, float worldZ, int* pDepthX, int* pDepthY, DepthPixel* pDepthZ) + { + float depthX, depthY, depthZ; + Status rc = (Status)oniCoordinateConverterWorldToDepth(depthStream._getHandle(), worldX, worldY, worldZ, &depthX, &depthY, &depthZ); + *pDepthX = (int)depthX; + *pDepthY = (int)depthY; + *pDepthZ = (DepthPixel)depthZ; + return rc; + } + + /** + Converts a single point from the World coordinate system to a floating point representation of the Depth coordinate system + @param [in] depthStream Reference to an openni::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] worldX The X coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldY The Y coordinate of the point to be converted, measured in millimeters in World coordinates + @param [in] worldZ The Z coordinate of the point to be converted, measured in millimeters in World coordinates + @param [out] pDepthX Pointer to a place to store the X coordinate of the output value, measured in pixels with 0.0 at far left of the image + @param [out] pDepthY Pointer to a place to store the Y coordinate of the output value, measured in pixels with 0.0 at the top of the image + @param [out] pDepthZ Pointer to a place to store the Z(depth) coordinate of the output value, measured in millimeters with 0.0 at the camera lens + */ + static Status convertWorldToDepth(const VideoStream& depthStream, float worldX, float worldY, float worldZ, float* pDepthX, float* pDepthY, float* pDepthZ) + { + return (Status)oniCoordinateConverterWorldToDepth(depthStream._getHandle(), worldX, worldY, worldZ, pDepthX, pDepthY, pDepthZ); + } + + /** + Converts a single point from the Depth coordinate system to the World coordinate system. + @param [in] depthStream Reference to an openi::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] depthX The X coordinate of the point to be converted, measured in pixels with 0 at the far left of the image + @param [in] depthY The Y coordinate of the point to be converted, measured in pixels with 0 at the top of the image + @param [in] depthZ the Z(depth) coordinate of the point to be converted, measured in the @ref PixelFormat of depthStream + @param [out] pWorldX Pointer to a place to store the X coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldY Pointer to a place to store the Y coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldZ Pointer to a place to store the Z coordinate of the output value, measured in millimeters in World coordinates + */ + static Status convertDepthToWorld(const VideoStream& depthStream, int depthX, int depthY, DepthPixel depthZ, float* pWorldX, float* pWorldY, float* pWorldZ) + { + return (Status)oniCoordinateConverterDepthToWorld(depthStream._getHandle(), float(depthX), float(depthY), float(depthZ), pWorldX, pWorldY, pWorldZ); + } + + /** + Converts a single point from a floating point representation of the Depth coordinate system to the World coordinate system. + @param [in] depthStream Reference to an openi::VideoStream that will be used to determine the format of the Depth coordinates + @param [in] depthX The X coordinate of the point to be converted, measured in pixels with 0.0 at the far left of the image + @param [in] depthY The Y coordinate of the point to be converted, measured in pixels with 0.0 at the top of the image + @param [in] depthZ Z(depth) coordinate of the point to be converted, measured in the @ref PixelFormat of depthStream + @param [out] pWorldX Pointer to a place to store the X coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldY Pointer to a place to store the Y coordinate of the output value, measured in millimeters in World coordinates + @param [out] pWorldZ Pointer to a place to store the Z coordinate of the output value, measured in millimeters in World coordinates + */ + static Status convertDepthToWorld(const VideoStream& depthStream, float depthX, float depthY, float depthZ, float* pWorldX, float* pWorldY, float* pWorldZ) + { + return (Status)oniCoordinateConverterDepthToWorld(depthStream._getHandle(), depthX, depthY, depthZ, pWorldX, pWorldY, pWorldZ); + } + + /** + For a given depth point, provides the coordinates of the corresponding color value. Useful for superimposing the depth and color images. + This operation is the same as turning on registration, but is performed on a single pixel rather than the whole image. + @param [in] depthStream Reference to a openni::VideoStream that produced the depth value + @param [in] colorStream Reference to a openni::VideoStream that we want to find the appropriate color pixel in + @param [in] depthX X value of the depth point, given in Depth coordinates and measured in pixels + @param [in] depthY Y value of the depth point, given in Depth coordinates and measured in pixels + @param [in] depthZ Z(depth) value of the depth point, given in the @ref PixelFormat of depthStream + @param [out] pColorX The X coordinate of the color pixel that overlaps the given depth pixel, measured in pixels + @param [out] pColorY The Y coordinate of the color pixel that overlaps the given depth pixel, measured in pixels + */ + static Status convertDepthToColor(const VideoStream& depthStream, const VideoStream& colorStream, int depthX, int depthY, DepthPixel depthZ, int* pColorX, int* pColorY) + { + return (Status)oniCoordinateConverterDepthToColor(depthStream._getHandle(), colorStream._getHandle(), depthX, depthY, depthZ, pColorX, pColorY); + } + + static Status convertC2DCoordinateByIntrinsic(const VideoStream& depthStream, int colorX, int colorY, DepthPixel depthZ, int* pDepthX, int* pDepthY) + { + return (Status)oniCoordinateConverterC2D(depthStream._getHandle(), colorX, colorY, depthZ, pDepthX, pDepthY); + } + static Status convertD2CCoordinateByIntrinsic(const VideoStream& depthStream, int depthX, int depthY, DepthPixel depthZ, int* pColorX, int* pColorY) + { + return (Status)oniCoordinateConverterD2C(depthStream._getHandle(), depthX, depthY, depthZ, pColorX, pColorY); + } +}; + +/** + * The Recorder class is used to record streams to an ONI file. + * + * After a recorder is instantiated, it must be initialized with a specific filename where + * the recording will be stored. The recorder is then attached to one or more streams. Once + * this is complete, the recorder can be told to start recording. The recorder will store + * every frame from every stream to the specified file. Later, this file can be used to + * initialize a file Device, and used to play back the same data that was recorded. + * + * Opening a file device is done by passing its path as the uri to the @ref Device::open() method. + * + * @see PlaybackControl for options available to play a reorded file. + * + */ +class Recorder +{ +public: + /** + * Creates a recorder. The recorder is not valid, i.e. @ref isValid() returns + * false. You must initialize the recorder before use with @ref create(). + */ + Recorder() : m_recorder(NULL) + { + } + + /** + * Destroys a recorder. This will also stop recording. + */ + ~Recorder() + { + destroy(); + } + + /** + * Initializes a recorder. You can initialize the recorder only once. Attempts + * to intialize more than once will result in an error code being returned. + * + * Initialization assigns the recorder to an output file that will be used for + * recording. Before use, the @ref attach() function must also be used to assign input + * data to the Recorder. + * + * @param [in] fileName The name of a file which will contain the recording. + * @returns Status code which indicates success or failure of the operation. + */ + Status create(const char* fileName) + { + if (!isValid()) + { + return (Status)oniCreateRecorder(fileName, &m_recorder); + } + return STATUS_ERROR; + } + + /** + * Verifies if the recorder is valid, i.e. if one can record with this recorder. A + * recorder object is not valid until the @ref create() method is called. + * + * @returns true if the recorder has been intialized, false otherwise. + */ + bool isValid() const + { + return NULL != getHandle(); + } + + /** + * Attaches a stream to the recorder. Note, this won't start recording, you + * should explicitly start it using @ref start() method. As soon as the recording + * process has been started, no more streams can be attached to the recorder. + * + * @param [in] stream The stream to be recorded. + * @param [in] allowLossyCompression [Optional] If this value is true, the recorder might use + * a lossy compression, which means that when the recording will be played-back, there might + * be small differences from the original frame. Default value is false. + */ + Status attach(VideoStream& stream, bool allowLossyCompression = false) + { + if (!isValid() || !stream.isValid()) + { + return STATUS_ERROR; + } + return (Status)oniRecorderAttachStream( + m_recorder, + stream._getHandle(), + allowLossyCompression); + } + + /** + * Starts recording. + * Once this method is called, the recorder will take all subsequent frames from the attached streams + * and store them in the file. + * You may not attach additional streams once recording was started. + */ + Status start() + { + if (!isValid()) + { + return STATUS_ERROR; + } + return (Status)oniRecorderStart(m_recorder); + } + + /** + * Stops recording. You may use @ref start() to resume the recording. + */ + void stop() + { + if (isValid()) + { + oniRecorderStop(m_recorder); + } + } + + /** + Destroys the recorder object. + */ + void destroy() + { + if (isValid()) + { + oniRecorderDestroy(&m_recorder); + } + } + +private: + Recorder(const Recorder&); + Recorder& operator=(const Recorder&); + + /** + * Returns a handle of this recorder. + */ + OniRecorderHandle getHandle() const + { + return m_recorder; + } + + + OniRecorderHandle m_recorder; +}; + +// Implemetation +Status VideoStream::create(const Device& device, SensorType sensorType) +{ + OniStreamHandle streamHandle; + Status rc = (Status)oniDeviceCreateStream(device._getHandle(), (OniSensorType)sensorType, &streamHandle); + if (rc != STATUS_OK) + { + return rc; + } + + m_isOwner = true; + _setHandle(streamHandle); + + if (isPropertySupported(STREAM_PROPERTY_AUTO_WHITE_BALANCE) && isPropertySupported(STREAM_PROPERTY_AUTO_EXPOSURE)) + { + m_pCameraSettings = new CameraSettings(this); + } + + return STATUS_OK; +} + +void VideoStream::destroy() +{ + if (!isValid()) + { + return; + } + + if (m_pCameraSettings != NULL) + { + delete m_pCameraSettings; + m_pCameraSettings = NULL; + } + + if (m_stream != NULL) + { + if(m_isOwner) + oniStreamDestroy(m_stream); + m_stream = NULL; + } +} + +Status Device::open(const char* uri) +{ + //If we are not the owners, we stick with our own device + if(!m_isOwner) + { + if(isValid()){ + return STATUS_OK; + }else{ + return STATUS_OUT_OF_FLOW; + } + } + + OniDeviceHandle deviceHandle; + Status rc = (Status)oniDeviceOpen(uri, &deviceHandle); + if (rc != STATUS_OK) + { + return rc; + } + + _setHandle(deviceHandle); + + return STATUS_OK; +} + +Status Device::_openEx(const char* uri, const char* mode) +{ + //If we are not the owners, we stick with our own device + if(!m_isOwner) + { + if(isValid()){ + return STATUS_OK; + }else{ + return STATUS_OUT_OF_FLOW; + } + } + + OniDeviceHandle deviceHandle; + Status rc = (Status)oniDeviceOpenEx(uri, mode, &deviceHandle); + if (rc != STATUS_OK) + { + return rc; + } + + _setHandle(deviceHandle); + + return STATUS_OK; +} + +Status Device::_setHandle(OniDeviceHandle deviceHandle) +{ + if (m_device == NULL) + { + m_device = deviceHandle; + + clearSensors(); + + oniDeviceGetInfo(m_device, &m_deviceInfo); + + if (isFile()) + { + m_pPlaybackControl = new PlaybackControl(this); + } + + // Read deviceInfo + return STATUS_OK; + } + + return STATUS_OUT_OF_FLOW; +} + +void Device::close() +{ + if (m_pPlaybackControl != NULL) + { + delete m_pPlaybackControl; + m_pPlaybackControl = NULL; + } + + if (m_device != NULL) + { + if(m_isOwner) + { + oniDeviceClose(m_device); + } + + m_device = NULL; + } +} + +} + +#endif // OPENNI_H diff --git a/src/ros_astra_camera/include/openni2/PS1080.h b/src/ros_astra_camera/include/openni2/PS1080.h new file mode 100644 index 0000000..27470b6 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/PS1080.h @@ -0,0 +1,752 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef PS1080_H +#define PS1080_H + +#include + +/** The maximum permitted Xiron device name string length. */ +#define XN_DEVICE_MAX_STRING_LENGTH 200 + +/* + * private properties of PS1080 devices. + * + * @remarks + * properties structure is 0x1080XXYY where XX is range and YY is code. + * range values: + * F0 - device properties + * E0 - device commands + * 00 - common stream properties + * 10 - depth stream properties + * 20 - color stream properties + */ +enum +{ + /*******************************************************************/ + /* Device properties */ + /*******************************************************************/ + + /** unsigned long long (XnSensorUsbInterface) */ + XN_MODULE_PROPERTY_USB_INTERFACE = 0x1080F001, // "UsbInterface" + /** Boolean */ + XN_MODULE_PROPERTY_MIRROR = 0x1080F002, // "Mirror" + /** unsigned long long, get only */ + XN_MODULE_PROPERTY_RESET_SENSOR_ON_STARTUP = 0x1080F004, // "ResetSensorOnStartup" + /** unsigned long long, get only */ + XN_MODULE_PROPERTY_LEAN_INIT = 0x1080F005, // "LeanInit" + /** char[XN_DEVICE_MAX_STRING_LENGTH], get only */ + XN_MODULE_PROPERTY_SERIAL_NUMBER = 0x1080F006, // "ID" + /** XnVersions, get only */ + XN_MODULE_PROPERTY_VERSION = 0x1080F007, // "Version" + /** Boolean */ + XN_MODULE_PROPERTY_FIRMWARE_FRAME_SYNC = 0x1080F008, + /** Boolean */ + XN_MODULE_PROPERTY_HOST_TIMESTAMPS = 0x1080FF77, // "HostTimestamps" + /** Boolean */ + XN_MODULE_PROPERTY_CLOSE_STREAMS_ON_SHUTDOWN = 0x1080FF78, // "CloseStreamsOnShutdown" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_LOG_INTERVAL = 0x1080FF7F, // "FirmwareLogInterval" + /** Boolean */ + XN_MODULE_PROPERTY_PRINT_FIRMWARE_LOG = 0x1080FF80, // "FirmwareLogPrint" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_LOG_FILTER = 0x1080FF81, // "FirmwareLogFilter" + /** String, get only */ + XN_MODULE_PROPERTY_FIRMWARE_LOG = 0x1080FF82, // "FirmwareLog" + /** Integer */ + XN_MODULE_PROPERTY_FIRMWARE_CPU_INTERVAL = 0x1080FF83, // "FirmwareCPUInterval" + /** String, get only */ + XN_MODULE_PROPERTY_PHYSICAL_DEVICE_NAME = 0x1080FF7A, // "PhysicalDeviceName" + /** String, get only */ + XN_MODULE_PROPERTY_VENDOR_SPECIFIC_DATA = 0x1080FF7B, // "VendorSpecificData" + /** String, get only */ + XN_MODULE_PROPERTY_SENSOR_PLATFORM_STRING = 0x1080FF7C, // "SensorPlatformString" + + /*******************************************************************/ + /* Device commands (activated via SetProperty/GetProperty) */ + /*******************************************************************/ + + /** XnInnerParam */ + XN_MODULE_PROPERTY_FIRMWARE_PARAM = 0x1080E001, // "FirmwareParam" + /** unsigned long long, set only */ + XN_MODULE_PROPERTY_RESET = 0x1080E002, // "Reset" + /** XnControlProcessingData */ + XN_MODULE_PROPERTY_IMAGE_CONTROL = 0x1080E003, // "ImageControl" + /** XnControlProcessingData */ + XN_MODULE_PROPERTY_DEPTH_CONTROL = 0x1080E004, // "DepthControl" + /** XnAHBData */ + XN_MODULE_PROPERTY_AHB = 0x1080E005, // "AHB" + /** XnLedState */ + XN_MODULE_PROPERTY_LED_STATE = 0x1080E006, // "LedState" + /** Boolean */ + XN_MODULE_PROPERTY_EMITTER_STATE = 0x1080E007, // "EmitterState" + + /** XnCmosBlankingUnits */ + XN_MODULE_PROPERTY_CMOS_BLANKING_UNITS = 0x1080FF74, // "CmosBlankingUnits" + /** XnCmosBlankingTime */ + XN_MODULE_PROPERTY_CMOS_BLANKING_TIME = 0x1080FF75, // "CmosBlankingTime" + /** XnFlashFileList, get only */ + XN_MODULE_PROPERTY_FILE_LIST = 0x1080FF84, // "FileList" + /** XnParamFlashData, get only */ + XN_MODULE_PROPERTY_FLASH_CHUNK = 0x1080FF85, // "FlashChunk" + XN_MODULE_PROPERTY_FILE = 0x1080FF86, // "FlashFile" + /** Integer */ + XN_MODULE_PROPERTY_DELETE_FILE = 0x1080FF87, // "DeleteFile" + XN_MODULE_PROPERTY_FILE_ATTRIBUTES = 0x1080FF88, // "FileAttributes" + XN_MODULE_PROPERTY_TEC_SET_POINT = 0x1080FF89, // "TecSetPoint" + /** get only */ + XN_MODULE_PROPERTY_TEC_STATUS = 0x1080FF8A, // "TecStatus" + /** get only */ + XN_MODULE_PROPERTY_TEC_FAST_CONVERGENCE_STATUS = 0x1080FF8B, // "TecFastConvergenceStatus" + XN_MODULE_PROPERTY_EMITTER_SET_POINT = 0x1080FF8C, // "EmitterSetPoint" + /** get only */ + XN_MODULE_PROPERTY_EMITTER_STATUS = 0x1080FF8D, // "EmitterStatus" + XN_MODULE_PROPERTY_I2C = 0x1080FF8E, // "I2C" + /** Integer, set only */ + XN_MODULE_PROPERTY_BIST = 0x1080FF8F, // "BIST" + /** XnProjectorFaultData, set only */ + XN_MODULE_PROPERTY_PROJECTOR_FAULT = 0x1080FF90, // "ProjectorFault" + /** Boolean, set only */ + XN_MODULE_PROPERTY_APC_ENABLED = 0x1080FF91, // "APCEnabled" + /** Boolean */ + XN_MODULE_PROPERTY_FIRMWARE_TEC_DEBUG_PRINT = 0x1080FF92, // "TecDebugPrint" + /** Boolean, set only */ + XN_MODULE_PROPERTY_READ_ALL_ENDPOINTS = 0x1080FF93, + /*IRFLOOD*/ + XN_MODULE_PROPERTY_IRFLOOD_STATE = 0x1080FF94, // "Ir floodState" + + //irgain + XN_MODULE_PROPERTY_IRGAIN = 0x1080FF95, //Ir gain + XN_MODULE_PROPERTY_IREXP = 0x1080FF96, //Ir exp + + XN_MODULE_PROPERTY_SENSOR_CHANGE = 0x1080FF97, //ado change sensor + + XN_MODULE_PROPERTY_PUBLIC_KEY = 0x1080FF98, //public key and batch version + XN_MODULE_PROPERTY_RANDOM_STRING = 0x1080FF99, //get random init string + + XN_MODULE_PROPERTY_RS_KEY = 0x1080FF9A, //rs key + //laser secure + XN_MODULE_PROPERTY_IS_SUPPORT_LASER_SECURE = 0x1080FF9B, //is support laser secure + XN_MODULE_PROPERTY_LASER_SECURE_STATUS = 0x1080FF9C, //laser secure (open or close) + XN_MODULE_PROPERTY_LASER_SECURE_KEEPALIVE = 0x1080FF9D, //keepalive heart packet + //laser current + XN_MODULE_PROPERTY_LASER_CURRENT = 0x1080FF9E, + + //soft reset + XN_MODULE_PROPERTY_SOFT_RESET = 0x1080FF9F, + //dual camera switch left and right ir + XN_MODULE_PROPERTY_SWITCH_IR = 0x1080FFB0, + + //rgb Ae mode + XN_MODULE_PROPERTY_RGB_AE_MODE = 0x1080FFB1, + + //IR Temperature mode + XN_MODULE_PROPERTY_CAL_IR_TEMP = 0x1080FFB2, + //LDMP Temperature mode + XN_MODULE_PROPERTY_CAL_LDMP_TEMP = 0x1080FFB3, + //IR real time Temperature mode + XN_MODULE_PROPERTY_RT_IR_TEMP = 0x1080FFB4, + //LDMP real time Temperature mode + XN_MODULE_PROPERTY_RT_LDMP_TEMP = 0x1080FFB5, + //IR temperature compensation coefficient mode + XN_MODULE_PROPERTY_IR_TEMP_COMP_CO = 0x1080FFB6, + //Ldmp temperature compensation coefficient mode + XN_MODULE_PROPERTY_LDMP_TEMP_COMP_CO = 0x1080FFB7, + + //Temperature comp + XN_MODULE_PROPERTY_TEMP_COMP = 0x1080FFB8, + + //Depth optimization enabled state + XN_MODULE_PROPERTY_DEPTH_OPTIM_STATE = 0x1080FFB9, + + //Depth optimization param + XN_MODULE_PROPERTY_DEPTH_OPTIM_PARAM = 0x1080FFBA, + + XN_MODULE_PROPERTY_UPDATE_FIRMWARE_FLASH_CHUNK = 0x1080FFBD, + + XN_MODULE_PROPERTY_LDP_ENABLE = 0x1080FFBE, + XN_MODULE_PROPERTY_EMITTER_STATE_V1 = 0x1080FFBF, // "get Emitter enable" + XN_MODULE_PROPERTY_LDP_SCALE = 0x1080FFC0, //ldp scale + XN_MODULE_PROPERTY_LDP_STATUS = 0x1080FFC1, //ldp status + /*******************************************************************/ + /* Common stream properties */ + /*******************************************************************/ + + /** unsigned long long */ + XN_STREAM_PROPERTY_INPUT_FORMAT = 0x10800001, // "InputFormat" + /** unsigned long long (XnCroppingMode) */ + XN_STREAM_PROPERTY_CROPPING_MODE = 0x10800002, // "CroppingMode" + + /*******************************************************************/ + /* Depth stream properties */ + /*******************************************************************/ + + /** unsigned long long */ + XN_STREAM_PROPERTY_CLOSE_RANGE = 0x1080F003, // "CloseRange" + /** unsigned long long */ + XN_STREAM_PROPERTY_FAST_ZOOM_CROP = 0x1080F009, // "FastZoomCrop" + /** XnPixelRegistration - get only */ + XN_STREAM_PROPERTY_PIXEL_REGISTRATION = 0x10801001, // "PixelRegistration" + /** XnPixelRegistration - get only */ + XN_STREAM_PROPERTY_PIXEL_C2D_REGISTRATION = 0x20801001, // "PixelRegistration" + /** XnPixelRegistration - get only */ + XN_STREAM_PROPERTY_PIXEL_D2C_REGISTRATION = 0x20801002, // "PixelRegistration" + /** unsigned long long */ + XN_STREAM_PROPERTY_WHITE_BALANCE_ENABLED = 0x10801002, // "WhiteBalancedEnabled" + /** unsigned long long */ + XN_STREAM_PROPERTY_GAIN = 0x10801003, // "Gain" + /** unsigned long long */ + XN_STREAM_PROPERTY_HOLE_FILTER = 0x10801004, // "HoleFilter" + /** unsigned long long (XnProcessingType) */ + XN_STREAM_PROPERTY_REGISTRATION_TYPE = 0x10801005, // "RegistrationType" + /** XnDepthAGCBin* */ + XN_STREAM_PROPERTY_AGC_BIN = 0x10801006, // "AGCBin" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_CONST_SHIFT = 0x10801007, // "ConstShift" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_PIXEL_SIZE_FACTOR = 0x10801008, // "PixelSizeFactor" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_MAX_SHIFT = 0x10801009, // "MaxShift" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_PARAM_COEFF = 0x1080100A, // "ParamCoeff" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_SHIFT_SCALE = 0x1080100B, // "ShiftScale" + /** unsigned long long, get only */ + XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE = 0x1080100C, // "ZPD" + /** double, get only */ + XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE = 0x1080100D, // "ZPPS" + /** double, get only */ + XN_STREAM_PROPERTY_EMITTER_DCMOS_DISTANCE = 0x1080100E, // "LDDIS" + /** double, get only */ + XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE = 0x1080100F, // "DCRCDIS" + /*dual sensor */ + XN_STREAM_PROPERTY_DUAL_FOCALL_LENGTH = 0x06010011, // "DCRCDIS" + /*dual sensor */ + XN_STREAM_PROPERTY_DUAL_COEFF_DISPARITY = 0x06010012, // "DCRCDIS" + /** OniDepthPixel[], get only */ + XN_STREAM_PROPERTY_S2D_TABLE = 0x10801112, // "S2D" + /** unsigned short[], get only */ + XN_STREAM_PROPERTY_D2S_TABLE = 0x10801113, // "D2S" + /** get only */ + XN_STREAM_PROPERTY_DEPTH_SENSOR_CALIBRATION_INFO = 0x10801012, + /** Boolean */ + XN_STREAM_PROPERTY_GMC_MODE = 0x1080FF44, // "GmcMode" + + XN_STREAM_PROPERTY_MIN_DEPTH = 0x1080FF40, // "MinDepthValue" + XN_STREAM_PROPERTY_MAX_DEPTH = 0x1080FF41, // "MaxDepthValue" + /** Boolean */ + XN_STREAM_PROPERTY_GMC_DEBUG = 0x1080FF45, // "GmcDebug" + /** Boolean */ + XN_STREAM_PROPERTY_WAVELENGTH_CORRECTION = 0x1080FF46, // "WavelengthCorrection" + /** Boolean */ + XN_STREAM_PROPERTY_WAVELENGTH_CORRECTION_DEBUG = 0x1080FF47, // "WavelengthCorrectionDebug" + + /** Boolean */ + XN_STREAM_PROPERTY_SOFTWARE_REGISTRATION = 0x2080FF42, // "Software Registration" + XN_STREAM_PROPERTY_SOFTWARE_FILTER = 0x2080FF43, //soft filter enable + + /*******************************************************************/ + /* Color stream properties */ + /*******************************************************************/ + /** Integer */ + XN_STREAM_PROPERTY_FLICKER = 0x10802001, // "Flicker" +}; + +typedef enum +{ + XN_SENSOR_FW_VER_UNKNOWN = 0, + XN_SENSOR_FW_VER_0_17 = 1, + XN_SENSOR_FW_VER_1_1 = 2, + XN_SENSOR_FW_VER_1_2 = 3, + XN_SENSOR_FW_VER_3_0 = 4, + XN_SENSOR_FW_VER_4_0 = 5, + XN_SENSOR_FW_VER_5_0 = 6, + XN_SENSOR_FW_VER_5_1 = 7, + XN_SENSOR_FW_VER_5_2 = 8, + XN_SENSOR_FW_VER_5_3 = 9, + XN_SENSOR_FW_VER_5_4 = 10, + XN_SENSOR_FW_VER_5_5 = 11, + XN_SENSOR_FW_VER_5_6 = 12, + XN_SENSOR_FW_VER_5_7 = 13, + XN_SENSOR_FW_VER_5_8 = 14, + XN_SENSOR_FW_VER_5_9 = 15, +} XnFWVer; + +typedef enum { + XN_SENSOR_VER_UNKNOWN = 0, + XN_SENSOR_VER_2_0 = 1, + XN_SENSOR_VER_3_0 = 2, + XN_SENSOR_VER_4_0 = 3, + XN_SENSOR_VER_5_0 = 4 +} XnSensorVer; + +typedef enum { + XN_SENSOR_HW_VER_UNKNOWN = 0, + XN_SENSOR_HW_VER_FPDB_10 = 1, + XN_SENSOR_HW_VER_CDB_10 = 2, + XN_SENSOR_HW_VER_RD_3 = 3, + XN_SENSOR_HW_VER_RD_5 = 4, + XN_SENSOR_HW_VER_RD1081 = 5, + XN_SENSOR_HW_VER_RD1082 = 6, + XN_SENSOR_HW_VER_RD109 = 7 +} XnHWVer; + +typedef enum { + XN_SENSOR_CHIP_VER_UNKNOWN = 0, + XN_SENSOR_CHIP_VER_PS1000 = 1, + XN_SENSOR_CHIP_VER_PS1080 = 2, + XN_SENSOR_CHIP_VER_PS1080A6 = 3, + XN_SENSOR_CHIP_VER_MX6000 = 6, + XN_SENSOR_CHIP_VER_DUAL_MX6000 = 7 + +} XnChipVer; + +typedef enum +{ + XN_CMOS_TYPE_IMAGE = 0, + XN_CMOS_TYPE_DEPTH = 1, + XN_CMOS_TYPE_IR = 2, + XN_CMOS_COUNT +} XnCMOSType; + +typedef enum +{ + XN_IO_IMAGE_FORMAT_BAYER = 0, + XN_IO_IMAGE_FORMAT_YUV422 = 1, + XN_IO_IMAGE_FORMAT_JPEG = 2, + XN_IO_IMAGE_FORMAT_JPEG_420 = 3, + XN_IO_IMAGE_FORMAT_JPEG_MONO = 4, + XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUV422 = 5, + XN_IO_IMAGE_FORMAT_UNCOMPRESSED_BAYER = 6, + XN_IO_IMAGE_FORMAT_UNCOMPRESSED_YUYV = 7, +} XnIOImageFormats; + +typedef enum +{ + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_16_BIT = 0, + XN_IO_DEPTH_FORMAT_COMPRESSED_PS = 1, + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_10_BIT = 2, + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_11_BIT = 3, + XN_IO_DEPTH_FORMAT_UNCOMPRESSED_12_BIT = 4, +} XnIODepthFormats; + +typedef enum +{ + XN_RESET_TYPE_POWER = 0, + XN_RESET_TYPE_SOFT = 1, + XN_RESET_TYPE_SOFT_FIRST = 2, +} XnParamResetType; + +typedef enum XnSensorUsbInterface +{ + XN_SENSOR_USB_INTERFACE_DEFAULT = 0, + XN_SENSOR_USB_INTERFACE_ISO_ENDPOINTS = 1, + XN_SENSOR_USB_INTERFACE_BULK_ENDPOINTS = 2, + XN_SENSOR_USB_INTERFACE_ISO_ENDPOINTS_LOW_DEPTH = 3, +} XnSensorUsbInterface; + +typedef enum XnProcessingType +{ + XN_PROCESSING_DONT_CARE = 0, + XN_PROCESSING_HARDWARE = 1, + XN_PROCESSING_SOFTWARE = 2, +} XnProcessingType; + +typedef enum XnCroppingMode +{ + XN_CROPPING_MODE_NORMAL = 1, + XN_CROPPING_MODE_INCREASED_FPS = 2, + XN_CROPPING_MODE_SOFTWARE_ONLY = 3, +} XnCroppingMode; + +enum +{ + XN_ERROR_STATE_OK = 0, + XN_ERROR_STATE_DEVICE_PROJECTOR_FAULT = 1, + XN_ERROR_STATE_DEVICE_OVERHEAT = 2, +}; + +typedef enum XnFirmwareCroppingMode +{ + XN_FIRMWARE_CROPPING_MODE_DISABLED = 0, + XN_FIRMWARE_CROPPING_MODE_NORMAL = 1, + XN_FIRMWARE_CROPPING_MODE_INCREASED_FPS = 2, +} XnFirmwareCroppingMode; + +typedef enum +{ + XnLogFilterDebug = 0x0001, + XnLogFilterInfo = 0x0002, + XnLogFilterError = 0x0004, + XnLogFilterProtocol = 0x0008, + XnLogFilterAssert = 0x0010, + XnLogFilterConfig = 0x0020, + XnLogFilterFrameSync = 0x0040, + XnLogFilterAGC = 0x0080, + XnLogFilterTelems = 0x0100, + + XnLogFilterAll = 0xFFFF +} XnLogFilter; + +typedef enum +{ + XnFileAttributeReadOnly = 0x8000 +} XnFilePossibleAttributes; + +typedef enum +{ + XnFlashFileTypeFileTable = 0x00, + XnFlashFileTypeScratchFile = 0x01, + XnFlashFileTypeBootSector = 0x02, + XnFlashFileTypeBootManager = 0x03, + XnFlashFileTypeCodeDownloader = 0x04, + XnFlashFileTypeMonitor = 0x05, + XnFlashFileTypeApplication = 0x06, + XnFlashFileTypeFixedParams = 0x07, + XnFlashFileTypeDescriptors = 0x08, + XnFlashFileTypeDefaultParams = 0x09, + XnFlashFileTypeImageCmos = 0x0A, + XnFlashFileTypeDepthCmos = 0x0B, + XnFlashFileTypeAlgorithmParams = 0x0C, + XnFlashFileTypeReferenceQVGA = 0x0D, + XnFlashFileTypeReferenceVGA = 0x0E, + XnFlashFileTypeMaintenance = 0x0F, + XnFlashFileTypeDebugParams = 0x10, + XnFlashFileTypePrimeProcessor = 0x11, + XnFlashFileTypeGainControl = 0x12, + XnFlashFileTypeRegistartionParams = 0x13, + XnFlashFileTypeIDParams = 0x14, + XnFlashFileTypeSensorTECParams = 0x15, + XnFlashFileTypeSensorAPCParams = 0x16, + XnFlashFileTypeSensorProjectorFaultParams = 0x17, + XnFlashFileTypeProductionFile = 0x18, + XnFlashFileTypeUpgradeInProgress = 0x19, + XnFlashFileTypeWavelengthCorrection = 0x1A, + XnFlashFileTypeGMCReferenceOffset = 0x1B, + XnFlashFileTypeSensorNESAParams = 0x1C, + XnFlashFileTypeSensorFault = 0x1D, + XnFlashFileTypeVendorData = 0x1E, +} XnFlashFileType; + +typedef enum XnBistType +{ + //Auto tests + XN_BIST_IMAGE_CMOS = 1 << 0, + XN_BIST_IR_CMOS = 1 << 1, + XN_BIST_POTENTIOMETER = 1 << 2, + XN_BIST_FLASH = 1 << 3, + XN_BIST_FULL_FLASH = 1 << 4, + XN_BIST_PROJECTOR_TEST_MASK = 1 << 5, + XN_BIST_TEC_TEST_MASK = 1 << 6, + + // Manual tests + XN_BIST_NESA_TEST_MASK = 1 << 7, + XN_BIST_NESA_UNLIMITED_TEST_MASK = 1 << 8, + + // Mask of all the auto tests + XN_BIST_ALL = (0xFFFFFFFF & ~XN_BIST_NESA_TEST_MASK & ~XN_BIST_NESA_UNLIMITED_TEST_MASK), + +} XnBistType; + +typedef enum XnBistError +{ + XN_BIST_RAM_TEST_FAILURE = 1 << 0, + XN_BIST_IR_CMOS_CONTROL_BUS_FAILURE = 1 << 1, + XN_BIST_IR_CMOS_DATA_BUS_FAILURE = 1 << 2, + XN_BIST_IR_CMOS_BAD_VERSION = 1 << 3, + XN_BIST_IR_CMOS_RESET_FAILUE = 1 << 4, + XN_BIST_IR_CMOS_TRIGGER_FAILURE = 1 << 5, + XN_BIST_IR_CMOS_STROBE_FAILURE = 1 << 6, + XN_BIST_COLOR_CMOS_CONTROL_BUS_FAILURE = 1 << 7, + XN_BIST_COLOR_CMOS_DATA_BUS_FAILURE = 1 << 8, + XN_BIST_COLOR_CMOS_BAD_VERSION = 1 << 9, + XN_BIST_COLOR_CMOS_RESET_FAILUE = 1 << 10, + XN_BIST_FLASH_WRITE_LINE_FAILURE = 1 << 11, + XN_BIST_FLASH_TEST_FAILURE = 1 << 12, + XN_BIST_POTENTIOMETER_CONTROL_BUS_FAILURE = 1 << 13, + XN_BIST_POTENTIOMETER_FAILURE = 1 << 14, + XN_BIST_AUDIO_TEST_FAILURE = 1 << 15, + XN_BIST_PROJECTOR_TEST_LD_FAIL = 1 << 16, + XN_BIST_PROJECTOR_TEST_LD_FAILSAFE_TRIG_FAIL = 1 << 17, + XN_BIST_PROJECTOR_TEST_FAILSAFE_HIGH_FAIL = 1 << 18, + XN_BIST_PROJECTOR_TEST_FAILSAFE_LOW_FAIL = 1 << 19, + XN_TEC_TEST_HEATER_CROSSED = 1 << 20, + XN_TEC_TEST_HEATER_DISCONNETED = 1 << 21, + XN_TEC_TEST_TEC_CROSSED = 1 << 22, + XN_TEC_TEST_TEC_FAULT = 1 << 23, +} XnBistError; + +typedef enum XnDepthCMOSType +{ + XN_DEPTH_CMOS_NONE = 0, + XN_DEPTH_CMOS_MT9M001 = 1, + XN_DEPTH_CMOS_AR130 = 2, + XN_DEPTH_CMOS_OV9151 = 3, + + XN_DEPTH_CMOS_OV9282 = 7, + XN_DEPTH_CMOS_AR0144 = 8, +} XnDepthCMOSType; + +typedef enum XnImageCMOSType +{ + XN_IMAGE_CMOS_NONE = 0, + XN_IMAGE_CMOS_MT9M112 = 1, + XN_IMAGE_CMOS_MT9D131 = 2, + XN_IMAGE_CMOS_MT9M114 = 3, +} XnImageCMOSType; + +#define XN_IO_MAX_I2C_BUFFER_SIZE 10 +#define XN_MAX_LOG_SIZE (6*1024) + +#pragma pack (push, 1) + +typedef struct XnSDKVersion +{ + unsigned char nMajor; + unsigned char nMinor; + unsigned char nMaintenance; + unsigned short nBuild; +} XnSDKVersion; + +typedef struct { + unsigned char nMajor; + unsigned char nMinor; + unsigned short nBuild; + unsigned int nChip; + unsigned short nFPGA; + unsigned short nSystemVersion; + + XnSDKVersion SDK; + + XnHWVer HWVer; + XnFWVer FWVer; + XnSensorVer SensorVer; + XnChipVer ChipVer; +} XnVersions; + +typedef struct +{ + unsigned short nParam; + unsigned short nValue; +} XnInnerParamData; + +typedef struct XnDepthAGCBin +{ + unsigned short nBin; + unsigned short nMin; + unsigned short nMax; +} XnDepthAGCBin; + +typedef struct XnControlProcessingData +{ + unsigned short nRegister; + unsigned short nValue; +} XnControlProcessingData; + +typedef struct XnAHBData +{ + unsigned int nRegister; + unsigned int nValue; + unsigned int nMask; +} XnAHBData; + +typedef struct XnPixelRegistration +{ + unsigned int nDepthX; + unsigned int nDepthY; + uint16_t nDepthValue; + unsigned int nImageXRes; + unsigned int nImageYRes; + unsigned int nImageX; // out + unsigned int nImageY; // out +} XnPixelRegistration; + +typedef struct XnLedState +{ + uint16_t nLedID; + uint16_t nState; +} XnLedState; + + +typedef struct XnCmosBlankingTime +{ + XnCMOSType nCmosID; + float nTimeInMilliseconds; + uint16_t nNumberOfFrames; +} XnCmosBlankingTime; + +typedef struct XnCmosBlankingUnits +{ + XnCMOSType nCmosID; + uint16_t nUnits; + uint16_t nNumberOfFrames; +} XnCmosBlankingUnits; + +typedef struct XnI2CWriteData +{ + uint16_t nBus; + uint16_t nSlaveAddress; + uint16_t cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t nWriteSize; +} XnI2CWriteData; + +typedef struct XnI2CReadData +{ + uint16_t nBus; + uint16_t nSlaveAddress; + uint16_t cpReadBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t cpWriteBuffer[XN_IO_MAX_I2C_BUFFER_SIZE]; + uint16_t nReadSize; + uint16_t nWriteSize; +} XnI2CReadData; + +typedef struct XnTecData +{ + uint16_t m_SetPointVoltage; + uint16_t m_CompensationVoltage; + uint16_t m_TecDutyCycle; //duty cycle on heater/cooler + uint16_t m_HeatMode; //TRUE - heat, FALSE - cool + int32_t m_ProportionalError; + int32_t m_IntegralError; + int32_t m_DerivativeError; + uint16_t m_ScanMode; //0 - crude, 1 - precise +} XnTecData; + +typedef struct XnTecFastConvergenceData +{ + int16_t m_SetPointTemperature; // set point temperature in celsius, + // scaled by factor of 100 (extra precision) + int16_t m_MeasuredTemperature; // measured temperature in celsius, + // scaled by factor of 100 (extra precision) + int32_t m_ProportionalError; // proportional error in system clocks + int32_t m_IntegralError; // integral error in system clocks + int32_t m_DerivativeError; // derivative error in system clocks + uint16_t m_ScanMode; // 0 - initial, 1 - crude, 2 - precise + uint16_t m_HeatMode; // 0 - idle, 1 - heat, 2 - cool + uint16_t m_TecDutyCycle; // duty cycle on heater/cooler in percents + uint16_t m_TemperatureRange; // 0 - cool, 1 - room, 2 - warm +} XnTecFastConvergenceData; + +typedef struct XnEmitterData +{ + uint16_t m_State; //idle, calibrating + uint16_t m_SetPointVoltage; //this is what should be written to the XML + uint16_t m_SetPointClocks; //target cross duty cycle + uint16_t m_PD_Reading; //current cross duty cycle in system clocks(high time) + uint16_t m_EmitterSet; //duty cycle on emitter set in system clocks (high time). + uint16_t m_EmitterSettingLogic; //TRUE = positive logic, FALSE = negative logic + uint16_t m_LightMeasureLogic; //TRUE - positive logic, FALSE - negative logic + uint16_t m_IsAPCEnabled; + uint16_t m_EmitterSetStepSize; // in MilliVolts + uint16_t m_ApcTolerance; // in system clocks (only valid up till v5.2) + uint16_t m_SubClocking; //in system clocks (only valid from v5.3) + uint16_t m_Precision; // (only valid from v5.3) +} XnEmitterData; + +typedef struct +{ + uint16_t nId; + uint16_t nAttribs; +} XnFileAttributes; + +typedef struct +{ + uint32_t nOffset; + const char* strFileName; + uint16_t nAttributes; +} XnParamFileData; + +typedef struct +{ + uint32_t nOffset; + uint32_t nSize; + unsigned char* pData; +} XnParamFlashData; + +typedef struct { + uint16_t nId; + uint16_t nType; + uint32_t nVersion; + uint32_t nOffset; + uint32_t nSize; + uint16_t nCrc; + uint16_t nAttributes; + uint16_t nReserve; +} XnFlashFile; + +typedef struct +{ + XnFlashFile* pFiles; + uint16_t nFiles; +} XnFlashFileList; + +typedef struct XnProjectorFaultData +{ + uint16_t nMinThreshold; + uint16_t nMaxThreshold; + int32_t bProjectorFaultEvent; +} XnProjectorFaultData; + +typedef struct XnBist +{ + uint32_t nTestsMask; + uint32_t nFailures; +} XnBist; + +//public key and batch version +typedef struct OBEccVerify +{ + char Pub_x[48]; //public key x 48 bytes + char Pub_y[48]; //public key y 48 bytes + char Batch_Ver[12]; //batch version 12 bytes +}OBEccVerify; + +//get init random string +typedef struct OBEccInit +{ + char RandomStr[48]; + char Batch_Ver[12]; +}OBEccInit; + +//r s key +typedef struct OBEccRSKey +{ + char R_key[48]; + char S_key[48]; +}OBEccRSKey; + +//rgb ae mode +typedef struct XnRgbAeMode +{ + uint16_t nAeMode; + uint16_t nAeTarget; +} XnRgbAeMode; + +typedef struct XnDepthOptimizationParam +{ + double nParam1; + double nParam2; + double nParam3; +}XnDepthOptimizationParam; + + +#pragma pack (pop) + +#endif // PS1080_H \ No newline at end of file diff --git a/src/ros_astra_camera/include/openni2/PSLink.h b/src/ros_astra_camera/include/openni2/PSLink.h new file mode 100644 index 0000000..3949329 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/PSLink.h @@ -0,0 +1,239 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef PSLINK_H +#define PSLINK_H + +#include + +enum +{ + /**** Device properties ****/ + + /* XnDetailedVersion, get only */ + LINK_PROP_FW_VERSION = 0x12000001, // "FWVersion" + /* Int, get only */ + LINK_PROP_VERSIONS_INFO_COUNT = 0x12000002, // "VersionsInfoCount" + /* General - array - XnComponentVersion * count elements, get only */ + LINK_PROP_VERSIONS_INFO = 0x12000003, // "VersionsInfo" + /* Int - 0 means off, 1 means on. */ + LINK_PROP_PROJECTOR_ACTIVE = 0x12000008, // "ProjectorActive" + /* String. Set only */ + LINK_PROP_PRESET_FILE = 0x1200000a, // "PresetFile" + /* Get only */ + LINK_PROP_BOOT_STATUS = 0x1200000b, + /* Int - system specific units */ + LINK_PROP_PROJECTOR_POWER = 0x1200000c, + /* SetAccActive*/ + LINK_PROP_ACC_ENABLED = 0x1200000d, + /* SetAccActive*/ + LINK_PROP_VDD_ENABLED = 0x1200000e, + /* SetAccActive*/ + LINK_PROP_PERIODIC_BIST_ENABLED = 0x1200000f, + + + /**** Device commands ****/ + /* XnCommandGetFwStreams */ + LINK_COMMAND_GET_FW_STREAM_LIST = 0x1200F001, + /* XnCommandCreateStream */ + LINK_COMMAND_CREATE_FW_STREAM = 0x1200F002, + /* XnCommandDestroyStream */ + LINK_COMMAND_DESTROY_FW_STREAM = 0x1200F003, + /* XnCommandStartStream */ + LINK_COMMAND_START_FW_STREAM = 0x1200F004, + /* XnCommandStopStream */ + LINK_COMMAND_STOP_FW_STREAM = 0x1200F005, + /* XnCommandGetFwStreamVideoModeList */ + LINK_COMMAND_GET_FW_STREAM_VIDEO_MODE_LIST = 0x1200F006, + /* XnCommandSetFwStreamVideoMode */ + LINK_COMMAND_SET_FW_STREAM_VIDEO_MODE = 0x1200F007, + /* XnCommandGetFwStreamVideoMode */ + LINK_COMMAND_GET_FW_STREAM_VIDEO_MODE = 0x1200F008, + /* XnCommandSetProjectorPulse */ + LINK_COMMAND_SET_PROJECTOR_PULSE = 0x1200F009, + /* No args */ + LINK_COMMAND_DISABLE_PROJECTOR_PULSE = 0x1200F00a, + + /**** Stream properties ****/ + /* Int. 1 - Shifts 9.3, 2 - Grayscale16, 3 - YUV422, 4 - Bayer8 */ + LINK_PROP_PIXEL_FORMAT = 0x12001001, // "PixelFormat" + /* Int. 0 - None, 1 - 8z, 2 - 16z, 3 - 24z, 4 - 6-bit, 5 - 10-bit, 6 - 11-bit, 7 - 12-bit */ + LINK_PROP_COMPRESSION = 0x12001002, // "Compression" + + /**** Depth Stream properties ****/ + /* Real, get only */ + LINK_PROP_DEPTH_SCALE = 0x1200000b, // "DepthScale" + /* Int, get only */ + LINK_PROP_MAX_SHIFT = 0x12002001, // "MaxShift" + /* Int, get only */ + LINK_PROP_ZERO_PLANE_DISTANCE = 0x12002002, // "ZPD" + /* Int, get only */ + LINK_PROP_CONST_SHIFT = 0x12002003, // "ConstShift" + /* Int, get only */ + LINK_PROP_PARAM_COEFF = 0x12002004, // "ParamCoeff" + /* Int, get only */ + LINK_PROP_SHIFT_SCALE = 0x12002005, // "ShiftScale" + /* Real, get only */ + LINK_PROP_ZERO_PLANE_PIXEL_SIZE = 0x12002006, // "ZPPS" + /* Real, get only */ + LINK_PROP_ZERO_PLANE_OUTPUT_PIXEL_SIZE = 0x12002007, // "ZPOPS" + /* Real, get only */ + LINK_PROP_EMITTER_DEPTH_CMOS_DISTANCE = 0x12002008, // "LDDIS" + /* General - array - MaxShift * XnDepthPixel elements, get only */ + LINK_PROP_SHIFT_TO_DEPTH_TABLE = 0x12002009, // "S2D" + /* General - array - MaxDepth * uint16_t elements, get only */ + LINK_PROP_DEPTH_TO_SHIFT_TABLE = 0x1200200a, // "D2S" +}; + +typedef enum XnFileZone +{ + XN_ZONE_FACTORY = 0x0000, + XN_ZONE_UPDATE = 0x0001, +} XnFileZone; + +typedef enum XnBootErrorCode +{ + XN_BOOT_OK = 0x0000, + XN_BOOT_BAD_CRC = 0x0001, + XN_BOOT_UPLOAD_IN_PROGRESS = 0x0002, + XN_BOOT_FW_LOAD_FAILED = 0x0003, +} XnBootErrorCode; + +typedef enum XnFwStreamType +{ + XN_FW_STREAM_TYPE_COLOR = 0x0001, + XN_FW_STREAM_TYPE_IR = 0x0002, + XN_FW_STREAM_TYPE_SHIFTS = 0x0003, + XN_FW_STREAM_TYPE_AUDIO = 0x0004, + XN_FW_STREAM_TYPE_DY = 0x0005, + XN_FW_STREAM_TYPE_LOG = 0x0008, +} XnFwStreamType; + +typedef enum XnFwPixelFormat +{ + XN_FW_PIXEL_FORMAT_NONE = 0x0000, + XN_FW_PIXEL_FORMAT_SHIFTS_9_3 = 0x0001, + XN_FW_PIXEL_FORMAT_GRAYSCALE16 = 0x0002, + XN_FW_PIXEL_FORMAT_YUV422 = 0x0003, + XN_FW_PIXEL_FORMAT_BAYER8 = 0x0004, +} XnFwPixelFormat; + +typedef enum XnFwCompressionType +{ + XN_FW_COMPRESSION_NONE = 0x0000, + XN_FW_COMPRESSION_8Z = 0x0001, + XN_FW_COMPRESSION_16Z = 0x0002, + XN_FW_COMPRESSION_24Z = 0x0003, + XN_FW_COMPRESSION_6_BIT_PACKED = 0x0004, + XN_FW_COMPRESSION_10_BIT_PACKED = 0x0005, + XN_FW_COMPRESSION_11_BIT_PACKED = 0x0006, + XN_FW_COMPRESSION_12_BIT_PACKED = 0x0007, +} XnFwCompressionType; + +#pragma pack (push, 1) + +#define XN_MAX_VERSION_MODIFIER_LENGTH 16 +typedef struct XnDetailedVersion +{ + uint8_t m_nMajor; + uint8_t m_nMinor; + uint16_t m_nMaintenance; + uint32_t m_nBuild; + char m_strModifier[XN_MAX_VERSION_MODIFIER_LENGTH]; +} XnDetailedVersion; + +typedef struct XnBootStatus +{ + XnFileZone zone; + XnBootErrorCode errorCode; +} XnBootStatus; + +typedef struct XnFwStreamInfo +{ + XnFwStreamType type; + char creationInfo[80]; +} XnFwStreamInfo; + +typedef struct XnFwStreamVideoMode +{ + uint32_t m_nXRes; + uint32_t m_nYRes; + uint32_t m_nFPS; + XnFwPixelFormat m_nPixelFormat; + XnFwCompressionType m_nCompression; +} XnFwStreamVideoMode; + +typedef struct XnCommandGetFwStreamList +{ + uint32_t count; // in: number of allocated elements in streams array. out: number of written elements in the array + XnFwStreamInfo* streams; +} XnCommandGetFwStreamList; + +typedef struct XnCommandCreateStream +{ + XnFwStreamType type; + const char* creationInfo; + uint32_t id; // out +} XnCommandCreateStream; + +typedef struct XnCommandDestroyStream +{ + uint32_t id; +} XnCommandDestroyStream; + +typedef struct XnCommandStartStream +{ + uint32_t id; +} XnCommandStartStream; + +typedef struct XnCommandStopStream +{ + uint32_t id; +} XnCommandStopStream; + +typedef struct XnCommandGetFwStreamVideoModeList +{ + int streamId; + uint32_t count; // in: number of allocated elements in videoModes array. out: number of written elements in the array + XnFwStreamVideoMode* videoModes; +} XnCommandGetFwStreamVideoModeList; + +typedef struct XnCommandSetFwStreamVideoMode +{ + int streamId; + XnFwStreamVideoMode videoMode; +} XnCommandSetFwStreamVideoMode; + +typedef struct XnCommandGetFwStreamVideoMode +{ + int streamId; + XnFwStreamVideoMode videoMode; // out +} XnCommandGetFwStreamVideoMode; + +typedef struct XnCommandSetProjectorPulse +{ + float delay; //start delay - delay time before start pulse + float width; //DC - duty cycle - the percentage of the pulse out of total cycle + float cycle; +} XnCommandSetProjectorPulse; + +#pragma pack (pop) + +#endif // PSLINK_H diff --git a/src/ros_astra_camera/include/openni2/PrimeSense.h b/src/ros_astra_camera/include/openni2/PrimeSense.h new file mode 100644 index 0000000..172b73d --- /dev/null +++ b/src/ros_astra_camera/include/openni2/PrimeSense.h @@ -0,0 +1,260 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef PRIMESENSE_H +#define PRIMESENSE_H + +#include + +/** +* Additional properties for PrimeSense devices +* +* @remarks +* properties structure is 0x1D27XXYY where XX is range and YY is code. +* range values: +* 00 - common stream properties +* 10 - depth stream properties +* E0 - device commands +* F0 - device properties +*/ +enum +{ + // Stream Properties + PS_PROPERTY_DUMP_DATA = 0x1d270001, // boolean + PS_PROPERTY_GAIN = 0x1d270002, // int - system specific + + // Device Properties + PS_PROPERTY_USB_INTERFACE = 0x1d27F001, // values from XnUsbInterfaceType +}; + +/** +* Additional commands for PrimeSense devices +* +* @remarks +* Commands structure is 0x1D27XXYY where XX is range and YY is code. +* range values: +* E0 - device commands +*/ +enum +{ + // Device Commands - use via invoke() + PS_COMMAND_AHB_READ = 0x1d27E001, // XnCommandAHB + PS_COMMAND_AHB_WRITE = 0x1d27E002, // XnCommandAHB + PS_COMMAND_I2C_READ = 0x1d27E003, // XnCommandI2C + PS_COMMAND_I2C_WRITE = 0x1d27E004, // XnCommandI2C + PS_COMMAND_SOFT_RESET = 0x1d27E005, // no arguments + PS_COMMAND_POWER_RESET = 0x1d27E006, // no arguments + PS_COMMAND_BEGIN_FIRMWARE_UPDATE = 0x1d27E007, // no arguments + PS_COMMAND_END_FIRMWARE_UPDATE = 0x1d27E008, // no arguments + PS_COMMAND_UPLOAD_FILE = 0x1d27E009, // XnCommandUploadFile + PS_COMMAND_DOWNLOAD_FILE = 0x1d27E00A, // XnCommandDownloadFile + PS_COMMAND_GET_FILE_LIST = 0x1d27E00B, // an array of XnFileEntry + PS_COMMAND_FORMAT_ZONE = 0x1d27E00C, // XnCommandFormatZone + PS_COMMAND_DUMP_ENDPOINT = 0x1d27E00D, // XnCommandDumpEndpoint + PS_COMMAND_GET_I2C_DEVICE_LIST = 0x1d27E00E, // XnCommandGetI2CDevices + PS_COMMAND_GET_BIST_LIST = 0x1d27E00F, // XnCommandGetBistList + PS_COMMAND_EXECUTE_BIST = 0x1d27E010, // XnCommandExecuteBist + PS_COMMAND_USB_TEST = 0x1d27E011, // XnCommandUsbTest + PS_COMMAND_GET_LOG_MASK_LIST = 0x1d27E012, // XnCommandGetLogMaskList + PS_COMMAND_SET_LOG_MASK_STATE = 0x1d27E013, // XnCommandSetLogMaskState + PS_COMMAND_START_LOG = 0x1d27E014, // no arguments + PS_COMMAND_STOP_LOG = 0x1d27E015, // no arguments + PS_COMMAND_READ_TEMPERATURE = 0x1d27E016, // no arguments + PS_COMMAND_GET_TEMP_LIST = 0x1d27E017,// PrintTempList + PS_COMMAND_READ_DEBUG_DATA = 0x1d27E018, //ReadDebugDaata +}; + +typedef enum XnUsbInterfaceType +{ + PS_USB_INTERFACE_DONT_CARE = 0, + PS_USB_INTERFACE_ISO_ENDPOINTS = 1, + PS_USB_INTERFACE_BULK_ENDPOINTS = 2, +} XnUsbInterfaceType; + +#pragma pack (push, 1) + +// Data Types +typedef struct XnFwFileVersion +{ + uint8_t major; + uint8_t minor; + uint8_t maintenance; + uint8_t build; +} XnFwFileVersion; + +typedef enum XnFwFileFlags +{ + XN_FILE_FLAG_BAD_CRC = 0x0001, +} XnFwFileFlags; + +typedef struct XnFwFileEntry +{ + char name[32]; + XnFwFileVersion version; + uint32_t address; + uint32_t size; + uint16_t crc; + uint16_t zone; + XnFwFileFlags flags; // bitmap +} XnFwFileEntry; + +typedef struct XnI2CDeviceInfo +{ + uint8_t masterId; + uint8_t slaveId; + uint32_t id; + char name[32]; +} XnI2CDeviceInfo; + +typedef struct XnBistInfo +{ + uint32_t id; + char name[32]; +} XnBistInfo; + +typedef struct XnTempInfo +{ + uint32_t id; + char name[16]; +} XnTempInfo; + +typedef struct XnFwLogMask +{ + uint32_t id; + char name[32]; +} XnFwLogMask; + +typedef struct XnUsbTestEndpointResult +{ + double averageBytesPerSecond; + uint32_t lostPackets; +} XnUsbTestEndpointResult; + +// Commands + +typedef struct XnCommandAHB +{ + uint32_t address; // Address of this register + uint32_t offsetInBits; // Offset of the field in bits within address + uint32_t widthInBits; // Width of the field in bits + uint32_t value; // For read requests, this is where the actual value will be filled. For write requests, the value to write. +} XnCommandAHB; + +typedef struct XnCommandI2C +{ + uint32_t deviceID; // Device to communicate with + uint32_t addressSize; // Size of the address, in bytes (1-4) + uint32_t address; // Address + uint32_t valueSize; // Size of the value, in bytes (1-4) + uint32_t mask; // For write request - a mask to be applied to the value. For read requests - ignored. + uint32_t value; // For write request - the value to be written. For read requests - the place where the actual value is written to +} XnCommandI2C; + +typedef struct XnCommandUploadFile +{ + const char* filePath; + uint32_t uploadToFactory; +} XnCommandUploadFile; + +typedef struct XnCommandDownloadFile +{ + uint16_t zone; + const char* firmwareFileName; + const char* targetPath; +} XnCommandDownloadFile; + +typedef struct XnCommandGetFileList +{ + uint32_t count; // in: number of allocated elements in files array. out: number of written elements in the array + XnFwFileEntry* files; +} XnCommandGetFileList; + +typedef struct XnCommandFormatZone +{ + uint8_t zone; +} XnCommandFormatZone; + +typedef struct XnCommandDumpEndpoint +{ + uint8_t endpoint; + bool enabled; +} XnCommandDumpEndpoint; + +typedef struct XnCommandGetI2CDeviceList +{ + uint32_t count; // in: number of allocated elements in devices array. out: number of written elements in the array + XnI2CDeviceInfo* devices; +} XnCommandGetI2CDeviceList; + +typedef struct XnCommandGetBistList +{ + uint32_t count; // in: number of allocated elements in tests array. out: number of written elements in the array + XnBistInfo* tests; +} XnCommandGetBistList; + +typedef struct XnCommandGetTempList +{ + uint32_t count; // in: number of allocated elements in tests array. out: number of written elements in the array + XnTempInfo* pTempInfos; +} XnCommandGetTempList; + +typedef struct XnCommandExecuteBist +{ + uint32_t id; + uint32_t errorCode; + uint32_t extraDataSize; // in: number of allocated bytes in extraData. out: number of written bytes in extraData + uint8_t* extraData; +} XnCommandExecuteBist; + +typedef struct XnCommandTemperatureResponse +{ + uint32_t id; + float temperature; +} XnCommandTemperatureResponse; + +typedef struct XnCommandUsbTest +{ + uint32_t seconds; + uint32_t endpointCount; // in: number of allocated bytes in endpoints array. out: number of written bytes in array + XnUsbTestEndpointResult* endpoints; +} XnCommandUsbTest; + +typedef struct XnCommandGetLogMaskList +{ + uint32_t count; // in: number of allocated elements in masks array. out: number of written elements in the array + XnFwLogMask* masks; +} XnCommandGetLogMaskList; + +typedef struct XnCommandSetLogMaskState +{ + uint32_t mask; + bool enabled; +} XnCommandSetLogMaskState; + +typedef struct XnCommandDebugData +{ + uint16_t dataID; // Values come from XnLinkInternalPropID + uint16_t dataSize; // in: size of allocated buffer in data, out: actual bytes written to data + uint8_t* data; +} XnCommandDebugData; + +#pragma pack (pop) + +#endif // PRIMESENSE_H diff --git a/src/ros_astra_camera/include/openni2/Win32/OniPlatformWin32.h b/src/ros_astra_camera/include/openni2/Win32/OniPlatformWin32.h new file mode 100644 index 0000000..dfb8953 --- /dev/null +++ b/src/ros_astra_camera/include/openni2/Win32/OniPlatformWin32.h @@ -0,0 +1,139 @@ +/***************************************************************************** +* * +* OpenNI 2.x Alpha * +* Copyright (C) 2012 PrimeSense Ltd. * +* * +* This file is part of OpenNI. * +* * +* Licensed under the Apache License, Version 2.0 (the "License"); * +* you may not use this file except in compliance with the License. * +* You may obtain a copy of the License at * +* * +* http://www.apache.org/licenses/LICENSE-2.0 * +* * +* Unless required by applicable law or agreed to in writing, software * +* distributed under the License is distributed on an "AS IS" BASIS, * +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * +* See the License for the specific language governing permissions and * +* limitations under the License. * +* * +*****************************************************************************/ +#ifndef ONIPLATFORMWIN32_H +#define ONIPLATFORMWIN32_H + +//--------------------------------------------------------------------------- +// Prerequisites +//--------------------------------------------------------------------------- +#ifndef WINVER // Allow use of features specific to Windows XP or later + #define WINVER 0x0501 +#endif +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later + #define _WIN32_WINNT 0x0501 +#endif +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later + #define _WIN32_WINDOWS 0x0410 +#endif +#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later + #define _WIN32_IE 0x0600 +#endif +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Undeprecate CRT functions +#ifndef _CRT_SECURE_NO_DEPRECATE + #define _CRT_SECURE_NO_DEPRECATE 1 +#endif + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if _MSC_VER < 1600 // Visual Studio 2008 and older doesn't have stdint.h... +typedef signed char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef __int64 int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned __int64 uint64_t; +#else +#include +#endif + +//--------------------------------------------------------------------------- +// Platform Basic Definition +//--------------------------------------------------------------------------- +#define ONI_PLATFORM ONI_PLATFORM_WIN32 +#define ONI_PLATFORM_STRING "Win32" + +//--------------------------------------------------------------------------- +// Platform Capabilities +//--------------------------------------------------------------------------- +#define ONI_PLATFORM_ENDIAN_TYPE ONI_PLATFORM_IS_LITTLE_ENDIAN + +#define ONI_PLATFORM_SUPPORTS_DYNAMIC_LIBS 1 + +//--------------------------------------------------------------------------- +// Memory +//--------------------------------------------------------------------------- +/** The default memory alignment. */ +#define ONI_DEFAULT_MEM_ALIGN 16 + +/** The thread static declarator (using TLS). */ +#define ONI_THREAD_STATIC __declspec(thread) + +//--------------------------------------------------------------------------- +// Files +//--------------------------------------------------------------------------- +/** The maximum allowed file path size (in bytes). */ +#define ONI_FILE_MAX_PATH MAX_PATH + +//--------------------------------------------------------------------------- +// Call backs +//--------------------------------------------------------------------------- +/** The std call type. */ +#define ONI_STDCALL __stdcall + +/** The call back calling convention. */ +#define ONI_CALLBACK_TYPE ONI_STDCALL + +/** The C and C++ calling convension. */ +#define ONI_C_DECL __cdecl + +//--------------------------------------------------------------------------- +// Macros +//--------------------------------------------------------------------------- +/** Returns the date and time at compile time. */ +#define ONI_TIMESTAMP __DATE__ " " __TIME__ + +/** Converts n into a pre-processor string. */ +#define ONI_STRINGIFY(n) ONI_STRINGIFY_HELPER(n) +#define ONI_STRINGIFY_HELPER(n) #n + +//--------------------------------------------------------------------------- +// API Export/Import Macros +//--------------------------------------------------------------------------- +/** Indicates an exported shared library function. */ +#define ONI_API_EXPORT __declspec(dllexport) + +/** Indicates an imported shared library function. */ +#define ONI_API_IMPORT __declspec(dllimport) + +/** Indicates a deprecated function */ +#if _MSC_VER < 1400 // Before VS2005 there was no support for declspec deprecated... + #define ONI_API_DEPRECATED(msg) +#else + #define ONI_API_DEPRECATED(msg) __declspec(deprecated(msg)) +#endif + +#endif // ONIPLATFORMWIN32_H diff --git a/src/ros_astra_camera/include/openni2_redist/arm/OpenNI.ini b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI.ini new file mode 100644 index 0000000..4bec19c --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI.ini @@ -0,0 +1,17 @@ +[Log] +; 0 - Verbose; 1 - Info; 2 - Warning; 3 - Error. Default - None +Verbosity=0 +LogToConsole=1 +;LogToFile=1 +;LogToAndroidLog=1 + +[Device] +;Override= +;RecordTo= + +[Drivers] +; Location of the drivers, relative to OpenNI shared library location. When not provided, "OpenNI2/Drivers" will be used. +;Repository=OpenNI2/Drivers + +; List of drivers to load, separated by commas. When not provided, OpenNI will try to load each shared library in Repository. +;List= diff --git a/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/OniFile.ini b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/OniFile.ini new file mode 100644 index 0000000..487c319 --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/OniFile.ini @@ -0,0 +1,7 @@ +;---------------- Player Configuration ------------------- +[Player] +; Speed. 1.0 - 1.0 * fps (default), Values can be R while R is real and grater the 0 +;Speed=1.0 + +; Repeat. 1 - on (default), 0 - off +;Repeat=1 \ No newline at end of file diff --git a/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/PSLink.ini b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/PSLink.ini new file mode 100644 index 0000000..577629b --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/PSLink.ini @@ -0,0 +1,48 @@ +;---------------- PSLink Driver Default Configuration ------------------- + +[Device] +; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines) +;UsbInterface=2 + +; Enable firmware logs. 0 - Off (default), 1 - On +;FirmwareLog=1 + +[Depth] +; Allows dumping all frames to files. 0 - Off (default), 1 - On +;DumpData=1 + +; Allow flipping the frame horizontally. 0 - Off, 1 - On (default) +;Mirror=0 + +; Compression of the data passed from device to host. 0 - None, 2 - 16z, 6 - 11-bit packed, 7 - 12-bit packed. Default is set by the firmware +;Compression=2 + +[Depth.VideoMode] +; Pixel Format. 100 - Depth 1 mm, 101 - Depth 100 um, 102 - Shifts 9.2, 103 - Shifts 9.3 +;PixelFormat=100 +; Requested X resolution +;XResolution=320 +; Requested Y resolution +;YResolution=240 +; Requested FPS +;FPS=30 + +[IR] +; Allows dumping all frames to files. 0 - Off (default), 1 - On +;DumpData=1 + +; Allow flipping the frame horizontally. 0 - Off, 1 - On (default) +;Mirror=0 + +; Compression of the data passed from device to host. 0 - None, 5 - 10-bit packed. Default is set by the firmware +;Compression=5 + +[IR.VideoMode] +; Pixel Format. 200 - RGB888, 202 - Grayscale 8-bit, 203 - Grayscale 16-bit +;PixelFormat=200 +; Requested X resolution +;XResolution=320 +; Requested Y resolution +;YResolution=240 +; Requested FPS +;FPS=30 diff --git a/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/libOniFile.so b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/libOniFile.so new file mode 100644 index 0000000..9dbee91 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/libOniFile.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/libPSLink.so b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/libPSLink.so new file mode 100644 index 0000000..80e13f0 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/libPSLink.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/liborbbec.so b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/liborbbec.so new file mode 100644 index 0000000..ac1dcef Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/liborbbec.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/orbbec.ini b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/orbbec.ini new file mode 100644 index 0000000..c620c94 --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/arm/OpenNI2/Drivers/orbbec.ini @@ -0,0 +1,183 @@ +;---------------- Sensor Default Configuration ------------------- +[Device] +; Mirroring. 0 - Off (default), 1 - On +;Mirror=1 + +; FrameSync. 0 - Off (default), 1 - On +;FrameSync=1 + +; Stream Data Timestamps. 0 - milliseconds, 1 - microseconds (default) +;HighResTimestamps=1 + +; Stream Data Timestamps Source. 0 - Firmware (default), 1 - Host +;HostTimestamps=0 + +; A filter for the firmware log. Default is determined by firmware. +;FirmwareLogFilter=0 + +; Automatic firmare log retrieval. 0 - Off (default), or the number of milliseconds between log retrievals operations. +;FirmwareLogInterval=1000 + +; Print firmware log to console when automatic firmware log retrieval is on. 0 - Off (default), 1 - On +;FirmwareLogPrint=1 + +; Is APC enabled. 0 - Off, 1 - On (default) +;APCEnabled=1 + +; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines), 3 - ISO endpoints for low-bandwidth depth +UsbInterface=2 + +[Depth] +; Output format. 100 - 1mm depth values (default), 102 - u9.2 Shift values. +;OutputFormat=100 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA, 1 - VGA, 4 - QQVGA. Default: Arm - 4, other platforms - 0, -14 1280x720, 15 1280x960,-16 1280x800, -17 640x400 -20 320x200,-21 480x640, -25 960x1280, -26 800x1280,-27 400x640 +Resolution=1 + +; Frames per second (default is 30) +;FPS=30 + +; Min depth cutoff. 0-10000 mm (default is 0) +;MinDepthValue=0 + +; Max depth cutoff. 0-10000 mm (default is 10000) +;MaxDepthValue=10000 + +; Input format. 0 - Uncompressed 16-bit, 1 - PS Compression,2 - Packed 10-bit, 3 - Packed 11-bit, 4 - Packed 12-bit. Default: Arm - 4, other platforms - 3 +InputFormat=3 + +; Registration. 0 - Off (default), 1 - On +;Registration=1 + +; Registration Type. 0 - Don't care (default), 1 - use hardware accelaration, 2 - perform in software +;RegistrationType=0 + +; software filter 0-off ,1--on (default) +;SoftFilter=0 + +; Depth Rotate 0-off(default) ,1--on (only atlas device support) +;DepthRotate=0 + +;Read Params (for test only) +;ReadParams=0 + +; dual sensor: 5.96 mm +;focallength=5.96 + +;dual sensor: 0.0052mm +;dPlanePixelSize=0.113967 + +;dPlaneDistance=130 + +;dual sensor: 75mm +;dEmitterDcmosDistance=7.500000 + +;dhorizontalFov=0.022600 + +;dverticalFov=0.796616 + + +; Hole Filler. 0 - Off, 1 - On (default) +;HoleFilter=0 + +; White Balance. 0 - Off, 1 - On (default) +;WhiteBalancedEnabled=0 + +; Gain. 0-50 (0 - Auto, 1 - Min., 50 - Max.). Default value is set by firmware. +;Gain=0 + +; Close Range Mode. 0 - Off (default), 1 - On +;CloseRange=1 + +; GMC Mode. 0 - Off, 1 - On (default) +;GMCMode=0 + +; GMC Debug. 0 - Off (default), 1 - On +;GMCDebug=1 + +; Depth Auto Gain Region-of-Interest. Default values are set by firmware. +;DepthAGCBin0MinDepth=500 +;DepthAGCBin0MaxDepth=800 +;DepthAGCBin1MinDepth=1500 +;DepthAGCBin1MaxDepth=1800 +;DepthAGCBin2MinDepth=2500 +;DepthAGCBin2MaxDepth=2800 +;DepthAGCBin3MinDepth=3500 +;DepthAGCBin3MaxDepth=3800 + +; Wavelength Correction Mechanism. 0 - Off (default), 1 - On +;WavelengthCorrection=1 + +; Wavelength Correction debug info. 0 - Off (default), 1 - On +;WavelengthCorrectionDebug=1 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=2 + +; Cropping area +[Depth.Cropping] +OffsetX=0 +OffsetY=0 +SizeX=320 +SizeY=240 +;Enabled=1 + +[Image] +; Output format. 200 - RGB888 (default), 201 - YUV422, 202 - Gray8 (2.0 MP only), 205 - YUYV +;OutputFormat=201 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA (default), 1 - VGA, 2 - SXGA (1.3MP), 3 - UXGA (2.0MP), 14 - 720p, 15 - 1280x960 +Resolution=1 + +; Frames per second (default is 30) +;FPS=30 + +; Input format. 0 - Compressed 8-bit BAYER (1.3MP or 2.0MP only), 1 - Compressed YUV422 (default in BULK), 2 - Jpeg, 5 - Uncompressed YUV422 (default in ISO), 6 - Uncompressed 8-bit BAYER (1.3MP or 2.0MP only), 7 - Uncompressed YUYV +InputFormat=5 + +; Anti Flicker. 0 - Off (default), 50 - 50Hz, 60 - 60 Hz. +;Flicker=50 + +; Image quality when using Jpeg. 1-10 (1 - Lowest, 10 - Highest (default)) +;Quality=10 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=1 + +; Cropping area +[Image.Cropping] +;OffsetX=0 +;OffsetY=0 +;SizeX=320 +;SizeY=240 +;Enabled=1 + +[IR] +; Output format. 200 - RGB888, 203 - Grayscale 16-bit (default) +;OutputFormat=203 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA (default), 1 - VGA, 2 - SXGA(1.3MP), 4 - QQVGA. -14 1280x720, 15 1280x960,-16 1280x800, -17 640x400 -20 320x200,-21 480x640, -25 960x1280, -26 800x1280,-27 400x640 +Resolution=1 + +; Frames per second (default is 30) +;FPS=30 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=1 + +; Cropping area +[IR.Cropping] +;OffsetX=0 +;OffsetY=0 +;SizeX=320 +;SizeY=240 +;Enabled=1 diff --git a/src/ros_astra_camera/include/openni2_redist/arm/libMWClosestPoint.so b/src/ros_astra_camera/include/openni2_redist/arm/libMWClosestPoint.so new file mode 100644 index 0000000..91b684c Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm/libMWClosestPoint.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm/libOpenNI2.jni.so b/src/ros_astra_camera/include/openni2_redist/arm/libOpenNI2.jni.so new file mode 100644 index 0000000..092a8f0 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm/libOpenNI2.jni.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm/libOpenNI2.so b/src/ros_astra_camera/include/openni2_redist/arm/libOpenNI2.so new file mode 100644 index 0000000..905195c Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm/libOpenNI2.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm/org.openni.jar b/src/ros_astra_camera/include/openni2_redist/arm/org.openni.jar new file mode 100644 index 0000000..73c6f65 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm/org.openni.jar differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI.ini b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI.ini new file mode 100644 index 0000000..4bec19c --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI.ini @@ -0,0 +1,17 @@ +[Log] +; 0 - Verbose; 1 - Info; 2 - Warning; 3 - Error. Default - None +Verbosity=0 +LogToConsole=1 +;LogToFile=1 +;LogToAndroidLog=1 + +[Device] +;Override= +;RecordTo= + +[Drivers] +; Location of the drivers, relative to OpenNI shared library location. When not provided, "OpenNI2/Drivers" will be used. +;Repository=OpenNI2/Drivers + +; List of drivers to load, separated by commas. When not provided, OpenNI will try to load each shared library in Repository. +;List= diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/OniFile.ini b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/OniFile.ini new file mode 100644 index 0000000..487c319 --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/OniFile.ini @@ -0,0 +1,7 @@ +;---------------- Player Configuration ------------------- +[Player] +; Speed. 1.0 - 1.0 * fps (default), Values can be R while R is real and grater the 0 +;Speed=1.0 + +; Repeat. 1 - on (default), 0 - off +;Repeat=1 \ No newline at end of file diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/PSLink.ini b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/PSLink.ini new file mode 100644 index 0000000..577629b --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/PSLink.ini @@ -0,0 +1,48 @@ +;---------------- PSLink Driver Default Configuration ------------------- + +[Device] +; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines) +;UsbInterface=2 + +; Enable firmware logs. 0 - Off (default), 1 - On +;FirmwareLog=1 + +[Depth] +; Allows dumping all frames to files. 0 - Off (default), 1 - On +;DumpData=1 + +; Allow flipping the frame horizontally. 0 - Off, 1 - On (default) +;Mirror=0 + +; Compression of the data passed from device to host. 0 - None, 2 - 16z, 6 - 11-bit packed, 7 - 12-bit packed. Default is set by the firmware +;Compression=2 + +[Depth.VideoMode] +; Pixel Format. 100 - Depth 1 mm, 101 - Depth 100 um, 102 - Shifts 9.2, 103 - Shifts 9.3 +;PixelFormat=100 +; Requested X resolution +;XResolution=320 +; Requested Y resolution +;YResolution=240 +; Requested FPS +;FPS=30 + +[IR] +; Allows dumping all frames to files. 0 - Off (default), 1 - On +;DumpData=1 + +; Allow flipping the frame horizontally. 0 - Off, 1 - On (default) +;Mirror=0 + +; Compression of the data passed from device to host. 0 - None, 5 - 10-bit packed. Default is set by the firmware +;Compression=5 + +[IR.VideoMode] +; Pixel Format. 200 - RGB888, 202 - Grayscale 8-bit, 203 - Grayscale 16-bit +;PixelFormat=200 +; Requested X resolution +;XResolution=320 +; Requested Y resolution +;YResolution=240 +; Requested FPS +;FPS=30 diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/libOniFile.so b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/libOniFile.so new file mode 100644 index 0000000..bbf91a5 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/libOniFile.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/libPSLink.so b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/libPSLink.so new file mode 100644 index 0000000..93f6069 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/libPSLink.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/liborbbec.so b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/liborbbec.so new file mode 100644 index 0000000..c4815e0 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/liborbbec.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/orbbec.ini b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/orbbec.ini new file mode 100644 index 0000000..c620c94 --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/arm64/OpenNI2/Drivers/orbbec.ini @@ -0,0 +1,183 @@ +;---------------- Sensor Default Configuration ------------------- +[Device] +; Mirroring. 0 - Off (default), 1 - On +;Mirror=1 + +; FrameSync. 0 - Off (default), 1 - On +;FrameSync=1 + +; Stream Data Timestamps. 0 - milliseconds, 1 - microseconds (default) +;HighResTimestamps=1 + +; Stream Data Timestamps Source. 0 - Firmware (default), 1 - Host +;HostTimestamps=0 + +; A filter for the firmware log. Default is determined by firmware. +;FirmwareLogFilter=0 + +; Automatic firmare log retrieval. 0 - Off (default), or the number of milliseconds between log retrievals operations. +;FirmwareLogInterval=1000 + +; Print firmware log to console when automatic firmware log retrieval is on. 0 - Off (default), 1 - On +;FirmwareLogPrint=1 + +; Is APC enabled. 0 - Off, 1 - On (default) +;APCEnabled=1 + +; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines), 3 - ISO endpoints for low-bandwidth depth +UsbInterface=2 + +[Depth] +; Output format. 100 - 1mm depth values (default), 102 - u9.2 Shift values. +;OutputFormat=100 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA, 1 - VGA, 4 - QQVGA. Default: Arm - 4, other platforms - 0, -14 1280x720, 15 1280x960,-16 1280x800, -17 640x400 -20 320x200,-21 480x640, -25 960x1280, -26 800x1280,-27 400x640 +Resolution=1 + +; Frames per second (default is 30) +;FPS=30 + +; Min depth cutoff. 0-10000 mm (default is 0) +;MinDepthValue=0 + +; Max depth cutoff. 0-10000 mm (default is 10000) +;MaxDepthValue=10000 + +; Input format. 0 - Uncompressed 16-bit, 1 - PS Compression,2 - Packed 10-bit, 3 - Packed 11-bit, 4 - Packed 12-bit. Default: Arm - 4, other platforms - 3 +InputFormat=3 + +; Registration. 0 - Off (default), 1 - On +;Registration=1 + +; Registration Type. 0 - Don't care (default), 1 - use hardware accelaration, 2 - perform in software +;RegistrationType=0 + +; software filter 0-off ,1--on (default) +;SoftFilter=0 + +; Depth Rotate 0-off(default) ,1--on (only atlas device support) +;DepthRotate=0 + +;Read Params (for test only) +;ReadParams=0 + +; dual sensor: 5.96 mm +;focallength=5.96 + +;dual sensor: 0.0052mm +;dPlanePixelSize=0.113967 + +;dPlaneDistance=130 + +;dual sensor: 75mm +;dEmitterDcmosDistance=7.500000 + +;dhorizontalFov=0.022600 + +;dverticalFov=0.796616 + + +; Hole Filler. 0 - Off, 1 - On (default) +;HoleFilter=0 + +; White Balance. 0 - Off, 1 - On (default) +;WhiteBalancedEnabled=0 + +; Gain. 0-50 (0 - Auto, 1 - Min., 50 - Max.). Default value is set by firmware. +;Gain=0 + +; Close Range Mode. 0 - Off (default), 1 - On +;CloseRange=1 + +; GMC Mode. 0 - Off, 1 - On (default) +;GMCMode=0 + +; GMC Debug. 0 - Off (default), 1 - On +;GMCDebug=1 + +; Depth Auto Gain Region-of-Interest. Default values are set by firmware. +;DepthAGCBin0MinDepth=500 +;DepthAGCBin0MaxDepth=800 +;DepthAGCBin1MinDepth=1500 +;DepthAGCBin1MaxDepth=1800 +;DepthAGCBin2MinDepth=2500 +;DepthAGCBin2MaxDepth=2800 +;DepthAGCBin3MinDepth=3500 +;DepthAGCBin3MaxDepth=3800 + +; Wavelength Correction Mechanism. 0 - Off (default), 1 - On +;WavelengthCorrection=1 + +; Wavelength Correction debug info. 0 - Off (default), 1 - On +;WavelengthCorrectionDebug=1 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=2 + +; Cropping area +[Depth.Cropping] +OffsetX=0 +OffsetY=0 +SizeX=320 +SizeY=240 +;Enabled=1 + +[Image] +; Output format. 200 - RGB888 (default), 201 - YUV422, 202 - Gray8 (2.0 MP only), 205 - YUYV +;OutputFormat=201 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA (default), 1 - VGA, 2 - SXGA (1.3MP), 3 - UXGA (2.0MP), 14 - 720p, 15 - 1280x960 +Resolution=1 + +; Frames per second (default is 30) +;FPS=30 + +; Input format. 0 - Compressed 8-bit BAYER (1.3MP or 2.0MP only), 1 - Compressed YUV422 (default in BULK), 2 - Jpeg, 5 - Uncompressed YUV422 (default in ISO), 6 - Uncompressed 8-bit BAYER (1.3MP or 2.0MP only), 7 - Uncompressed YUYV +InputFormat=5 + +; Anti Flicker. 0 - Off (default), 50 - 50Hz, 60 - 60 Hz. +;Flicker=50 + +; Image quality when using Jpeg. 1-10 (1 - Lowest, 10 - Highest (default)) +;Quality=10 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=1 + +; Cropping area +[Image.Cropping] +;OffsetX=0 +;OffsetY=0 +;SizeX=320 +;SizeY=240 +;Enabled=1 + +[IR] +; Output format. 200 - RGB888, 203 - Grayscale 16-bit (default) +;OutputFormat=203 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA (default), 1 - VGA, 2 - SXGA(1.3MP), 4 - QQVGA. -14 1280x720, 15 1280x960,-16 1280x800, -17 640x400 -20 320x200,-21 480x640, -25 960x1280, -26 800x1280,-27 400x640 +Resolution=1 + +; Frames per second (default is 30) +;FPS=30 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=1 + +; Cropping area +[IR.Cropping] +;OffsetX=0 +;OffsetY=0 +;SizeX=320 +;SizeY=240 +;Enabled=1 diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/libMWClosestPoint.so b/src/ros_astra_camera/include/openni2_redist/arm64/libMWClosestPoint.so new file mode 100644 index 0000000..464bb2a Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm64/libMWClosestPoint.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/libOpenNI2.jni.so b/src/ros_astra_camera/include/openni2_redist/arm64/libOpenNI2.jni.so new file mode 100644 index 0000000..63f519f Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm64/libOpenNI2.jni.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/libOpenNI2.so b/src/ros_astra_camera/include/openni2_redist/arm64/libOpenNI2.so new file mode 100644 index 0000000..a38685f Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm64/libOpenNI2.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/arm64/org.openni.jar b/src/ros_astra_camera/include/openni2_redist/arm64/org.openni.jar new file mode 100644 index 0000000..a64cbb5 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/arm64/org.openni.jar differ diff --git a/src/ros_astra_camera/include/openni2_redist/x64/OpenNI.ini b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI.ini new file mode 100644 index 0000000..4bec19c --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI.ini @@ -0,0 +1,17 @@ +[Log] +; 0 - Verbose; 1 - Info; 2 - Warning; 3 - Error. Default - None +Verbosity=0 +LogToConsole=1 +;LogToFile=1 +;LogToAndroidLog=1 + +[Device] +;Override= +;RecordTo= + +[Drivers] +; Location of the drivers, relative to OpenNI shared library location. When not provided, "OpenNI2/Drivers" will be used. +;Repository=OpenNI2/Drivers + +; List of drivers to load, separated by commas. When not provided, OpenNI will try to load each shared library in Repository. +;List= diff --git a/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/OniFile.ini b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/OniFile.ini new file mode 100644 index 0000000..487c319 --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/OniFile.ini @@ -0,0 +1,7 @@ +;---------------- Player Configuration ------------------- +[Player] +; Speed. 1.0 - 1.0 * fps (default), Values can be R while R is real and grater the 0 +;Speed=1.0 + +; Repeat. 1 - on (default), 0 - off +;Repeat=1 \ No newline at end of file diff --git a/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/PSLink.ini b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/PSLink.ini new file mode 100644 index 0000000..577629b --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/PSLink.ini @@ -0,0 +1,48 @@ +;---------------- PSLink Driver Default Configuration ------------------- + +[Device] +; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines) +;UsbInterface=2 + +; Enable firmware logs. 0 - Off (default), 1 - On +;FirmwareLog=1 + +[Depth] +; Allows dumping all frames to files. 0 - Off (default), 1 - On +;DumpData=1 + +; Allow flipping the frame horizontally. 0 - Off, 1 - On (default) +;Mirror=0 + +; Compression of the data passed from device to host. 0 - None, 2 - 16z, 6 - 11-bit packed, 7 - 12-bit packed. Default is set by the firmware +;Compression=2 + +[Depth.VideoMode] +; Pixel Format. 100 - Depth 1 mm, 101 - Depth 100 um, 102 - Shifts 9.2, 103 - Shifts 9.3 +;PixelFormat=100 +; Requested X resolution +;XResolution=320 +; Requested Y resolution +;YResolution=240 +; Requested FPS +;FPS=30 + +[IR] +; Allows dumping all frames to files. 0 - Off (default), 1 - On +;DumpData=1 + +; Allow flipping the frame horizontally. 0 - Off, 1 - On (default) +;Mirror=0 + +; Compression of the data passed from device to host. 0 - None, 5 - 10-bit packed. Default is set by the firmware +;Compression=5 + +[IR.VideoMode] +; Pixel Format. 200 - RGB888, 202 - Grayscale 8-bit, 203 - Grayscale 16-bit +;PixelFormat=200 +; Requested X resolution +;XResolution=320 +; Requested Y resolution +;YResolution=240 +; Requested FPS +;FPS=30 diff --git a/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/libOniFile.so b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/libOniFile.so new file mode 100644 index 0000000..047e19d Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/libOniFile.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/libPSLink.so b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/libPSLink.so new file mode 100644 index 0000000..fcc666c Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/libPSLink.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/liborbbec.so b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/liborbbec.so new file mode 100644 index 0000000..9c575d6 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/liborbbec.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/orbbec.ini b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/orbbec.ini new file mode 100644 index 0000000..336914e --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/x64/OpenNI2/Drivers/orbbec.ini @@ -0,0 +1,183 @@ +;---------------- Sensor Default Configuration ------------------- +[Device] +; Mirroring. 0 - Off (default), 1 - On +;Mirror=1 + +; FrameSync. 0 - Off (default), 1 - On +;FrameSync=1 + +; Stream Data Timestamps. 0 - milliseconds, 1 - microseconds (default) +;HighResTimestamps=1 + +; Stream Data Timestamps Source. 0 - Firmware (default), 1 - Host +;HostTimestamps=0 + +; A filter for the firmware log. Default is determined by firmware. +;FirmwareLogFilter=0 + +; Automatic firmare log retrieval. 0 - Off (default), or the number of milliseconds between log retrievals operations. +;FirmwareLogInterval=1000 + +; Print firmware log to console when automatic firmware log retrieval is on. 0 - Off (default), 1 - On +;FirmwareLogPrint=1 + +; Is APC enabled. 0 - Off, 1 - On (default) +;APCEnabled=1 + +; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines), 3 - ISO endpoints for low-bandwidth depth +UsbInterface=2 + +[Depth] +; Output format. 100 - 1mm depth values (default), 102 - u9.2 Shift values. +;OutputFormat=100 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA, 1 - VGA, 4 - QQVGA. Default: Arm - 4, other platforms - 0, -14 1280x720, 15 1280x960,-16 1280x800, -17 640x400 -20 320x200,-21 480x640, -25 960x1280, -26 800x1280,-27 400x640 +Resolution=17 + +; Frames per second (default is 30) +;FPS=30 + +; Min depth cutoff. 0-10000 mm (default is 0) +;MinDepthValue=0 + +; Max depth cutoff. 0-10000 mm (default is 10000) +;MaxDepthValue=10000 + +; Input format. 0 - Uncompressed 16-bit, 1 - PS Compression,2 - Packed 10-bit, 3 - Packed 11-bit, 4 - Packed 12-bit. Default: Arm - 4, other platforms - 3 +InputFormat=3 + +; Registration. 0 - Off (default), 1 - On +;Registration=1 + +; Registration Type. 0 - Don't care (default), 1 - use hardware accelaration, 2 - perform in software +;RegistrationType=0 + +; software filter 0-off ,1--on (default) +;SoftFilter=0 + +; Depth Rotate 0-off(default) ,1--on (only atlas device support) +;DepthRotate=0 + +;Read Params (for test only) +;ReadParams=0 + +; dual sensor: 5.96 mm +;focallength=5.96 + +;dual sensor: 0.0052mm +;dPlanePixelSize=0.113967 + +;dPlaneDistance=130 + +;dual sensor: 75mm +;dEmitterDcmosDistance=7.500000 + +;dhorizontalFov=0.022600 + +;dverticalFov=0.796616 + + +; Hole Filler. 0 - Off, 1 - On (default) +;HoleFilter=0 + +; White Balance. 0 - Off, 1 - On (default) +;WhiteBalancedEnabled=0 + +; Gain. 0-50 (0 - Auto, 1 - Min., 50 - Max.). Default value is set by firmware. +;Gain=0 + +; Close Range Mode. 0 - Off (default), 1 - On +;CloseRange=1 + +; GMC Mode. 0 - Off, 1 - On (default) +;GMCMode=0 + +; GMC Debug. 0 - Off (default), 1 - On +;GMCDebug=1 + +; Depth Auto Gain Region-of-Interest. Default values are set by firmware. +;DepthAGCBin0MinDepth=500 +;DepthAGCBin0MaxDepth=800 +;DepthAGCBin1MinDepth=1500 +;DepthAGCBin1MaxDepth=1800 +;DepthAGCBin2MinDepth=2500 +;DepthAGCBin2MaxDepth=2800 +;DepthAGCBin3MinDepth=3500 +;DepthAGCBin3MaxDepth=3800 + +; Wavelength Correction Mechanism. 0 - Off (default), 1 - On +;WavelengthCorrection=1 + +; Wavelength Correction debug info. 0 - Off (default), 1 - On +;WavelengthCorrectionDebug=1 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=2 + +; Cropping area +[Depth.Cropping] +OffsetX=0 +OffsetY=0 +SizeX=320 +SizeY=240 +;Enabled=1 + +[Image] +; Output format. 200 - RGB888 (default), 201 - YUV422, 202 - Gray8 (2.0 MP only), 205 - YUYV +;OutputFormat=201 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA (default), 1 - VGA, 2 - SXGA (1.3MP), 3 - UXGA (2.0MP), 14 - 720p, 15 - 1280x960 +Resolution=1 + +; Frames per second (default is 30) +;FPS=30 + +; Input format. 0 - Compressed 8-bit BAYER (1.3MP or 2.0MP only), 1 - Compressed YUV422 (default in BULK), 2 - Jpeg, 5 - Uncompressed YUV422 (default in ISO), 6 - Uncompressed 8-bit BAYER (1.3MP or 2.0MP only), 7 - Uncompressed YUYV +InputFormat=5 + +; Anti Flicker. 0 - Off (default), 50 - 50Hz, 60 - 60 Hz. +;Flicker=50 + +; Image quality when using Jpeg. 1-10 (1 - Lowest, 10 - Highest (default)) +;Quality=10 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=1 + +; Cropping area +[Image.Cropping] +;OffsetX=0 +;OffsetY=0 +;SizeX=320 +;SizeY=240 +;Enabled=1 + +[IR] +; Output format. 200 - RGB888, 203 - Grayscale 16-bit (default) +;OutputFormat=203 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA (default), 1 - VGA, 2 - SXGA(1.3MP), 4 - QQVGA. -14 1280x720, 15 1280x960,-16 1280x800, -17 640x400 -20 320x200,-21 480x640, -25 960x1280, -26 800x1280,-27 400x640 +Resolution=17 + +; Frames per second (default is 30) +;FPS=30 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=1 + +; Cropping area +[IR.Cropping] +;OffsetX=0 +;OffsetY=0 +;SizeX=320 +;SizeY=240 +;Enabled=1 diff --git a/src/ros_astra_camera/include/openni2_redist/x64/libDepthUtils.a b/src/ros_astra_camera/include/openni2_redist/x64/libDepthUtils.a new file mode 100644 index 0000000..5bd9def Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x64/libDepthUtils.a differ diff --git a/src/ros_astra_camera/include/openni2_redist/x64/libMWClosestPoint.so b/src/ros_astra_camera/include/openni2_redist/x64/libMWClosestPoint.so new file mode 100644 index 0000000..1406d9e Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x64/libMWClosestPoint.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x64/libOpenNI2.jni.so b/src/ros_astra_camera/include/openni2_redist/x64/libOpenNI2.jni.so new file mode 100644 index 0000000..addb524 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x64/libOpenNI2.jni.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x64/libOpenNI2.so b/src/ros_astra_camera/include/openni2_redist/x64/libOpenNI2.so new file mode 100644 index 0000000..1a4e828 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x64/libOpenNI2.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x64/org.openni.jar b/src/ros_astra_camera/include/openni2_redist/x64/org.openni.jar new file mode 100644 index 0000000..facc51c Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x64/org.openni.jar differ diff --git a/src/ros_astra_camera/include/openni2_redist/x86/OpenNI.ini b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI.ini new file mode 100644 index 0000000..4bec19c --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI.ini @@ -0,0 +1,17 @@ +[Log] +; 0 - Verbose; 1 - Info; 2 - Warning; 3 - Error. Default - None +Verbosity=0 +LogToConsole=1 +;LogToFile=1 +;LogToAndroidLog=1 + +[Device] +;Override= +;RecordTo= + +[Drivers] +; Location of the drivers, relative to OpenNI shared library location. When not provided, "OpenNI2/Drivers" will be used. +;Repository=OpenNI2/Drivers + +; List of drivers to load, separated by commas. When not provided, OpenNI will try to load each shared library in Repository. +;List= diff --git a/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/OniFile.ini b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/OniFile.ini new file mode 100644 index 0000000..487c319 --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/OniFile.ini @@ -0,0 +1,7 @@ +;---------------- Player Configuration ------------------- +[Player] +; Speed. 1.0 - 1.0 * fps (default), Values can be R while R is real and grater the 0 +;Speed=1.0 + +; Repeat. 1 - on (default), 0 - off +;Repeat=1 \ No newline at end of file diff --git a/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/PSLink.ini b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/PSLink.ini new file mode 100644 index 0000000..577629b --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/PSLink.ini @@ -0,0 +1,48 @@ +;---------------- PSLink Driver Default Configuration ------------------- + +[Device] +; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines) +;UsbInterface=2 + +; Enable firmware logs. 0 - Off (default), 1 - On +;FirmwareLog=1 + +[Depth] +; Allows dumping all frames to files. 0 - Off (default), 1 - On +;DumpData=1 + +; Allow flipping the frame horizontally. 0 - Off, 1 - On (default) +;Mirror=0 + +; Compression of the data passed from device to host. 0 - None, 2 - 16z, 6 - 11-bit packed, 7 - 12-bit packed. Default is set by the firmware +;Compression=2 + +[Depth.VideoMode] +; Pixel Format. 100 - Depth 1 mm, 101 - Depth 100 um, 102 - Shifts 9.2, 103 - Shifts 9.3 +;PixelFormat=100 +; Requested X resolution +;XResolution=320 +; Requested Y resolution +;YResolution=240 +; Requested FPS +;FPS=30 + +[IR] +; Allows dumping all frames to files. 0 - Off (default), 1 - On +;DumpData=1 + +; Allow flipping the frame horizontally. 0 - Off, 1 - On (default) +;Mirror=0 + +; Compression of the data passed from device to host. 0 - None, 5 - 10-bit packed. Default is set by the firmware +;Compression=5 + +[IR.VideoMode] +; Pixel Format. 200 - RGB888, 202 - Grayscale 8-bit, 203 - Grayscale 16-bit +;PixelFormat=200 +; Requested X resolution +;XResolution=320 +; Requested Y resolution +;YResolution=240 +; Requested FPS +;FPS=30 diff --git a/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/libOniFile.so b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/libOniFile.so new file mode 100644 index 0000000..6f62efe Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/libOniFile.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/libPSLink.so b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/libPSLink.so new file mode 100644 index 0000000..6125a94 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/libPSLink.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/liborbbec.so b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/liborbbec.so new file mode 100644 index 0000000..602f508 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/liborbbec.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/orbbec.ini b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/orbbec.ini new file mode 100644 index 0000000..c620c94 --- /dev/null +++ b/src/ros_astra_camera/include/openni2_redist/x86/OpenNI2/Drivers/orbbec.ini @@ -0,0 +1,183 @@ +;---------------- Sensor Default Configuration ------------------- +[Device] +; Mirroring. 0 - Off (default), 1 - On +;Mirror=1 + +; FrameSync. 0 - Off (default), 1 - On +;FrameSync=1 + +; Stream Data Timestamps. 0 - milliseconds, 1 - microseconds (default) +;HighResTimestamps=1 + +; Stream Data Timestamps Source. 0 - Firmware (default), 1 - Host +;HostTimestamps=0 + +; A filter for the firmware log. Default is determined by firmware. +;FirmwareLogFilter=0 + +; Automatic firmare log retrieval. 0 - Off (default), or the number of milliseconds between log retrievals operations. +;FirmwareLogInterval=1000 + +; Print firmware log to console when automatic firmware log retrieval is on. 0 - Off (default), 1 - On +;FirmwareLogPrint=1 + +; Is APC enabled. 0 - Off, 1 - On (default) +;APCEnabled=1 + +; USB interface to be used. 0 - FW Default, 1 - ISO endpoints (default on Windows), 2 - BULK endpoints (default on Linux/Mac/Android machines), 3 - ISO endpoints for low-bandwidth depth +UsbInterface=2 + +[Depth] +; Output format. 100 - 1mm depth values (default), 102 - u9.2 Shift values. +;OutputFormat=100 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA, 1 - VGA, 4 - QQVGA. Default: Arm - 4, other platforms - 0, -14 1280x720, 15 1280x960,-16 1280x800, -17 640x400 -20 320x200,-21 480x640, -25 960x1280, -26 800x1280,-27 400x640 +Resolution=1 + +; Frames per second (default is 30) +;FPS=30 + +; Min depth cutoff. 0-10000 mm (default is 0) +;MinDepthValue=0 + +; Max depth cutoff. 0-10000 mm (default is 10000) +;MaxDepthValue=10000 + +; Input format. 0 - Uncompressed 16-bit, 1 - PS Compression,2 - Packed 10-bit, 3 - Packed 11-bit, 4 - Packed 12-bit. Default: Arm - 4, other platforms - 3 +InputFormat=3 + +; Registration. 0 - Off (default), 1 - On +;Registration=1 + +; Registration Type. 0 - Don't care (default), 1 - use hardware accelaration, 2 - perform in software +;RegistrationType=0 + +; software filter 0-off ,1--on (default) +;SoftFilter=0 + +; Depth Rotate 0-off(default) ,1--on (only atlas device support) +;DepthRotate=0 + +;Read Params (for test only) +;ReadParams=0 + +; dual sensor: 5.96 mm +;focallength=5.96 + +;dual sensor: 0.0052mm +;dPlanePixelSize=0.113967 + +;dPlaneDistance=130 + +;dual sensor: 75mm +;dEmitterDcmosDistance=7.500000 + +;dhorizontalFov=0.022600 + +;dverticalFov=0.796616 + + +; Hole Filler. 0 - Off, 1 - On (default) +;HoleFilter=0 + +; White Balance. 0 - Off, 1 - On (default) +;WhiteBalancedEnabled=0 + +; Gain. 0-50 (0 - Auto, 1 - Min., 50 - Max.). Default value is set by firmware. +;Gain=0 + +; Close Range Mode. 0 - Off (default), 1 - On +;CloseRange=1 + +; GMC Mode. 0 - Off, 1 - On (default) +;GMCMode=0 + +; GMC Debug. 0 - Off (default), 1 - On +;GMCDebug=1 + +; Depth Auto Gain Region-of-Interest. Default values are set by firmware. +;DepthAGCBin0MinDepth=500 +;DepthAGCBin0MaxDepth=800 +;DepthAGCBin1MinDepth=1500 +;DepthAGCBin1MaxDepth=1800 +;DepthAGCBin2MinDepth=2500 +;DepthAGCBin2MaxDepth=2800 +;DepthAGCBin3MinDepth=3500 +;DepthAGCBin3MaxDepth=3800 + +; Wavelength Correction Mechanism. 0 - Off (default), 1 - On +;WavelengthCorrection=1 + +; Wavelength Correction debug info. 0 - Off (default), 1 - On +;WavelengthCorrectionDebug=1 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=2 + +; Cropping area +[Depth.Cropping] +OffsetX=0 +OffsetY=0 +SizeX=320 +SizeY=240 +;Enabled=1 + +[Image] +; Output format. 200 - RGB888 (default), 201 - YUV422, 202 - Gray8 (2.0 MP only), 205 - YUYV +;OutputFormat=201 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA (default), 1 - VGA, 2 - SXGA (1.3MP), 3 - UXGA (2.0MP), 14 - 720p, 15 - 1280x960 +Resolution=1 + +; Frames per second (default is 30) +;FPS=30 + +; Input format. 0 - Compressed 8-bit BAYER (1.3MP or 2.0MP only), 1 - Compressed YUV422 (default in BULK), 2 - Jpeg, 5 - Uncompressed YUV422 (default in ISO), 6 - Uncompressed 8-bit BAYER (1.3MP or 2.0MP only), 7 - Uncompressed YUYV +InputFormat=5 + +; Anti Flicker. 0 - Off (default), 50 - 50Hz, 60 - 60 Hz. +;Flicker=50 + +; Image quality when using Jpeg. 1-10 (1 - Lowest, 10 - Highest (default)) +;Quality=10 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=1 + +; Cropping area +[Image.Cropping] +;OffsetX=0 +;OffsetY=0 +;SizeX=320 +;SizeY=240 +;Enabled=1 + +[IR] +; Output format. 200 - RGB888, 203 - Grayscale 16-bit (default) +;OutputFormat=203 + +; Is stream mirrored. 0 - Off, 1 - On +;Mirror=1 + +; 0 - QVGA (default), 1 - VGA, 2 - SXGA(1.3MP), 4 - QQVGA. -14 1280x720, 15 1280x960,-16 1280x800, -17 640x400 -20 320x200,-21 480x640, -25 960x1280, -26 800x1280,-27 400x640 +Resolution=1 + +; Frames per second (default is 30) +;FPS=30 + +; Cropping mode. 1 - Normal (default), 2 - Increased FPS, 3 - Software only +;CroppingMode=1 + +; Cropping area +[IR.Cropping] +;OffsetX=0 +;OffsetY=0 +;SizeX=320 +;SizeY=240 +;Enabled=1 diff --git a/src/ros_astra_camera/include/openni2_redist/x86/libMWClosestPoint.so b/src/ros_astra_camera/include/openni2_redist/x86/libMWClosestPoint.so new file mode 100644 index 0000000..06a29ad Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x86/libMWClosestPoint.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x86/libOpenNI2.jni.so b/src/ros_astra_camera/include/openni2_redist/x86/libOpenNI2.jni.so new file mode 100644 index 0000000..4cd3263 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x86/libOpenNI2.jni.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x86/libOpenNI2.so b/src/ros_astra_camera/include/openni2_redist/x86/libOpenNI2.so new file mode 100644 index 0000000..aecab0c Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x86/libOpenNI2.so differ diff --git a/src/ros_astra_camera/include/openni2_redist/x86/org.openni.jar b/src/ros_astra_camera/include/openni2_redist/x86/org.openni.jar new file mode 100644 index 0000000..604b9f7 Binary files /dev/null and b/src/ros_astra_camera/include/openni2_redist/x86/org.openni.jar differ diff --git a/src/ros_astra_camera/launch/astra.launch b/src/ros_astra_camera/launch/astra.launch new file mode 100644 index 0000000..d5a7d84 --- /dev/null +++ b/src/ros_astra_camera/launch/astra.launch @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/astra_rgb.launch b/src/ros_astra_camera/launch/astra_rgb.launch new file mode 100644 index 0000000..432bbfe --- /dev/null +++ b/src/ros_astra_camera/launch/astra_rgb.launch @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/astra_tf_prefix.launch b/src/ros_astra_camera/launch/astra_tf_prefix.launch new file mode 100644 index 0000000..09b44ff --- /dev/null +++ b/src/ros_astra_camera/launch/astra_tf_prefix.launch @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/astrapro.launch b/src/ros_astra_camera/launch/astrapro.launch new file mode 100644 index 0000000..71bcec0 --- /dev/null +++ b/src/ros_astra_camera/launch/astrapro.launch @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/astraprosm.launch b/src/ros_astra_camera/launch/astraprosm.launch new file mode 100644 index 0000000..5cd5bb9 --- /dev/null +++ b/src/ros_astra_camera/launch/astraprosm.launch @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/embedded_s.launch b/src/ros_astra_camera/launch/embedded_s.launch new file mode 100644 index 0000000..11ad3b5 --- /dev/null +++ b/src/ros_astra_camera/launch/embedded_s.launch @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/includes/astra_frames.launch b/src/ros_astra_camera/launch/includes/astra_frames.launch new file mode 100644 index 0000000..5d1935c --- /dev/null +++ b/src/ros_astra_camera/launch/includes/astra_frames.launch @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/includes/color.launch b/src/ros_astra_camera/launch/includes/color.launch new file mode 100644 index 0000000..97966cf --- /dev/null +++ b/src/ros_astra_camera/launch/includes/color.launch @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/includes/depth.launch b/src/ros_astra_camera/launch/includes/depth.launch new file mode 100644 index 0000000..508b6d4 --- /dev/null +++ b/src/ros_astra_camera/launch/includes/depth.launch @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/includes/device.launch b/src/ros_astra_camera/launch/includes/device.launch new file mode 100644 index 0000000..98e91a5 --- /dev/null +++ b/src/ros_astra_camera/launch/includes/device.launch @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/includes/device.launch.xml b/src/ros_astra_camera/launch/includes/device.launch.xml new file mode 100644 index 0000000..df033ed --- /dev/null +++ b/src/ros_astra_camera/launch/includes/device.launch.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/includes/ir.launch b/src/ros_astra_camera/launch/includes/ir.launch new file mode 100644 index 0000000..8bde33c --- /dev/null +++ b/src/ros_astra_camera/launch/includes/ir.launch @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/includes/manager.launch b/src/ros_astra_camera/launch/includes/manager.launch new file mode 100644 index 0000000..2a134e9 --- /dev/null +++ b/src/ros_astra_camera/launch/includes/manager.launch @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/includes/pointclouds.launch b/src/ros_astra_camera/launch/includes/pointclouds.launch new file mode 100644 index 0000000..2115b89 --- /dev/null +++ b/src/ros_astra_camera/launch/includes/pointclouds.launch @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/includes/processing.launch b/src/ros_astra_camera/launch/includes/processing.launch new file mode 100644 index 0000000..3203e8a --- /dev/null +++ b/src/ros_astra_camera/launch/includes/processing.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/multi_astra.launch b/src/ros_astra_camera/launch/multi_astra.launch new file mode 100644 index 0000000..f6c1ef4 --- /dev/null +++ b/src/ros_astra_camera/launch/multi_astra.launch @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/stereo_s.launch b/src/ros_astra_camera/launch/stereo_s.launch new file mode 100644 index 0000000..d2f7b40 --- /dev/null +++ b/src/ros_astra_camera/launch/stereo_s.launch @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ros_astra_camera/launch/stereo_s_u3.launch b/src/ros_astra_camera/launch/stereo_s_u3.launch new file mode 100644 index 0000000..21fabcc --- /dev/null +++ b/src/ros_astra_camera/launch/stereo_s_u3.launch @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ros_astra_camera/package.xml b/src/ros_astra_camera/package.xml new file mode 100644 index 0000000..05e6b53 --- /dev/null +++ b/src/ros_astra_camera/package.xml @@ -0,0 +1,36 @@ + + + astra_camera + 0.3.0 + Drivers for Orbbec Astra Devices. + Tim Liu + Apache License 2.0 + Orbbec3D + + catkin + + camera_info_manager + git + libudev-dev + libusb-1.0-dev + nodelet + sensor_msgs + roscpp + dynamic_reconfigure + image_transport + message_generation + libuvc + + camera_info_manager + nodelet + dynamic_reconfigure + sensor_msgs + roscpp + image_transport + message_runtime + rgbd_launch + + + + + diff --git a/src/ros_astra_camera/ros/astra_camera_node.cpp b/src/ros_astra_camera/ros/astra_camera_node.cpp new file mode 100644 index 0000000..ec89e64 --- /dev/null +++ b/src/ros_astra_camera/ros/astra_camera_node.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#include "astra_camera/astra_driver.h" + +int main(int argc, char **argv){ + + ros::init(argc, argv, "astra_camera"); + ros::NodeHandle n; + ros::NodeHandle pnh("~"); + + astra_wrapper::AstraDriver drv(n, pnh); + + ros::spin(); + + return 0; +} diff --git a/src/ros_astra_camera/ros/astra_camera_nodelet.cpp b/src/ros_astra_camera/ros/astra_camera_nodelet.cpp new file mode 100644 index 0000000..6cf51de --- /dev/null +++ b/src/ros_astra_camera/ros/astra_camera_nodelet.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#include "astra_camera/astra_driver.h" +#include + +namespace astra_camera +{ + +class AstraDriverNodelet : public nodelet::Nodelet +{ +public: + AstraDriverNodelet() {}; + + ~AstraDriverNodelet() {} + +private: + virtual void onInit() + { + lp.reset(new astra_wrapper::AstraDriver(getNodeHandle(), getPrivateNodeHandle())); + }; + + boost::shared_ptr lp; +}; + +} + +#include +PLUGINLIB_EXPORT_CLASS(astra_camera::AstraDriverNodelet, nodelet::Nodelet) diff --git a/src/ros_astra_camera/scripts/create_udev_rules b/src/ros_astra_camera/scripts/create_udev_rules new file mode 100644 index 0000000..aceca5d --- /dev/null +++ b/src/ros_astra_camera/scripts/create_udev_rules @@ -0,0 +1,16 @@ +#!/bin/bash + +echo "" +echo "This script copies a udev rule to /etc to facilitate bringing" +echo "up the astra usb connection as /dev/astra*" +echo "" + +sudo cp `rospack find astra_camera`/56-orbbec-usb.rules /etc/udev/rules.d + + +echo "" +echo "Restarting udev" +echo "" +sudo service udev reload +sudo service udev restart +#sudo udevadm trigger --action=change diff --git a/src/ros_astra_camera/src/astra_convert.cpp b/src/ros_astra_camera/src/astra_convert.cpp new file mode 100644 index 0000000..a9376c1 --- /dev/null +++ b/src/ros_astra_camera/src/astra_convert.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#include "astra_camera/astra_convert.h" +#include "astra_camera/astra_exception.h" + +#include + +#include + +namespace astra_wrapper +{ + +const AstraDeviceInfo astra_convert(const openni::DeviceInfo* pInfo) +{ + if (!pInfo) + THROW_OPENNI_EXCEPTION("astra_convert called with zero pointer\n"); + + AstraDeviceInfo output; + + output.name_ = pInfo->getName(); + output.uri_ = pInfo->getUri(); + output.vendor_ = pInfo->getVendor(); + output.product_id_ = pInfo->getUsbProductId(); + output.vendor_id_ = pInfo->getUsbVendorId(); + + return output; +} + + +const AstraVideoMode astra_convert(const openni::VideoMode& input) +{ + AstraVideoMode output; + + output.x_resolution_ = input.getResolutionX(); + output.y_resolution_ = input.getResolutionY(); + output.frame_rate_ = input.getFps(); + output.pixel_format_ = static_cast(input.getPixelFormat()); + + return output; +} + +const openni::VideoMode astra_convert(const AstraVideoMode& input) +{ + openni::VideoMode output; + + output.setResolution(input.x_resolution_, input.y_resolution_); + output.setFps(input.frame_rate_); + output.setPixelFormat(static_cast(input.pixel_format_)); + + return output; +} + + +const std::vector astra_convert(const openni::Array& input) +{ + std::vector output; + + int size = input.getSize(); + + output.reserve(size); + + for (int i=0; i +#include + +#include "astra_camera/astra_driver.h" +#include "astra_camera/astra_device.h" +#include "astra_camera/astra_exception.h" +#include "astra_camera/astra_convert.h" +#include "astra_camera/astra_frame_listener.h" + +#include "openni2/PS1080.h" + +#include +#include + +#include +#include + +namespace astra_wrapper +{ + +AstraDevice::AstraDevice(const std::string& device_URI): + openni_device_(), + ir_video_started_(false), + color_video_started_(false), + depth_video_started_(false), + image_registration_activated_(false), + use_device_time_(false) +{ + openni::Status rc = openni::OpenNI::initialize(); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Initialize failed\n%s\n", openni::OpenNI::getExtendedError()); + + openni_device_ = boost::make_shared(); + + if (device_URI.length() > 0) + { + rc = openni_device_->open(device_URI.c_str()); + } + else + { + rc = openni_device_->open(openni::ANY_DEVICE); + } + + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Device open failed\n%s\n", openni::OpenNI::getExtendedError()); + + device_info_ = boost::make_shared(); + *device_info_ = openni_device_->getDeviceInfo(); + + int param_size = sizeof(OBCameraParams); + openni_device_->getProperty(openni::OBEXTENSION_ID_CAM_PARAMS, (uint8_t*)&m_CamParams, ¶m_size); + m_ParamsValid = true; + if (std::isnan(m_CamParams.l_intr_p[0]) || std::isnan(m_CamParams.l_intr_p[1]) || + std::isnan(m_CamParams.l_intr_p[2]) || std::isnan(m_CamParams.l_intr_p[3])) + { + m_ParamsValid = false; + } + + int serial_number_size = sizeof(serial_number); + memset(serial_number, 0, serial_number_size); + openni_device_->getProperty(openni::OBEXTENSION_ID_SERIALNUMBER, (uint8_t*)&serial_number, &serial_number_size); + + int device_type_size = sizeof(device_type); + memset(device_type, 0, device_type_size); + openni_device_->getProperty(openni::OBEXTENSION_ID_DEVICETYPE, (uint8_t*)&device_type, &device_type_size); + if (strcmp(device_type, OB_STEREO_S) == 0) + { + device_type_no = OB_STEREO_S_NO; + } + else if (strcmp(device_type, OB_EMBEDDED_S) == 0) + { + device_type_no = OB_EMBEDDED_S_NO; + } + else if (strcmp(device_type, OB_STEREO_S_U3) == 0) + { + device_type_no = OB_STEREO_S_U3_NO; + } + else if (strcmp(device_type, OB_ASTRA_PRO) == 0) + { + device_type_no = OB_ASTRA_PRO_NO; + } + else + { + device_type_no = OB_ASTRA_NO; + } + + ir_frame_listener = boost::make_shared(); + color_frame_listener = boost::make_shared(); + depth_frame_listener = boost::make_shared(); + +} + +AstraDevice::~AstraDevice() +{ + stopAllStreams(); + + shutdown(); + + openni_device_->close(); +} + +const std::string AstraDevice::getUri() const +{ + return std::string(device_info_->getUri()); +} + +const std::string AstraDevice::getVendor() const +{ + return std::string(device_info_->getVendor()); +} + +const std::string AstraDevice::getName() const +{ + return std::string(device_info_->getName()); +} + +uint16_t AstraDevice::getUsbVendorId() const +{ + return device_info_->getUsbVendorId(); +} + +uint16_t AstraDevice::getUsbProductId() const +{ + return device_info_->getUsbProductId(); +} + +const std::string AstraDevice::getStringID() const +{ + std::string ID_str = getName() + "_" + getVendor(); + + boost::replace_all(ID_str, "/", ""); + boost::replace_all(ID_str, ".", ""); + boost::replace_all(ID_str, "@", ""); + + return ID_str; +} + +bool AstraDevice::isValid() const +{ + return (openni_device_.get() != 0) && openni_device_->isValid(); +} + +OBCameraParams AstraDevice::getCameraParams() const +{ + return m_CamParams; +} + +bool AstraDevice::isCameraParamsValid() +{ + return m_ParamsValid; +} + +char* AstraDevice::getSerialNumber() +{ + return serial_number; +} + +char* AstraDevice::getDeviceType() +{ + return device_type; +} + +OB_DEVICE_NO AstraDevice::getDeviceTypeNo() +{ + return device_type_no; +} + +int AstraDevice::getIRGain() const +{ + int gain = 0; + int data_size = 4; + openni_device_->getProperty(openni::OBEXTENSION_ID_IR_GAIN, (uint8_t*)&gain, &data_size); + return gain; +} + +int AstraDevice::getIRExposure() const +{ + int exposure = 0; + int data_size = 4; + openni_device_->getProperty(openni::OBEXTENSION_ID_IR_EXP, (uint8_t*)&exposure, &data_size); + return exposure; +} + +void AstraDevice::setCameraParams(OBCameraParams param) +{ + int data_size = sizeof(OBCameraParams); + openni_device_->setProperty(openni::OBEXTENSION_ID_CAM_PARAMS, (uint8_t*)¶m, data_size); +} + +void AstraDevice::setIRGain(int gain) +{ + int data_size = 4; + openni_device_->setProperty(openni::OBEXTENSION_ID_IR_GAIN, (uint8_t*)&gain, data_size); +} + +void AstraDevice::setIRExposure(int exposure) +{ + int data_size = 4; + openni_device_->setProperty(openni::OBEXTENSION_ID_IR_EXP, (uint8_t*)&exposure, data_size); +} + +void AstraDevice::setLaser(bool enable) +{ + int data_size = 4; + int laser_enable = 1; + if (enable == false) + { + laser_enable = 0; + } + openni_device_->setProperty(openni::OBEXTENSION_ID_LASER_EN, (uint8_t*)&laser_enable, data_size); +} + +void AstraDevice::setIRFlood(bool enable) +{ + int data_size = 4; + int enable_ = 1; + if (enable == false) + { + enable_ = 0; + } + openni_device_->setProperty(XN_MODULE_PROPERTY_IRFLOOD_STATE, enable_); +} + +void AstraDevice::setLDP(bool enable) +{ + int data_size = 4; + int enable_ = 1; + if (enable == false) + { + enable_ = 0; + } + if (device_type_no == OB_STEREO_S_U3_NO) + { + openni_device_->setProperty(XN_MODULE_PROPERTY_LDP_ENABLE, (uint8_t *)&enable_, 4); + } + else + { + boost::shared_ptr depth_stream = getDepthVideoStream(); + boost::shared_ptr ir_stream = getIRVideoStream(); + depth_stream->stop(); + ir_stream->stop(); + openni_device_->setProperty(openni::OBEXTENSION_ID_LDP_EN, (uint8_t *)&enable_, 4); + depth_stream->start(); + ir_stream->start(); + } +} + +void AstraDevice::switchIRCamera(int cam) +{ + if (device_type_no == OB_STEREO_S_NO || device_type_no == OB_STEREO_S_U3_NO) + { + openni_device_->setProperty(XN_MODULE_PROPERTY_SWITCH_IR, (uint8_t*)&cam, 4); + } +} + +float AstraDevice::getIRFocalLength(int output_y_resolution) const +{ + float focal_length = 0.0f; + boost::shared_ptr stream = getIRVideoStream(); + + if (stream) + { + focal_length = (float)output_y_resolution / (2 * tan(stream->getVerticalFieldOfView() / 2)); + } + + return focal_length; +} + +float AstraDevice::getColorFocalLength(int output_y_resolution) const +{ + float focal_length = 0.0f; + boost::shared_ptr stream = getColorVideoStream(); + + if (stream) + { + focal_length = (float)output_y_resolution / (2 * tan(stream->getVerticalFieldOfView() / 2)); + } + + return focal_length; +} + +float AstraDevice::getDepthFocalLength(int output_y_resolution) const +{ + float focal_length = 0.0f; + boost::shared_ptr stream = getDepthVideoStream(); + + if (stream) + { + focal_length = (float)output_y_resolution / (2 * tan(stream->getVerticalFieldOfView() / 2)); + } + + return focal_length; +} + +float AstraDevice::getBaseline() const +{ + return 0.075f; +} + +bool AstraDevice::isIRVideoModeSupported(const AstraVideoMode& video_mode) const +{ + getSupportedIRVideoModes(); + + bool supported = false; + + std::vector::const_iterator it = ir_video_modes_.begin(); + std::vector::const_iterator it_end = ir_video_modes_.end(); + + while (it != it_end && !supported) + { + supported = (*it == video_mode); + ++it; + } + + return supported; +} + +bool AstraDevice::isColorVideoModeSupported(const AstraVideoMode& video_mode) const +{ + getSupportedColorVideoModes(); + + bool supported = false; + + std::vector::const_iterator it = color_video_modes_.begin(); + std::vector::const_iterator it_end = color_video_modes_.end(); + + while (it != it_end && !supported) + { + supported = (*it == video_mode); + ++it; + } + + return supported; +} + +bool AstraDevice::isDepthVideoModeSupported(const AstraVideoMode& video_mode) const +{ + getSupportedDepthVideoModes(); + + bool supported = false; + + std::vector::const_iterator it = depth_video_modes_.begin(); + std::vector::const_iterator it_end = depth_video_modes_.end(); + + while (it != it_end && !supported) + { + supported = (*it == video_mode); + ++it; + } + + return supported; + +} + +bool AstraDevice::hasIRSensor() const +{ + return openni_device_->hasSensor(openni::SENSOR_IR); +} + +bool AstraDevice::hasColorSensor() const +{ + return (getUsbProductId()!=0x0403)?openni_device_->hasSensor(openni::SENSOR_COLOR):0; +} + +bool AstraDevice::hasDepthSensor() const +{ + return openni_device_->hasSensor(openni::SENSOR_DEPTH); +} + +void AstraDevice::startIRStream() +{ + boost::shared_ptr stream = getIRVideoStream(); + + if (stream) + { + stream->setMirroringEnabled(false); + stream->start(); + stream->addNewFrameListener(ir_frame_listener.get()); + ir_video_started_ = true; + } + +} + +void AstraDevice::startColorStream() +{ + boost::shared_ptr stream = getColorVideoStream(); + + if (stream) + { + stream->setMirroringEnabled(false); + stream->start(); + stream->addNewFrameListener(color_frame_listener.get()); + color_video_started_ = true; + } +} +void AstraDevice::startDepthStream() +{ + boost::shared_ptr stream = getDepthVideoStream(); + + if (stream) + { + stream->setMirroringEnabled(false); + stream->start(); + stream->addNewFrameListener(depth_frame_listener.get()); + depth_video_started_ = true; + } +} + +void AstraDevice::stopAllStreams() +{ + stopIRStream(); + stopColorStream(); + stopDepthStream(); +} + +void AstraDevice::stopIRStream() +{ + if (ir_video_stream_.get() != 0) + { + ir_video_started_ = false; + + ir_video_stream_->removeNewFrameListener(ir_frame_listener.get()); + + ir_video_stream_->stop(); + } +} +void AstraDevice::stopColorStream() +{ + if (color_video_stream_.get() != 0) + { + color_video_started_ = false; + + color_video_stream_->removeNewFrameListener(color_frame_listener.get()); + + color_video_stream_->stop(); + } +} +void AstraDevice::stopDepthStream() +{ + if (depth_video_stream_.get() != 0) + { + depth_video_started_ = false; + + depth_video_stream_->removeNewFrameListener(depth_frame_listener.get()); + + depth_video_stream_->stop(); + } +} + +void AstraDevice::shutdown() +{ + if (ir_video_stream_.get() != 0) + ir_video_stream_->destroy(); + + if (color_video_stream_.get() != 0) + color_video_stream_->destroy(); + + if (depth_video_stream_.get() != 0) + depth_video_stream_->destroy(); + +} + +bool AstraDevice::isIRStreamStarted() +{ + return ir_video_started_; +} +bool AstraDevice::isColorStreamStarted() +{ + return color_video_started_; +} +bool AstraDevice::isDepthStreamStarted() +{ + return depth_video_started_; +} + +const std::vector& AstraDevice::getSupportedIRVideoModes() const +{ + boost::shared_ptr stream = getIRVideoStream(); + + ir_video_modes_.clear(); + + if (stream) + { + const openni::SensorInfo& sensor_info = stream->getSensorInfo(); + + ir_video_modes_ = astra_convert(sensor_info.getSupportedVideoModes()); + } + + return ir_video_modes_; +} + +const std::vector& AstraDevice::getSupportedColorVideoModes() const +{ + boost::shared_ptr stream = getColorVideoStream(); + + color_video_modes_.clear(); + + if (stream) + { + const openni::SensorInfo& sensor_info = stream->getSensorInfo(); + + color_video_modes_ = astra_convert(sensor_info.getSupportedVideoModes()); + } + + return color_video_modes_; +} + +const std::vector& AstraDevice::getSupportedDepthVideoModes() const +{ + boost::shared_ptr stream = getDepthVideoStream(); + + depth_video_modes_.clear(); + + if (stream) + { + const openni::SensorInfo& sensor_info = stream->getSensorInfo(); + + depth_video_modes_ = astra_convert(sensor_info.getSupportedVideoModes()); + } + + return depth_video_modes_; +} + +bool AstraDevice::isImageRegistrationModeSupported() const +{ + return openni_device_->isImageRegistrationModeSupported(openni::IMAGE_REGISTRATION_DEPTH_TO_COLOR); +} + +void AstraDevice::setImageRegistrationMode(bool enabled) +{ + if (isImageRegistrationModeSupported()) + { + image_registration_activated_ = enabled; + if (enabled) + { + openni::Status rc = openni_device_->setImageRegistrationMode(openni::IMAGE_REGISTRATION_DEPTH_TO_COLOR); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Enabling image registration mode failed: \n%s\n", openni::OpenNI::getExtendedError()); + } + else + { + openni::Status rc = openni_device_->setImageRegistrationMode(openni::IMAGE_REGISTRATION_OFF); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Enabling image registration mode failed: \n%s\n", openni::OpenNI::getExtendedError()); + } + } +} + +void AstraDevice::setDepthColorSync(bool enabled) +{ + openni::Status rc = openni_device_->setDepthColorSyncEnabled(enabled); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Enabling depth color synchronization failed: \n%s\n", openni::OpenNI::getExtendedError()); +} + +const AstraVideoMode AstraDevice::getIRVideoMode() +{ + AstraVideoMode ret; + + boost::shared_ptr stream = getIRVideoStream(); + + if (stream) + { + openni::VideoMode video_mode = stream->getVideoMode(); + + ret = astra_convert(video_mode); + } + else + THROW_OPENNI_EXCEPTION("Could not create video stream."); + + return ret; +} + +const AstraVideoMode AstraDevice::getColorVideoMode() +{ + AstraVideoMode ret; + + boost::shared_ptr stream = getColorVideoStream(); + + if (stream) + { + openni::VideoMode video_mode = stream->getVideoMode(); + + ret = astra_convert(video_mode); + } + else + THROW_OPENNI_EXCEPTION("Could not create video stream."); + + return ret; +} + +const AstraVideoMode AstraDevice::getDepthVideoMode() +{ + AstraVideoMode ret; + + boost::shared_ptr stream = getDepthVideoStream(); + + if (stream) + { + openni::VideoMode video_mode = stream->getVideoMode(); + + ret = astra_convert(video_mode); + } + else + THROW_OPENNI_EXCEPTION("Could not create video stream."); + + return ret; +} + +void AstraDevice::setIRVideoMode(const AstraVideoMode& video_mode) +{ + boost::shared_ptr stream = getIRVideoStream(); + + if (stream) + { + const openni::VideoMode videoMode = astra_convert(video_mode); + const openni::Status rc = stream->setVideoMode(videoMode); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Couldn't set IR video mode: \n%s\n", openni::OpenNI::getExtendedError()); + } +} + +void AstraDevice::setColorVideoMode(const AstraVideoMode& video_mode) +{ + boost::shared_ptr stream = getColorVideoStream(); + + if (stream) + { + const openni::VideoMode videoMode = astra_convert(video_mode); + const openni::Status rc = stream->setVideoMode(videoMode); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Couldn't set color video mode: \n%s\n", openni::OpenNI::getExtendedError()); + } +} + +void AstraDevice::setDepthVideoMode(const AstraVideoMode& video_mode) +{ + boost::shared_ptr stream = getDepthVideoStream(); + + if (stream) + { + const openni::VideoMode videoMode = astra_convert(video_mode); + const openni::Status rc = stream->setVideoMode(videoMode); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Couldn't set depth video mode: \n%s\n", openni::OpenNI::getExtendedError()); + } +} + +void AstraDevice::setAutoExposure(bool enable) +{ + boost::shared_ptr stream = getColorVideoStream(); + + if (stream) + { + openni::CameraSettings* camera_seeting = stream->getCameraSettings(); + if (camera_seeting) + { + const openni::Status rc = camera_seeting->setAutoExposureEnabled(enable); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Couldn't set auto exposure: \n%s\n", openni::OpenNI::getExtendedError()); + } + + } +} +void AstraDevice::setAutoWhiteBalance(bool enable) +{ + boost::shared_ptr stream = getColorVideoStream(); + + if (stream) + { + openni::CameraSettings* camera_seeting = stream->getCameraSettings(); + if (camera_seeting) + { + const openni::Status rc = camera_seeting->setAutoWhiteBalanceEnabled(enable); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Couldn't set auto white balance: \n%s\n", openni::OpenNI::getExtendedError()); + } + + } +} + +bool AstraDevice::getAutoExposure() const +{ + bool ret = false; + + boost::shared_ptr stream = getColorVideoStream(); + + if (stream) + { + openni::CameraSettings* camera_seeting = stream->getCameraSettings(); + if (camera_seeting) + ret = camera_seeting->getAutoExposureEnabled(); + } + + return ret; +} +bool AstraDevice::getAutoWhiteBalance() const +{ + bool ret = false; + + boost::shared_ptr stream = getColorVideoStream(); + + if (stream) + { + openni::CameraSettings* camera_seeting = stream->getCameraSettings(); + if (camera_seeting) + ret = camera_seeting->getAutoWhiteBalanceEnabled(); + } + + return ret; +} + +void AstraDevice::setUseDeviceTimer(bool enable) +{ + if (ir_frame_listener) + ir_frame_listener->setUseDeviceTimer(enable); + + if (color_frame_listener) + color_frame_listener->setUseDeviceTimer(enable); + + if (depth_frame_listener) + depth_frame_listener->setUseDeviceTimer(enable); +} + +void AstraDevice::setIRFrameCallback(FrameCallbackFunction callback) +{ + ir_frame_listener->setCallback(callback); +} + +void AstraDevice::setColorFrameCallback(FrameCallbackFunction callback) +{ + color_frame_listener->setCallback(callback); +} + +void AstraDevice::setDepthFrameCallback(FrameCallbackFunction callback) +{ + depth_frame_listener->setCallback(callback); +} + +boost::shared_ptr AstraDevice::getIRVideoStream() const +{ + if (ir_video_stream_.get() == 0) + { + if (hasIRSensor()) + { + ir_video_stream_ = boost::make_shared(); + + const openni::Status rc = ir_video_stream_->create(*openni_device_, openni::SENSOR_IR); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Couldn't create IR video stream: \n%s\n", openni::OpenNI::getExtendedError()); + } + } + return ir_video_stream_; +} + +boost::shared_ptr AstraDevice::getColorVideoStream() const +{ + if (color_video_stream_.get() == 0) + { + if (hasColorSensor()) + { + color_video_stream_ = boost::make_shared(); + + const openni::Status rc = color_video_stream_->create(*openni_device_, openni::SENSOR_COLOR); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Couldn't create color video stream: \n%s\n", openni::OpenNI::getExtendedError()); + } + } + return color_video_stream_; +} + +boost::shared_ptr AstraDevice::getDepthVideoStream() const +{ + if (depth_video_stream_.get() == 0) + { + if (hasDepthSensor()) + { + depth_video_stream_ = boost::make_shared(); + + const openni::Status rc = depth_video_stream_->create(*openni_device_, openni::SENSOR_DEPTH); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Couldn't create depth video stream: \n%s\n", openni::OpenNI::getExtendedError()); + } + } + return depth_video_stream_; +} + +std::ostream& operator <<(std::ostream& stream, const AstraDevice& device) +{ + + stream << "Device info (" << device.getUri() << ")" << std::endl; + stream << " Vendor: " << device.getVendor() << std::endl; + stream << " Name: " << device.getName() << std::endl; + stream << " USB Vendor ID: " << device.getUsbVendorId() << std::endl; + stream << " USB Product ID: " << device.getUsbVendorId() << std::endl << std::endl; + + if (device.hasIRSensor()) + { + stream << "IR sensor video modes:" << std::endl; + const std::vector& video_modes = device.getSupportedIRVideoModes(); + + std::vector::const_iterator it = video_modes.begin(); + std::vector::const_iterator it_end = video_modes.end(); + for (; it != it_end; ++it) + stream << " - " << *it << std::endl; + } + else + { + stream << "No IR sensor available" << std::endl; + } + + if (device.hasColorSensor()) + { + stream << "Color sensor video modes:" << std::endl; + const std::vector& video_modes = device.getSupportedColorVideoModes(); + + std::vector::const_iterator it = video_modes.begin(); + std::vector::const_iterator it_end = video_modes.end(); + for (; it != it_end; ++it) + stream << " - " << *it << std::endl; + } + else + { + stream << "No Color sensor available" << std::endl; + } + + if (device.hasDepthSensor()) + { + stream << "Depth sensor video modes:" << std::endl; + const std::vector& video_modes = device.getSupportedDepthVideoModes(); + + std::vector::const_iterator it = video_modes.begin(); + std::vector::const_iterator it_end = video_modes.end(); + for (; it != it_end; ++it) + stream << " - " << *it << std::endl; + } + else + { + stream << "No Depth sensor available" << std::endl; + } + + return stream; +} + +} diff --git a/src/ros_astra_camera/src/astra_device_info.cpp b/src/ros_astra_camera/src/astra_device_info.cpp new file mode 100644 index 0000000..38fd117 --- /dev/null +++ b/src/ros_astra_camera/src/astra_device_info.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#include "astra_camera/astra_device_info.h" + +namespace astra_wrapper +{ + + +std::ostream& operator << (std::ostream& stream, const AstraDeviceInfo& device_info) { + stream << "Uri: " << device_info.uri_ << " (Vendor: " << device_info.vendor_ << + ", Name: " << device_info.name_ << + ", Vendor ID: " << std::hex << device_info.vendor_id_ << + ", Product ID: " << std::hex << device_info.product_id_ << + ")" << std::endl; + return stream; +} + + + +} //namespace openni2_wrapper diff --git a/src/ros_astra_camera/src/astra_device_manager.cpp b/src/ros_astra_camera/src/astra_device_manager.cpp new file mode 100644 index 0000000..082e3dd --- /dev/null +++ b/src/ros_astra_camera/src/astra_device_manager.cpp @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#include "astra_camera/astra_device_manager.h" +#include "astra_camera/astra_convert.h" +#include "astra_camera/astra_device.h" +#include "astra_camera/astra_exception.h" + +#include + +#include + +#include +#include + +#include "openni2/OpenNI.h" + +namespace astra_wrapper +{ + +class AstraDeviceInfoComparator +{ +public: + bool operator()(const AstraDeviceInfo& di1, const AstraDeviceInfo& di2) + { + return (di1.uri_.compare(di2.uri_) < 0); + } +}; + +typedef std::set DeviceSet; + +class AstraDeviceListener : public openni::OpenNI::DeviceConnectedListener, + public openni::OpenNI::DeviceDisconnectedListener, + public openni::OpenNI::DeviceStateChangedListener +{ +public: + AstraDeviceListener() : + openni::OpenNI::DeviceConnectedListener(), + openni::OpenNI::DeviceDisconnectedListener(), + openni::OpenNI::DeviceStateChangedListener() + { + openni::OpenNI::addDeviceConnectedListener(this); + openni::OpenNI::addDeviceDisconnectedListener(this); + openni::OpenNI::addDeviceStateChangedListener(this); + + // get list of currently connected devices + openni::Array device_info_list; + openni::OpenNI::enumerateDevices(&device_info_list); + + for (int i = 0; i < device_info_list.getSize(); ++i) + { + onDeviceConnected(&device_info_list[i]); + } + } + + ~AstraDeviceListener() + { + openni::OpenNI::removeDeviceConnectedListener(this); + openni::OpenNI::removeDeviceDisconnectedListener(this); + openni::OpenNI::removeDeviceStateChangedListener(this); + } + + virtual void onDeviceStateChanged(const openni::DeviceInfo* pInfo, openni::DeviceState state) + { + ROS_INFO("Device \"%s\" error state changed to %d\n", pInfo->getUri(), state); + + switch (state) + { + case openni::DEVICE_STATE_OK: + onDeviceConnected(pInfo); + break; + case openni::DEVICE_STATE_ERROR: + case openni::DEVICE_STATE_NOT_READY: + case openni::DEVICE_STATE_EOF: + default: + onDeviceDisconnected(pInfo); + break; + } + } + + virtual void onDeviceConnected(const openni::DeviceInfo* pInfo) + { + boost::mutex::scoped_lock l(device_mutex_); + + const AstraDeviceInfo device_info_wrapped = astra_convert(pInfo); + + ROS_INFO("Device \"%s\" found.", pInfo->getUri()); + + // make sure it does not exist in set before inserting + device_set_.erase(device_info_wrapped); + device_set_.insert(device_info_wrapped); + } + + + virtual void onDeviceDisconnected(const openni::DeviceInfo* pInfo) + { + boost::mutex::scoped_lock l(device_mutex_); + + ROS_WARN("Device \"%s\" disconnected\n", pInfo->getUri()); + + const AstraDeviceInfo device_info_wrapped = astra_convert(pInfo); + device_set_.erase(device_info_wrapped); + } + + boost::shared_ptr > getConnectedDeviceURIs() + { + boost::mutex::scoped_lock l(device_mutex_); + + boost::shared_ptr > result = boost::make_shared >(); + + result->reserve(device_set_.size()); + + std::set::const_iterator it; + std::set::const_iterator it_end = device_set_.end(); + + for (it = device_set_.begin(); it != it_end; ++it) + result->push_back(it->uri_); + + return result; + } + + boost::shared_ptr > getConnectedDeviceInfos() + { + boost::mutex::scoped_lock l(device_mutex_); + + boost::shared_ptr > result = boost::make_shared >(); + + result->reserve(device_set_.size()); + + DeviceSet::const_iterator it; + DeviceSet::const_iterator it_end = device_set_.end(); + + for (it = device_set_.begin(); it != it_end; ++it) + result->push_back(*it); + + return result; + } + + std::size_t getNumOfConnectedDevices() + { + boost::mutex::scoped_lock l(device_mutex_); + + return device_set_.size(); + } + + boost::mutex device_mutex_; + DeviceSet device_set_; +}; + +////////////////////////////////////////////////////////////////////////// + +boost::shared_ptr AstraDeviceManager::singelton_; + +AstraDeviceManager::AstraDeviceManager() +{ + openni::Status rc = openni::OpenNI::initialize(); + if (rc != openni::STATUS_OK) + THROW_OPENNI_EXCEPTION("Initialize failed\n%s\n", openni::OpenNI::getExtendedError()); + + device_listener_ = boost::make_shared(); +} + +AstraDeviceManager::~AstraDeviceManager() +{ +} + +boost::shared_ptr AstraDeviceManager::getSingelton() +{ + if (singelton_.get()==0) + singelton_ = boost::make_shared(); + + return singelton_; +} + +boost::shared_ptr > AstraDeviceManager::getConnectedDeviceInfos() const +{ +return device_listener_->getConnectedDeviceInfos(); +} + +boost::shared_ptr > AstraDeviceManager::getConnectedDeviceURIs() const +{ + return device_listener_->getConnectedDeviceURIs(); +} + +std::size_t AstraDeviceManager::getNumOfConnectedDevices() const +{ + return device_listener_->getNumOfConnectedDevices(); +} + +std::string AstraDeviceManager::getSerial(const std::string& Uri) const +{ + openni::Device openni_device; + std::string ret; + + // we need to open the device to query the serial number + if (Uri.length() > 0 && openni_device.open(Uri.c_str()) == openni::STATUS_OK) + { + int serial_len = 100; + char serial[serial_len]; + + openni::Status rc = openni_device.getProperty(openni::DEVICE_PROPERTY_SERIAL_NUMBER, serial, &serial_len); + if (rc == openni::STATUS_OK) + ret = serial; + else + { + THROW_OPENNI_EXCEPTION("Serial number query failed: %s", openni::OpenNI::getExtendedError()); + } + // close the device again + openni_device.close(); + } + else + { + //THROW_OPENNI_EXCEPTION("Device open failed: %s", openni::OpenNI::getExtendedError()); + } + return ret; +} + +boost::shared_ptr AstraDeviceManager::getAnyDevice() +{ + return boost::make_shared(""); +} +boost::shared_ptr AstraDeviceManager::getDevice(const std::string& device_URI) +{ + return boost::make_shared(device_URI); +} + + +std::ostream& operator << (std::ostream& stream, const AstraDeviceManager& device_manager) { + + boost::shared_ptr > device_info = device_manager.getConnectedDeviceInfos(); + + std::vector::const_iterator it; + std::vector::const_iterator it_end = device_info->end(); + + for (it = device_info->begin(); it != it_end; ++it) + { + stream << "Uri: " << it->uri_ << " (Vendor: " << it->vendor_ << + ", Name: " << it->name_ << + ", Vendor ID: " << it->vendor_id_ << + ", Product ID: " << it->product_id_ << + ")" << std::endl; + } + + return stream; +} + + +} //namespace openni2_wrapper diff --git a/src/ros_astra_camera/src/astra_device_type.cpp b/src/ros_astra_camera/src/astra_device_type.cpp new file mode 100644 index 0000000..8a029ea --- /dev/null +++ b/src/ros_astra_camera/src/astra_device_type.cpp @@ -0,0 +1,8 @@ +#include "astra_camera/astra_device_type.h" + +bool astraWithUVC(OB_DEVICE_NO id) +{ + if (id == OB_STEREO_S_NO || id == OB_EMBEDDED_S_NO || id == OB_ASTRA_PRO_NO || id == OB_STEREO_S_U3_NO) + return true; + return false; +} \ No newline at end of file diff --git a/src/ros_astra_camera/src/astra_driver.cpp b/src/ros_astra_camera/src/astra_driver.cpp new file mode 100644 index 0000000..7904c82 --- /dev/null +++ b/src/ros_astra_camera/src/astra_driver.cpp @@ -0,0 +1,1344 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#include "astra_camera/astra_driver.h" +#include "astra_camera/astra_exception.h" +#include "astra_camera/astra_device_type.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#define MULTI_ASTRA 1 +namespace astra_wrapper +{ + +AstraDriver::AstraDriver(ros::NodeHandle& n, ros::NodeHandle& pnh) : + nh_(n), + pnh_(pnh), + device_manager_(AstraDeviceManager::getSingelton()), + config_init_(false), + data_skip_ir_counter_(0), + data_skip_color_counter_(0), + data_skip_depth_counter_ (0), + ir_subscribers_(false), + color_subscribers_(false), + depth_subscribers_(false), + depth_raw_subscribers_(false), + uvc_flip_(0) +{ + + genVideoModeTableMap(); + + readConfigFromParameterServer(); + +#if MULTI_ASTRA + int bootOrder, devnums; + if (!pnh.getParam("bootorder", bootOrder)) + { + bootOrder = 0; + } + + if (!pnh.getParam("devnums", devnums)) + { + devnums = 1; + } + + if( devnums>1 ) + { + int shmid; + char *shm = NULL; + char *tmp; + + if( bootOrder==1 ) + { + if( (shmid = shmget((key_t)0401, 1, 0666|IPC_CREAT)) == -1 ) + { + ROS_ERROR("Create Share Memory Error:%s", strerror(errno)); + } + shm = (char *)shmat(shmid, 0, 0); + *shm = 1; + initDevice(); + ROS_INFO("*********** device_id %s already open device************************ ", device_id_.c_str()); + *shm = 2; + } + else + { + if( (shmid = shmget((key_t)0401, 1, 0666|IPC_CREAT)) == -1 ) + { + ROS_ERROR("Create Share Memory Error:%s", strerror(errno)); + } + shm = (char *)shmat(shmid, 0, 0); + while( *shm!=bootOrder) + { + boost::this_thread::sleep(boost::posix_time::milliseconds(10)); + } + + initDevice(); + ROS_INFO("*********** device_id %s already open device************************ ", device_id_.c_str()); + *shm = (bootOrder+1); + } + if( bootOrder==devnums ) + { + if(shmdt(shm) == -1) + { + ROS_ERROR("shmdt failed\n"); + } + if(shmctl(shmid, IPC_RMID, 0) == -1) + { + ROS_ERROR("shmctl(IPC_RMID) failed\n"); + } + } + else + { + if(shmdt(shm) == -1) + { + ROS_ERROR("shmdt failed\n"); + } + } + } + else + { + initDevice(); + } +#else + initDevice(); + +#endif + // Initialize dynamic reconfigure + reconfigure_server_.reset(new ReconfigureServer(pnh_)); + reconfigure_server_->setCallback(boost::bind(&AstraDriver::configCb, this, _1, _2)); + + while (!config_init_) + { + ROS_DEBUG("Waiting for dynamic reconfigure configuration."); + boost::this_thread::sleep(boost::posix_time::milliseconds(100)); + } + ROS_DEBUG("Dynamic reconfigure configuration received."); + + advertiseROSTopics(); +} + +AstraDriver::~AstraDriver() { + device_->stopAllStreams(); +} + +void AstraDriver::advertiseROSTopics() +{ + + // Allow remapping namespaces rgb, ir, depth, depth_registered + ros::NodeHandle color_nh(nh_, "rgb"); + image_transport::ImageTransport color_it(color_nh); + ros::NodeHandle ir_nh(nh_, "ir"); + image_transport::ImageTransport ir_it(ir_nh); + ros::NodeHandle depth_nh(nh_, "depth"); + image_transport::ImageTransport depth_it(depth_nh); + ros::NodeHandle depth_raw_nh(nh_, "depth"); + image_transport::ImageTransport depth_raw_it(depth_raw_nh); + ros::NodeHandle projector_nh(nh_, "projector"); + // Advertise all published topics + + // Prevent connection callbacks from executing until we've set all the publishers. Otherwise + // connectCb() can fire while we're advertising (say) "depth/image_raw", but before we actually + // assign to pub_depth_raw_. Then pub_depth_raw_.getNumSubscribers() returns 0, and we fail to start + // the depth generator. + boost::lock_guard lock(connect_mutex_); + + // Asus Xtion PRO does not have an RGB camera + //ROS_WARN("-------------has color sensor is %d----------- ", device_->hasColorSensor()); + if (device_->hasColorSensor()) + { + image_transport::SubscriberStatusCallback itssc = boost::bind(&AstraDriver::imageConnectCb, this); + ros::SubscriberStatusCallback rssc = boost::bind(&AstraDriver::imageConnectCb, this); + pub_color_ = color_it.advertiseCamera("image", 1, itssc, itssc, rssc, rssc); + } + + if (device_->hasIRSensor()) + { + image_transport::SubscriberStatusCallback itssc = boost::bind(&AstraDriver::imageConnectCb, this); + ros::SubscriberStatusCallback rssc = boost::bind(&AstraDriver::imageConnectCb, this); + pub_ir_ = ir_it.advertiseCamera("image", 1, itssc, itssc, rssc, rssc); + } + + if (device_->hasDepthSensor()) + { + image_transport::SubscriberStatusCallback itssc = boost::bind(&AstraDriver::depthConnectCb, this); + ros::SubscriberStatusCallback rssc = boost::bind(&AstraDriver::depthConnectCb, this); + pub_depth_raw_ = depth_it.advertiseCamera("image_raw", 1, itssc, itssc, rssc, rssc); + pub_depth_ = depth_raw_it.advertiseCamera("image", 1, itssc, itssc, rssc, rssc); + pub_projector_info_ = projector_nh.advertise("camera_info", 1, rssc, rssc); + } + + ////////// CAMERA INFO MANAGER + + // Pixel offset between depth and IR images. + // By default assume offset of (5,4) from 9x7 correlation window. + // NOTE: These are now (temporarily?) dynamically reconfigurable, to allow tweaking. + //param_nh.param("depth_ir_offset_x", depth_ir_offset_x_, 5.0); + //param_nh.param("depth_ir_offset_y", depth_ir_offset_y_, 4.0); + + // The camera names are set to [rgb|depth]_[serial#], e.g. depth_B00367707227042B. + // camera_info_manager substitutes this for ${NAME} in the URL. + std::string serial_number = device_->getStringID(); + std::string color_name, ir_name; + + color_name = "rgb_" + serial_number; + ir_name = "depth_" + serial_number; + + // Load the saved calibrations, if they exist + color_info_manager_ = boost::make_shared(color_nh, color_name, color_info_url_); + ir_info_manager_ = boost::make_shared(ir_nh, ir_name, ir_info_url_); + + get_serial_server = nh_.advertiseService("get_serial", &AstraDriver::getSerialCb, this); + get_device_type_server = nh_.advertiseService("get_device_type", &AstraDriver::getDeviceTypeCb, this); + get_ir_gain_server = nh_.advertiseService("get_ir_gain", &AstraDriver::getIRGainCb, this); + set_ir_gain_server = nh_.advertiseService("set_ir_gain", &AstraDriver::setIRGainCb, this); + get_ir_exposure_server = nh_.advertiseService("get_ir_exposure", &AstraDriver::getIRExposureCb, this); + set_ir_exposure_server = nh_.advertiseService("set_ir_exposure", &AstraDriver::setIRExposureCb, this); + set_ir_flood_server = nh_.advertiseService("set_ir_flood", &AstraDriver::setIRFloodCb, this); + set_laser_server = nh_.advertiseService("set_laser", &AstraDriver::setLaserCb, this); + set_ldp_server = nh_.advertiseService("set_ldp", &AstraDriver::setLDPCb, this); + reset_ir_gain_server = nh_.advertiseService("reset_ir_gain", &AstraDriver::resetIRGainCb, this); + reset_ir_exposure_server = nh_.advertiseService("reset_ir_exposure", &AstraDriver::resetIRExposureCb, this); + get_camera_info = nh_.advertiseService("get_camera_info", &AstraDriver::getCameraInfoCb, this); + if (device_->getDeviceTypeNo() == OB_STEREO_S_NO || device_->getDeviceTypeNo() == OB_STEREO_S_U3_NO) + { + switch_ir_camera = nh_.advertiseService("switch_ir_camera", &AstraDriver::switchIRCameraCb, this); + } +} + +bool AstraDriver::getSerialCb(astra_camera::GetSerialRequest& req, astra_camera::GetSerialResponse& res) +{ + res.serial = device_manager_->getSerial(device_->getUri()); + return true; +} + +bool AstraDriver::getDeviceTypeCb(astra_camera::GetDeviceTypeRequest& req, astra_camera::GetDeviceTypeResponse& res) +{ + res.device_type = std::string(device_->getDeviceType()); + return true; +} + +bool AstraDriver::getIRGainCb(astra_camera::GetIRGainRequest& req, astra_camera::GetIRGainResponse& res) +{ + res.gain = device_->getIRGain(); + return true; +} + +bool AstraDriver::setIRGainCb(astra_camera::SetIRGainRequest& req, astra_camera::SetIRGainResponse& res) +{ + device_->setIRGain(req.gain); + return true; +} + +bool AstraDriver::getIRExposureCb(astra_camera::GetIRExposureRequest& req, astra_camera::GetIRExposureResponse& res) +{ + res.exposure = device_->getIRExposure(); + return true; +} + +bool AstraDriver::setIRExposureCb(astra_camera::SetIRExposureRequest& req, astra_camera::SetIRExposureResponse& res) +{ + device_->setIRExposure(req.exposure); + return true; +} + +bool AstraDriver::setLaserCb(astra_camera::SetLaserRequest& req, astra_camera::SetLaserResponse& res) +{ + device_->setLaser(req.enable); + return true; +} + +bool AstraDriver::setLDPCb(astra_camera::SetLDPRequest& req, astra_camera::SetLDPResponse& res) +{ + device_->setLDP(req.enable); + return true; +} + +bool AstraDriver::resetIRGainCb(astra_camera::ResetIRGainRequest& req, astra_camera::ResetIRGainResponse& res) +{ + device_->setIRGain(0x8); + return true; +} + +bool AstraDriver::resetIRExposureCb(astra_camera::ResetIRExposureRequest& req, astra_camera::ResetIRExposureResponse& res) +{ + device_->setIRExposure(0x419); + return true; +} + +bool AstraDriver::getCameraInfoCb(astra_camera::GetCameraInfoRequest& req, astra_camera::GetCameraInfoResponse& res) +{ + res.info = convertAstraCameraInfo(device_->getCameraParams(), ros::Time::now()); + return true; +} + +bool AstraDriver::setIRFloodCb(astra_camera::SetIRFloodRequest& req, astra_camera::SetIRFloodResponse& res) +{ + device_->setIRFlood(req.enable); + return true; +} + +bool AstraDriver::switchIRCameraCb(astra_camera::SwitchIRCameraRequest& req, astra_camera::SwitchIRCameraResponse& res) +{ + if (req.camera == "left") + device_->switchIRCamera(0); + else if (req.camera == "right") + device_->switchIRCamera(1); + else + ROS_ERROR("Only support left/right"); + return true; +} + +void AstraDriver::configCb(Config &config, uint32_t level) +{ + if (device_->getDeviceTypeNo() == OB_STEREO_S_NO) + { + if (config.depth_mode != 13 && config.depth_mode != 14) + { + config.depth_mode = 13; + } + if (config.ir_mode != 13 && config.ir_mode != 14 && config.ir_mode != 16) + { + config.ir_mode = 13; + } + device_->switchIRCamera(0); + } + else if (device_->getDeviceTypeNo() == OB_EMBEDDED_S_NO) + { + if (config.depth_mode != 13 && config.depth_mode != 17) + { + config.depth_mode = 13; + } + if (config.ir_mode != 13 && config.ir_mode != 17) + { + config.ir_mode = 13; + } + uvc_flip_ = 1; + } + else if (device_->getDeviceTypeNo() == OB_STEREO_S_U3_NO) + { + if (config.depth_mode != 13 && config.depth_mode != 14) + { + config.depth_mode = 13; + } + if (config.ir_mode != 13 && config.ir_mode != 14) + { + config.ir_mode = 13; + } + device_->switchIRCamera(0); + } + bool stream_reset = false; + + rgb_preferred_ = config.rgb_preferred; + + if (config_init_ && old_config_.rgb_preferred != config.rgb_preferred) + imageConnectCb(); + + depth_ir_offset_x_ = config.depth_ir_offset_x; + depth_ir_offset_y_ = config.depth_ir_offset_y; + z_offset_mm_ = config.z_offset_mm; + z_scaling_ = config.z_scaling; + + ir_time_offset_ = ros::Duration(config.ir_time_offset); + color_time_offset_ = ros::Duration(config.color_time_offset); + depth_time_offset_ = ros::Duration(config.depth_time_offset); + + if (lookupVideoModeFromDynConfig(config.ir_mode, ir_video_mode_)<0) + { + ROS_ERROR("Undefined IR video mode received from dynamic reconfigure"); + exit(-1); + } + + if (lookupVideoModeFromDynConfig(config.color_mode, color_video_mode_)<0) + { + ROS_ERROR("Undefined color video mode received from dynamic reconfigure"); + exit(-1); + } + + if (lookupVideoModeFromDynConfig(config.depth_mode, depth_video_mode_)<0) + { + ROS_ERROR("Undefined depth video mode received from dynamic reconfigure"); + exit(-1); + } + + // assign pixel format + + ir_video_mode_.pixel_format_ = PIXEL_FORMAT_GRAY16; + color_video_mode_.pixel_format_ = PIXEL_FORMAT_RGB888; + depth_video_mode_.pixel_format_ = PIXEL_FORMAT_DEPTH_1_MM; + + color_depth_synchronization_ = config.color_depth_synchronization; + depth_registration_ = config.depth_registration; + + auto_exposure_ = config.auto_exposure; + auto_white_balance_ = config.auto_white_balance; + + use_device_time_ = config.use_device_time; + + data_skip_ = config.data_skip+1; + + applyConfigToOpenNIDevice(); + + config_init_ = true; + + old_config_ = config; +} + +void AstraDriver::setIRVideoMode(const AstraVideoMode& ir_video_mode) +{ + if (device_->isIRVideoModeSupported(ir_video_mode)) + { + if (ir_video_mode != device_->getIRVideoMode()) + { + device_->setIRVideoMode(ir_video_mode); + } + + } + else + { + ROS_ERROR_STREAM("Unsupported IR video mode - " << ir_video_mode); + } +} +void AstraDriver::setColorVideoMode(const AstraVideoMode& color_video_mode) +{ + if (device_->isColorVideoModeSupported(color_video_mode)) + { + if (color_video_mode != device_->getColorVideoMode()) + { + device_->setColorVideoMode(color_video_mode); + } + } + else + { + ROS_ERROR_STREAM("Unsupported color video mode - " << color_video_mode); + } +} +void AstraDriver::setDepthVideoMode(const AstraVideoMode& depth_video_mode) +{ + if (device_->isDepthVideoModeSupported(depth_video_mode)) + { + if (depth_video_mode != device_->getDepthVideoMode()) + { + device_->setDepthVideoMode(depth_video_mode); + } + } + else + { + ROS_ERROR_STREAM("Unsupported depth video mode - " << depth_video_mode); + } +} + +void AstraDriver::applyConfigToOpenNIDevice() +{ + + data_skip_ir_counter_ = 0; + data_skip_color_counter_= 0; + data_skip_depth_counter_ = 0; + + setIRVideoMode(ir_video_mode_); + if (device_->hasColorSensor()) + { + setColorVideoMode(color_video_mode_); + } + setDepthVideoMode(depth_video_mode_); + + if (device_->isImageRegistrationModeSupported()) + { + try + { + if (!config_init_ || (old_config_.depth_registration != depth_registration_)) + device_->setImageRegistrationMode(depth_registration_); + } + catch (const AstraException& exception) + { + ROS_ERROR("Could not set image registration. Reason: %s", exception.what()); + } + } + + try + { + if (!config_init_ || (old_config_.color_depth_synchronization != color_depth_synchronization_)) + device_->setDepthColorSync(color_depth_synchronization_); + } + catch (const AstraException& exception) + { + ROS_ERROR("Could not set color depth synchronization. Reason: %s", exception.what()); + } + + try + { + if (!config_init_ || (old_config_.auto_exposure != auto_exposure_)) + device_->setAutoExposure(auto_exposure_); + } + catch (const AstraException& exception) + { + ROS_ERROR("Could not set auto exposure. Reason: %s", exception.what()); + } + + try + { + if (!config_init_ || (old_config_.auto_white_balance != auto_white_balance_)) + device_->setAutoWhiteBalance(auto_white_balance_); + } + catch (const AstraException& exception) + { + ROS_ERROR("Could not set auto white balance. Reason: %s", exception.what()); + } + + device_->setUseDeviceTimer(use_device_time_); + +} + +void AstraDriver::imageConnectCb() +{ + boost::lock_guard lock(connect_mutex_); + + bool ir_started = device_->isIRStreamStarted(); + bool color_started = device_->isColorStreamStarted(); + + ir_subscribers_ = pub_ir_.getNumSubscribers() > 0; + color_subscribers_ = pub_color_.getNumSubscribers() > 0; + + if (color_subscribers_ && (!ir_subscribers_ || rgb_preferred_)) + { + if (ir_subscribers_) + ROS_ERROR("Cannot stream RGB and IR at the same time. Streaming RGB only."); + + if (ir_started) + { + ROS_INFO("Stopping IR stream."); + device_->stopIRStream(); + } + + if (!color_started) + { + device_->setColorFrameCallback(boost::bind(&AstraDriver::newColorFrameCallback, this, _1)); + + ROS_INFO("Starting color stream."); + device_->startColorStream(); + } + } + else if (ir_subscribers_ && (!color_subscribers_ || !rgb_preferred_)) + { + + if (color_subscribers_) + ROS_ERROR("Cannot stream RGB and IR at the same time. Streaming IR only."); + + if (color_started) + { + ROS_INFO("Stopping color stream."); + device_->stopColorStream(); + } + + if (!ir_started) + { + device_->setIRFrameCallback(boost::bind(&AstraDriver::newIRFrameCallback, this, _1)); + + ROS_INFO("Starting IR stream."); + device_->startIRStream(); + } + } + else + { + if (color_started) + { + ROS_INFO("Stopping color stream."); + device_->stopColorStream(); + } + if (ir_started) + { + ROS_INFO("Stopping IR stream."); + device_->stopIRStream(); + } + } +} + +void AstraDriver::depthConnectCb() +{ + boost::lock_guard lock(connect_mutex_); + + depth_subscribers_ = pub_depth_.getNumSubscribers() > 0; + depth_raw_subscribers_ = pub_depth_raw_.getNumSubscribers() > 0; + projector_info_subscribers_ = pub_projector_info_.getNumSubscribers() > 0; + + bool need_depth = depth_subscribers_ || depth_raw_subscribers_; + + if (need_depth && !device_->isDepthStreamStarted()) + { + device_->setDepthFrameCallback(boost::bind(&AstraDriver::newDepthFrameCallback, this, _1)); + + ROS_INFO("Starting depth stream."); + device_->startDepthStream(); + } + else if (!need_depth && device_->isDepthStreamStarted()) + { + ROS_INFO("Stopping depth stream."); + device_->stopDepthStream(); + } +} + +void AstraDriver::newIRFrameCallback(sensor_msgs::ImagePtr image) +{ + if ((++data_skip_ir_counter_)%data_skip_==0) + { + data_skip_ir_counter_ = 0; + + if (ir_subscribers_) + { + image->header.frame_id = ir_frame_id_; + image->header.stamp = image->header.stamp + ir_time_offset_; + + pub_ir_.publish(image, getIRCameraInfo(image->width, image->height, image->header.stamp)); + } + } +} + +void AstraDriver::newColorFrameCallback(sensor_msgs::ImagePtr image) +{ + if ((++data_skip_color_counter_)%data_skip_==0) + { + data_skip_color_counter_ = 0; + + if (color_subscribers_) + { + image->header.frame_id = color_frame_id_; + image->header.stamp = image->header.stamp + color_time_offset_; + + pub_color_.publish(image, getColorCameraInfo(image->width, image->height, image->header.stamp)); + } + } +} + +void AstraDriver::newDepthFrameCallback(sensor_msgs::ImagePtr image) +{ + if ((++data_skip_depth_counter_)%data_skip_==0) + { + + data_skip_depth_counter_ = 0; + + if (depth_raw_subscribers_||depth_subscribers_||projector_info_subscribers_) + { + image->header.stamp = image->header.stamp + depth_time_offset_; + + if (z_offset_mm_ != 0) + { + uint16_t* data = reinterpret_cast(&image->data[0]); + for (unsigned int i = 0; i < image->width * image->height; ++i) + if (data[i] != 0) + data[i] += z_offset_mm_; + } + + if (fabs(z_scaling_ - 1.0) > 1e-6) + { + uint16_t* data = reinterpret_cast(&image->data[0]); + for (unsigned int i = 0; i < image->width * image->height; ++i) + if (data[i] != 0) + data[i] = static_cast(data[i] * z_scaling_); + } + + sensor_msgs::CameraInfoPtr cam_info; + + if (depth_registration_) + { + image->header.frame_id = color_frame_id_; + } else + { + image->header.frame_id = depth_frame_id_; + } + cam_info = getDepthCameraInfo(image->width, image->height, image->header.stamp); + + if (depth_raw_subscribers_) + { + pub_depth_raw_.publish(image, cam_info); + } + + if (depth_subscribers_ ) + { + sensor_msgs::ImageConstPtr floating_point_image = rawToFloatingPointConversion(image); + pub_depth_.publish(floating_point_image, cam_info); + } + + // Projector "info" probably only useful for working with disparity images + if (projector_info_subscribers_) + { + pub_projector_info_.publish(getProjectorCameraInfo(image->width, image->height, image->header.stamp)); + } + } + } +} + +sensor_msgs::CameraInfo AstraDriver::convertAstraCameraInfo(OBCameraParams p, ros::Time time) const +{ + sensor_msgs::CameraInfo info; + // info.width = width; + // info.height = height; + info.distortion_model = sensor_msgs::distortion_models::PLUMB_BOB; + info.D.resize(5, 0.0); + info.D[0] = p.r_k[0]; + info.D[1] = p.r_k[1]; + info.D[2] = p.r_k[3]; + info.D[3] = p.r_k[4]; + info.D[4] = p.r_k[2]; + + info.K.assign(0.0); + info.K[0] = p.r_intr_p[0]; + info.K[2] = p.r_intr_p[2]; + info.K[4] = p.r_intr_p[1]; + info.K[5] = p.r_intr_p[3]; + info.K[8] = 1.0; + + info.R.assign(0.0); + for (int i = 0; i < 9; i++) + { + info.R[i] = p.r2l_r[i]; + } + + info.P.assign(0.0); + info.P[0] = info.K[0]; + info.P[2] = info.K[2]; + info.P[3] = p.r2l_t[0]; + info.P[5] = info.K[4]; + info.P[6] = info.K[5]; + info.P[7] = p.r2l_t[1]; + info.P[10] = 1.0; + info.P[11] = p.r2l_t[2]; + // Fill in header + info.header.stamp = time; + info.header.frame_id = color_frame_id_; + return info; +} + +// Methods to get calibration parameters for the various cameras +sensor_msgs::CameraInfoPtr AstraDriver::getDefaultCameraInfo(int width, int height, double f) const +{ + sensor_msgs::CameraInfoPtr info = boost::make_shared(); + + info->width = width; + info->height = height; + + // No distortion + info->D.resize(5, 0.0); + info->distortion_model = sensor_msgs::distortion_models::PLUMB_BOB; + + // Simple camera matrix: square pixels (fx = fy), principal point at center + info->K.assign(0.0); + info->K[0] = info->K[4] = f; + info->K[2] = (width / 2) - 0.5; + // Aspect ratio for the camera center on Astra (and other devices?) is 4/3 + // This formula keeps the principal point the same in VGA and SXGA modes + info->K[5] = (width * (3./8.)) - 0.5; + info->K[8] = 1.0; + + // No separate rectified image plane, so R = I + info->R.assign(0.0); + info->R[0] = info->R[4] = info->R[8] = 1.0; + + // Then P=K(I|0) = (K|0) + info->P.assign(0.0); + info->P[0] = info->P[5] = f; // fx, fy + info->P[2] = info->K[2]; // cx + info->P[6] = info->K[5]; // cy + info->P[10] = 1.0; + + return info; +} + +/// @todo Use binning/ROI properly in publishing camera infos +sensor_msgs::CameraInfoPtr AstraDriver::getColorCameraInfo(int width, int height, ros::Time time) const +{ + sensor_msgs::CameraInfoPtr info; + + if (color_info_manager_->isCalibrated()) + { + info = boost::make_shared(color_info_manager_->getCameraInfo()); + if ( info->width != width ) + { + // Use uncalibrated values + ROS_WARN_ONCE("Image resolution doesn't match calibration of the RGB camera. Using default parameters."); + info = getDefaultCameraInfo(width, height, device_->getColorFocalLength(height)); + } + } + else + { + // If uncalibrated, fill in default values + if (device_->isCameraParamsValid()) + { + sensor_msgs::CameraInfo cinfo = convertAstraCameraInfo(device_->getCameraParams(), time); + info = boost::make_shared(ir_info_manager_->getCameraInfo()); + info->D.resize(5, 0.0); + info->K.assign(0.0); + info->R.assign(0.0); + info->P.assign(0.0); + info->distortion_model = sensor_msgs::distortion_models::PLUMB_BOB; + info->width = width; + info->height = height; + + for (int i = 0; i < 9; i++) + { + info->K[i] = cinfo.K[i]; + info->R[i] = cinfo.R[i]; + } + + for (int i = 0; i < 12; i++) + { + info->P[i] = cinfo.P[i]; + } +/*02112020 color camera param change according to resolution */ + double scaling = (double)width / 640; + info->K[0] *= scaling; // fx + info->K[2] *= scaling; // cx + info->K[4] *= scaling; // fy + info->K[5] *= scaling; // cy + info->P[0] *= scaling; // fx + info->P[2] *= scaling; // cx + info->P[5] *= scaling; // fy + info->P[6] *= scaling; // cy +/* 02112020 end*/ + + } + else + { + info = getDefaultCameraInfo(width, height, device_->getColorFocalLength(height)); + } + } + + // Fill in header + info->header.stamp = time; + info->header.frame_id = color_frame_id_; + + return info; +} + + +sensor_msgs::CameraInfoPtr AstraDriver::getIRCameraInfo(int width, int height, ros::Time time) const +{ + sensor_msgs::CameraInfoPtr info; + + if (ir_info_manager_->isCalibrated()) + { + info = boost::make_shared(ir_info_manager_->getCameraInfo()); + if ( info->width != width ) + { + // Use uncalibrated values + ROS_WARN_ONCE("Image resolution doesn't match calibration of the IR camera. Using default parameters."); + info = getDefaultCameraInfo(width, height, device_->getIRFocalLength(height)); + } + } + else + { + // If uncalibrated, fill in default values + info = getDefaultCameraInfo(width, height, device_->getDepthFocalLength(height)); + + if (device_->isCameraParamsValid()) + { + OBCameraParams p = device_->getCameraParams(); + info->D.resize(5, 0.0); + // info->D[0] = p.l_k[0]; + // info->D[1] = p.l_k[1]; + // info->D[2] = p.l_k[3]; + // info->D[3] = p.l_k[4]; + // info->D[4] = p.l_k[2]; + + info->K.assign(0.0); + info->K[0] = p.l_intr_p[0]; + info->K[2] = p.l_intr_p[2]; + info->K[4] = p.l_intr_p[1]; + info->K[5] = p.l_intr_p[3]; + info->K[8] = 1.0; + + info->R.assign(0.0); + info->R[0] = 1; + info->R[4] = 1; + info->R[8] = 1; + + info->P.assign(0.0); + info->P[0] = info->K[0]; + info->P[2] = info->K[2]; + info->P[5] = info->K[4]; + info->P[6] = info->K[5]; + info->P[10] = 1.0; +/* 02122020 Scale IR Params */ + double scaling = (double)width / 640; + info->K[0] *= scaling; // fx + info->K[2] *= scaling; // cx + info->K[4] *= scaling; // fy + info->K[5] *= scaling; // cy + info->P[0] *= scaling; // fx + info->P[2] *= scaling; // cx + info->P[5] *= scaling; // fy + info->P[6] *= scaling; // cy +/* 02122020 end */ + + } + } + + // Fill in header + info->header.stamp = time; + info->header.frame_id = depth_frame_id_; + + return info; +} + +sensor_msgs::CameraInfoPtr AstraDriver::getDepthCameraInfo(int width, int height, ros::Time time) const +{ + // The depth image has essentially the same intrinsics as the IR image, BUT the + // principal point is offset by half the size of the hardware correlation window + // (probably 9x9 or 9x7 in 640x480 mode). See http://www.ros.org/wiki/kinect_calibration/technical + double scaling = (double)width / 640; + sensor_msgs::CameraInfoPtr info = getIRCameraInfo(width, height, time); + info->K[2] -= depth_ir_offset_x_ * scaling; + info->K[5] -= depth_ir_offset_y_ * scaling; + info->P[2] -= depth_ir_offset_x_ * scaling; + info->P[6] -= depth_ir_offset_y_ * scaling; + + /// @todo Could put this in projector frame so as to encode the baseline in P[3] + return info; +} + +sensor_msgs::CameraInfoPtr AstraDriver::getProjectorCameraInfo(int width, int height, ros::Time time) const +{ + // The projector info is simply the depth info with the baseline encoded in the P matrix. + // It's only purpose is to be the "right" camera info to the depth camera's "left" for + // processing disparity images. + sensor_msgs::CameraInfoPtr info = getDepthCameraInfo(width, height, time); + // Tx = -baseline * fx + info->P[3] = -device_->getBaseline() * info->P[0]; + return info; +} + +void AstraDriver::readConfigFromParameterServer() +{ + if (!pnh_.getParam("device_id", device_id_)) + { + ROS_WARN ("~device_id is not set! Using first device."); + device_id_ = "#1"; + } + + // Camera TF frames + pnh_.param("ir_frame_id", ir_frame_id_, std::string("/openni_ir_optical_frame")); + pnh_.param("rgb_frame_id", color_frame_id_, std::string("/openni_rgb_optical_frame")); + pnh_.param("depth_frame_id", depth_frame_id_, std::string("/openni_depth_optical_frame")); + + ROS_DEBUG("ir_frame_id = '%s' ", ir_frame_id_.c_str()); + ROS_DEBUG("rgb_frame_id = '%s' ", color_frame_id_.c_str()); + ROS_DEBUG("depth_frame_id = '%s' ", depth_frame_id_.c_str()); + + pnh_.param("rgb_camera_info_url", color_info_url_, std::string()); + pnh_.param("depth_camera_info_url", ir_info_url_, std::string()); + +} + +std::string AstraDriver::resolveDeviceURI(const std::string& device_id) +{ + // retrieve available device URIs, they look like this: "1d27/0601@1/5" + // which is /@/ + boost::shared_ptr > available_device_URIs = + device_manager_->getConnectedDeviceURIs(); + + //for tes + #if 0 + for (size_t i = 0; i < available_device_URIs->size(); ++i) + { + std::string s = (*available_device_URIs)[i]; + ROS_WARN("------------id %d, available_device_uri is %s-----------", i, s.c_str()); + } + #endif + //end + // look for '#' format + if (device_id.size() > 1 && device_id[0] == '#') + { + std::istringstream device_number_str(device_id.substr(1)); + int device_number; + device_number_str >> device_number; + int device_index = device_number - 1; // #1 refers to first device + if (device_index >= available_device_URIs->size() || device_index < 0) + { + THROW_OPENNI_EXCEPTION( + "Invalid device number %i, there are %zu devices connected.", + device_number, available_device_URIs->size()); + } + else + { + return available_device_URIs->at(device_index); + } + } + // look for '@' format + // is usb bus id, typically start at 1 + // is the device number, for consistency with astra_camera, these start at 1 + // although 0 specifies "any device on this bus" + else if (device_id.size() > 1 && device_id.find('@') != std::string::npos && device_id.find('/') == std::string::npos) + { + // get index of @ character + size_t index = device_id.find('@'); + if (index <= 0) + { + THROW_OPENNI_EXCEPTION( + "%s is not a valid device URI, you must give the bus number before the @.", + device_id.c_str()); + } + if (index >= device_id.size() - 1) + { + THROW_OPENNI_EXCEPTION( + "%s is not a valid device URI, you must give a number after the @, specify 0 for first device", + device_id.c_str()); + } + + // pull out device number on bus + std::istringstream device_number_str(device_id.substr(index+1)); + int device_number; + device_number_str >> device_number; + + // reorder to @ + std::string bus = device_id.substr(0, index); + bus.insert(0, "@"); + + for (size_t i = 0; i < available_device_URIs->size(); ++i) + { + std::string s = (*available_device_URIs)[i]; + if (s.find(bus) != std::string::npos) + { + // this matches our bus, check device number + --device_number; + if (device_number <= 0) + return s; + } + } + + THROW_OPENNI_EXCEPTION("Device not found %s", device_id.c_str()); + } + else + { + // check if the device id given matches a serial number of a connected device + for(std::vector::const_iterator it = available_device_URIs->begin(); + it != available_device_URIs->end(); ++it) + { + #if 0 + try + { + std::string serial = device_manager_->getSerial(*it); + if (serial.size() > 0 && device_id == serial) + return *it; + } + #else + try + { + std::set::iterator iter; + if((iter = alreadyOpen.find(*it)) == alreadyOpen.end()) + { + // ROS_WARN("------------seraial num it is %s, device_id is %s -----------", (*it).c_str(), device_id_.c_str()); + std::string serial = device_manager_->getSerial(*it); + if (serial.size() > 0 && device_id == serial) + { + alreadyOpen.insert(*it); + return *it; + } + } + } + #endif + catch (const AstraException& exception) + { + ROS_WARN("Could not query serial number of device \"%s\":", exception.what()); + } + } + + // everything else is treated as part of the device_URI + bool match_found = false; + std::string matched_uri; + for (size_t i = 0; i < available_device_URIs->size(); ++i) + { + std::string s = (*available_device_URIs)[i]; + if (s.find(device_id) != std::string::npos) + { + if (!match_found) + { + matched_uri = s; + match_found = true; + } + else + { + // more than one match + THROW_OPENNI_EXCEPTION("Two devices match the given device id '%s': %s and %s.", device_id.c_str(), matched_uri.c_str(), s.c_str()); + } + } + } + return matched_uri; + } + + return "INVALID"; +} + +void AstraDriver::initDevice() +{ + while (ros::ok() && !device_) + { + try + { + std::string device_URI = resolveDeviceURI(device_id_); + #if 0 + if( device_URI == "" ) + { + boost::this_thread::sleep(boost::posix_time::milliseconds(500)); + continue; + } + #endif + device_ = device_manager_->getDevice(device_URI); + } + catch (const AstraException& exception) + { + if (!device_) + { + ROS_INFO("No matching device found.... waiting for devices. Reason: %s", exception.what()); + boost::this_thread::sleep(boost::posix_time::seconds(3)); + continue; + } + else + { + ROS_ERROR("Could not retrieve device. Reason: %s", exception.what()); + exit(-1); + } + } + } + + while (ros::ok() && !device_->isValid()) + { + ROS_DEBUG("Waiting for device initialization.."); + boost::this_thread::sleep(boost::posix_time::milliseconds(100)); + } + +} + +void AstraDriver::genVideoModeTableMap() +{ + /* + * # Video modes defined by dynamic reconfigure: +output_mode_enum = gen.enum([ gen.const( "SXGA_30Hz", int_t, 1, "1280x1024@30Hz"), + gen.const( "SXGA_15Hz", int_t, 2, "1280x1024@15Hz"), + gen.const( "XGA_30Hz", int_t, 3, "1280x720@30Hz"), + gen.const( "XGA_15Hz", int_t, 4, "1280x720@15Hz"), + gen.const( "VGA_30Hz", int_t, 5, "640x480@30Hz"), + gen.const( "VGA_25Hz", int_t, 6, "640x480@25Hz"), + gen.const( "QVGA_25Hz", int_t, 7, "320x240@25Hz"), + gen.const( "QVGA_30Hz", int_t, 8, "320x240@30Hz"), + gen.const( "QVGA_60Hz", int_t, 9, "320x240@60Hz"), + gen.const( "QQVGA_25Hz", int_t, 10, "160x120@25Hz"), + gen.const( "QQVGA_30Hz", int_t, 11, "160x120@30Hz"), + gen.const( "QQVGA_60Hz", int_t, 12, "160x120@60Hz"), + gen.const("640400_30Hz", int_t, 13, "640x400@30Hz"), + gen.const("320200_30Hz", int_t, 14, "320x200@30Hz"), + gen.const("1280800_7Hz", int_t, 15, "1280x800@7Hz"), + gen.const("1280800_30Hz", int_t, 16, "1280x800@30Hz"), + gen.const("640400_60Hz", int_t, 17, "640x400@60Hz")], + "output mode") + */ + + video_modes_lookup_.clear(); + + AstraVideoMode video_mode; + + // SXGA_30Hz + video_mode.x_resolution_ = 1280; + video_mode.y_resolution_ = 1024; + video_mode.frame_rate_ = 30; + + video_modes_lookup_[1] = video_mode; + + // SXGA_15Hz + video_mode.x_resolution_ = 1280; + video_mode.y_resolution_ = 1024; + video_mode.frame_rate_ = 15; + + video_modes_lookup_[2] = video_mode; + + // XGA_30Hz + video_mode.x_resolution_ = 1280; + video_mode.y_resolution_ = 720; + video_mode.frame_rate_ = 30; + + video_modes_lookup_[3] = video_mode; + + // XGA_15Hz + video_mode.x_resolution_ = 1280; + video_mode.y_resolution_ = 720; + video_mode.frame_rate_ = 15; + + video_modes_lookup_[4] = video_mode; + + // VGA_30Hz + video_mode.x_resolution_ = 640; + video_mode.y_resolution_ = 480; + video_mode.frame_rate_ = 30; + + video_modes_lookup_[5] = video_mode; + + // VGA_25Hz + video_mode.x_resolution_ = 640; + video_mode.y_resolution_ = 480; + video_mode.frame_rate_ = 25; + + video_modes_lookup_[6] = video_mode; + + // QVGA_25Hz + video_mode.x_resolution_ = 320; + video_mode.y_resolution_ = 240; + video_mode.frame_rate_ = 25; + + video_modes_lookup_[7] = video_mode; + + // QVGA_30Hz + video_mode.x_resolution_ = 320; + video_mode.y_resolution_ = 240; + video_mode.frame_rate_ = 30; + + video_modes_lookup_[8] = video_mode; + + // QVGA_60Hz + video_mode.x_resolution_ = 320; + video_mode.y_resolution_ = 240; + video_mode.frame_rate_ = 60; + + video_modes_lookup_[9] = video_mode; + + // QQVGA_25Hz + video_mode.x_resolution_ = 160; + video_mode.y_resolution_ = 120; + video_mode.frame_rate_ = 25; + + video_modes_lookup_[10] = video_mode; + + // QQVGA_30Hz + video_mode.x_resolution_ = 160; + video_mode.y_resolution_ = 120; + video_mode.frame_rate_ = 30; + + video_modes_lookup_[11] = video_mode; + + // QQVGA_60Hz + video_mode.x_resolution_ = 160; + video_mode.y_resolution_ = 120; + video_mode.frame_rate_ = 60; + + video_modes_lookup_[12] = video_mode; + + // 640*400_30Hz + video_mode.x_resolution_ = 640; + video_mode.y_resolution_ = 400; + video_mode.frame_rate_ = 30; + + video_modes_lookup_[13] = video_mode; + + // 320*200_30Hz + video_mode.x_resolution_ = 320; + video_mode.y_resolution_ = 200; + video_mode.frame_rate_ = 30; + + video_modes_lookup_[14] = video_mode; + + // 1280*800_7Hz + video_mode.x_resolution_ = 1280; + video_mode.y_resolution_ = 800; + video_mode.frame_rate_ = 7; + + video_modes_lookup_[15] = video_mode; + + // 1280*800_30Hz + video_mode.x_resolution_ = 1280; + video_mode.y_resolution_ = 800; + video_mode.frame_rate_ = 30; + + video_modes_lookup_[16] = video_mode; + + // 640*400_60Hz + video_mode.x_resolution_ = 640; + video_mode.y_resolution_ = 400; + video_mode.frame_rate_ = 60; + + video_modes_lookup_[17] = video_mode; +} + +int AstraDriver::lookupVideoModeFromDynConfig(int mode_nr, AstraVideoMode& video_mode) +{ + int ret = -1; + + std::map::const_iterator it; + + it = video_modes_lookup_.find(mode_nr); + + if (it!=video_modes_lookup_.end()) + { + video_mode = it->second; + ret = 0; + } + + return ret; +} + +sensor_msgs::ImageConstPtr AstraDriver::rawToFloatingPointConversion(sensor_msgs::ImageConstPtr raw_image) +{ + static const float bad_point = std::numeric_limits::quiet_NaN (); + + sensor_msgs::ImagePtr new_image = boost::make_shared(); + + new_image->header = raw_image->header; + new_image->width = raw_image->width; + new_image->height = raw_image->height; + new_image->is_bigendian = 0; + new_image->encoding = sensor_msgs::image_encodings::TYPE_32FC1; + new_image->step = sizeof(float)*raw_image->width; + + std::size_t data_size = new_image->width*new_image->height; + new_image->data.resize(data_size*sizeof(float)); + + const unsigned short* in_ptr = reinterpret_cast(&raw_image->data[0]); + float* out_ptr = reinterpret_cast(&new_image->data[0]); + + for (std::size_t i = 0; i(*in_ptr)/1000.0f; + } + } + + return new_image; +} + +} diff --git a/src/ros_astra_camera/src/astra_exception.cpp b/src/ros_astra_camera/src/astra_exception.cpp new file mode 100644 index 0000000..d0d412b --- /dev/null +++ b/src/ros_astra_camera/src/astra_exception.cpp @@ -0,0 +1,85 @@ +/* + * Software License Agreement (BSD License) + * + * Copyright (c) 2011, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * Tim Liu + * + * 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 Willow Garage, Inc. 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 OWNER 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. + * + */ +#include "astra_camera/astra_exception.h" +#include + +namespace astra_wrapper +{ + +AstraException::AstraException (const std::string& function_name, const std::string& file_name, unsigned line_number, const std::string& message) +: function_name_ (function_name) +, file_name_ (file_name) +, line_number_ (line_number) +, message_ (message) +{ + std::stringstream sstream; + sstream << function_name_ << " @ " << file_name_ << " @ " << line_number_ << " : " << message_; + message_long_ = sstream.str(); +} + +AstraException::~AstraException () throw() +{ +} + +AstraException& AstraException::operator = (const AstraException& exception) +{ + message_ = exception.message_; + return *this; +} + +const char* AstraException::what () const throw() +{ + return message_long_.c_str(); +} + +const std::string& AstraException::getFunctionName () const +{ + return function_name_; +} + +const std::string& AstraException::getFileName () const +{ + return file_name_; +} + +unsigned AstraException::getLineNumber () const +{ + return line_number_; +} + +} //namespace astra_camera diff --git a/src/ros_astra_camera/src/astra_frame_listener.cpp b/src/ros_astra_camera/src/astra_frame_listener.cpp new file mode 100644 index 0000000..67bb4c7 --- /dev/null +++ b/src/ros_astra_camera/src/astra_frame_listener.cpp @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ +#include "openni2/OpenNI.h" + +#include "astra_camera/astra_frame_listener.h" +#include "astra_camera/astra_timer_filter.h" + +#include + +#include + +#define TIME_FILTER_LENGTH 15 + +namespace astra_wrapper +{ + +AstraFrameListener::AstraFrameListener() : + callback_(0), + user_device_timer_(false), + timer_filter_(new AstraTimerFilter(TIME_FILTER_LENGTH)), + prev_time_stamp_(0.0) +{ + ros::Time::init(); +} + +void AstraFrameListener::setUseDeviceTimer(bool enable) +{ + user_device_timer_ = enable; + + if (user_device_timer_) + timer_filter_->clear(); +} + +void AstraFrameListener::onNewFrame(openni::VideoStream& stream) +{ + stream.readFrame(&m_frame); + + if (m_frame.isValid() && callback_) + { + sensor_msgs::ImagePtr image(new sensor_msgs::Image); + + ros::Time ros_now = ros::Time::now(); + + if (!user_device_timer_) + { + image->header.stamp = ros_now; + + ROS_DEBUG("Time interval between frames: %.4f ms", (float)((ros_now.toSec()-prev_time_stamp_)*1000.0)); + + prev_time_stamp_ = ros_now.toSec(); + } else + { + uint64_t device_time = m_frame.getTimestamp(); + + double device_time_in_sec = static_cast(device_time)/1000000.0; + double ros_time_in_sec = ros_now.toSec(); + + double time_diff = ros_time_in_sec-device_time_in_sec; + + timer_filter_->addSample(time_diff); + + double filtered_time_diff = timer_filter_->getMedian(); + + double corrected_timestamp = device_time_in_sec+filtered_time_diff; + + image->header.stamp.fromSec(corrected_timestamp); + + ROS_DEBUG("Time interval between frames: %.4f ms", (float)((corrected_timestamp-prev_time_stamp_)*1000.0)); + + prev_time_stamp_ = corrected_timestamp; + } + + image->width = m_frame.getWidth(); + image->height = m_frame.getHeight(); + + std::size_t data_size = m_frame.getDataSize(); + + image->data.resize(data_size); + memcpy(&image->data[0], m_frame.getData(), data_size); + + image->is_bigendian = 0; + + const openni::VideoMode& video_mode = m_frame.getVideoMode(); + switch (video_mode.getPixelFormat()) + { + case openni::PIXEL_FORMAT_DEPTH_1_MM: + image->encoding = sensor_msgs::image_encodings::TYPE_16UC1; + image->step = sizeof(unsigned char) * 2 * image->width; + break; + case openni::PIXEL_FORMAT_DEPTH_100_UM: + image->encoding = sensor_msgs::image_encodings::TYPE_16UC1; + image->step = sizeof(unsigned char) * 2 * image->width; + break; + case openni::PIXEL_FORMAT_SHIFT_9_2: + image->encoding = sensor_msgs::image_encodings::TYPE_16UC1; + image->step = sizeof(unsigned char) * 2 * image->width; + break; + case openni::PIXEL_FORMAT_SHIFT_9_3: + image->encoding = sensor_msgs::image_encodings::TYPE_16UC1; + image->step = sizeof(unsigned char) * 2 * image->width; + break; + + case openni::PIXEL_FORMAT_RGB888: + image->encoding = sensor_msgs::image_encodings::RGB8; + image->step = sizeof(unsigned char) * 3 * image->width; + break; + case openni::PIXEL_FORMAT_YUV422: + image->encoding = sensor_msgs::image_encodings::YUV422; + image->step = sizeof(unsigned char) * 4 * image->width; + break; + case openni::PIXEL_FORMAT_GRAY8: + image->encoding = sensor_msgs::image_encodings::MONO8; + image->step = sizeof(unsigned char) * 1 * image->width; + break; + case openni::PIXEL_FORMAT_GRAY16: + image->encoding = sensor_msgs::image_encodings::MONO16; + image->step = sizeof(unsigned char) * 2 * image->width; + break; + case openni::PIXEL_FORMAT_JPEG: + default: + ROS_ERROR("Invalid image encoding"); + break; + } + + callback_(image); + } + +} + +} + diff --git a/src/ros_astra_camera/src/astra_timer_filter.cpp b/src/ros_astra_camera/src/astra_timer_filter.cpp new file mode 100644 index 0000000..2bb4c6c --- /dev/null +++ b/src/ros_astra_camera/src/astra_timer_filter.cpp @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#include "astra_camera/astra_timer_filter.h" +#include + + +namespace astra_wrapper +{ + +AstraTimerFilter::AstraTimerFilter(std::size_t filter_len): + filter_len_(filter_len) +{ +} + +AstraTimerFilter::~AstraTimerFilter() +{ +} + +void AstraTimerFilter::addSample(double sample) +{ + buffer_.push_back(sample); + if (buffer_.size()>filter_len_) + buffer_.pop_front(); +} + +double AstraTimerFilter::getMedian() +{ + if (buffer_.size()>0) + { + std::deque sort_buffer = buffer_; + + std::sort(sort_buffer.begin(), sort_buffer.end()); + + return sort_buffer[sort_buffer.size()/2]; + } else + return 0.0; +} + +double AstraTimerFilter::getMovingAvg() +{ + if (buffer_.size() > 0) + { + double sum = 0; + + std::deque::const_iterator it = buffer_.begin(); + std::deque::const_iterator it_end = buffer_.end(); + + while (it != it_end) + { + sum += *(it++); + } + + return sum / static_cast(buffer_.size()); + } else + return 0.0; +} + + +void AstraTimerFilter::clear() +{ + buffer_.clear(); +} + + +} //namespace openni2_wrapper diff --git a/src/ros_astra_camera/src/astra_video_mode.cpp b/src/ros_astra_camera/src/astra_video_mode.cpp new file mode 100644 index 0000000..9ef5c84 --- /dev/null +++ b/src/ros_astra_camera/src/astra_video_mode.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#include "astra_camera/astra_video_mode.h" + +namespace astra_wrapper +{ + + +std::ostream& operator << (std::ostream& stream, const AstraVideoMode& video_mode) { + stream << "Resolution: " << (int)video_mode.x_resolution_ << "x" << (int)video_mode.y_resolution_ << + "@" << video_mode.frame_rate_ << + "Hz Format: "; + + switch (video_mode.pixel_format_) + { + case PIXEL_FORMAT_DEPTH_1_MM: + stream << "Depth 1mm"; + break; + case PIXEL_FORMAT_DEPTH_100_UM: + stream << "Depth 100um"; + break; + case PIXEL_FORMAT_SHIFT_9_2: + stream << "Shift 9/2"; + break; + case PIXEL_FORMAT_SHIFT_9_3: + stream << "Shift 9/3"; + break; + case PIXEL_FORMAT_RGB888: + stream << "RGB888"; + break; + case PIXEL_FORMAT_YUV422: + stream << "YUV422"; + break; + case PIXEL_FORMAT_GRAY8: + stream << "Gray8"; + break; + case PIXEL_FORMAT_GRAY16: + stream << "Gray16"; + break; + case PIXEL_FORMAT_JPEG: + stream << "JPEG"; + break; + + default: + break; + } + + return stream; +} + +bool operator==(const AstraVideoMode& video_mode_a, const AstraVideoMode& video_mode_b) +{ + return (video_mode_a.x_resolution_==video_mode_b.x_resolution_) && + (video_mode_a.y_resolution_==video_mode_b.y_resolution_) && + (video_mode_a.frame_rate_ ==video_mode_b.frame_rate_) && + (video_mode_a.pixel_format_==video_mode_b.pixel_format_); +} + +bool operator!=(const AstraVideoMode& video_mode_a, const AstraVideoMode& video_mode_b) +{ + return !(video_mode_a==video_mode_b); +} + +} //namespace openni2_wrapper diff --git a/src/ros_astra_camera/src/libuvc_camera/camera_driver.cpp b/src/ros_astra_camera/src/libuvc_camera/camera_driver.cpp new file mode 100644 index 0000000..eab3744 --- /dev/null +++ b/src/ros_astra_camera/src/libuvc_camera/camera_driver.cpp @@ -0,0 +1,620 @@ +/********************************************************************* +* Software License Agreement (BSD License) +* +* Copyright (C) 2012 Ken Tossell +* 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 author nor other 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 OWNER 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. +*********************************************************************/ +#include "libuvc_camera/camera_driver.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define libuvc_VERSION (libuvc_VERSION_MAJOR * 10000 \ + + libuvc_VERSION_MINOR * 100 \ + + libuvc_VERSION_PATCH) + +namespace libuvc_camera { + +CameraDriver::CameraDriver(ros::NodeHandle nh, ros::NodeHandle priv_nh) + : nh_(nh), priv_nh_(priv_nh), + state_(kInitial), + ctx_(NULL), dev_(NULL), devh_(NULL), rgb_frame_(NULL), + it_(nh_), + config_server_(mutex_, priv_nh_), + config_changed_(false), + cinfo_manager_(nh) { + cam_pub_ = it_.advertiseCamera("image_raw", 1, false); + ns = ros::this_node::getNamespace(); + device_type_client = nh_.serviceClient(ns + "/get_device_type"); + camera_info_client = nh_.serviceClient(ns + "/get_camera_info"); + get_uvc_exposure_server = nh_.advertiseService("get_uvc_exposure", &CameraDriver::getUVCExposureCb, this); + set_uvc_exposure_server = nh_.advertiseService("set_uvc_exposure", &CameraDriver::setUVCExposureCb, this); + get_uvc_gain_server = nh_.advertiseService("get_uvc_gain", &CameraDriver::getUVCGainCb, this); + set_uvc_gain_server = nh_.advertiseService("set_uvc_gain", &CameraDriver::setUVCGainCb, this); + get_uvc_white_balance_server = nh_.advertiseService("get_uvc_white_balance", &CameraDriver::getUVCWhiteBalanceCb, this); + set_uvc_white_balance_server = nh_.advertiseService("set_uvc_white_balance", &CameraDriver::setUVCWhiteBalanceCb, this); + device_type_init_ = false; + camera_info_init_ = false; + uvc_flip_ = 0; + device_type_no_ = OB_ASTRA_NO; + int slash_end; + for (slash_end = 0; slash_end < ns.length(); slash_end++) + { + if (ns[slash_end] != '/') + { + break; + } + } + ns_no_slash = ns.substr(slash_end); + camera_info_valid_ = false; +} + +CameraDriver::~CameraDriver() { + if (rgb_frame_) + uvc_free_frame(rgb_frame_); + + if (ctx_) + uvc_exit(ctx_); // Destroys dev_, devh_, etc. +} + +bool CameraDriver::getUVCExposureCb(astra_camera::GetUVCExposureRequest& req, astra_camera::GetUVCExposureResponse& res) +{ + uint32_t expo; + uvc_error_t err = uvc_get_exposure_abs(devh_, &expo, UVC_GET_CUR); + res.exposure = expo; + return (err == UVC_SUCCESS); +} + +bool CameraDriver::setUVCExposureCb(astra_camera::SetUVCExposureRequest& req, astra_camera::SetUVCExposureResponse& res) +{ + if (req.exposure == 0) + { + uvc_set_ae_mode(devh_, 2); + return true; + } + uvc_set_ae_mode(devh_, 1); // mode 1: manual mode; 2: auto mode; 4: shutter priority mode; 8: aperture priority mode + if (req.exposure > 330) + { + ROS_ERROR("Please set exposure lower than 330"); + return false; + } + uvc_error_t err = uvc_set_exposure_abs(devh_, req.exposure); + return (err == UVC_SUCCESS); +} + +bool CameraDriver::getUVCGainCb(astra_camera::GetUVCGainRequest& req, astra_camera::GetUVCGainResponse& res) +{ + uint16_t gain; + uvc_error_t err = uvc_get_gain(devh_, &gain, UVC_GET_CUR); + res.gain = gain; + return (err == UVC_SUCCESS); +} + +bool CameraDriver::setUVCGainCb(astra_camera::SetUVCGainRequest& req, astra_camera::SetUVCGainResponse& res) +{ + uvc_error_t err = uvc_set_gain(devh_, req.gain); + return (err == UVC_SUCCESS); +} + +bool CameraDriver::getUVCWhiteBalanceCb(astra_camera::GetUVCWhiteBalanceRequest& req, astra_camera::GetUVCWhiteBalanceResponse& res) +{ + uint16_t white_balance; + uvc_error_t err = uvc_get_white_balance_temperature(devh_, &white_balance, UVC_GET_CUR); + res.white_balance = white_balance; + return (err == UVC_SUCCESS); +} + +bool CameraDriver::setUVCWhiteBalanceCb(astra_camera::SetUVCWhiteBalanceRequest& req, astra_camera::SetUVCWhiteBalanceResponse& res) +{ + if (req.white_balance == 0) + { + uvc_set_white_balance_temperature_auto(devh_, 1); + return true; + } + uvc_set_white_balance_temperature_auto(devh_, 0); // 0: manual, 1: auto + uvc_error_t err = uvc_set_white_balance_temperature(devh_, req.white_balance); + return (err == UVC_SUCCESS); +} + +bool CameraDriver::Start() { + assert(state_ == kInitial); + + uvc_error_t err; + + err = uvc_init(&ctx_, NULL); + + if (err != UVC_SUCCESS) { + uvc_perror(err, "ERROR: uvc_init"); + return false; + } + + state_ = kStopped; + + config_server_.setCallback(boost::bind(&CameraDriver::ReconfigureCallback, this, _1, _2)); + + return state_ == kRunning; +} + +void CameraDriver::Stop() { + boost::recursive_mutex::scoped_lock(mutex_); + + assert(state_ != kInitial); + + if (state_ == kRunning) + CloseCamera(); + + assert(state_ == kStopped); + + uvc_exit(ctx_); + ctx_ = NULL; + + state_ = kInitial; +} + +void CameraDriver::ReconfigureCallback(UVCCameraConfig &new_config, uint32_t level) { + boost::recursive_mutex::scoped_lock(mutex_); + + if ((level & kReconfigureClose) == kReconfigureClose) { + if (state_ == kRunning) + CloseCamera(); + } + + if (state_ == kStopped) { + OpenCamera(new_config); + } + + if (new_config.camera_info_url != config_.camera_info_url) + cinfo_manager_.loadCameraInfo(new_config.camera_info_url); + + if (state_ == kRunning) { +#define PARAM_INT(name, fn, value) if (new_config.name != config_.name) { \ + int val = (value); \ + if (uvc_set_##fn(devh_, val)) { \ + ROS_WARN("Unable to set " #name " to %d", val); \ + new_config.name = config_.name; \ + } \ + } + + PARAM_INT(scanning_mode, scanning_mode, new_config.scanning_mode); + PARAM_INT(auto_exposure, ae_mode, 1 << new_config.auto_exposure); + PARAM_INT(auto_exposure_priority, ae_priority, new_config.auto_exposure_priority); + PARAM_INT(exposure_absolute, exposure_abs, new_config.exposure_absolute * 10000); + PARAM_INT(auto_focus, focus_auto, new_config.auto_focus ? 1 : 0); + PARAM_INT(focus_absolute, focus_abs, new_config.focus_absolute); +#if libuvc_VERSION > 00005 /* version > 0.0.5 */ + PARAM_INT(gain, gain, new_config.gain); + PARAM_INT(iris_absolute, iris_abs, new_config.iris_absolute); + PARAM_INT(brightness, brightness, new_config.brightness); +#endif + + + if (new_config.pan_absolute != config_.pan_absolute || new_config.tilt_absolute != config_.tilt_absolute) { + if (uvc_set_pantilt_abs(devh_, new_config.pan_absolute, new_config.tilt_absolute)) { + ROS_WARN("Unable to set pantilt to %d, %d", new_config.pan_absolute, new_config.tilt_absolute); + new_config.pan_absolute = config_.pan_absolute; + new_config.tilt_absolute = config_.tilt_absolute; + } + } + // TODO: roll_absolute + // TODO: privacy + // TODO: backlight_compensation + // TODO: contrast + // TODO: power_line_frequency + // TODO: auto_hue + // TODO: saturation + // TODO: sharpness + // TODO: gamma + // TODO: auto_white_balance + // TODO: white_balance_temperature + // TODO: white_balance_BU + // TODO: white_balance_RV + } + + config_ = new_config; +} + +void CameraDriver::ImageCallback(uvc_frame_t *frame) { + ros::Time timestamp = ros::Time(frame->capture_time.tv_sec, frame->capture_time.tv_usec); + if ( timestamp == ros::Time(0) ) { + timestamp = ros::Time::now(); + } + + boost::recursive_mutex::scoped_lock(mutex_); + + assert(state_ == kRunning); + assert(rgb_frame_); + + sensor_msgs::Image::Ptr image(new sensor_msgs::Image()); + image->width = config_.width; + image->height = config_.height; + image->step = image->width * 3; + image->data.resize(image->step * image->height); + + if (frame->frame_format == UVC_FRAME_FORMAT_BGR){ + image->encoding = "bgr8"; + memcpy(&(image->data[0]), frame->data, frame->data_bytes); + } else if (frame->frame_format == UVC_FRAME_FORMAT_RGB){ + image->encoding = "rgb8"; + memcpy(&(image->data[0]), frame->data, frame->data_bytes); + } else if (frame->frame_format == UVC_FRAME_FORMAT_UYVY) { + image->encoding = "yuv422"; + memcpy(&(image->data[0]), frame->data, frame->data_bytes); + } else if (frame->frame_format == UVC_FRAME_FORMAT_YUYV) { + // FIXME: uvc_any2bgr does not work on "yuyv" format, so use uvc_yuyv2bgr directly. + uvc_error_t conv_ret = uvc_yuyv2bgr(frame, rgb_frame_); + if (conv_ret != UVC_SUCCESS) { + uvc_perror(conv_ret, "Couldn't convert frame to RGB"); + return; + } + image->encoding = "bgr8"; + memcpy(&(image->data[0]), rgb_frame_->data, rgb_frame_->data_bytes); +#if libuvc_VERSION > 00005 /* version > 0.0.5 */ + } else if (frame->frame_format == UVC_FRAME_FORMAT_MJPEG) { + // Enable mjpeg support despite uvs_any2bgr shortcoming + // https://github.com/ros-drivers/libuvc_ros/commit/7508a09f + uvc_error_t conv_ret = uvc_mjpeg2rgb(frame, rgb_frame_); + if (conv_ret != UVC_SUCCESS) { + uvc_perror(conv_ret, "Couldn't convert frame to RGB"); + return; + } + image->encoding = "rgb8"; + memcpy(&(image->data[0]), rgb_frame_->data, rgb_frame_->data_bytes); +#endif + } else { + uvc_error_t conv_ret = uvc_any2bgr(frame, rgb_frame_); + if (conv_ret != UVC_SUCCESS) { + uvc_perror(conv_ret, "Couldn't convert frame to RGB"); + return; + } + image->encoding = "bgr8"; + memcpy(&(image->data[0]), rgb_frame_->data, rgb_frame_->data_bytes); + } + + astra_camera::GetDeviceType device_type_srv; + astra_camera::GetCameraInfo camera_info_srv; + + if (device_type_init_ == false) + { + if (device_type_client.call(device_type_srv)) + { + device_type_ = device_type_srv.response.device_type; + if (strcmp(device_type_.c_str(), OB_STEREO_S) == 0) + { + device_type_no_ = OB_STEREO_S_NO; + } + else if (strcmp(device_type_.c_str(), OB_EMBEDDED_S) == 0) + { + device_type_no_ = OB_EMBEDDED_S_NO; + uvc_flip_ = 1; + } + else if (strcmp(device_type_.c_str(), OB_ASTRA_PRO) == 0) + { + device_type_no_ = OB_ASTRA_PRO_NO; + } + else if (strcmp(device_type_.c_str(), OB_STEREO_S_U3) == 0) + { + device_type_no_ = OB_STEREO_S_U3_NO; + } + else + { + device_type_no_ = OB_ASTRA_NO; + } + device_type_init_ = true; + } + } + + if (camera_info_init_ == false) + { + if (camera_info_client.call(camera_info_srv)) + { + camera_info_ = camera_info_srv.response.info; + camera_info_init_ = true; + camera_info_valid_ = true; + if (std::isnan(camera_info_.K[0]) || std::isnan(camera_info_.K[2]) || std::isnan(camera_info_.K[4]) || std::isnan(camera_info_.K[5])) + { + camera_info_valid_ = false; + } + } + } + + sensor_msgs::CameraInfo::Ptr cinfo(new sensor_msgs::CameraInfo(cinfo_manager_.getCameraInfo())); + if (device_type_init_ == true && astraWithUVC(device_type_no_)) + { + // update cinfo + if (camera_info_init_ == true && camera_info_valid_ == true) + { + cinfo->height = image->height; + cinfo->width = image->width; + cinfo->distortion_model = camera_info_.distortion_model; + cinfo->D.resize(5, 0.0); + cinfo->D[4] = 0.0000000001; + // for (int i = 0; i < 5; i++) + // { + // cinfo->D[i] = camera_info_.D[i]; + // } + for (int i = 0; i < 9; i++) + { + cinfo->K[i] = camera_info_.K[i]; + cinfo->R[i] = camera_info_.R[i]; + } + cinfo->K[0] = (1 - uvc_flip_)*(camera_info_.K[0]) + (uvc_flip_)*(-camera_info_.K[0]); + cinfo->K[2] = (1 - uvc_flip_)*(camera_info_.K[2]) + (uvc_flip_)*(image->width - camera_info_.K[2]); + for (int i = 0; i < 12; i++) + { + cinfo->P[i] = camera_info_.P[i]; + } + } + image->header.frame_id = ns_no_slash + "_rgb_optical_frame"; + cinfo->header.frame_id = ns_no_slash + "_rgb_optical_frame"; + } + else + { + image->header.frame_id = config_.frame_id; + cinfo->header.frame_id = config_.frame_id; + } + image->header.stamp = timestamp; + cinfo->header.stamp = timestamp; + + cam_pub_.publish(image, cinfo); + + if (config_changed_) + { + config_server_.updateConfig(config_); + config_changed_ = false; + } +} + +/* static */ void CameraDriver::ImageCallbackAdapter(uvc_frame_t *frame, void *ptr) { + CameraDriver *driver = static_cast(ptr); + + driver->ImageCallback(frame); +} + +void CameraDriver::AutoControlsCallback( + enum uvc_status_class status_class, + int event, + int selector, + enum uvc_status_attribute status_attribute, + void *data, size_t data_len) { + boost::recursive_mutex::scoped_lock(mutex_); + + printf("Controls callback. class: %d, event: %d, selector: %d, attr: %d, data_len: %zu\n", + status_class, event, selector, status_attribute, data_len); + + if (status_attribute == UVC_STATUS_ATTRIBUTE_VALUE_CHANGE) { + switch (status_class) { + case UVC_STATUS_CLASS_CONTROL_CAMERA: { + switch (selector) { + case UVC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL: + uint8_t *data_char = (uint8_t*) data; + uint32_t exposure_int = ((data_char[0]) | (data_char[1] << 8) | + (data_char[2] << 16) | (data_char[3] << 24)); + config_.exposure_absolute = exposure_int * 0.0001; + config_changed_ = true; + break; + } + break; + } + case UVC_STATUS_CLASS_CONTROL_PROCESSING: { + switch (selector) { + case UVC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL: + uint8_t *data_char = (uint8_t*) data; + config_.white_balance_temperature = + data_char[0] | (data_char[1] << 8); + config_changed_ = true; + break; + } + break; + } + } + + // config_server_.updateConfig(config_); + } +} + +/* static */ void CameraDriver::AutoControlsCallbackAdapter( + enum uvc_status_class status_class, + int event, + int selector, + enum uvc_status_attribute status_attribute, + void *data, size_t data_len, + void *ptr) { + CameraDriver *driver = static_cast(ptr); + + driver->AutoControlsCallback(status_class, event, selector, + status_attribute, data, data_len); +} + +enum uvc_frame_format CameraDriver::GetVideoMode(std::string vmode){ + if(vmode == "uncompressed") { + return UVC_COLOR_FORMAT_UNCOMPRESSED; + } else if (vmode == "compressed") { + return UVC_COLOR_FORMAT_COMPRESSED; + } else if (vmode == "yuyv") { + return UVC_COLOR_FORMAT_YUYV; + } else if (vmode == "uyvy") { + return UVC_COLOR_FORMAT_UYVY; + } else if (vmode == "rgb") { + return UVC_COLOR_FORMAT_RGB; + } else if (vmode == "bgr") { + return UVC_COLOR_FORMAT_BGR; + } else if (vmode == "mjpeg") { + return UVC_COLOR_FORMAT_MJPEG; + } else if (vmode == "gray8") { + return UVC_COLOR_FORMAT_GRAY8; + } else { + ROS_ERROR_STREAM("Invalid Video Mode: " << vmode); + ROS_WARN_STREAM("Continue using video mode: uncompressed"); + return UVC_COLOR_FORMAT_UNCOMPRESSED; + } +}; + +void CameraDriver::OpenCamera(UVCCameraConfig &new_config) { + assert(state_ == kStopped); + + int vendor_id = strtol(new_config.vendor.c_str(), NULL, 0); + int product_id = strtol(new_config.product.c_str(), NULL, 0); + + ROS_INFO("Opening camera with vendor=0x%x, product=0x%x, serial=\"%s\", index=%d", + vendor_id, product_id, new_config.serial.c_str(), new_config.index); + + uvc_device_t **devs; + + // Implement missing index select behavior + // https://github.com/ros-drivers/libuvc_ros/commit/4f30e9a0 +#if libuvc_VERSION > 00005 /* version > 0.0.5 */ + uvc_error_t find_err = uvc_find_devices( + ctx_, &devs, + vendor_id, + product_id, + new_config.serial.empty() ? NULL : new_config.serial.c_str()); + + if (find_err != UVC_SUCCESS) { + uvc_perror(find_err, "uvc_find_device"); + return; + } + + // select device by index + dev_ = NULL; + int dev_idx = 0; + while (devs[dev_idx] != NULL) { + if(dev_idx == new_config.index) { + dev_ = devs[dev_idx]; + } + else { + uvc_unref_device(devs[dev_idx]); + } + + dev_idx++; + } + + if(dev_ == NULL) { + ROS_ERROR("Unable to find device at index %d", new_config.index); + return; + } +#else + uvc_error_t find_err = uvc_find_device( + ctx_, &dev_, + vendor_id, + product_id, + new_config.serial.empty() ? NULL : new_config.serial.c_str()); + + if (find_err != UVC_SUCCESS) { + uvc_perror(find_err, "uvc_find_device"); + return; + } + +#endif + uvc_error_t open_err = uvc_open(dev_, &devh_); + + if (open_err != UVC_SUCCESS) { + switch (open_err) { + case UVC_ERROR_ACCESS: +#ifdef __linux__ + ROS_ERROR("Permission denied opening /dev/bus/usb/%03d/%03d", + uvc_get_bus_number(dev_), uvc_get_device_address(dev_)); +#else + ROS_ERROR("Permission denied opening device %d on bus %d", + uvc_get_device_address(dev_), uvc_get_bus_number(dev_)); +#endif + break; + default: +#ifdef __linux__ + ROS_ERROR("Can't open /dev/bus/usb/%03d/%03d: %s (%d)", + uvc_get_bus_number(dev_), uvc_get_device_address(dev_), + uvc_strerror(open_err), open_err); +#else + ROS_ERROR("Can't open device %d on bus %d: %s (%d)", + uvc_get_device_address(dev_), uvc_get_bus_number(dev_), + uvc_strerror(open_err), open_err); +#endif + break; + } + + uvc_unref_device(dev_); + return; + } + + uvc_set_status_callback(devh_, &CameraDriver::AutoControlsCallbackAdapter, this); + + uvc_stream_ctrl_t ctrl; + uvc_error_t mode_err = uvc_get_stream_ctrl_format_size( + devh_, &ctrl, + GetVideoMode(new_config.video_mode), + new_config.width, new_config.height, + new_config.frame_rate); + + if (mode_err != UVC_SUCCESS) { + uvc_perror(mode_err, "uvc_get_stream_ctrl_format_size"); + uvc_close(devh_); + uvc_unref_device(dev_); + ROS_ERROR("check video_mode/width/height/frame_rate are available"); + uvc_print_diag(devh_, NULL); + return; + } + + uvc_error_t stream_err = uvc_start_streaming(devh_, &ctrl, &CameraDriver::ImageCallbackAdapter, this, 0); + + if (stream_err != UVC_SUCCESS) { + uvc_perror(stream_err, "uvc_start_streaming"); + uvc_close(devh_); + uvc_unref_device(dev_); + return; + } + + if (rgb_frame_) + uvc_free_frame(rgb_frame_); + + rgb_frame_ = uvc_allocate_frame(new_config.width * new_config.height * 3); + assert(rgb_frame_); + + state_ = kRunning; +} + +void CameraDriver::CloseCamera() { + assert(state_ == kRunning); + + uvc_close(devh_); + devh_ = NULL; + + uvc_unref_device(dev_); + dev_ = NULL; + + state_ = kStopped; +} + +}; diff --git a/src/ros_astra_camera/src/libuvc_camera/main.cpp b/src/ros_astra_camera/src/libuvc_camera/main.cpp new file mode 100644 index 0000000..e596a36 --- /dev/null +++ b/src/ros_astra_camera/src/libuvc_camera/main.cpp @@ -0,0 +1,53 @@ +/********************************************************************* +* Software License Agreement (BSD License) +* +* Copyright (C) 2012 Ken Tossell +* 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 author nor other 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 OWNER 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. +*********************************************************************/ +#include + +#include "libuvc_camera/camera_driver.h" + +int main (int argc, char **argv) { + ros::init(argc, argv, "libuvc_camera"); + ros::NodeHandle nh; + ros::NodeHandle priv_nh("~"); + + libuvc_camera::CameraDriver driver(nh, priv_nh); + + if (!driver.Start()) + return -1; + + ros::spin(); + + driver.Stop(); + + return 0; +} diff --git a/src/ros_astra_camera/src/libuvc_camera/nodelet.cpp b/src/ros_astra_camera/src/libuvc_camera/nodelet.cpp new file mode 100644 index 0000000..91d2f3c --- /dev/null +++ b/src/ros_astra_camera/src/libuvc_camera/nodelet.cpp @@ -0,0 +1,78 @@ +/********************************************************************* +* Software License Agreement (BSD License) +* +* Copyright (C) 2012 Ken Tossell +* 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 author nor other 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 OWNER 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. +*********************************************************************/ +#include +#include +#include + +#include "libuvc_camera/camera_driver.h" + +namespace libuvc_camera { + +class CameraNodelet : public nodelet::Nodelet { +public: + CameraNodelet() : running_(false) {} + ~CameraNodelet(); + +private: + virtual void onInit(); + + volatile bool running_; + boost::shared_ptr driver_; +}; + +CameraNodelet::~CameraNodelet() { + if (running_) { + driver_->Stop(); + } +} + +void CameraNodelet::onInit() { + ros::NodeHandle nh(getNodeHandle()); + ros::NodeHandle priv_nh(getPrivateNodeHandle()); + + driver_.reset(new CameraDriver(nh, priv_nh)); + if (driver_->Start()) { + running_ = true; + } else { + NODELET_ERROR("Unable to open camera."); + driver_.reset(); + } +} + +}; + +// Register this plugin with pluginlib. +// +// parameters are: class type, base class type +PLUGINLIB_EXPORT_CLASS(libuvc_camera::CameraNodelet, nodelet::Nodelet) diff --git a/src/ros_astra_camera/src/list_devices.cpp b/src/ros_astra_camera/src/list_devices.cpp new file mode 100644 index 0000000..fe5319f --- /dev/null +++ b/src/ros_astra_camera/src/list_devices.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014, Savioke, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +/** + * Small executable that creates a device manager to print the information of all devices including their + * serial number. + */ + +#include +#include "astra_camera/astra_device_manager.h" +#include "astra_camera/astra_exception.h" + +using astra_wrapper::AstraDeviceManager; +using astra_wrapper::AstraDeviceInfo; +using astra_wrapper::AstraException; + +int main(int arc, char** argv) +{ + astra_wrapper::AstraDeviceManager manager; + boost::shared_ptr > device_infos = manager.getConnectedDeviceInfos(); + std::cout << "Found " << device_infos->size() << " devices:" << std::endl << std::endl; + for (size_t i = 0; i < device_infos->size(); ++i) + { + std::cout << "Device #" << i << ":" << std::endl; + std::cout << device_infos->at(i) << std::endl; + try { + std::string serial = manager.getSerial(device_infos->at(i).uri_); + std::cout << "Serial number: " << serial << std::endl; + } + catch (const AstraException& exception) + { + std::cerr << "Could not retrieve serial number: " << exception.what() << std::endl; + } + } + return 0; +} + diff --git a/src/ros_astra_camera/src/usb_reset.c b/src/ros_astra_camera/src/usb_reset.c new file mode 100644 index 0000000..499c2ca --- /dev/null +++ b/src/ros_astra_camera/src/usb_reset.c @@ -0,0 +1,72 @@ +/* usbreset -- send a USB port reset to a USB device */ + +/* + * Copyright (c) 2014, JSK Robotics Lab, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#include +#include +#include +#include +#include + +#include + + +int main(int argc, char **argv) +{ + const char *filename; + int fd; + int rc; + + if (argc != 2) { + fprintf(stderr, "Usage: usbreset device-filename\n"); + return 1; + } + filename = argv[1]; + + fd = open(filename, O_WRONLY); + if (fd < 0) { + perror("Error opening output file"); + return 1; + } + + printf("Resetting USB device %s\n", filename); + rc = ioctl(fd, USBDEVFS_RESET, 0); + if (rc < 0) { + perror("Error in ioctl"); + return 1; + } + printf("Reset successful\n"); + + close(fd); + return 0; +} diff --git a/src/ros_astra_camera/srv/GetCameraInfo.srv b/src/ros_astra_camera/srv/GetCameraInfo.srv new file mode 100644 index 0000000..6704761 --- /dev/null +++ b/src/ros_astra_camera/srv/GetCameraInfo.srv @@ -0,0 +1,2 @@ +--- +sensor_msgs/CameraInfo info \ No newline at end of file diff --git a/src/ros_astra_camera/srv/GetDeviceType.srv b/src/ros_astra_camera/srv/GetDeviceType.srv new file mode 100644 index 0000000..fa2b58f --- /dev/null +++ b/src/ros_astra_camera/srv/GetDeviceType.srv @@ -0,0 +1,2 @@ +--- +string device_type \ No newline at end of file diff --git a/src/ros_astra_camera/srv/GetIRExposure.srv b/src/ros_astra_camera/srv/GetIRExposure.srv new file mode 100644 index 0000000..3004719 --- /dev/null +++ b/src/ros_astra_camera/srv/GetIRExposure.srv @@ -0,0 +1,2 @@ +--- +int32 exposure \ No newline at end of file diff --git a/src/ros_astra_camera/srv/GetIRGain.srv b/src/ros_astra_camera/srv/GetIRGain.srv new file mode 100644 index 0000000..0e9a2dd --- /dev/null +++ b/src/ros_astra_camera/srv/GetIRGain.srv @@ -0,0 +1,2 @@ +--- +int32 gain \ No newline at end of file diff --git a/src/ros_astra_camera/srv/GetSerial.srv b/src/ros_astra_camera/srv/GetSerial.srv new file mode 100644 index 0000000..23d23a0 --- /dev/null +++ b/src/ros_astra_camera/srv/GetSerial.srv @@ -0,0 +1,2 @@ +--- +string serial diff --git a/src/ros_astra_camera/srv/GetUVCExposure.srv b/src/ros_astra_camera/srv/GetUVCExposure.srv new file mode 100644 index 0000000..3004719 --- /dev/null +++ b/src/ros_astra_camera/srv/GetUVCExposure.srv @@ -0,0 +1,2 @@ +--- +int32 exposure \ No newline at end of file diff --git a/src/ros_astra_camera/srv/GetUVCGain.srv b/src/ros_astra_camera/srv/GetUVCGain.srv new file mode 100644 index 0000000..0e9a2dd --- /dev/null +++ b/src/ros_astra_camera/srv/GetUVCGain.srv @@ -0,0 +1,2 @@ +--- +int32 gain \ No newline at end of file diff --git a/src/ros_astra_camera/srv/GetUVCWhiteBalance.srv b/src/ros_astra_camera/srv/GetUVCWhiteBalance.srv new file mode 100644 index 0000000..75eefb1 --- /dev/null +++ b/src/ros_astra_camera/srv/GetUVCWhiteBalance.srv @@ -0,0 +1,2 @@ +--- +int32 white_balance \ No newline at end of file diff --git a/src/ros_astra_camera/srv/ResetIRExposure.srv b/src/ros_astra_camera/srv/ResetIRExposure.srv new file mode 100644 index 0000000..73b314f --- /dev/null +++ b/src/ros_astra_camera/srv/ResetIRExposure.srv @@ -0,0 +1 @@ +--- \ No newline at end of file diff --git a/src/ros_astra_camera/srv/ResetIRGain.srv b/src/ros_astra_camera/srv/ResetIRGain.srv new file mode 100644 index 0000000..73b314f --- /dev/null +++ b/src/ros_astra_camera/srv/ResetIRGain.srv @@ -0,0 +1 @@ +--- \ No newline at end of file diff --git a/src/ros_astra_camera/srv/SetIRExposure.srv b/src/ros_astra_camera/srv/SetIRExposure.srv new file mode 100644 index 0000000..e934df4 --- /dev/null +++ b/src/ros_astra_camera/srv/SetIRExposure.srv @@ -0,0 +1,2 @@ +int32 exposure +--- \ No newline at end of file diff --git a/src/ros_astra_camera/srv/SetIRFlood.srv b/src/ros_astra_camera/srv/SetIRFlood.srv new file mode 100644 index 0000000..10fc45d --- /dev/null +++ b/src/ros_astra_camera/srv/SetIRFlood.srv @@ -0,0 +1,2 @@ +bool enable +--- \ No newline at end of file diff --git a/src/ros_astra_camera/srv/SetIRGain.srv b/src/ros_astra_camera/srv/SetIRGain.srv new file mode 100644 index 0000000..1f66113 --- /dev/null +++ b/src/ros_astra_camera/srv/SetIRGain.srv @@ -0,0 +1,2 @@ +int32 gain +--- \ No newline at end of file diff --git a/src/ros_astra_camera/srv/SetLDP.srv b/src/ros_astra_camera/srv/SetLDP.srv new file mode 100644 index 0000000..10fc45d --- /dev/null +++ b/src/ros_astra_camera/srv/SetLDP.srv @@ -0,0 +1,2 @@ +bool enable +--- \ No newline at end of file diff --git a/src/ros_astra_camera/srv/SetLaser.srv b/src/ros_astra_camera/srv/SetLaser.srv new file mode 100644 index 0000000..10fc45d --- /dev/null +++ b/src/ros_astra_camera/srv/SetLaser.srv @@ -0,0 +1,2 @@ +bool enable +--- \ No newline at end of file diff --git a/src/ros_astra_camera/srv/SetUVCExposure.srv b/src/ros_astra_camera/srv/SetUVCExposure.srv new file mode 100644 index 0000000..e934df4 --- /dev/null +++ b/src/ros_astra_camera/srv/SetUVCExposure.srv @@ -0,0 +1,2 @@ +int32 exposure +--- \ No newline at end of file diff --git a/src/ros_astra_camera/srv/SetUVCGain.srv b/src/ros_astra_camera/srv/SetUVCGain.srv new file mode 100644 index 0000000..1f66113 --- /dev/null +++ b/src/ros_astra_camera/srv/SetUVCGain.srv @@ -0,0 +1,2 @@ +int32 gain +--- \ No newline at end of file diff --git a/src/ros_astra_camera/srv/SetUVCWhiteBalance.srv b/src/ros_astra_camera/srv/SetUVCWhiteBalance.srv new file mode 100644 index 0000000..6badd4e --- /dev/null +++ b/src/ros_astra_camera/srv/SetUVCWhiteBalance.srv @@ -0,0 +1,2 @@ +int32 white_balance +--- \ No newline at end of file diff --git a/src/ros_astra_camera/srv/SwitchIRCamera.srv b/src/ros_astra_camera/srv/SwitchIRCamera.srv new file mode 100644 index 0000000..9940847 --- /dev/null +++ b/src/ros_astra_camera/srv/SwitchIRCamera.srv @@ -0,0 +1,2 @@ +string camera +--- \ No newline at end of file diff --git a/src/ros_astra_camera/test/test_wrapper.cpp b/src/ros_astra_camera/test/test_wrapper.cpp new file mode 100644 index 0000000..c7dae1d --- /dev/null +++ b/src/ros_astra_camera/test/test_wrapper.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2016, Orbbec Ltd. + * 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 Willow Garage, Inc. 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 OWNER 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. + * + * Author: Tim Liu (liuhua@orbbec.com) + */ + +#include "astra_camera/astra_device_manager.h" +#include "astra_camera/astra_device.h" + +#include +#include +#include + +#include + +using namespace std; +using namespace astra_wrapper; + +int ir_counter_ = 0; +int color_counter_ = 0; +int depth_counter_ = 0; + +void IRCallback(sensor_msgs::ImagePtr image) +{ + ++ir_counter_; +} + +void ColorCallback(sensor_msgs::ImagePtr image) +{ + ++color_counter_; +} + +void DepthCallback(sensor_msgs::ImagePtr image) +{ + ++depth_counter_; +} + +int main() +{ + AstraDeviceManager device_manager; + + std::cout << device_manager; + + boost::shared_ptr > device_uris = device_manager.getConnectedDeviceURIs(); + + BOOST_FOREACH(const std::string& uri, *device_uris) + { + boost::shared_ptr device = device_manager.getDevice(uri); + + std::cout << *device; + + device->setIRFrameCallback(boost::bind(&IRCallback, _1)); + device->setColorFrameCallback(boost::bind(&ColorCallback, _1)); + device->setDepthFrameCallback(boost::bind(&DepthCallback, _1)); + + ir_counter_ = 0; + color_counter_ = 0; + depth_counter_ = 0; + + device->startColorStream(); + device->startDepthStream(); + + boost::this_thread::sleep(boost::posix_time::milliseconds(1000)); + + device->stopAllStreams(); + + std::cout<`_ from dawonn/master + Issue `#1 `_ - missing libmath link +* Ubuntu 14.04 Fix - missing libmath link +* Fix build for Android. +* Contributors: Chad Rockey, dawonn + +1.0.403 (2013-08-21) +-------------------- +* No more Willow Garage email. +* Contributors: Chad Rockey + +1.0.402 (2013-04-04) +-------------------- +* Missing header for Ubuntu Raring 13.04 +* Contributors: chadrockey + +1.0.401 (2013-03-03) +-------------------- +* Updated version to 1.0.401 +* Added files for catkin/bloom to release. +* Added better system timestamp +* Added more information functions. +* Updated includes for urg_c folder. +* Moving header files to be standardized for source builds. +* fix document +* fixed laser off fail when urg_close() has called +* fixed tcpclient_open bug on Linux +* added angle_convert_test.c +* fixed for ethernet sensor +* fixed windows.h include timing +* fixed urg_c-config created +* fixed ethernet open problem +* fixed compile error +* added reported user Adrian Boeing. thanks! +* added releasenotes +* removed rt link script +* fixed for OSX +* added AUTHORS.txt +* fixed plotter's bug +* fixed multiecho data's bug +* fixed urg_tcpclient_open()'s bug +* fixed receive_length data handling +* fixed 'if' condition handling data store +* fixed NULL pointer access bug +* fixed QT after RB +* fixed Gx stop bug +* translated page titles +* fixed urg_sensor_status() function's bug +* fixed buffer size +* remove duplicated file +* fixed doxygen comment +* fixed dependency +* fixed closing time is too long. +* added receive_command_response() internal function. +* added document tag +* sepalated urg_debug.[ch] +* added samples +* fixed download path document. +* urg_sleep(), urg_wakeup, urg_is_stabl() are implemented. +* fixed parameter receive method. +* fixed localhost convert +* fixed localhost ip_address +* added type item +* changed error handler return type +* added urg_scip_decode() function. +* added error handler +* removed temporary image files +* fixed OpenGL 1 support +* fixed html mainpage +* added sample compile check +* translated some files. +* translated mainpage.dox +* fixed document. +* added timestamp tutorial +* added images +* fixed indent +* added doxygen comment +* added document. +* added tutorial samples +* fixed dox comment +* mainpage is created. +* fixed document mainpage layout +* added usage document. +* adjusted mainpage.dox +* modify how to build sample with Visual Studio on Readme_ja.txt +* added install dox document +* added install document +* fixed laser_off handling +* fixed connection timeout +* fixed capture_times +* fixed sample's bug +* added visual studio samples. +* added sensor_parameter vc project. +* added visual studio 2005 project files. +* windows compile.bat for winsock2 +* fixed for VC++ compile error. +* omit stdbool.h . +* changed UTF-8 -> CP932 +* fixed snprintf implementation. +* New directory windowsexe to make windows exe files. +* adjusted for cl.exe compile. +* changed the character encoding SJIS +* added connect timeout function. +* fixed TCP/IP connect timeout +* added CC=gcc +* fixed information funciton's bug +* fixed urg_firmware_version() fail at URG-04LX +* fixed serial connection fail. +* fixed sh scripts +* fixed release package compile failed. +* added comment. +* added impelementation comment. +* fixed winsock close +* fixed Makefile error +* adjusted open routine. +* fixed link libraries +* added mingw install setting +* fixed sort bug. +* fixed urg_serial_utils_windows.c +* implemented urg_serial_utils_windows.c +* implemented urg_serial_utils_linux.c +* added urg_sensor_product_type() function +* fixed scan times bug +* fixed make clean rule +* fixed link directory +* added read/write function +* fixed multiecho sample +* fixed sample bug +* urg_sensor_id() -> urg_sensor_serial_id() +* fixed scan_skip timeout problem +* added extern C +* fixed viewer compile setting +* fixed split script +* fixed sample code's indent +* fixed header indent +* fixed urg_c-config +* urg_c-config addes +* include directory added +* doxygen tag added +* conflict COPYRIGHT and current/COPYRIGHT +* Doxyfile added +* fixed using OS env +* fixed dist rule +* printf debug message removed. +* error output code removed +* key zoom enabled +* Readme.txt modified and COPYRIGHT added. +* urg_tcpclient.h comments +* fixed urg_index2rad()'s bug +* remove debug print +* Merge +* fixed sample args parser +* fixed urg_serial_windows.c compile error. +* added ld_rt.sh +* fixed multiecho intensity bug +* plotter_sdl.c is implemented. +* viewer_sdl debugging +* viewer_sdl.c is implemented. +* fixed struct name +* fixed multiecho sample +* fixed samples for -e option +* adjusted for mingw. +* fixed sh script +* windows socket debugging +* windows tcp debugging +* windows tcp debugging +* fixed mingw compile failed. +* fixed ethernet sample error +* removed -lrt option +* fixed for mingw +* 'urg_tcpclient.c urg_tcpclient.h modified and fixed.' +* urg_tcpclient.c (tcpclient_readline() modified) +* directories reaaranged. +* Readme.txt modified. +* tcpclient debugging. +* urg_tcpclient.c was compiled by mingw gcc. +* Merge +* Merge +* to commit. +* removing urg_ethernet.* files +* tcpclient module for linux. +* added wait enter code +* fixed sample output +* fixed urg_time_stamp()'s bug +* removed implemented todo task comment +* urg_sensor.c:change_sensor_baudrate() is implemented. +* added ethernet option +* fixed sample output +* fixed length data receive misstake +* fixed errno misstake. +* fixed gcc warning +* added device selection ifdef +* Merge +* Merge +* addes multiecho intensity sample +* fixed error handling +* Merge +* Merge +* fixed MD stop +* fixed MD handling +* fixed MD command handling +* multiecho_intensity ã�®ãƒ†ã‚¹ãƒˆã‚’追加 +* HD command acceptable. +* fixed multiecho parser +* new directory configuration. +* New directory configuration. +* removed debug message +* Merge +* added files using win32 +* multiecho function is implemented. +* applied scip_checksum() +* get_distance*() functions were implemented. +* urg_utils.c is implemented. +* RB command is implemented. +* get_distance.c is implemented. +* removed debug code +* added static receive_data_line() function +* fixed infinity loop error +* added parameter test program for URG-04LX +* removed debug message +* fixed indent +* sensor_parameter.cpp is implemented. +* urg_sensor_id() is implemented. +* added debug comment +* added debug comment +* added URG_NOT_DETECT_BAUDRATE_ERROR +* renamed variable +* fixed doxygen comment +* added urg_t variables +* fixed indent +* removed urg_ethernet_t.h +* urg_communication.c is implemented. +* urg_detect_os.h is implemented. +* added urg_detect_os.h +* added windows serial implementetion. +* added serial_test.c +* urg_serial_linux.c is implemented. +* removed urg/Makefile +* changed test function api +* added test case +* adjusted urg directory removed. +* remove urg directory +* add test directory +* add urg_*_t.h +* fixed character-code +* Merge urg_connection +* Merge urg_connection +* Checksum function is implemented +* fixed compile error +* changed connection -> communication +* renamed +* fixed doxygen tag +* added urg_reboot() +* removed urg_connection_utils.h +* added doxygen comment +* added urg_connection.c functions +* implemented some functions. +* add internal functions +* renamed +* added urg_connection.h +* added image +* fix mainpage.dox link +* added urg/sample/get_multiecho_intensity.c +* added doxygen image tag +* fixed urg c API +* changed timestamp -> time_stamp +* added doxygen comment +* added doxygen comment +* added doxygen comment +* adjusted c/urg/*.c files API +* changed C API +* adjusted URG API +* ライブラリã�®å®Ÿè£…方法を追記 +* added library API +* added sample programs +* added package files +* added dox files +* add urg manual written in Japanese +* add package files +* Contributors: K. Kimoto, Kunihiro Yasuda, Satofumi KAMIMURA, chadrockey, hokuyo2@free53.hokuyo-aut.co.jp, hokuyo@free53.hokuyo-aut.co.jp, k-yasuda@1433-yasuda3, katsumik, satofumi diff --git a/src/urg_c/CMakeLists.txt b/src/urg_c/CMakeLists.txt new file mode 100644 index 0000000..3563831 --- /dev/null +++ b/src/urg_c/CMakeLists.txt @@ -0,0 +1,102 @@ +cmake_minimum_required(VERSION 3.0.2) +project(urg_c) + +# Set library locations to better handle if upstream locations change +set(LIBRARY_DIR current) +set(LIBRARY_INCLUDE_DIR ${LIBRARY_DIR}/include) +set(LIBRARY_SRC_DIR ${LIBRARY_DIR}/src) +set(LIBRARY_SAMPLE_DIR ${LIBRARY_DIR}/samples) + +find_package(catkin REQUIRED) + +################################################### +## Declare things to be passed to other projects ## +################################################### + +## LIBRARIES: libraries you create in this project that dependent projects also need +## CATKIN_DEPENDS: catkin_packages dependent projects also need +## DEPENDS: system dependencies of this project that dependent projects also need +catkin_package( + INCLUDE_DIRS ${LIBRARY_INCLUDE_DIR} + LIBRARIES liburg_c + CATKIN_DEPENDS + DEPENDS +) + +########### +## Build ## +########### + +## Specify additional locations of header files +include_directories(${LIBRARY_INCLUDE_DIR} ${catkin_INCLUDE_DIRS}) + +## Declare libraries +add_library(liburg_c ${LIBRARY_SRC_DIR}/urg_sensor.c + ${LIBRARY_SRC_DIR}/urg_utils.c + ${LIBRARY_SRC_DIR}/urg_debug.c + ${LIBRARY_SRC_DIR}/urg_connection.c + ${LIBRARY_SRC_DIR}/urg_ring_buffer.c + ${LIBRARY_SRC_DIR}/urg_serial.c + ${LIBRARY_SRC_DIR}/urg_serial_utils.c + ${LIBRARY_SRC_DIR}/urg_tcpclient.c + ${LIBRARY_SRC_DIR}/urg_time.c + +) +if(NOT ANDROID) + target_link_libraries(liburg_c -lrt -lm) +endif(NOT ANDROID) + +add_library(open_urg_sensor ${LIBRARY_SAMPLE_DIR}/open_urg_sensor.c) +target_link_libraries(open_urg_sensor -lm liburg_c ${catkin_LIBRARIES}) + +## Declare samples +add_executable(angle_convert_test ${LIBRARY_SAMPLE_DIR}/angle_convert_test.c) +target_link_libraries(angle_convert_test liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +add_executable(calculate_xy ${LIBRARY_SAMPLE_DIR}/calculate_xy.c) +target_link_libraries(calculate_xy liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +add_executable(find_port ${LIBRARY_SAMPLE_DIR}/find_port.c) +target_link_libraries(find_port liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +add_executable(get_distance ${LIBRARY_SAMPLE_DIR}/get_distance.c) +target_link_libraries(get_distance liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +add_executable(get_distance_intensity ${LIBRARY_SAMPLE_DIR}/get_distance_intensity.c) +target_link_libraries(get_distance_intensity liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +add_executable(get_multiecho ${LIBRARY_SAMPLE_DIR}/get_multiecho.c) +target_link_libraries(get_multiecho liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +add_executable(get_multiecho_intensity ${LIBRARY_SAMPLE_DIR}/get_multiecho_intensity.c) +target_link_libraries(get_multiecho_intensity liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +add_executable(reboot_test ${LIBRARY_SAMPLE_DIR}/reboot_test.c) +target_link_libraries(reboot_test liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +add_executable(sensor_parameter ${LIBRARY_SAMPLE_DIR}/sensor_parameter.c) +target_link_libraries(sensor_parameter liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +add_executable(sync_time_stamp ${LIBRARY_SAMPLE_DIR}/sync_time_stamp.c) +target_link_libraries(sync_time_stamp liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +add_executable(timeout_test ${LIBRARY_SAMPLE_DIR}/timeout_test.c) +target_link_libraries(timeout_test liburg_c open_urg_sensor ${catkin_LIBRARIES}) + +############# +## Install ## +############# + +## Mark executables and/or libraries for installation +install(TARGETS liburg_c open_urg_sensor angle_convert_test calculate_xy find_port + get_distance get_distance_intensity get_multiecho get_multiecho_intensity + reboot_test sensor_parameter sync_time_stamp timeout_test + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +## Mark cpp header files for installation +install(DIRECTORY ${LIBRARY_INCLUDE_DIR}/${PROJECT_NAME}/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +) diff --git a/src/urg_c/Makefile b/src/urg_c/Makefile new file mode 100644 index 0000000..fdbacca --- /dev/null +++ b/src/urg_c/Makefile @@ -0,0 +1,71 @@ +# urgwidget + +VERSION = 1.0.4 +RELEASE_DIR = release +PACKAGE_EN_DIR = urg_library-$(VERSION) +PACKAGE_JA_DIR = urg_library_ja-$(VERSION) + + +all : + cd current/ && $(MAKE) + +clean : release_clean + cd current/ && $(MAKE) clean + $(RM) -rf $(RELEASE_DIR) + +install : dist + cd $(RELEASE_DIR)/$(PACKAGE_JA_DIR) && $(MAKE) install + + +TARGET_DIR = $(PACKAGE_EN_DIR) $(PACKAGE_JA_DIR) +dist : release_clean + mkdir -p $(RELEASE_DIR) + for i in $(TARGET_DIR) ; \ + do \ + mkdir -p $(RELEASE_DIR)/$$i; \ + mkdir -p $(RELEASE_DIR)/$$i/include; \ + mkdir -p $(RELEASE_DIR)/$$i/src; \ + mkdir -p $(RELEASE_DIR)/$$i/windowsexe; \ + mkdir -p $(RELEASE_DIR)/$$i/visual_cpp; \ + mkdir -p $(RELEASE_DIR)/$$i/visual_cpp/calculate_xy; \ + mkdir -p $(RELEASE_DIR)/$$i/visual_cpp/find_port; \ + mkdir -p $(RELEASE_DIR)/$$i/visual_cpp/get_distance; \ + mkdir -p $(RELEASE_DIR)/$$i/visual_cpp/get_multiecho; \ + mkdir -p $(RELEASE_DIR)/$$i/visual_cpp/get_multiecho_intensity; \ + mkdir -p $(RELEASE_DIR)/$$i/visual_cpp/sensor_parameter; \ + mkdir -p $(RELEASE_DIR)/$$i/visual_cpp/sync_time_stamp; \ + mkdir -p $(RELEASE_DIR)/$$i/visual_cpp/urg; \ + mkdir -p $(RELEASE_DIR)/$$i/samples; \ + cp current/COPYRIGHT.txt current/Install.txt current/build_rule.mk Readme.txt AUTHORS.txt Releasenotes.txt $(RELEASE_DIR)/$$i/; \ + cp current/Makefile.release $(RELEASE_DIR)/$$i/Makefile; \ + cp current/src/Makefile.release $(RELEASE_DIR)/$$i/src/Makefile; \ + cp current/samples/Makefile.release $(RELEASE_DIR)/$$i/samples/Makefile ; \ + cp current/include/*.h $(RELEASE_DIR)/$$i/include/; \ + cp current/src/*.c $(RELEASE_DIR)/$$i/src/; \ + cp current/samples/*.sh $(RELEASE_DIR)/$$i/samples/; \ + cp current/windowsexe/*.bat $(RELEASE_DIR)/$$i/windowsexe/; \ + cp -r current/visual_cpp/ $(RELEASE_DIR)/$$i/; \ + cat current/urg_c-config.in | sed -e "s/VERSION/$(VERSION)/g" > $(RELEASE_DIR)/$$i/urg_c-config.in ; \ + done + ruby split_comment.rb -e current/include/*.h $(RELEASE_DIR)/$(PACKAGE_EN_DIR)/include/ + ruby split_comment.rb -e current/src/*.c $(RELEASE_DIR)/$(PACKAGE_EN_DIR)/src/ + ruby split_comment.rb -e current/samples/*.c $(RELEASE_DIR)/$(PACKAGE_EN_DIR)/samples/ + ruby split_comment.rb -e current/samples/*.h $(RELEASE_DIR)/$(PACKAGE_EN_DIR)/samples/ + ruby split_comment.rb -j current/include/*.h $(RELEASE_DIR)/$(PACKAGE_JA_DIR)/include/ + ruby split_comment.rb -j current/src/*.c $(RELEASE_DIR)/$(PACKAGE_JA_DIR)/src/ + ruby split_comment.rb -j current/samples/*.c $(RELEASE_DIR)/$(PACKAGE_JA_DIR)/samples/ + ruby split_comment.rb -j current/samples/*.h $(RELEASE_DIR)/$(PACKAGE_JA_DIR)/samples/ + for i in $(TARGET_DIR) ; \ + do \ + cd $(PWD); \ + cd $(RELEASE_DIR)/$$i && $(MAKE) && $(MAKE) clean; \ + done + for i in $(TARGET_DIR) ; \ + do \ + cd $(PWD); \ + cd $(RELEASE_DIR)/ && (zip -r $$i.zip $$i) && mv $$i.zip ../; \ + done + +release_clean : + $(RM) -rf $(RELEASE_DIR)/$(PACKAGE_EN_DIR) $(RELEASE_DIR)/$(PACKAGE_JA_DIR) + $(RM) $(PACKAGE_EN_DIR).zip $(PACKAGE_JA_DIR).zip diff --git a/src/urg_c/README.md b/src/urg_c/README.md new file mode 100644 index 0000000..bf37f43 --- /dev/null +++ b/src/urg_c/README.md @@ -0,0 +1,6 @@ +Packaging for URG Helper / URG Widget / URG Library / urg_c + +Original Source at: +http://sourceforge.net/projects/urgwidget + +This project introduces sample programs of the URG library. Applications using URG and URG library are also introduced here. URG is Scanning Laser Range Finder of Hokuyo Automatic Co., for robots, autonomous systems and security systems. diff --git a/src/urg_c/Readme.txt b/src/urg_c/Readme.txt new file mode 100644 index 0000000..0aa2529 --- /dev/null +++ b/src/urg_c/Readme.txt @@ -0,0 +1,76 @@ +URG C Library + +About this software: + This software have been developed to provide a library to use + scanning range sensors of Hokuyo Automatic Corporation. Samples + will help to know how to use them. + +Authors: + Satofumi Kamimura Design and implementation of the first version. + Katsumi Kimoto + +License: + Simplified BSD License. + See COPYRIGHT file. + + +Mailing list: + urgwidget-users@lists.sourceforge.net + + +Library usage: + +Visual Studio Solution (Windows) + + urg_library-X.X.X/visual_cpp/urg.sln をビルドã�—ã�¾ã�™ã€‚ + + ビルド後ã�¯ã€�urg.lib ã�®ã‚¹ã‚¿ãƒ†ã‚£ãƒƒã‚¯ãƒ©ã‚¤ãƒ–ラリã�¨å�„サンプルã�® + 実行ファイルã�Œç”Ÿæˆ�ã�•れã�¦ã�„ã�¾ã�™ã€‚ + + + +Visual Studio bat compile (Windows) + +*以下ã�®ä½œæ¥­ã�¯ã‚³ãƒžãƒ³ãƒ‰ãƒ—ロンプト上ã�§è¡Œã�£ã�¦ã��ã� ã�•ã�„* + + 1. 環境変数を設定ã�™ã‚‹ã�Ÿã‚�ã�« Visual Studio ã�Œæ��ä¾›ã�—ã�¦ã�„ã‚‹ bat ファイルを + コピーã�—ã�¾ã�™ã€‚ + + Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat ã‚’ + urgwidget\current\windowsexeã�«ã‚³ãƒ”ーã�™ã‚‹ã€‚ + + + 2. 環境変数を設定後ã€�コンパイル用ã�®batファイルを実行ã�™ã‚‹ã€‚ + + urgwidget\current\windowsexe\vsvars32.batを実行ã�— + urgwidget\current\windowsexe\compile.batを実行ã�™ã‚‹ã€‚ + + + 3. 生æˆ�ã�•れã�Ÿã‚µãƒ³ãƒ—ルã�®å®Ÿè¡Œãƒ•ァイルを動ã�‹ã�™ã€‚ + + urgwidget\current\windowsexeã�«ç”Ÿæˆ�ã�•れるexeを実行ã�™ã‚‹ã€‚ + + + 4. 生æˆ�ã�•れã�Ÿã‚µãƒ³ãƒ—ルã�®å®Ÿè¡Œãƒ•ァイルを削除ã�™ã‚‹ã€‚ + + urgwidget\current\windowsexe\cleanobj.batを実行ã�— + 生æˆ�ã�•れã�Ÿå®Ÿè¡Œãƒ•ァイルを削除ã�™ã‚‹ã€‚ + + +gcc (Linux, MinGW) + + å¿…è¦�ã�ªã‚‰ã�° urg_library-X.X.X/Makefile ã�® PREFIX を編集ã�—ã�¦ + インストール先を変更ã�—ã�¾ã�™ã€‚ + + !!! ç�¾çжã�“ã�†ã�ªã�£ã�¦ã�„ã‚‹ã�®ã�§ã€�ä»–ã�®å ´æ‰€ã�«ã�—ã�Ÿã�‘れã�°ã€�変更ã�—ã�¦ä¸‹ã�•ã�„。 +PREFIX = /usr/local +#PREFIX = /mingw + + コンパイルã�¨ã‚¤ãƒ³ã‚¹ãƒˆãƒ¼ãƒ«ã‚’行ã�„ã�¾ã�™ã€‚ + + % make + # make install + + ライブラリã�®ä½¿ã�„æ–¹ã�¯ã€�urg-library-X.X.X/samples/ 中ã�® Makefile ã‚’ã�”覧下ã�•ã�„。 + + !!! ライブラリã�®ä½¿ã�„æ–¹ã�¯ã€�ã‚‚ã�†å°‘ã�—ã�¡ã‚ƒã‚“ã�¨æ›¸ã��ã�Ÿã�„。 diff --git a/src/urg_c/Readme_ja.txt b/src/urg_c/Readme_ja.txt new file mode 100644 index 0000000..b05e4f4 Binary files /dev/null and b/src/urg_c/Readme_ja.txt differ diff --git a/src/urg_c/Releasenotes.txt b/src/urg_c/Releasenotes.txt new file mode 100644 index 0000000..c41db39 --- /dev/null +++ b/src/urg_c/Releasenotes.txt @@ -0,0 +1,7 @@ +2012-02-21 + * Fixed ethernet open problem. + * Fixed laser off fail when "urg_close()" function has called. + +2012-01-31 + * 1.0.3 released. + * Fixed Macintosh implementation to work. (reported Adrian Boeing) diff --git a/src/urg_c/current/COPYRIGHT.txt b/src/urg_c/current/COPYRIGHT.txt new file mode 100644 index 0000000..3770816 --- /dev/null +++ b/src/urg_c/current/COPYRIGHT.txt @@ -0,0 +1,22 @@ +Copyright (c) 2010 urg helper project All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. 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. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. diff --git a/src/urg_c/current/Doxyfile b/src/urg_c/current/Doxyfile new file mode 100644 index 0000000..2cdcc50 --- /dev/null +++ b/src/urg_c/current/Doxyfile @@ -0,0 +1,1630 @@ +# Doxyfile 1.7.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = CP932 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = dox/ include/ samples/ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = CP932 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.dox */include/*.h *.c + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = */dox/*.c + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = samples/ dox/ + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = dox/ + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = dox/doxygen_stylesheet.css + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvances is that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans.ttf + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif. +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/src/urg_c/current/Doxyfile_ja b/src/urg_c/current/Doxyfile_ja new file mode 100644 index 0000000..501a04a --- /dev/null +++ b/src/urg_c/current/Doxyfile_ja @@ -0,0 +1,1630 @@ +# Doxyfile 1.7.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = Japanese + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = dox/ include/ samples/ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = CP932 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = *.dox */include/*.h *.c + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = */dox/*.c + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = samples/ dox/ + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = dox/ + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html_ja + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = dox/doxygen_stylesheet.css + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = NO + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvances is that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans.ttf + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif. +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/src/urg_c/current/Install.txt b/src/urg_c/current/Install.txt new file mode 100644 index 0000000..dd6e6c2 --- /dev/null +++ b/src/urg_c/current/Install.txt @@ -0,0 +1 @@ +Description for install. diff --git a/src/urg_c/current/Makefile b/src/urg_c/current/Makefile new file mode 100644 index 0000000..7472dc6 --- /dev/null +++ b/src/urg_c/current/Makefile @@ -0,0 +1,25 @@ +# Makefile for urgwidget + +OUTPUT_HTML_DIR = html +OUTPUT_HTML_JA_DIR = html_ja + +all : + cd src/ && $(MAKE) + cd samples/ && $(MAKE) + +clean : + $(RM) -rf html html_ja $(OUTPUT_HTML_DIR) $(OUTPUT_HTML_JA_DIR) + cd src/ && $(MAKE) clean + cd samples/ && $(MAKE) clean + -cd viewers/ && $(MAKE) clean + cd dox/ && $(MAKE) clean + +html : + cd dox/ && $(MAKE) img + doxygen Doxyfile_ja + cp COPYRIGHT.txt $(OUTPUT_HTML_JA_DIR) + doxygen Doxyfile + cp COPYRIGHT.txt $(OUTPUT_HTML_DIR) + +.PHONY : all clean html +###################################################################### diff --git a/src/urg_c/current/Makefile.release b/src/urg_c/current/Makefile.release new file mode 100644 index 0000000..038dc9a --- /dev/null +++ b/src/urg_c/current/Makefile.release @@ -0,0 +1,27 @@ +PREFIX = /usr/local +#PREFIX = /mingw + +include build_rule.mk + +CONFIG_FILE = urg_c-config +S_PREFIX = $(shell echo "$(PREFIX)" | sed "s/\//\\\\\\\\\//g") +S_LIBS = $(shell if test x$(MSYSTEM) == x"MINGW32"; then echo "-lwsock32 -lsetupapi"; fi) +all : $(CONFIG_FILE) + cd src/ && $(MAKE) + cd samples/ && $(MAKE) + +clean : + $(RM) $(CONFIG_FILE) + cd src/ && $(MAKE) clean + cd samples/ && $(MAKE) clean + +install : all + install -d $(PREFIX)/include/urg_c/ + install -m 644 include/*.h $(PREFIX)/include/urg_c/ + install -d $(PREFIX)/lib/ + install -m 644 src/liburg_c.a $(PREFIX)/lib/ + install -d $(PREFIX)/bin/ + install -m 755 $(CONFIG_FILE) $(PREFIX)/bin/ + +$(CONFIG_FILE) : urg_c-config.in Makefile + cat $(CONFIG_FILE).in | sed "s/PREFIX/$(S_PREFIX)/g" | sed "s/LIBS/$(S_LIBS)/g" > $(CONFIG_FILE) diff --git a/src/urg_c/current/build_rule.mk b/src/urg_c/current/build_rule.mk new file mode 100644 index 0000000..17e8538 --- /dev/null +++ b/src/urg_c/current/build_rule.mk @@ -0,0 +1,8 @@ +ARCH = +CC = $(ARCH)gcc +CXX = $(ARCH)g++ +AS = $(ARCH)as +LD = $(ARCH)ld +AR = $(ARCH)ar +OBJ_COPY = $(ARCH)objcopy +OBJ_DUMP = $(ARCH)objdump diff --git a/src/urg_c/current/dox/Makefile b/src/urg_c/current/dox/Makefile new file mode 100644 index 0000000..d5ba93a --- /dev/null +++ b/src/urg_c/current/dox/Makefile @@ -0,0 +1,35 @@ +# current/dox + +CFLAGS = -g -O0 -Wall -Werror -W `urg_c-config --cflags` +LDFLAGS = +LDLIBS = `urg_c-config --libs` -lm + + +TARGET = \ + connect_and_get \ + connect_ethernet \ + get_scans \ + get_timestamp \ + set_parameter \ + convert_xy \ + +IMAGE_TARGET = \ + multiecho_image.png \ + sensor_angle_image.png \ + sensor_index_image.png \ + sensor_step_image.png \ + skip_scan_image.png \ + +all : $(TARGET) img + cd ../ && $(MAKE) html + +img : $(IMAGE_TARGET) + +clean : + $(RM) $(TARGET) $(IMAGE_TARGET) + +.PHONY : all clean +###################################################################### +.SUFFIXES: .png .svg +.svg.png: + convert $< $@ diff --git a/src/urg_c/current/dox/connect_and_get.c b/src/urg_c/current/dox/connect_and_get.c new file mode 100644 index 0000000..f11a6b3 --- /dev/null +++ b/src/urg_c/current/dox/connect_and_get.c @@ -0,0 +1,38 @@ +// ƒVƒŠƒAƒ‹�Ú‘±‚ł̃Zƒ“ƒT‚Æ‚Ì�Ú‘±‚Æ‹——£ƒf�[ƒ^‚̎擾 + +#include "urg_sensor.h" +#include "urg_utils.h" +#include + + +int main(void) +{ + urg_t urg; + int ret; + long *length_data; + int length_data_size; + + // "COM1" ‚Í�AƒZƒ“ƒT‚ª”Fޝ‚³‚ê‚Ä‚¢‚éƒfƒoƒCƒX–¼‚É‚·‚é•K—v‚ª‚ ‚é + const char connect_device[] = "COM1"; + const long connect_baudrate = 115200; + + // ƒZƒ“ƒT‚ɑ΂µ‚Ä�Ú‘±‚ð�s‚¤�B + ret = urg_open(&urg, URG_SERIAL, connect_device, connect_baudrate); + // \todo check error code + + // ƒf�[ƒ^Žó�M‚Ì‚½‚߂̗̈æ‚ðŠm•Û‚·‚é + length_data = (long *)malloc(sizeof(long) * urg_max_data_size(&urg)); + // \todo check length_data is not NULL + + // ƒZƒ“ƒT‚©‚ç‹——£ƒf�[ƒ^‚ðŽæ“¾‚·‚é�B + ret = urg_start_measurement(&urg, URG_DISTANCE, 1, 0); + // \todo check error code + + length_data_size = urg_get_distance(&urg, length_data, NULL); + // \todo process length_data array + + // ƒZƒ“ƒT‚Æ‚Ì�Ú‘±‚ð•‚¶‚é�B + urg_close(&urg); + + return 0; +} diff --git a/src/urg_c/current/dox/connect_ethernet.c b/src/urg_c/current/dox/connect_ethernet.c new file mode 100644 index 0000000..706fdc6 --- /dev/null +++ b/src/urg_c/current/dox/connect_ethernet.c @@ -0,0 +1,17 @@ +#include "urg_sensor.h" + + +int main(void) +{ + urg_t urg; + int ret; +// ƒC�[ƒT�[ƒlƒbƒg�Ú‘±‚ł̃Zƒ“ƒT‚Æ‚Ì�Ú‘±‚Æ‹——£ƒf�[ƒ^‚̎擾 + +const char connect_address[] = "192.168.0.10"; +const long connect_port = 10940; + +// ƒZƒ“ƒT‚ɑ΂µ‚Ä�Ú‘±‚ð�s‚¤�B +ret = urg_open(&urg, URG_ETHERNET, connect_address, connect_port); +// \todo check error code +return 0; +} diff --git a/src/urg_c/current/dox/convert_xy.c b/src/urg_c/current/dox/convert_xy.c new file mode 100644 index 0000000..7fc90da --- /dev/null +++ b/src/urg_c/current/dox/convert_xy.c @@ -0,0 +1,32 @@ +#include "urg_sensor.h" +#include "urg_utils.h" +#include +#include + +int main(void) +{ +urg_t urg; +long *length_data = NULL; +int length_data_size; +int i; +// ‹——£ƒf�[ƒ^‚ð X-Y �À•WŒn‚ɕϊ·‚µ‚Ä•\ަ‚·‚é + +length_data_size = urg_get_distance(&urg, length_data, NULL); +for (i = 0; i < length_data_size; ++i) { + // ‚»‚Ì‹——£ƒf�[ƒ^‚̃‰ƒWƒAƒ“Šp“x‚ð‹�‚ß�AX, Y ‚Ì�À•W’l‚ðŒvŽZ‚·‚é + double radian; + long length; + long x; + long y; + + radian = urg_index2rad(&urg, i); + length = length_data[i]; + // \todo check length is valid + + x = (long)(length * cos(radian)); + y = (long)(length * sin(radian)); + printf("(%ld, %ld), ", x, y); +} +printf("\n"); +return 0; +} diff --git a/src/urg_c/current/dox/doxygen_stylesheet.css b/src/urg_c/current/dox/doxygen_stylesheet.css new file mode 100644 index 0000000..1d1fab8 --- /dev/null +++ b/src/urg_c/current/dox/doxygen_stylesheet.css @@ -0,0 +1,688 @@ +/* The standard CSS for doxygen */ + +body, table, div, p, dl { + font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size: 12px; +} + +/* @group Heading Levels */ + +h1 { + font-size: 140%; +} + +h2 { + font-size: 130%; + margin-top: 30px; +} + +h3 { + font-size: 120%; + margin-top: 28px; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd, p.starttd { + margin-top: 2px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + padding: 2px; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #3D578C; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #4665A2; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #9CAFD4; + color: #ffffff; + border: 1px double #869DCA; +} + +.contents a.qindexHL:visited { + color: #ffffff; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code { + color: #4665A2; +} + +a.codeRef { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +.fragment { + font-family: monospace, fixed; + font-size: 105%; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; +} + +div.ah { + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background: white; + color: black; + margin: 0; +} + +div.contents { + margin-top: 10px; + margin-left: 10px; + margin-right: 10px; +} + +td.indexkey { + background-color: #EBEFF6; + font-weight: bold; + border: 1px solid #C4CFE5; + margin: 2px 0px 2px 0; + padding: 2px 10px; +} + +td.indexvalue { + background-color: #EBEFF6; + border: 1px solid #C4CFE5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #EEF1F7; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #A3B4D7; +} + +th.dirtab { + background: #EBEFF6; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #4A6AAA; +} + +hr.footer { + height: 1px; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #F9FAFC; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memItemLeft, .memItemRight, .memTemplParams { + border-top: 1px solid #C4CFE5; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memTemplParams { + color: #4665A2; + white-space: nowrap; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtemplate { + font-size: 80%; + color: #4665A2; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #EBEFF6; + border: 1px solid #A3B4D7; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.memitem { + padding: 0; + margin-bottom: 10px; +} + +.memname { + white-space: nowrap; + font-weight: bold; + margin-left: 6px; +} + +.memproto { + border-top: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 6px 0px 6px 0px; + color: #253555; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + /* opera specific markup */ + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 8px; + border-top-left-radius: 8px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 8px; + -moz-border-radius-topleft: 8px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 8px; + -webkit-border-top-left-radius: 8px; + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #E2E8F2; + +} + +.memdoc { + border-bottom: 1px solid #A8B8D9; + border-left: 1px solid #A8B8D9; + border-right: 1px solid #A8B8D9; + padding: 2px 5px; + background-color: #FBFCFD; + border-top-width: 0; + /* opera specific markup */ + border-bottom-left-radius: 8px; + border-bottom-right-radius: 8px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 8px; + -moz-border-radius-bottomright: 8px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F7F8FB 95%, #EEF1F7); + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 8px; + -webkit-border-bottom-right-radius: 8px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F7F8FB), to(#EEF1F7)); +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} + +.params, .retval, .exception, .tparams { + border-spacing: 6px 2px; +} + +.params .paramname, .retval .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir { + font-family: "courier new",courier,monospace; + vertical-align: top; +} + + + + +/* @end */ + +/* @group Directory (tree) */ + +/* for the tree view */ + +.ftvtree { + font-family: sans-serif; + margin: 0px; +} + +/* these are for tree view when used as main index */ + +.directory { + font-size: 9pt; + font-weight: bold; + margin: 5px; +} + +.directory h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +/* +The following two styles can be used to replace the root node title +with an image of your choice. Simply uncomment the next two styles, +specify the name of your image and be sure to set 'height' to the +proper pixel height of your image. +*/ + +/* +.directory h3.swap { + height: 61px; + background-repeat: no-repeat; + background-image: url("yourimage.gif"); +} +.directory h3.swap span { + display: none; +} +*/ + +.directory > h3 { + margin-top: 0; +} + +.directory p { + margin: 0px; + white-space: nowrap; +} + +.directory div { + display: none; + margin: 0px; +} + +.directory img { + vertical-align: -30%; +} + +/* these are for tree view when not used as main index */ + +.directory-alt { + font-size: 100%; + font-weight: bold; +} + +.directory-alt h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +.directory-alt > h3 { + margin-top: 0; +} + +.directory-alt p { + margin: 0px; + white-space: nowrap; +} + +.directory-alt div { + display: none; + margin: 0px; +} + +.directory-alt img { + vertical-align: -30%; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; +} + +address { + font-style: normal; + color: #2A3D61; +} + +table.doxtable { + border-collapse:collapse; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #2D4068; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #374F7F; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; +} + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + height:30px; + line-height:30px; + color:#8AA0CC; + border:solid 1px #C2CDE4; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right: 15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#364D7C; +} + +.navpath a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; +} + +.navpath a:hover +{ + color:#6884BD; +} + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #F9FAFC; + margin: 0px; + border-bottom: 1px solid #C4CFE5; +} + +div.headertitle +{ + padding: 5px 5px 5px 10px; +} + diff --git a/src/urg_c/current/dox/get_scans.c b/src/urg_c/current/dox/get_scans.c new file mode 100644 index 0000000..4ce7c71 --- /dev/null +++ b/src/urg_c/current/dox/get_scans.c @@ -0,0 +1,27 @@ +#include "urg_sensor.h" +#include + +int main(void) +{ + urg_t urg; + int ret; + long *length_data = NULL; +// scan_times ‰ñ‚̃XƒLƒƒƒ“ƒf�[ƒ^‚ðŽæ“¾ + +// urg_start_measurement() ŠÖ�”‚ŃXƒLƒƒƒ“‰ñ�”‚ðŽw’肵 +// urg_get_distance() ŠÖ�”‚ÅŽw’肵‚½‰ñ�”‚¾‚¯ƒf�[ƒ^‚ðŽó�M‚·‚é�B + +const int scan_times = 123; +int length_data_size; +int i; + +// ƒZƒ“ƒT‚©‚ç‹——£ƒf�[ƒ^‚ðŽæ“¾‚·‚é�B +ret = urg_start_measurement(&urg, URG_DISTANCE, scan_times, 0); +// \todo check error code + +for (i = 0; i < scan_times; ++i) { + length_data_size = urg_get_distance(&urg, length_data, NULL); + // \todo process length_data array +} +return 0; +} diff --git a/src/urg_c/current/dox/get_timestamp.c b/src/urg_c/current/dox/get_timestamp.c new file mode 100644 index 0000000..17039b5 --- /dev/null +++ b/src/urg_c/current/dox/get_timestamp.c @@ -0,0 +1,30 @@ +#include "urg_sensor.h" +#include + +int main(void) +{ +urg_t urg; +long *length_data = NULL; +int ret; +// ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv‚̎擾 + +// urg_get_distance() ŠÖ�”‚É•Ï�”‚ð—^‚¦�Aƒ^ƒCƒ€ƒXƒ^ƒ“ƒv‚ðŽæ“¾‚·‚é�B + +const int scan_times = 123; +int length_data_size; +long timestamp; +int i; + +// ƒZƒ“ƒT‚©‚ç‹——£ƒf�[ƒ^‚ðŽæ“¾‚·‚é�B +ret = urg_start_measurement(&urg, URG_DISTANCE, scan_times, 0); +// \todo check error code + +for (i = 0; i < scan_times; ++i) { + length_data_size = urg_get_distance(&urg, length_data, ×tamp); + // \todo process length_data array + + // Žæ“¾‚µ‚½ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv‚ð�o—Í‚·‚é + printf("%ld\n", timestamp); +} +return 0; +} diff --git a/src/urg_c/current/dox/library_sample.dox b/src/urg_c/current/dox/library_sample.dox new file mode 100644 index 0000000..e8c7109 --- /dev/null +++ b/src/urg_c/current/dox/library_sample.dox @@ -0,0 +1,35 @@ +/*! + \~japanese + \page library_sample_page ƒ‰ƒCƒuƒ‰ƒŠ‚̃Tƒ“ƒvƒ‹‚ɂ‚¢‚Ä + + ƒ‰ƒCƒuƒ‰ƒŠ•t‘®ƒTƒ“ƒvƒ‹‚ÌŽg‚¢•û‚ð�à–¾‚µ‚Ä‚¢‚Ü‚·�B + + \~english + \page library_sample_page Library samples (under construction) + + !!! + + + \~japanese + \section library_tutorial_samples ƒ‰ƒCƒuƒ‰ƒŠ•t‘®‚̃Tƒ“ƒvƒ‹ + + urg_library ‚Í�A‚¢‚­‚‚©‚̃Tƒ“ƒvƒ‹‚ð—pˆÓ‚µ‚Ä‚¢‚Ü‚·�B\n + ƒTƒ“ƒvƒ‹‚Ì�Ú‘±‚·‚éƒfƒoƒCƒX‚ð•Ï�X‚·‚é‚É‚Í open_urg_sensor.c ‚̉º‹L‚Ì�Ý’è‚ð•Ï�X‚µ‚ĉº‚³‚¢�B + + - �Ú‘±�Ý’è‚ð•Ï�X‚·‚é‰Ó�Š (open_urg_sensor.c ‚æ‚蔲�ˆ) + \dontinclude open_urg_sensor.c + \skip int open_urg_sensor + \until const char *ip_address + + ‚Ü‚½�AŠeƒTƒ“ƒvƒ‹‚Í "-e" ‚ð•t‰Á‚·‚邯ƒC�[ƒT�[ƒlƒbƒg‚Å�Ú‘±‚·‚邿‚¤‚ɂȂÁ‚Ä‚¢‚Ü‚·�B + + - ƒTƒ“ƒvƒ‹ˆê—— + - ƒZƒ“ƒT�î•ñ‚ð•\ަ‚·‚éƒTƒ“ƒvƒ‹ ... \ref sensor_parameter.c + - ‹——£‚̃f�[ƒ^‚ðŽæ“¾‚·‚éƒTƒ“ƒvƒ‹ ... \ref get_distance.c + - ‹——£‚Æ‹­“x‚̃f�[ƒ^‚ðŽæ“¾‚·‚éƒTƒ“ƒvƒ‹ ... \ref get_distance_intensity.c + - ƒ}ƒ‹ƒ`ƒGƒR�[‚Å‹——£‚̃f�[ƒ^‚ðŽæ“¾‚·‚éƒTƒ“ƒvƒ‹ ... \ref get_multiecho.c + - ƒ}ƒ‹ƒ`ƒGƒR�[‚Å‹——£‚Æ‹­“x‚̃f�[ƒ^‚ðŽæ“¾‚·‚éƒTƒ“ƒvƒ‹ ... \ref get_multiecho_intensity.c + - Œv‘ª‚µ‚½ƒf�[ƒ^‚ð X-Y �À•W‚ɕϊ·‚·‚éƒTƒ“ƒvƒ‹ ... \ref calculate_xy.c + - ƒZƒ“ƒT‚̃^ƒCƒ€ƒXƒ^ƒ“ƒv‚ð PC ‚Æ“¯Šú‚³‚¹‚éƒTƒ“ƒvƒ‹ ... \ref sync_time_stamp.c + - ƒVƒŠƒAƒ‹ƒ|�[ƒgˆê——‚̎擾ƒTƒ“ƒvƒ‹ ... \ref find_port.c +*/ diff --git a/src/urg_c/current/dox/library_tutorial.dox b/src/urg_c/current/dox/library_tutorial.dox new file mode 100644 index 0000000..42807cc --- /dev/null +++ b/src/urg_c/current/dox/library_tutorial.dox @@ -0,0 +1,117 @@ +/*! + \~japanese + \page library_tutorial_page ƒ`ƒ…�[ƒgƒŠƒAƒ‹ + + ƒ‰ƒCƒuƒ‰ƒŠ‚ÌŽg‚¢•û‚ðƒTƒ“ƒvƒ‹‚ð—p‚¢‚Ä�à–¾‚µ‚Ü‚·�B + + \~english + \page library_tutorial_page Tutorial (under construction) + + ƒ‰ƒCƒuƒ‰ƒŠ‚ÌŽg‚¢•û‚ðƒTƒ“ƒvƒ‹‚ð—p‚¢‚Ä�à–¾‚µ‚Ü‚·�B + + + \~jepanese + - ƒ`ƒ…�[ƒgƒŠƒAƒ‹ + - \ref library_tutorial_connect_and_get + - \ref library_tutorial_get_scans + - \ref library_tutorial_settings + - \ref library_tutorial_timestamp + - \ref library_tutorial_xy + + \~english + - Tutorial + - \ref library_tutorial_connect_and_get + - \ref library_tutorial_get_scans + - \ref library_tutorial_settings + - \ref library_tutorial_timestamp + - \ref library_tutorial_xy + + + \~japanese + \section library_tutorial_connect_and_get ƒZƒ“ƒT‚Æ‚Ì�Ú‘±‚Æ‹——£ƒf�[ƒ^‚̎擾 + + ƒZƒ“ƒT‚©‚ç‹——£ƒf�[ƒ^‚ðŽæ“¾‚·‚éŠî–{“I‚ÈŽè�‡‚Í + + - ƒZƒ“ƒT‚ɑ΂µ‚Ä�Ú‘±‚ð�s‚¤�B + - ƒVƒŠƒAƒ‹ƒ|�[ƒg–¼‚ðŽw’肵‚Ä�Ú‘±‚·‚é�B(ƒVƒŠƒAƒ‹�AUSB �Ú‘±‚̂Ƃ«) + - IP ƒAƒhƒŒƒX‚ðŽw’肵‚Ä�Ú‘±‚·‚é�B(Ethernet �Ú‘±‚̂Ƃ«) + + - ƒf�[ƒ^Žó�M‚Ì‚½‚߂̗̈æ‚ðŠm•Û‚·‚é + - malloc ‚Ȃǂŗ̈æ‚ðŠm•Û‚·‚é�B + + - ƒZƒ“ƒT‚©‚ç‹——£ƒf�[ƒ^‚ðŽæ“¾‚·‚é�B + - Œv‘ª‚ðŠJŽn‚·‚é�B + - Œv‘ª‚³‚ꂽ‹——£ƒf�[ƒ^‚ðŽó�M‚·‚é�B + + - ƒZƒ“ƒT‚Æ‚Ì�Ú‘±‚ð•‚¶‚é�B + - Œv‘ª‚ð’†’f‚µ�AƒZƒ“ƒT‚Æ‚Ì�Ú‘±‚ð�Ø’f‚·‚é�B + + ‚ƂȂè‚Ü‚·�B + + �ã‹L‚Ì�ˆ—�‚ðƒvƒ�ƒOƒ‰ƒ€‚Å‹L�q‚µ‚½‚à‚Ì‚ð�AˆÈ‰º‚ÉŽ¦‚µ‚Ü‚·�B + \include connect_and_get.c + + ƒvƒ�ƒOƒ‰ƒ€’†‚É�o‚Ä‚­‚é urg_t �\‘¢‘Ì‚Í urg_open() ŠÖ�”‚ðŒÄ‚Ñ�o‚µ‚½‚Æ‚«‚É�‰Šú‰»‚³‚ê�AƒZƒ“ƒTƒpƒ‰ƒ��[ƒ^‚̎擾‚âˆÈ�~‚̃f�[ƒ^‘—Žó�M‚ðŠÇ—�‚µ‚Ä‚¢‚Ü‚·�B + + ‚±‚̃vƒ�ƒOƒ‰ƒ€‚ðŽÀ�s‚·‚邯 length_data —̈æ‚É length_data_size ŒÂ‚̃f�[ƒ^‚ªŠi”[‚³‚ê‚Ü‚·�B\n + Žæ“¾‚µ‚½‹——£ƒf�[ƒ^‚ð�‡‚É•\ަ‚·‚é‚É‚Í�AˆÈ‰º‚̂悤‚É‹L�q‚µ‚Ü‚·�B + \code +for (i = 0; i < length_data; ++i) { + printf("%ld, ", length_data[i]); +} +printf("\n"); \endcode + + \n + ‚Ü‚½�AƒZƒ“ƒT‚Æ‚Ì�Ú‘±‚ðƒC�[ƒT�[ƒlƒbƒg‚Å�s‚¤�ê�‡ urg_open() ‚Ì‹L�q‚ðˆÈ‰º‚̂悤‚É•Ï�X‚µ‚Ü‚·�B + \dontinclude connect_ethernet.c + \skip // + \until todo check error + + + \section library_tutorial_get_scans ˜A‘±‚µ‚Ä‹——£ƒf�[ƒ^‚ðŽæ“¾‚·‚é + + scan_times ‰ñ‚Ì‹——£ƒf�[ƒ^‚ðŽæ“¾‚·‚éƒvƒ�ƒOƒ‰ƒ€‚Í�AˆÈ‰º‚̂悤‚É‹L�q‚Å‚«‚Ü‚·�B + \dontinclude get_scans.c + \skip // + \until } + + + ‘å’ï‚Ì�ê�‡ urg_start_measurement() ‚Æ urg_get_distance() ‚̃yƒA‚ðŒJ‚è•Ô‚µ‚ČĂÑ�o‚·‚æ‚è‚à�AŽæ“¾‰ñ�”‚ðŽw’肵‚Ä‚P“x urg_start_measurement() ‚ðŒÄ‚Ñ�o‚µ‚Ä‚¨‚« urg_get_distance() ‚ÅŒJ‚è•Ô‚µƒf�[ƒ^‚ðŽæ“¾‚·‚é•û‚ªŒø—¦‚æ‚­ƒf�[ƒ^‚ðŽæ“¾‚Å‚«‚Ü‚·�B + + + \section library_tutorial_settings Œv‘ª‚̃pƒ‰ƒ��[ƒ^�Ý’è + + Œv‘ª‚͈̔Í�AƒXƒeƒbƒv�”‚ÌŠÔˆø‚«�Ý’è�AƒXƒLƒƒƒ“‚ÌŠÔˆø‚«�Ý’è‚ð�s‚¤‚±‚Æ‚ª‚Å‚«‚Ü‚·�BŒv‘ª‚Ì”ÍˆÍ‚ð‹·‚­‚µ‚½‚è�AŠÔˆø‚«‚ð�s‚¤‚±‚ƂŎó�Mƒf�[ƒ^—Ê‚ðŒ¸‚ç‚·‚±‚Æ‚ª‚Å‚«�Aƒ‰ƒCƒuƒ‰ƒŠ“®�ì‚Ì•‰‰×‚ªŒ¸�­‚µ‚Ü‚·�B + + \dontinclude set_parameter.c + \skip // + \until urg_start + \line check error code + + + \section library_tutorial_timestamp ‹——£ƒf�[ƒ^‚ðŽæ“¾‚µ‚½‚Æ‚«‚̃^ƒCƒ€ƒXƒ^ƒ“ƒv‚ðŽæ“¾‚·‚é + + Œv‘ª‚ª‚¢‚‚̃^ƒCƒ~ƒ“ƒO‚Å�s‚í‚ꂽ‚©‚Í urg_get_distance() ŠÖ�”‚Ŏ擾‚Å‚«‚Ü‚·�B + + urg_get_distance() ‚ð—p‚¢‚Ď擾‚µ‚½ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv‚ð•\ަ‚·‚éƒvƒ�ƒOƒ‰ƒ€‚Í�AˆÈ‰º‚̂悤‚É‹L�q‚Å‚«‚Ü‚·�B + \dontinclude get_timestamp.c + \skip // + \until } + + + ’Ê�í‚̓Zƒ“ƒT‚ÌŒv‘ªŽüŠú‚ÅŒv‘ª‚ª�s‚í‚ê‚Ü‚·‚ª�Aƒ‰ƒCƒuƒ‰ƒŠ‚ð�ˆ—�‚·‚é PC ‚Ì•‰‰×‚ª�‚‚¢�ê�‡‚ÍŒv‘ªƒf�[ƒ^‚̃^ƒCƒ€ƒXƒ^ƒ“ƒvŠÔŠu‚ª�AƒZƒ“ƒT‚ÌŒv‘ªŽüŠú‚æ‚è‚à’·‚­‚È‚é�ê�‡‚ª‚ ‚è‚Ü‚·�B‚±‚Ì�ê�‡�AŒv‘ª‚·‚éƒXƒeƒbƒv�”‚ðŠÔˆø‚­‚Ȃǂ̕Ï�X‚Å‘Î�ˆ‚Å‚«‚邱‚Æ‚ª‚ ‚è‚Ü‚·�B + + + \section library_tutorial_xy ‹——£ƒf�[ƒ^‚ð X-Y �À•WŒn‚ɕϊ·‚·‚é + + Œv‘ª‚µ‚½‹——£ƒf�[ƒ^‚ð X-Y �À•W‚ɕϊ·‚·‚é‚É‚Í urg_index2rad() ‚ð—p‚¢‚Ä‚»‚Ì‹——£‚ª‚ǂ̕ûŒü‚É‚ ‚é‚©‚ðŒvŽZ‚µ‚Ü‚·�B + + \dontinclude convert_xy.c + \skip // + \until printf("\n"); + + + urg_index2rad() ‚Í�AƒZƒ“ƒT�³–Ê‚ª 0 [deg] ‚Æ‚µ‚½‚Æ‚«‚̃Xƒeƒbƒv‚ÌŒü‚«‚ðƒ‰ƒWƒAƒ“’PˆÊ‚ŕԂµ‚Ü‚·�B + + \image html sensor_index_image.png ƒZƒ“ƒT‚Æ urg_index2rad() ‚ÌŠÖŒW +*/ diff --git a/src/urg_c/current/dox/mainpage.dox b/src/urg_c/current/dox/mainpage.dox new file mode 100644 index 0000000..6844b54 --- /dev/null +++ b/src/urg_c/current/dox/mainpage.dox @@ -0,0 +1,120 @@ +/*! + \mainpage URG C Library document + + \~japanese + \section mainpage_what ŠT—v + + ‚±‚ê‚Í�AƒŒ�[ƒU‹——£ƒZƒ“ƒT URG ƒVƒŠ�[ƒY—p‚̃I�[ƒvƒ“ƒ\�[ƒX C ƒ‰ƒCƒuƒ‰ƒŠ‚Å‚·�B\n + ‚±‚̃‰ƒCƒuƒ‰ƒŠ‚Í�AˆÈ‰º‚̊‹«‚ɂē®�ì‚ðŠm”F‚µ‚Ä‚¢‚Ü‚·�B + + - Visual C++ 2005 + - gcc 4.6.0 (Linux) + + + \~english + \section mainpage_what Abstract + + This is open source C library for Hokuyo URG laser range scanners. This library is confirmed to work in the following environments: + + - Visual C++ 2005 + - gcc 4.6.0 (Linux) + + + \~japanese + \section mainpage_license ƒ‰ƒCƒZƒ“ƒX + + �C�³ BSD ƒ‰ƒCƒZƒ“ƒX‚ÉŠî‚¢‚Ä”z•z‚µ‚Ü‚·�B\n + ƒ‰ƒCƒZƒ“ƒX‚Ì�Ú�ׂ̓‰ƒCƒuƒ‰ƒŠ•t‘®‚Ì COPYRIGHT.txt ƒtƒ@ƒCƒ‹‚ð‚²——‰º‚³‚¢�B + + + \~english + \section mainpage_license License + + This software is licensed using the New BSD license. See the COPYRIGHT.txt for the actual license text. + + + \~japanese + \section mainpage_download ƒ_ƒEƒ“ƒ��[ƒh + + ‚±‚̃‰ƒCƒuƒ‰ƒŠ‚Ì zip ƒtƒ@ƒCƒ‹‚Í�AˆÈ‰º‚̃AƒhƒŒƒX‚©‚çƒ_ƒEƒ“ƒ��[ƒh‚Å‚«‚Ü‚·�B + - http://sourceforge.net/projects/urgwidget/files/urg/ + + ŠJ”­”ł̃\�[ƒXƒR�[ƒh‚Í Mercurial ƒŠƒ|ƒWƒgƒŠ‚ÅŠÇ—�‚³‚ê‚Ä‚¢‚Ü‚·�B + \verbatim +hg clone http://urgwidget.hg.sourceforge.net:8000/hgroot/urgwidget/urgwidget \endverbatim + + + \~english + \section mainpage_download Download + + Use the below link to download the urg_library zip file. + - http://sourceforge.net/projects/urgwidget/files/urg/ + + In this Mercurial repository you can be find the lastest source code. + \verbatim +hg clone http://urgwidget.hg.sourceforge.net:8000/hgroot/urgwidget/urgwidget \endverbatim + + + \~japanese + \section mainpage_compile_and_usage ƒ‰ƒCƒuƒ‰ƒŠ‚Æ�AƒTƒ“ƒvƒ‹ƒvƒ�ƒOƒ‰ƒ€‚̃Rƒ“ƒpƒCƒ‹ + + - Windows + - \subpage usage_windows_vcproj_page + - \subpage usage_windows_bat_page + + - Linux, Mac + - \subpage usage_gcc_page + + + \~english + \section mainpage_compile_and_usage Build library and sample programs. + + - Windows + - \subpage usage_windows_vcproj_page + - \subpage usage_windows_bat_page + + - Linux, Mac + - \subpage usage_gcc_page + + + \~japanese + \section mainpage_library ƒ‰ƒCƒuƒ‰ƒŠ‚ÌŽg‚¢•û + + - \subpage library_tutorial_page + - \subpage library_sample_page + + - ƒ‰ƒCƒuƒ‰ƒŠ API + - \ref urg_sensor.h + - \ref urg_utils.h + + + \~english + \section mainpage_library Library tutorial + + - \subpage library_tutorial_page + - \subpage library_sample_page + + - Library API + - \ref urg_sensor.h (under construction) + - \ref urg_utils.h (under construction) + + + \~japanese + \section mainpage_support –â‚¢�‡‚킹�æ + + Ž¿–â‚â—v–]‚Í�AˆÈ‰º‚̃��[ƒŠƒ“ƒOƒŠƒXƒg‚܂ł¨Šè‚¢‚µ‚Ü‚·�B\n + - urgwidget-users-jp@lists.sourceforge.net + + ‚Ü‚½�Aƒ��[ƒŠƒ“ƒOƒŠƒXƒg‚Ì‰ß‹Žƒ�ƒO‚͉º‹Lƒy�[ƒW‚©‚çŽQ�Ƃł«‚Ü‚·�B\n + - http://sourceforge.net/mailarchive/forum.php?forum_name=urgwidget-users-jp + + + \~english + \section mainpage_support Support + + Send your question and request to the urgwidget mailing list. + - urgwidget-users@lists.sourceforge.net + + Mailing list archive: + - http://sourceforge.net/mailarchive/forum.php?forum_name=urgwidget-users +*/ diff --git a/src/urg_c/current/dox/multiecho_image.svg b/src/urg_c/current/dox/multiecho_image.svg new file mode 100644 index 0000000..930193d --- /dev/null +++ b/src/urg_c/current/dox/multiecho_image.svg @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + sensor + object + object + + + diff --git a/src/urg_c/current/dox/sensor_angle_image.svg b/src/urg_c/current/dox/sensor_angle_image.svg new file mode 100644 index 0000000..868d924 --- /dev/null +++ b/src/urg_c/current/dox/sensor_angle_image.svg @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + sensorback + sensorfront + sensorleft + sensorright + 0 + +PI/2 + -PI/2 + + + + diff --git a/src/urg_c/current/dox/sensor_index_image.svg b/src/urg_c/current/dox/sensor_index_image.svg new file mode 100644 index 0000000..15620f2 --- /dev/null +++ b/src/urg_c/current/dox/sensor_index_image.svg @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + sensorback + sensorfront + sensorleft + sensorright + 0 + + + max index + + diff --git a/src/urg_c/current/dox/sensor_step_image.svg b/src/urg_c/current/dox/sensor_step_image.svg new file mode 100644 index 0000000..9561d64 --- /dev/null +++ b/src/urg_c/current/dox/sensor_step_image.svg @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + sensorback + sensorfront + sensorleft + sensorright + 0 + + + min step + max step + + diff --git a/src/urg_c/current/dox/set_parameter.c b/src/urg_c/current/dox/set_parameter.c new file mode 100644 index 0000000..88e43cb --- /dev/null +++ b/src/urg_c/current/dox/set_parameter.c @@ -0,0 +1,37 @@ +#include "urg_sensor.h" +#include "urg_utils.h" + +int main(void) +{ +const char connect_device[] = "/dev/ttyACM0"; +const long connect_baudrate = 115200; +urg_t urg; +int first_step; +int last_step; +int skip_step; +int scan_times; +int skip_scan; +int ret; +// Œv‘ªƒpƒ‰ƒ��[ƒ^‚Ì�Ý’è + +// ƒZƒ“ƒT‚ɑ΂µ‚Ä�Ú‘±‚ð�s‚¤�B +// �Ú‘±‚ð�s‚¤‚Æ�AŒv‘ªƒpƒ‰ƒ��[ƒ^‚Ì�Ý’è‚Í�‰Šú‰»‚³‚ê‚é +ret = urg_open(&urg, URG_SERIAL, connect_device, connect_baudrate); +// \todo check error code + +// Œv‘ª”͈͂ðŽw’è‚·‚é +// ƒZƒ“ƒT�³–Ê•ûŒü‚Ì 90 [deg] ”͈͂̃f�[ƒ^Žæ“¾‚ð�s‚¢�AƒXƒeƒbƒvŠÔˆø‚«‚ð�s‚í‚È‚¢—á +first_step = urg_rad2step(&urg, -45); +last_step = urg_rad2step(&urg, +45); +skip_step = 0; +ret = urg_set_scanning_parameter(&urg, first_step, last_step, skip_step); +// \todo check error code + +// Œv‘ª‰ñ�”‚ÆŒv‘ª‚ÌŠÔˆø‚«‚ðŽw’肵‚Ä�AŒv‘ª‚ðŠJŽn‚·‚é +// 123 ‰ñ‚ÌŒv‘ª‚ðŽwަ‚µ�AƒXƒLƒƒƒ“‚ÌŠÔˆø‚«‚ð�s‚í‚È‚¢—á +scan_times = 123; +skip_scan = 0; +ret = urg_start_measurement(&urg, URG_DISTANCE, scan_times, skip_scan); +// \todo check error code +return 0; +} diff --git a/src/urg_c/current/dox/skip_scan_image.svg b/src/urg_c/current/dox/skip_scan_image.svg new file mode 100644 index 0000000..031937e --- /dev/null +++ b/src/urg_c/current/dox/skip_scan_image.svg @@ -0,0 +1,352 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + when skip scan == 2 + + + + + + + + + + + + + + + + + { + { + { + no scan + no scan + scan + scan + scan + scan + no scan + + diff --git a/src/urg_c/current/dox/usage_gcc.dox b/src/urg_c/current/dox/usage_gcc.dox new file mode 100644 index 0000000..aa8711b --- /dev/null +++ b/src/urg_c/current/dox/usage_gcc.dox @@ -0,0 +1,76 @@ +/*! + \~japanese + \page usage_gcc_page gcc (Makefile ‚ðŽg‚Á‚½ƒRƒ“ƒpƒCƒ‹) + + ƒ‰ƒCƒuƒ‰ƒŠ‚̃Rƒ“ƒpƒCƒ‹•û–@‚Æ�Aƒ‰ƒCƒuƒ‰ƒŠ‚ðŽg‚Á‚½ŽÀ�sƒtƒ@ƒCƒ‹‚Ì�ì‚è•û‚ð�à–¾‚µ‚Ü‚·�B + + + \~english + \page usage_gcc_page gcc (using Makefile) + + This guide shows how to compile the library and the executable with the library. + + + \~japanese + \section usage_gcc_install_gcc ƒ‰ƒCƒuƒ‰ƒŠ‚̃Cƒ“ƒXƒg�[ƒ‹•û–@ + + ƒpƒbƒP�[ƒW‚ð“WŠJŒã make ƒRƒ}ƒ“ƒh‚ŃRƒ“ƒpƒCƒ‹‚ƃCƒ“ƒXƒg�[ƒ‹‚ð�s‚¢‚Ü‚·�B\n + + + \~english + \section usage_gcc_install_gcc Install library + + Expand the package. And compile & install using by make command. + + \~ +\verbatim +% unzip urg_library-1.0.2.zip +% cd urg_library-1.0.2/ +% make +% sudo make install \endverbatim + + \~japanese + ƒfƒtƒHƒ‹ƒg‚Å‚Í /usr/local ƒfƒBƒŒƒNƒgƒŠˆÈ‰º‚Ì include/, lib/, bin/ ƒfƒBƒŒƒNƒgƒŠˆÈ‰º‚Ƀtƒ@ƒCƒ‹‚ªƒCƒ“ƒXƒg�[ƒ‹‚³‚ê‚Ü‚·�B\n + ‚±‚ê‚ç‚̃fƒBƒŒƒNƒgƒŠ‚̃Cƒ“ƒXƒg�[ƒ‹�ê�Š‚ð•Ï�X‚·‚é�ê�‡‚Í urg_library-1.0.2/Makefile ’†‚Ì PREFIX ‚ð•Ï�X‚µ‚ĉº‚³‚¢�B \n + (ƒ‰ƒCƒuƒ‰ƒŠ‚̃o�[ƒWƒ‡ƒ“”Ô�†‚Í�A—˜—p‚·‚é‚à‚̂ɓǂݑւ¦‚ĉº‚³‚¢�B) + +ƒCƒ“ƒXƒg�[ƒ‹�æ‚ð /usr/ ‚É•Ï�X‚·‚é�ê�‡‚Ì•Ï�X—á (urg-libaray-1.0.2/Makefile ‚ð•Ò�W) + + + \~english + The default installation directory on linux was lib/, bin/ and bin/ under /usr/local directory. Please edit the description of PREFIX in urg_library-1.0.2/Makefile if you change the installation location for these directories. + + This is an example of text to change installation directory to /usr/. (edit urg_library-1.0.2/Makefile) + + \~ +\verbatim +PREFIX = /usr \endverbatim + + + \~japanese + \section usage_gcc_usage_gcc ƒ‰ƒCƒuƒ‰ƒŠ‚ðŽg‚Á‚½ŽÀ�sƒtƒ@ƒCƒ‹‚Ì�ì‚è•û + + test.c ‚ðƒRƒ“ƒpƒCƒ‹‚·‚邯‚«‚̃Rƒ}ƒ“ƒh—á + + + \~english + \section usage_gcc_usage_gcc Compile program with library + + Example of command to compile test.c file. + + \~ + \verbatim +% gcc -I/usr/local/include/urg_c test.c -o test -lurg_c -lm +\endverbatim + + \~japanese + ƒ‰ƒCƒuƒ‰ƒŠ‚ƈê��‚ɃCƒ“ƒXƒg�[ƒ‹‚³‚ê‚é urg_c-config ƒXƒNƒŠƒvƒg‚ðŽg‚¤‚Æ�AƒRƒ“ƒpƒCƒ‹‚·‚éƒRƒ}ƒ“ƒh‚ðˆÈ‰º‚̂悤‚É‹L�q‚·‚邱‚Æ‚à‚Å‚«‚Ü‚·�B + + \~english + You can write like this by using urg_c-config script. + + \~ + \verbatim +% gcc `urg_c-config --cflags` test.c -o test `urg_c-config --libs` -lm +\endverbatim +*/ diff --git a/src/urg_c/current/dox/usage_windows_bat.dox b/src/urg_c/current/dox/usage_windows_bat.dox new file mode 100644 index 0000000..b78d910 --- /dev/null +++ b/src/urg_c/current/dox/usage_windows_bat.dox @@ -0,0 +1,57 @@ +/*! + \~japanese + \page usage_windows_bat_page Visual C++ (ƒoƒbƒ`ƒtƒ@ƒCƒ‹‚ðŽg‚Á‚½ƒRƒ“ƒpƒCƒ‹) + + Visual Studio ‚Ì’ñ‹Ÿ‚·‚éƒoƒbƒ`ƒtƒ@ƒCƒ‹‚ð—p‚¢‚Ä�AƒRƒ}ƒ“ƒhƒvƒ�ƒ“ƒvƒg‚©‚çƒRƒ“ƒpƒCƒ‹‚·‚é•û–@‚ð�Љ‚Ü‚·�B\n + ˆÈ‰º‚Ì�ì‹Æ‚̓Rƒ}ƒ“ƒhƒvƒ�ƒ“ƒvƒg�ã‚Å�s‚¢‚Ü‚·�B + + + \~english + \page usage_windows_bat_page Visual C++ (using batch file) + + This page shows how to compile using by the batch file provided by Visual Studio. The following work is done at the command prompt. + + + \~japanese + \section usage_windows_bat_link_make ƒRƒ“ƒpƒCƒ‹ + + -# ƒRƒ“ƒpƒCƒ‹‚É•K—v‚Ȋ‹«•Ï�”‚ð�Ý’è‚·‚邽‚ß‚É Visual Studio ‚ª’ñ‹Ÿ‚µ‚Ä‚¢‚é bat ƒtƒ@ƒCƒ‹‚ðƒRƒs�[‚µ‚Ü‚·�B \n + Microsoft Visual Studio 8\\Common7\\Tools\\vsvars32.bat ‚ð urg_library-1.0.2\\windowsexe ‚ɃRƒs�[‚µ‚Ü‚·�B \n + (ƒ‰ƒCƒuƒ‰ƒŠ‚̃o�[ƒWƒ‡ƒ“”Ô�†‚Í�A—˜—p‚·‚é‚à‚̂ɓǂݑւ¦‚ĉº‚³‚¢�B) + \n \n + -# ŠÂ‹«•Ï�”‚ð�Ý’è‚Æ�AƒRƒ“ƒpƒCƒ‹—p‚Ì bat ƒtƒ@ƒCƒ‹‚ÌŽÀ�s \n + urg_library-1.0.2\\windowsexe\\vsvars32.bat ‚ðŽÀ�s‚µ‚Ċ‹«•Ï�”‚ð�Ý’èŒã urg_library-1.0.2\\windowsexe\\compile.bat ‚ðŽÀ�s‚µ‚ăRƒ“ƒpƒCƒ‹‚ð�s‚¢‚Ü‚·�B + \n \n + -# �¶�¬‚³‚ꂽƒTƒ“ƒvƒ‹‚ÌŽÀ�s \n + urg_library-1.0.2\\windowsexe ‚Å�¶�¬‚³‚ê‚é exe ‚ðŽÀ�s‚µ‚Ü‚·�B + + �Ú�×‚Í compile.bat ‚ð‚²——‰º‚³‚¢�B + + + \~english + \section usage_windows_bat_link_make Compile + + -# Copy the batch file provided by Visual Studio to set the environment variables needs for compiling. \n + Copy Microsoft Visual Studio 8\\Common7\\Tools\\vsvars32.bat to urg_library-1.0.2\\windowsexe \n + (Version of the library, please replace what you use.) + \n \n + -# Running the bat file for compilation, and set the environment variable. \n + After setting the environment variable, run urg_library-1.0.2\\windowsexe\\compile.bat file to compile. + \n \n + -# Running the generated samples. + Run generated execute files in urg_library-1.0.2\\windowsexe folder. + + For more information, please see compile.bat file. + + + \~japanese + \section usage_windows_bat_link_clean ƒNƒŠ�[ƒ“ƒAƒbƒv + + �¶�¬‚³‚ꂽƒTƒ“ƒvƒ‹‚ÌŽÀ�sƒtƒ@ƒCƒ‹‚ð�í�œ‚·‚é‚É‚Í urg_library-1.0.2\\windowsexe\\cleanobj.bat ‚ðŽÀ�s‚µ‚ĉº‚³‚¢�B + + + \~english + \section usage_windows_bat_link_clean Clean up + + Run urg_library-1.0.2\\windowsexe\\cleanobj.bat to delete a file that is generated. +*/ diff --git a/src/urg_c/current/dox/usage_windows_vcproj.dox b/src/urg_c/current/dox/usage_windows_vcproj.dox new file mode 100644 index 0000000..6a5a3b5 --- /dev/null +++ b/src/urg_c/current/dox/usage_windows_vcproj.dox @@ -0,0 +1,74 @@ +/*! + \~japanese + \page usage_windows_vcproj_page Visual C++ (ƒvƒ�ƒWƒFƒNƒgƒtƒ@ƒCƒ‹‚ðŽg‚Á‚½ƒRƒ“ƒpƒCƒ‹) + + Visual C++ ‚̃vƒ�ƒWƒFƒNƒgƒtƒ@ƒCƒ‹‚ðŽg‚Á‚½ƒ‰ƒCƒuƒ‰ƒŠ‚̃Rƒ“ƒpƒCƒ‹•û–@‚Æ�A‚»‚̃‰ƒCƒuƒ‰ƒŠ‚ÌŽg‚¢•û‚ð�à–¾‚µ‚Ä‚¢‚Ü‚·�B + + + \~english + \page usage_windows_vcproj_page Visual C++ (using vcproj) (under construction) + + This page shows how to compile and run using by Visual studio's project file. + + + \~ + - \ref usage_windows_vcproj_compile + - \ref usage_windows_vcproj_link + - \ref usage_windows_vcproj_sample + + + \~japanese + \section usage_windows_vcproj_compile ƒ‰ƒCƒuƒ‰ƒŠ‚̃Rƒ“ƒpƒCƒ‹ + + urg_library-1.0.2\\visual_cpp\\urg.sln ‚©‚ç Visual C++ ‚ð‹N“®‚µ�Aƒ\ƒŠƒ…�[ƒVƒ‡ƒ“‚̃rƒ‹ƒh‚ð�s‚¢‚Ü‚·�B \n + (ƒ‰ƒCƒuƒ‰ƒŠ‚̃o�[ƒWƒ‡ƒ“”Ô�†‚Í�A—˜—p‚·‚é‚à‚̂ɓǂݑւ¦‚ĉº‚³‚¢�B) + + ƒrƒ‹ƒhŒã‚Í�AƒXƒ^ƒeƒBƒbƒNƒ‰ƒCƒuƒ‰ƒŠ urg.lib ‚ª�¶�¬‚³‚ê‚Ü‚·�B\n + ƒ‰ƒCƒuƒ‰ƒŠ‚ðŽg‚Á‚½ƒvƒ�ƒOƒ‰ƒ€‚̃Rƒ“ƒpƒCƒ‹‚Í�A‚±‚Ì urg.lib ‚Æ urg_library-1.0.2\\include ƒtƒHƒ‹ƒ_“à‚̃tƒ@ƒCƒ‹‚ð—˜—p‚µ‚Ü‚·�B + + + \~english + \section usage_windows_vcproj_compile Compile Library + + urg_library-1.0.2\\visual_cpp\\urg.sln ‚©‚ç Visual C++ ‚ð‹N“®‚µ�Aƒ\ƒŠƒ…�[ƒVƒ‡ƒ“‚̃rƒ‹ƒh‚ð�s‚¢‚Ü‚·�B \n + (ƒ‰ƒCƒuƒ‰ƒŠ‚̃o�[ƒWƒ‡ƒ“”Ô�†‚Í�A—˜—p‚·‚é‚à‚̂ɓǂݑւ¦‚ĉº‚³‚¢�B) + + ƒrƒ‹ƒhŒã‚Í�AƒXƒ^ƒeƒBƒbƒNƒ‰ƒCƒuƒ‰ƒŠ urg.lib ‚ª�¶�¬‚³‚ê‚Ü‚·�B\n + ƒ‰ƒCƒuƒ‰ƒŠ‚ðŽg‚Á‚½ƒvƒ�ƒOƒ‰ƒ€‚̃Rƒ“ƒpƒCƒ‹‚Í�A‚±‚Ì urg.lib ‚Æ urg_library-1.0.2\\include ƒtƒHƒ‹ƒ_“à‚̃tƒ@ƒCƒ‹‚ð—˜—p‚µ‚Ü‚·�B + + + \~japanese + \section usage_windows_vcproj_link ƒ‰ƒCƒuƒ‰ƒŠ‚ð—˜—p‚·‚邽‚ß‚Ì Visual C++ �Ý’è + + �¶�¬‚³‚ꂽ urg.lib ‚Æ urg_libaray-1.0.2\\include\\ ‚Ì‚Q‚‚ðƒRƒs�[‚µ‚Ä—˜—p‚µ‚Ü‚·�B \n + ƒvƒ�ƒWƒFƒNƒg‚Ɉȉº‚Ì‚R‚‚Ì�Ý’è‚ð‚·‚é‚±‚Æ‚Å�Aƒ‰ƒCƒuƒ‰ƒŠ‚ª—˜—p‚Å‚«‚Ü‚·�B + + -# ƒvƒ�ƒWƒFƒNƒg‚̃vƒ�ƒpƒeƒB "�\�¬ƒvƒ�ƒpƒeƒB" -> "C/C++" -> "‘S”Ê" ‚̃tƒH�[ƒ€‚É‚ ‚é "’ljÁ‚̃Cƒ“ƒNƒ‹�[ƒhƒfƒBƒŒƒNƒgƒŠ" ‚É urg_library-1.0.2\\include ‚̃pƒX‚ð‹L�q‚µ‚Ü‚·�B + -# ƒvƒ�ƒWƒFƒNƒg‚̃vƒ�ƒpƒeƒB "ƒŠƒ“ƒJ" -> "‘S”Ê" ‚̃tƒH�[ƒ€‚É‚ ‚é "’ljÁ‚̃‰ƒCƒuƒ‰ƒŠƒfƒBƒŒƒNƒgƒŠ" ‚É urg.lib ‚ðƒRƒs�[‚µ‚½ƒfƒBƒŒƒNƒgƒŠ‚ð‹L�q‚µ‚Ü‚·�B + -# ƒvƒ�ƒWƒFƒNƒg‚̃vƒ�ƒpƒeƒB "ƒŠƒ“ƒJ" -> "“ü—Í" ‚̃tƒH�[ƒ€‚É‚ ‚é "’ljÁ‚̈ˑ¶ƒtƒ@ƒCƒ‹" ‚É urg.lib ‚Æ‹L�q‚µ‚Ü‚·�B + + + \~english + \section usage_windows_vcproj_link Settings for the Visual C++ + + �¶�¬‚³‚ꂽ urg.lib ‚Æ urg_libaray-1.0.2\\include\\ ‚Ì‚Q‚‚ðƒRƒs�[‚µ‚Ä—˜—p‚µ‚Ü‚·�B \n + ƒvƒ�ƒWƒFƒNƒg‚Ɉȉº‚Ì‚R‚‚Ì�Ý’è‚ð‚·‚é‚±‚Æ‚Å�Aƒ‰ƒCƒuƒ‰ƒŠ‚ª—˜—p‚Å‚«‚Ü‚·�B + + -# ƒvƒ�ƒWƒFƒNƒg‚̃vƒ�ƒpƒeƒB "�\�¬ƒvƒ�ƒpƒeƒB" -> "C/C++" -> "‘S”Ê" ‚̃tƒH�[ƒ€‚É‚ ‚é "’ljÁ‚̃Cƒ“ƒNƒ‹�[ƒhƒfƒBƒŒƒNƒgƒŠ" ‚É urg_library-1.0.2\\include ‚̃pƒX‚ð‹L�q‚µ‚Ü‚·�B + -# ƒvƒ�ƒWƒFƒNƒg‚̃vƒ�ƒpƒeƒB "ƒŠƒ“ƒJ" -> "‘S”Ê" ‚̃tƒH�[ƒ€‚É‚ ‚é "’ljÁ‚̃‰ƒCƒuƒ‰ƒŠƒfƒBƒŒƒNƒgƒŠ" ‚É urg.lib ‚ðƒRƒs�[‚µ‚½ƒfƒBƒŒƒNƒgƒŠ‚ð‹L�q‚µ‚Ü‚·�B + -# ƒvƒ�ƒWƒFƒNƒg‚̃vƒ�ƒpƒeƒB "ƒŠƒ“ƒJ" -> "“ü—Í" ‚̃tƒH�[ƒ€‚É‚ ‚é "’ljÁ‚̈ˑ¶ƒtƒ@ƒCƒ‹" ‚É urg.lib ‚Æ‹L�q‚µ‚Ü‚·�B + + + \~japanese + \section usage_windows_vcproj_sample ƒTƒ“ƒvƒ‹‚̃Rƒ“ƒpƒCƒ‹ + + ‚±‚̃‰ƒCƒuƒ‰ƒŠ‚ð—˜—p‚·‚é�Ý’è‚ð‚µ‚½ Visual C++ ‚̃vƒ�ƒWƒFƒNƒg‚ª urg_library-1.0.2\\visual_cpp\\samples ˆÈ‰º‚É‚ ‚è‚Ü‚·�B\n + Ž©•ª‚̃vƒ�ƒWƒFƒNƒg‚щƒCƒuƒ‰ƒŠ‚ðŽg‚¤‚Æ‚«‚ÌŽQ�l‚É‚µ‚ĉº‚³‚¢�B + + + \~english + \section usage_windows_vcproj_sample Compile Samples + + ‚±‚̃‰ƒCƒuƒ‰ƒŠ‚ð—˜—p‚·‚é�Ý’è‚ð‚µ‚½ Visual C++ ‚̃vƒ�ƒWƒFƒNƒg‚ª urg_library-1.0.2\\visual_cpp\\samples ˆÈ‰º‚É‚ ‚è‚Ü‚·�B\n + Ž©•ª‚̃vƒ�ƒWƒFƒNƒg‚щƒCƒuƒ‰ƒŠ‚ðŽg‚¤‚Æ‚«‚ÌŽQ�l‚É‚µ‚ĉº‚³‚¢�B +*/ diff --git a/src/urg_c/current/include/urg_c/urg_connection.h b/src/urg_c/current/include/urg_c/urg_connection.h new file mode 100644 index 0000000..865c6e9 --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_connection.h @@ -0,0 +1,196 @@ +#ifndef URG_CONNECTION_H +#define URG_CONNECTION_H + +/*! + \file + \brief ’Ê�M‚Ì�ˆ—� + + \author Satofumi KAMIMURA + + $Id: urg_connection.h,v 1d233c7a2240 2011/02/19 03:08:45 Satofumi $ +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "urg_c/urg_serial.h" +#include "urg_c/urg_tcpclient.h" + + +/*! + \brief ’è�”’è‹` +*/ +enum { + URG_CONNECTION_TIMEOUT = -1, //!< ƒ^ƒCƒ€ƒAƒEƒg‚ª”­�¶‚µ‚½‚Æ‚«‚Ì–ß‚è’l +}; + + +/*! + \brief ’Ê�Mƒ^ƒCƒv +*/ +typedef enum { + URG_SERIAL, //!< ƒVƒŠƒAƒ‹, USB �Ú‘± + URG_ETHERNET, //!< ƒC�[ƒT�[ƒlƒbƒg�Ú‘± +} urg_connection_type_t; + + +/*! + \brief ’Ê�MƒŠƒ\�[ƒX +*/ +typedef struct +{ + urg_connection_type_t type; //!< �Ú‘±ƒ^ƒCƒv + urg_serial_t serial; //!< ƒVƒŠƒAƒ‹�Ú‘± + urg_tcpclient_t tcpclient; //!< ƒC�[ƒT�[ƒlƒbƒg�Ú‘± +} urg_connection_t; + + +/*! + \brief �Ú‘± + + Žw’肳‚ꂽƒfƒoƒCƒX‚É�Ú‘±‚·‚é�B + + \param[in,out] connection ’Ê�MƒŠƒ\�[ƒX + \param[in] connection_type �Ú‘±ƒ^ƒCƒv + \param[in] device �Ú‘±–¼ + \param[in] baudrate_or_port ƒ{�[ƒŒ�[ƒg / ƒ|�[ƒg”Ô�† + + \retval 0 �³�í + \retval <0 ƒGƒ‰�[ + + connection_type ‚É‚Í + + - URG_SERIAL ... ƒVƒŠƒAƒ‹’Ê�M + - URG_ETHERNET .. ƒC�[ƒT�[ƒlƒbƒg’Ê�M + + ‚ðŽw’è‚·‚é�B + + device, baudrate_or_port ‚ÌŽw’è‚Í connection_type ‚É‚æ‚èŽw’è‚Å‚«‚é’l‚ªˆÙ‚È‚é�B + —Ⴆ‚Î�AƒVƒŠƒAƒ‹’Ê�M‚Ì�ê�‡‚͈ȉº‚̂悤‚ɂȂé�B + + Example + \code + connection_t connection; + if (! connection_open(&connection, URG_SERIAL, "COM1", 115200)) { + return 1; + } \endcode + + ‚Ü‚½�AƒC�[ƒT�[ƒlƒbƒg’Ê�M‚Ì�ê�‡‚͈ȉº‚̂悤‚ɂȂé�B + + Example + \code + connection_t connection; + if (! connection_open(&connection, URG_ETHERNET, "192.168.0.10", 10940)) { + return 1; + } \endcode + + \see connection_close() +*/ +extern int connection_open(urg_connection_t *connection, + urg_connection_type_t connection_type, + const char *device, long baudrate_or_port); + + +/*! + \brief �Ø’f + + ƒfƒoƒCƒX‚Æ‚Ì�Ú‘±‚ð�Ø’f‚·‚é�B + + \param[in,out] connection ’Ê�MƒŠƒ\�[ƒX + + \code + connection_close(&connection); \endcode + + \see connection_open() +*/ +extern void connection_close(urg_connection_t *connection); + + +/*! ƒ{�[ƒŒ�[ƒg‚ð�Ý’è‚·‚é */ +extern int connection_set_baudrate(urg_connection_t *connection, long baudrate); + + +/*! + \brief ‘—�M + + ƒf�[ƒ^‚ð‘—�M‚·‚é�B + + \param[in,out] connection ’Ê�MƒŠƒ\�[ƒX + \param[in] data ‘—�Mƒf�[ƒ^ + \param[in] size ‘—�MƒoƒCƒg�” + + \retval >=0 ‘—�Mƒf�[ƒ^�” + \retval <0 ƒGƒ‰�[ + + Example + \code + n = connection_write(&connection, "QT\n", 3); \endcode + + \see connection_read(), connection_readline() +*/ +extern int connection_write(urg_connection_t *connection, + const char *data, int size); + + +/*! + \brief Žó�M + + ƒf�[ƒ^‚ðŽó�M‚·‚é�B + + \param[in,out] connection ’Ê�MƒŠƒ\�[ƒX + \param[in] data Žó�Mƒf�[ƒ^‚ðŠi”[‚·‚éƒoƒbƒtƒ@ + \param[in] max_size Žó�Mƒf�[ƒ^‚ðŠi”[‚Å‚«‚éƒoƒCƒg�” + \param[in] timeout ƒ^ƒCƒ€ƒAƒEƒgŽžŠÔ [msec] + + \retval >=0 Žó�Mƒf�[ƒ^�” + \retval <0 ƒGƒ‰�[ + + timeout ‚É•‰‚Ì’l‚ðŽw’肵‚½�ê�‡�Aƒ^ƒCƒ€ƒAƒEƒg‚Í”­�¶‚µ‚È‚¢�B + + 1 •¶Žš‚àŽó�M‚µ‚È‚©‚Á‚½‚Æ‚«‚Í #URG_CONNECTION_TIMEOUT ‚ð•Ô‚·�B + + Example + \code +enum { + BUFFER_SIZE = 256, + TIMEOUT_MSEC = 1000, +}; +char buffer[BUFFER_SIZE]; +n = connection_read(&connection, buffer, BUFFER_SIZE, TIMEOUT_MSEC); \endcode + + \see connection_write(), connection_readline() +*/ +extern int connection_read(urg_connection_t *connection, + char *data, int max_size, int timeout); + + +/*! + \brief ‰ü�s•¶Žš‚܂ł̎ó�M + + ‰ü�s•¶Žš‚܂ł̃f�[ƒ^‚ðŽó�M‚·‚é�B + + \param[in,out] connection ’Ê�MƒŠƒ\�[ƒX + \param[in] data Žó�Mƒf�[ƒ^‚ðŠi”[‚·‚éƒoƒbƒtƒ@ + \param[in] max_size Žó�Mƒf�[ƒ^‚ðŠi”[‚Å‚«‚éƒoƒCƒg�” + \param[in] timeout ƒ^ƒCƒ€ƒAƒEƒgŽžŠÔ [msec] + + \retval >=0 Žó�Mƒf�[ƒ^�” + \retval <0 ƒGƒ‰�[ + + data ‚É‚Í�A'\\0' �I’[‚³‚ꂽ•¶Žš—ñ‚ª max_size ‚ð‰z‚¦‚È‚¢ƒoƒCƒg�”‚¾‚¯Ši”[‚³‚ê‚é�B ‚‚܂è�AŽó�M‚Å‚«‚é•¶Žš‚̃oƒCƒg�”‚Í�A�Å‘å‚Å max_size - 1 ‚ƂȂé�B + + ‰ü�s•¶Žš‚Í '\\r' ‚Ü‚½‚Í '\\n' ‚Æ‚·‚é�B + + Žó�M‚µ‚½�Å�‰‚Ì•¶Žš‚ª‰ü�s‚Ì�ê�‡‚Í�A0 ‚ð•Ô‚µ�A1 •¶Žš‚àŽó�M‚µ‚È‚©‚Á‚½‚Æ‚«‚Í #URG_CONNECTION_TIMEOUT ‚ð•Ô‚·�B + + \see connection_write(), connection_read() +*/ +extern int connection_readline(urg_connection_t *connection, + char *data, int max_size, int timeout); + +#ifdef __cplusplus +} +#endif + +#endif /* !URG_CONNECTION_H */ diff --git a/src/urg_c/current/include/urg_c/urg_debug.h b/src/urg_c/current/include/urg_c/urg_debug.h new file mode 100644 index 0000000..0b79b8e --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_debug.h @@ -0,0 +1,42 @@ +#ifndef URG_DEBUG_H +#define URG_DEBUG_H + +/*! + \file + \brief URG debugging functions + + \author Satofumi KAMIMURA + + \~japanese + \attention Žg‚¤•K—v‚Í‚ ‚è‚Ü‚¹‚ñ�B + + \~english + \attention Don't need to use these functions. + + $Id$ +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "urg_c/urg_sensor.h" + + + /*! \~japanese ƒZƒ“ƒT‚Ƀf�[ƒ^‚ð’¼�Ú‘—�M‚·‚é */ + extern int urg_raw_write(urg_t *urg, const char *data, int data_size); + + + /*! \~japanese ƒZƒ“ƒT‚©‚çƒf�[ƒ^‚ð’¼�ÚŽó�M‚·‚é */ + extern int urg_raw_read(urg_t *urg, char *data, int max_data_size, + int timeout); + + /*! \~japanese ƒZƒ“ƒT‚©‚ç‰ü�s‚܂ł̃f�[ƒ^‚ð’¼�ÚŽó�M‚·‚é */ + extern int urg_raw_readline(urg_t *urg,char *data, int max_data_size, + int timeout); + +#ifdef __cplusplus +} +#endif + +#endif /* !URG_DEBUG_H */ diff --git a/src/urg_c/current/include/urg_c/urg_detect_os.h b/src/urg_c/current/include/urg_c/urg_detect_os.h new file mode 100644 index 0000000..ab5b6fb --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_detect_os.h @@ -0,0 +1,28 @@ +#ifndef URG_DETECT_OS_H +#define URG_DETECT_OS_H + +/*! + \file + \brief OS ‚ÌŒŸ�o + + \author Satofumi KAMIMURA + + $Id: urg_detect_os.h,v 0caa22c18f6b 2010/12/30 03:36:32 Satofumi $ +*/ + +#if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) +#define URG_WINDOWS_OS + +#if defined(_MSC_VER) +#define URG_MSC +#endif + +#elif defined(__linux__) +#define URG_LINUX_OS + +#else +// ŒŸ�o‚Å‚«‚È‚¢‚Æ‚«‚ð�AMac ˆµ‚¢‚É‚µ‚Ä‚µ‚Ü‚¤ +#define URG_MAC_OS +#endif + +#endif /* !URG_DETECT_OS_H */ diff --git a/src/urg_c/current/include/urg_c/urg_errno.h b/src/urg_c/current/include/urg_c/urg_errno.h new file mode 100644 index 0000000..08cac7d --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_errno.h @@ -0,0 +1,35 @@ +#ifndef URG_ERRNO_H +#define URG_ERRNO_H + +/*! + \file + \brief URG ƒ‰ƒCƒuƒ‰ƒŠ‚̃Gƒ‰�[’è‹` + + \author Satofumi KAMIMURA + + $Id$ +*/ + +enum { + URG_NO_ERROR = 0, + URG_UNKNOWN_ERROR = -1, + URG_NOT_CONNECTED = -2, + URG_NOT_IMPLEMENTED = -3, + URG_INVALID_RESPONSE = -4, + URG_NO_RESPONSE = -5, + + URG_SEND_ERROR = -6, + URG_RECEIVE_ERROR = -7, + URG_CHECKSUM_ERROR = -8, + URG_INVALID_PARAMETER = -9, + URG_MEASUREMENT_TYPE_MISMATCH = -10, + URG_COMMON_ERROR_LAST, + + URG_SERIAL_OPEN_ERROR = (URG_COMMON_ERROR_LAST -1) -1, + URG_NOT_DETECT_BAUDRATE_ERROR = (URG_COMMON_ERROR_LAST -1) -2, + URG_ETHERNET_OPEN_ERROR = (URG_COMMON_ERROR_LAST -1) -3, + URG_SCANNING_PARAMETER_ERROR = (URG_COMMON_ERROR_LAST -1) -4, + URG_DATA_SIZE_PARAMETER_ERROR = (URG_COMMON_ERROR_LAST -1) -5, +}; + +#endif /* !URG_ERRNO_H */ diff --git a/src/urg_c/current/include/urg_c/urg_ring_buffer.h b/src/urg_c/current/include/urg_c/urg_ring_buffer.h new file mode 100644 index 0000000..dfe8d77 --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_ring_buffer.h @@ -0,0 +1,82 @@ +#ifndef URG_RING_BUFFER_H +#define URG_RING_BUFFER_H + +/*! + \file + \brief ƒŠƒ“ƒOƒoƒbƒtƒ@ + + \author Satofumi KAMIMURA + + $Id$ +*/ + + +//! ƒŠƒ“ƒOƒoƒbƒtƒ@‚ÌŠÇ—��î•ñ +typedef struct +{ + char *buffer; //!< ƒoƒbƒtƒ@‚ւ̃|ƒCƒ“ƒ^ + int buffer_size; //!< ƒoƒbƒtƒ@ƒTƒCƒY + int first; //!< ƒoƒbƒtƒ@‚Ì�擪ˆÊ’u + int last; //!< ƒoƒbƒtƒ@‚Ì�Å�IˆÊ’u +} ring_buffer_t; + + +/*! + \brief �‰Šú‰» + + \param[in] ring ƒŠƒ“ƒOƒoƒbƒtƒ@‚Ì�\‘¢‘Ì + \param[in] buffer Š„‚è“–‚Ä‚éƒoƒbƒtƒ@ + \param[in] shift_length ƒoƒbƒtƒ@ƒTƒCƒY‚Ì 2 ‚Ì�æ�” +*/ +extern void ring_initialize(ring_buffer_t *ring, + char *buffer, const int shift_length); + + +/*! + \brief ƒŠƒ“ƒOƒoƒbƒtƒ@‚̃NƒŠƒA + + \param[in] ring ƒŠƒ“ƒOƒoƒbƒtƒ@‚Ì�\‘¢‘Ì +*/ +extern void ring_clear(ring_buffer_t *ring); + + +/*! + \brief Ši”[ƒf�[ƒ^�”‚ð•Ô‚· + + \param[in] ring ƒŠƒ“ƒOƒoƒbƒtƒ@‚Ì�\‘¢‘Ì +*/ +extern int ring_size(const ring_buffer_t *ring); + + +/*! + \brief �Å‘å‚ÌŠi”[ƒf�[ƒ^�”‚ð•Ô‚· + + \param[in] ring ƒŠƒ“ƒOƒoƒbƒtƒ@‚Ì�\‘¢‘Ì +*/ +extern int ring_capacity(const ring_buffer_t *ring); + + +/*! + \brief ƒf�[ƒ^‚ÌŠi”[ + + \param[in] ring ƒŠƒ“ƒOƒoƒbƒtƒ@‚Ì�\‘¢‘Ì + \param[in] data ƒf�[ƒ^ + \param[in] size ƒf�[ƒ^ƒTƒCƒY + + \return Ši”[‚µ‚½ƒf�[ƒ^�” +*/ +extern int ring_write(ring_buffer_t *ring, const char *data, int size); + + +/*! + \brief ƒf�[ƒ^‚ÌŽæ‚è�o‚µ + + \param[in] ring ƒŠƒ“ƒOƒoƒbƒtƒ@‚Ì�\‘¢‘Ì + \param[out] buffer ƒf�[ƒ^ + \param[in] size �Å‘å‚̃f�[ƒ^ƒTƒCƒY + + \return Žæ‚è�o‚µ‚½ƒf�[ƒ^�” +*/ +extern int ring_read(ring_buffer_t *ring, char *buffer, int size); + +#endif /* ! RING_BUFFER_H */ diff --git a/src/urg_c/current/include/urg_c/urg_sensor.h b/src/urg_c/current/include/urg_c/urg_sensor.h new file mode 100644 index 0000000..018d932 --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_sensor.h @@ -0,0 +1,691 @@ +#ifndef URG_SENSOR_H +#define URG_SENSOR_H + +/*! + \file + \~japanese + \brief URG ƒZƒ“ƒT�§Œä + + URG —p‚ÌŠî–{“I‚ÈŠÖ�”‚ð’ñ‹Ÿ‚µ‚Ü‚·�B + + + \~english + \brief URG sensor + + URG —p‚ÌŠî–{“I‚ÈŠÖ�”‚ð’ñ‹Ÿ‚µ‚Ü‚·�B + + \~ + \author Satofumi KAMIMURA + + $Id: urg_sensor.h,v 540bc11f70c8 2011/05/08 23:04:49 satofumi $ +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "urg_c/urg_connection.h" +#include "urg_c/urg_time.h" + + + /*! + \~japanese + \brief Œv‘ªƒ^ƒCƒv + */ + typedef enum { + URG_DISTANCE, /*!< \~japanese ‹——£ */ + URG_DISTANCE_INTENSITY, /*!< \~japanese ‹——£ + ‹­“x */ + URG_MULTIECHO, /*!< \~japanese ƒ}ƒ‹ƒ`ƒGƒR�[‚Ì‹——£ */ + URG_MULTIECHO_INTENSITY, /*!< \~japanese ƒ}ƒ‹ƒ`ƒGƒR�[‚Ì(‹——£ + ‹­“x) */ + URG_STOP, /*!< \~japanese Œv‘ª‚Ì’âŽ~ */ + URG_UNKNOWN, /*!< \~japanese •s–¾ */ + } urg_measurement_type_t; + + /*! + \~japanese + \brief ‹——£‚ð‰½ byte ‚Å•\Œ»‚·‚é‚©‚ÌŽw’è + */ + typedef enum { + URG_COMMUNICATION_3_BYTE, /*!< \~japanese ‹——£‚ð 3 byte ‚Å•\Œ»‚·‚é */ + URG_COMMUNICATION_2_BYTE, /*!< \~japanese ‹——£‚ð 2 byte ‚Å•\Œ»‚·‚é */ + } urg_range_data_byte_t; + + + enum { + URG_SCAN_INFINITY = 0, /*!< \~japanese –³ŒÀ‰ñ‚̃f�[ƒ^Žæ“¾ */ + URG_MAX_ECHO = 3, /*!< \~japanese ƒ}ƒ‹ƒ`ƒGƒR�[‚Ì�Å‘åƒGƒR�[�” */ + }; + + + /*! \~japanese ƒGƒ‰�[ƒnƒ“ƒhƒ‰ \~english error handler */ + typedef urg_measurement_type_t + (*urg_error_handler)(const char *status, void *urg); + + + /*! + \~japanese + \brief URG ƒZƒ“ƒTŠÇ—� + + \~english + \brief URG sensor + */ + typedef struct + { + int is_active; + int last_errno; + urg_connection_t connection; + + int first_data_index; + int last_data_index; + int front_data_index; + int area_resolution; + long scan_usec; + int min_distance; + int max_distance; + int scanning_first_step; + int scanning_last_step; + int scanning_skip_step; + int scanning_skip_scan; + urg_range_data_byte_t range_data_byte; + + int timeout; + int specified_scan_times; + int scanning_remain_times; + int is_laser_on; + + int received_first_index; + int received_last_index; + int received_skip_step; + urg_range_data_byte_t received_range_data_byte; + int is_sending; + + urg_error_handler error_handler; + + char return_buffer[80]; + } urg_t; + + + /*! + \~japanese + \brief �Ú‘± + + Žw’肵‚½ƒfƒoƒCƒX‚É�Ú‘±‚µ�A‹——£‚ðŒv‘ª‚Å‚«‚邿‚¤‚É‚·‚é�B + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + \param[in] connection_type ’Ê�Mƒ^ƒCƒv + \param[in] device_or_address �Ú‘±ƒfƒoƒCƒX–¼ + \param[in] baudrate_or_port �Ú‘±ƒ{�[ƒŒ�[ƒg [bps] / TCP/IP ƒ|�[ƒg + + \retval 0 �³�í + \retval <0 ƒGƒ‰�[ + + connection_type ‚É‚Í�AˆÈ‰º‚Ì�€–Ú‚ªŽw’è‚Å‚«‚Ü‚·�B + + - #URG_SERIAL + - ƒVƒŠƒAƒ‹�AUSB �Ú‘± + + - #URG_ETHERNET + - ƒC�[ƒT�[ƒlƒbƒg�Ú‘± + + Example + \code + urg_t urg; + + if (urg_open(&urg, URG_SERIAL, "/dev/ttyACM0", 115200) < 0) { + return 1; + } + + ... + + urg_close(&urg); \endcode + + \attention URG C ƒ‰ƒCƒuƒ‰ƒŠ‚Ì‘¼‚ÌŠÖ�”‚ðŒÄ‚Ñ�o‚·‘O‚É�A‚±‚ÌŠÖ�”‚ðŒÄ‚Ñ�o‚·•K—v‚ª‚ ‚è‚Ü‚·�B + + \~ + \see urg_close() + */ + extern int urg_open(urg_t *urg, urg_connection_type_t connection_type, + const char *device_or_address, + long baudrate_or_port); + + + /*! + \~japanese + \brief �Ø’f + + ƒŒ�[ƒU‚ð�Á“”‚µ�AURG ‚Æ‚Ì�Ú‘±‚ð�Ø’f‚µ‚Ü‚·�B + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + + \~ + \see urg_open() + */ + extern void urg_close(urg_t *urg); + + + /*! + \brief ƒ^ƒCƒ€ƒAƒEƒgŽžŠÔ‚Ì�Ý’è + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + \param[in] msec ƒ^ƒCƒ€ƒAƒEƒg‚·‚鎞ŠÔ [msec] + + \attention urg_open() ‚ðŒÄ‚Ñ�o‚·‚Æ timeout ‚Ì�Ý’è’l‚̓fƒtƒHƒ‹ƒg’l‚É�‰Šú‰»‚³‚ê‚邽‚ß�A‚±‚ÌŠÖ�”‚Í urg_open() Œã‚ɌĂÑ�o‚·‚±‚Æ�B + */ + extern void urg_set_timeout_msec(urg_t *urg, int msec); + + + /*! \~japanese ƒ^ƒCƒ€ƒXƒ^ƒ“ƒvƒ‚�[ƒh‚ÌŠJŽn */ + extern int urg_start_time_stamp_mode(urg_t *urg); + + + /*! + \~japanese + \brief ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv‚̎擾 + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + + \retval >=0 ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv [msec] + \retval <0 ƒGƒ‰�[ + + Example + \code + urg_start_time_stamp_mode(&urg); + + before_ticks = get_pc_msec_function(); + time_stamp = urg_time_stamp(&urg); + after_ticks = get_pc_msec_function(); + + // ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv‚ɂ‚¢‚Ă̌vŽZ + ... + + urg_stop_time_stamp_mode(&urg); \endcode + + �Ú‚µ‚­‚Í \ref sync_time_stamp.c ‚ðŽQ�Æ‚µ‚ĉº‚³‚¢�B + */ + extern long urg_time_stamp(urg_t *urg); + + + /*! \~japanese ƒ^ƒCƒ€ƒXƒ^ƒ“ƒvƒ‚�[ƒh‚Ì�I—¹ */ + extern int urg_stop_time_stamp_mode(urg_t *urg); + + + /*! + \~japanese + \brief ‹——£ƒf�[ƒ^‚̎擾‚ðŠJŽn + + ‹——£ƒf�[ƒ^‚̎擾‚ðŠJŽn‚µ‚Ü‚·�BŽÀ�ۂ̃f�[ƒ^‚Í urg_get_distance(), urg_get_distance_intensity(), urg_get_multiecho(), urg_get_multiecho_intensity() ‚Ŏ擾‚Å‚«‚Ü‚·�B + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + \param[in] type ƒf�[ƒ^�Eƒ^ƒCƒv + \param[in] scan_times ƒf�[ƒ^‚̎擾‰ñ�” + \param[in] skip_scan ƒf�[ƒ^‚̎擾ŠÔŠu + + \retval 0 �³�í + \retval <0 ƒGƒ‰�[ + + type ‚ɂ͎擾‚·‚éƒf�[ƒ^‚ÌŽí—Þ‚ðŽw’肵‚Ü‚·�B + + - #URG_DISTANCE ... ‹——£ƒf�[ƒ^ + - #URG_DISTANCE_INTENSITY ... ‹——£ƒf�[ƒ^‚Æ‹­“xƒf�[ƒ^ + - #URG_MULTIECHO ... ƒ}ƒ‹ƒ`ƒGƒR�[”ł̋——£ƒf�[ƒ^ + - #URG_MULTIECHO_INTENSITY ... ƒ}ƒ‹ƒ`ƒGƒR�[”Å‚Ì(‹——£ƒf�[ƒ^‚Æ‹­“xƒf�[ƒ^) + + scan_times ‚͉½‰ñ‚̃f�[ƒ^‚ðŽæ“¾‚·‚é‚©‚ð 0 ˆÈ�ã‚Ì�”‚ÅŽw’肵‚Ü‚·�B‚½‚¾‚µ�A0 ‚Ü‚½‚Í #URG_SCAN_INFINITY ‚ðŽw’肵‚½�ê�‡‚Í�A–³ŒÀ‰ñ‚̃f�[ƒ^‚ðŽæ“¾‚µ‚Ü‚·�B\n + ŠJŽn‚µ‚½Œv‘ª‚ð’†’f‚·‚é‚É‚Í urg_stop_measurement() ‚ðŽg‚¢‚Ü‚·�B + + skip_scan ‚̓~ƒ‰�[‚̉ñ“]�”‚Ì‚¤‚¿�A‚P‰ñ‚̃XƒLƒƒƒ“Œã‚ɉ½‰ñƒXƒLƒƒƒ“‚µ‚È‚¢‚©‚ðŽw’肵‚Ü‚·�Bskip_scan ‚ÉŽw’è‚Å‚«‚é”ÍˆÍ‚Í [0, 9] ‚Å‚·�B + + \image html skip_scan_image.png ‰½‰ñ‚É‚P‰ñ‚¾‚¯Œv‘ª‚·‚é‚© + + ‚½‚Æ‚¦‚Î�Aƒ~ƒ‰�[‚Ì‚P‰ñ“]‚ª 100 [msec] ‚̃Zƒ“ƒT‚Å skip_scan ‚É 1 ‚ðŽw’肵‚½�ê�‡�Aƒf�[ƒ^‚̎擾ŠÔŠu‚Í 200 [msec] ‚ɂȂè‚Ü‚·�B + + Example + \code + enum { CAPTURE_TIMES = 10 }; + urg_start_measurement(&urg, URG_DISTANCE, CAPTURE_TIMES, 0); + + for (i = 0; i < CAPTURE_TIMES; ++i) { + int n = urg_get_distance(&urg, data, &time_stamp); + + // Žó�M‚µ‚½ƒf�[ƒ^‚Ì—˜—p + ... + } \endcode + + \~ + \see urg_get_distance(), urg_get_distance_intensity(), urg_get_multiecho(), urg_get_multiecho_intensity(), urg_stop_measurement() + */ + extern int urg_start_measurement(urg_t *urg, urg_measurement_type_t type, + int scan_times, int skip_scan); + + + /*! + \~japanese + \brief ‹——£ƒf�[ƒ^‚̎擾 + + ƒZƒ“ƒT‚©‚ç‹——£ƒf�[ƒ^‚ðŽæ“¾‚µ‚Ü‚·�BŽ–‘O‚É urg_start_measurement() ‚ð #URG_DISTANCE Žw’è‚ŌĂÑ�o‚µ‚Ä‚¨‚­•K—v‚ª‚ ‚è‚Ü‚·�B + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + \param[out] data ‹——£ƒf�[ƒ^ [mm] + \param[out] time_stamp ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv [msec] + + \retval >=0 Žó�M‚µ‚½ƒf�[ƒ^ŒÂ�” + \retval <0 ƒGƒ‰�[ + + data ‚É‚Í�AƒZƒ“ƒT‚©‚çŽæ“¾‚µ‚½‹——£ƒf�[ƒ^‚ªŠi”[‚³‚ê‚Ü‚·�Bdata ‚̓f�[ƒ^‚ðŠi”[‚·‚é‚̃TƒCƒY‚ðŠm•Û‚µ‚Ä‚¨‚­•K—v‚ª‚ ‚è‚Ü‚·�Bdata ‚ÉŠi”[‚³‚ê‚éƒf�[ƒ^�”‚Í urg_max_data_size() ‚Ŏ擾‚Å‚«‚Ü‚·�B + + time_stamp ‚É‚Í�AƒZƒ“ƒT“à•”‚̃^ƒCƒ€ƒXƒ^ƒ“ƒv‚ªŠi”[‚³‚ê‚Ü‚·�Btime_stamp ‚ðŽæ“¾‚µ‚½‚­‚È‚¢�ê�‡ NULL ‚ðŽw’肵‚ĉº‚³‚¢�B + + Example + \code + long *data = (long*)malloc(urg_max_data_size(&urg) * sizeof(data[0])); + + ... + + // ƒf�[ƒ^‚̂ݎ擾‚·‚é + urg_start_measurement(&urg, URG_DISTANCE, 1, 0); + int n = urg_get_distance(&urg, data, NULL); + + ... + + // ƒf�[ƒ^‚ƃ^ƒCƒ€ƒXƒ^ƒ“ƒv‚ðŽæ“¾‚·‚é + long time_stamp; + urg_start_measurement(&urg, URG_DISTANCE, 1, 0); + n = urg_get_distance(&urg, data, &time_stamp); \endcode + + \~ + \see urg_start_measurement(), urg_max_data_size() + */ + extern int urg_get_distance(urg_t *urg, long data[], long *time_stamp, unsigned long long *system_time_stamp); + + + /*! + \~japanese + \brief ‹——£‚Æ‹­“xƒf�[ƒ^‚̎擾 + + urg_get_distance() ‚ɉÁ‚¦�A‹­“xƒf�[ƒ^‚̎擾‚ª‚Å‚«‚éŠÖ�”‚Å‚·�BŽ–‘O‚É urg_start_measurement() ‚ð #URG_DISTANCE_INTENSITY Žw’è‚ŌĂÑ�o‚µ‚Ä‚¨‚­•K—v‚ª‚ ‚è‚Ü‚·�B + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + \param[out] data ‹——£ƒf�[ƒ^ [mm] + \param[out] intensity ‹­“xƒf�[ƒ^ + \param[out] time_stamp ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv [msec] + + \retval >=0 Žó�M‚µ‚½ƒf�[ƒ^ŒÂ�” + \retval <0 ƒGƒ‰�[ + + ‹­“xƒf�[ƒ^‚Æ‚Í�A‹——£ŒvŽZ‚ÉŽg‚Á‚½”gŒ`‚Ì”½ŽË‹­“x‚Å‚ ‚è�AƒZƒ“ƒT‚̃VƒŠ�[ƒY–ˆ‚É“Á�«‚ªˆÙ‚È‚è‚Ü‚·�B ‹­“xƒf�[ƒ^‚ðŽg‚¤‚±‚Æ‚Å�A•¨‘̂̔½ŽË—¦‚âŠÂ‹«‚Ì‘å‚Ü‚©‚È”Z’W‚ð�„‘ª‚Å‚«‚Ü‚·�B + + data, time_stamp ‚ɂ‚¢‚Ä‚Í urg_get_distance() ‚Æ“¯‚¶‚Å‚·�B + + intensity ‚É‚Í�AƒZƒ“ƒT‚©‚çŽæ“¾‚µ‚½‹­“xƒf�[ƒ^‚ªŠi”[‚³‚ê‚Ü‚·�Bintensity ‚̓f�[ƒ^‚ðŠi”[‚·‚é‚̃TƒCƒY‚ðŠm•Û‚µ‚Ä‚¨‚­•K—v‚ª‚ ‚è‚Ü‚·�Bintensity ‚ÉŠi”[‚³‚ê‚éƒf�[ƒ^�”‚Í urg_max_data_size() ‚Ŏ擾‚Å‚«‚Ü‚·�B + + \~ + Example + \code + int data_size = urg_max_data_size(&urg); + long *data = malloc(data_size * sizeof(long)); + long *intensity = malloc(data_size * sizeof(unsigned short)); + + ... + + urg_start_measurement(&urg, URG_DISTANCE_INTENSITY, 1, 0); + int n = urg_get_distance_intensity(&urg, data, intesnity, NULLL); \endcode + + \~ + \see urg_start_measurement(), urg_max_data_size() + */ + extern int urg_get_distance_intensity(urg_t *urg, long data[], + unsigned short intensity[], + long *time_stamp, unsigned long long *system_time_stamp); + + + /*! + \~japanese + \brief ‹——£ƒf�[ƒ^‚̎擾 (ƒ}ƒ‹ƒ`ƒGƒR�[”Å) + + ƒ}ƒ‹ƒ`ƒGƒR�[”ł̋——£ƒf�[ƒ^Žæ“¾ŠÖ�”‚Å‚·�BŽ–‘O‚É urg_start_measurement() ‚ð #URG_MULTIECHO Žw’è‚ŌĂÑ�o‚µ‚Ä‚¨‚­•K—v‚ª‚ ‚è‚Ü‚·�B + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + \param[out] data_multi ‹——£ƒf�[ƒ^ [mm] + \param[out] time_stamp ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv [msec] + + \retval >=0 Žó�M‚µ‚½ƒf�[ƒ^ŒÂ�” + \retval <0 ƒGƒ‰�[ + + ƒ}ƒ‹ƒ`ƒGƒR�[‚Ƃ͕¡�”‚Ì‹——£ƒf�[ƒ^‚Å‚·�B ƒ}ƒ‹ƒ`ƒGƒR�[‚Í�A‚P‚‚̃Œ�[ƒU”­Œõ‚É‚¨‚¢‚Ä•¡�”‚Ì‹——£ƒf�[ƒ^‚ª“¾‚ç‚ꂽ‚Æ‚«‚É“¾‚ç‚ê‚Ü‚·�B + + \image html multiecho_image.png ƒ}ƒ‹ƒ`ƒGƒR�[‚̃Cƒ��[ƒW�} + + time_stamp ‚ɂ‚¢‚Ä‚Í urg_get_distance() ‚Æ“¯‚¶‚Å‚·�B + + data_multi ‚É‚Í�AƒZƒ“ƒT‚©‚çŽæ“¾‚µ‚½‹——£ƒf�[ƒ^‚ª‚P‚Â‚Ì step ‚ ‚½‚è�Å‘å‚Å #URG_MAX_ECHO (3 ‚Â)Ši”[‚³‚ê‚Ü‚·�Bƒ}ƒ‹ƒ`ƒGƒR�[‚ª‘¶�Ý‚µ‚È‚¢�€–ڂ̃f�[ƒ^’l‚Í -1 ‚ªŠi”[‚³‚ê‚Ä‚¢‚Ü‚·�B + + \verbatim + data_multi[0] ... step n ‚Ì‹——£ƒf�[ƒ^ (1 ‚‚ß) + data_multi[1] ... step n ‚Ì‹——£ƒf�[ƒ^ (2 ‚‚ß) + data_multi[2] ... step n ‚Ì‹——£ƒf�[ƒ^ (3 ‚‚ß) + data_multi[3] ... step (n + 1) ‚Ì ‹——£ƒf�[ƒ^ (1 ‚‚ß) + data_multi[4] ... step (n + 1) ‚Ì ‹——£ƒf�[ƒ^ (2 ‚‚ß) + data_multi[5] ... step (n + 1) ‚Ì ‹——£ƒf�[ƒ^ (3 ‚‚ß) + ... \endverbatim + + Ši”[�‡‚Í�AŠe step ‚É‚¨‚¢‚Ä urg_get_distance() ‚̂Ƃ«‚Æ“¯‚¶‹——£‚̃f�[ƒ^‚ª (3n + 0) ‚̈ʒu‚ÉŠi”[‚³‚ê�A‚»‚êˆÈŠO‚̃f�[ƒ^‚ª (3n + 1), (3n + 2) ‚̈ʒu‚É�~�‡‚ÉŠi”[‚³‚ê‚Ü‚·�B\n + ‚‚܂è data_multi[3n + 1] >= data_multi[3n + 2] ‚ɂȂ邱‚Ƃ͕Û�Ø‚³‚ê‚Ü‚·‚ª data_multi[3n + 0] ‚Æ data_multi[3n + 1] ‚ÌŠÖŒW‚Í–¢’è‹`‚Å‚·�B(data_multi[3n + 1] == data_multi[3n + 2] ‚ª�¬‚è—§‚‚̂̓f�[ƒ^’l‚ª -1 ‚̂Ƃ«�B) + + \~ + Example + \code + long *data_multi = malloc(3 * urg_max_data_size(&urg) * sizeof(long)); + + ... + + urg_start_measurement(&urg, URG_MULTIECHO, 1, 0); + int n = urg_get_distance_intensity(&urg, data_multi, NULLL); \endcode + + \~ + \see urg_start_measurement(), urg_max_data_size() + */ + extern int urg_get_multiecho(urg_t *urg, long data_multi[], long *time_stamp, unsigned long long *system_time_stamp); + + + /*! + \~japanese + \brief ‹——£‚Æ‹­“xƒf�[ƒ^‚̎擾 (ƒ}ƒ‹ƒ`ƒGƒR�[”Å) + + urg_get_multiecho() ‚ɉÁ‚¦�A‹­“xƒf�[ƒ^‚̎擾‚Å‚«‚éŠÖ�”‚Å‚·�BŽ–‘O‚É urg_start_measurement() ‚ð #URG_MULTIECHO_INTENSITY Žw’è‚ŌĂÑ�o‚µ‚Ä‚¨‚­•K—v‚ª‚ ‚è‚Ü‚·�B + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + \param[out] data_multi ‹——£ƒf�[ƒ^ [mm] + \param[out] intensity_multi ‹­“xƒf�[ƒ^ + \param[out] time_stamp ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv [msec] + + \retval >=0 Žó�M‚µ‚½ƒf�[ƒ^ŒÂ�” + \retval <0 ƒGƒ‰�[ + + data_multi, time_stamp ‚ɂ‚¢‚Ä‚Í urg_get_multiecho() ‚Æ“¯‚¶‚Å‚·�B + + intensity_multi ‚̃f�[ƒ^‚Ì•À‚Ñ‚Í data_multi ‚ƑΉž‚µ‚½‚à‚̂ɂȂè‚Ü‚·�Bintensity_multi ‚ÉŠi”[‚³‚ê‚éƒf�[ƒ^�”‚Í urg_max_data_size() ‚Ŏ擾‚Å‚«‚Ü‚·�B + + \~ + Example + \code + int data_size = urg_max_data_size(&urg); + long *data_multi = malloc(3 * data_size * sizeof(long)); + long *intensity_multi = malloc(3 * data_size * sizeof(unsigned short)); + + ... + + urg_start_measurement(&urg, URG_DISTANCE_INTENSITY, 1, 0); + int n = urg_get_multiecho_intensity(&urg, data_multi, + intesnity_multi, NULLL); \endcode + + \~ + \see urg_start_measurement(), urg_max_data_size() + */ + extern int urg_get_multiecho_intensity(urg_t *urg, long data_multi[], + unsigned short intensity_multi[], + long *time_stamp, unsigned long long *system_time_stamp); + + + /*! + \~japanese + \brief Œv‘ª‚ð’†’f‚µ�AƒŒ�[ƒU‚ð�Á“”‚³‚¹‚Ü‚· + + \ref urg_start_measurement() ‚ÌŒv‘ª‚ð’†’f‚µ‚Ü‚·�B + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + + \retval 0 �³�í + \retval <0 ƒGƒ‰�[ + + \~ + Example + \code + urg_start_measurement(&urg, URG_DISTANCE, URG_SCAN_INFINITY, 0); + for (int i = 0; i < 10; ++i) { + urg_get_distance(&urg, data, NULL); + } + urg_stop_measurement(&urg); \endcode + + \~ + \see urg_start_measurement() + */ + extern int urg_stop_measurement(urg_t *urg); + + + /*! + \~japanese + \brief Œv‘ª”͈͂ð�ݒ肵‚Ü‚· + + ƒZƒ“ƒT‚ªŒv‘ª‚·‚é”͈͂ð step ’l‚ÅŽw’肵‚Ü‚·�Burg_get_distance() ‚Ȃǂ̋——£ƒf�[ƒ^Žæ“¾‚ÌŠÖ�”‚ŕԂ³‚ê‚éƒf�[ƒ^�”‚Í�A‚±‚±‚ÅŽw’肵‚½”͈͂Å�§ŒÀ‚³‚ê‚Ü‚·�B + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + \param[in] first_step Œv‘ª‚ÌŠJŽn step + \param[in] last_step Œv‘ª‚Ì�I—¹ step + \param[in] skip_step Œv‘ªƒf�[ƒ^‚ðƒOƒ‹�[ƒsƒ“ƒO‚·‚éŒÂ�” + + \retval 0 �³�í + \retval <0 ƒGƒ‰�[ + + ƒZƒ“ƒT‚Ì step ‚Í�AƒZƒ“ƒT�³–Ê‚ð 0 ‚Æ‚µ�AƒZƒ“ƒT�ã•”‚©‚猩‚Ä”½ŽžŒv‚Ü‚í‚è‚ÌŒü‚«‚ª�³‚Ì’l‚ƂȂé�‡‚ÉŠ„‚è�U‚ç‚ê‚Ü‚·�B + + \image html sensor_angle_image.png ƒZƒ“ƒT‚Æ step ‚ÌŠÖŒW + + step ‚ÌŠÔŠu‚Æ�A�Å‘å’l�A�Å�¬’l‚̓Zƒ“ƒTˆË‘¶‚Å‚·�Bstep ’l‚Ì�Å‘å’l�A�Å�¬’l‚Í urg_step_min_max() ‚Ŏ擾‚Å‚«‚Ü‚·�B\n + + first_step, last_step ‚Ńf�[ƒ^‚ÌŒv‘ª”͈͂ðŽw’肵‚Ü‚·�BŒv‘ª”ÍˆÍ‚Í [first_step, last_step] ‚ƂȂè‚Ü‚·�B + + skip_step ‚Í�AŒv‘ªƒf�[ƒ^‚ðƒOƒ‹�[ƒsƒ“ƒO‚·‚éŒÂ�”‚ðŽw’肵‚Ü‚·�BŽw’è‚Å‚«‚é’l‚Í [0, 99] ‚Å‚·�B\n + skip_step ‚Í�AŽw’肳‚ꂽ�”‚̃f�[ƒ^‚ð 1 ‚‚ɂ܂Ƃ߂邱‚Æ‚Å�AƒZƒ“ƒT‚©‚çŽó�M‚·‚éƒf�[ƒ^—Ê‚ðŒ¸‚ç‚µ�A‹——£Žæ“¾‚ð�s‚¤ŠÖ�”‚̉ž“š�«‚ð�‚‚߂邯‚«‚ÉŽg‚¢‚Ü‚·�B‚½‚¾‚µ�Aƒf�[ƒ^‚ð‚܂Ƃ߂邽‚ß�A“¾‚ç‚ê‚éƒf�[ƒ^‚Ì•ª‰ð”\‚ÍŒ¸‚è‚Ü‚·�B + + —Ⴆ‚Έȉº‚̂悤‚È‹——£ƒf�[ƒ^‚ª“¾‚ç‚ê‚é�ê�‡‚É + \verbatim + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109 + \endverbatim + + skip_step ‚É 2 ‚ðŽw’è‚·‚邯�A“¾‚ç‚ê‚éƒf�[ƒ^‚Í + \verbatim + \endverbatim + + ƒf�[ƒ^‚Í�A‚܂Ƃ߂éƒf�[ƒ^‚Ì‚¤‚¿�Aˆê”Ô�¬‚³‚È’l‚̃f�[ƒ^‚ª—p‚¢‚ç‚ê‚Ü‚·�B + + \~ + Example + \code + urg_set_scanning_parameter(&urg, urg_deg2step(&urg, -45), + urg_deg2step(&urg, +45), 1); + urg_start_measurement(&urg, URG_DISTANCE, 0); + int n = urg_get_distance(&urg, data, NULL); + for (int i = 0; i < n; ++i) { + printf("%d [mm], %d [deg]\n", data[i], urg_index2deg(&urg, i)); + } \endcode + + \~ + \see urg_step_min_max(), urg_rad2step(), urg_deg2step() + */ + extern int urg_set_scanning_parameter(urg_t *urg, int first_step, + int last_step, int skip_step); + + + /*! + \~japanese + \brief ’Ê�Mƒf�[ƒ^‚̃TƒCƒY•Ï�X + + ‹——£ƒf�[ƒ^‚ðƒZƒ“ƒT‚©‚çŽó�M‚Ì�ۂ̃f�[ƒ^ƒTƒCƒY‚ð•Ï�X‚µ‚Ü‚·�B + + \param[in,out] urg URG ƒZƒ“ƒTŠÇ—� + \param[in] data_byte ‹——£’l‚ð•\Œ»‚·‚éƒf�[ƒ^‚̃oƒCƒg�” + + \retval 0 �¬Œ÷ + \retval <0 ƒGƒ‰�[ + + data_byte ‚É‚Í + + - URG_COMMUNICATION_3_BYTE ... ‹——£‚ð 3 byte ‚Å•\Œ»‚·‚é + - URG_COMMUNICATION_2_BYTE ... ‹——£‚ð 2 byte ‚Å•\Œ»‚·‚é + + ‚ðŽw’è‚Å‚«‚Ü‚·�B\n + �‰Šú�ó‘Ԃł͋——£‚ð 3 byte ‚Å•\Œ»‚·‚邿‚¤‚ɂȂÁ‚Ä‚¢‚Ü‚·�B‚±‚Ì�Ý’è‚ð 2 byte ‚É�Ý’è‚·‚邱‚Æ‚Å�AƒZƒ“ƒT‚©‚çŽó�M‚·‚éƒf�[ƒ^�”‚Í 2/3 ‚ɂȂè‚Ü‚·�B‚½‚¾‚µ�AŽæ“¾‚Å‚«‚é‹——£‚Ì�Å‘å’l‚ª 4095 ‚ɂȂ邽‚ß�AŠÏ‘ª‚µ‚½‚¢‘Î�Û‚ª 4 [m] ˆÈ“à‚͈̔͂ɑ¶�Ý‚·‚é�ê�‡‚̂ݗ˜—p‚µ‚ĉº‚³‚¢�B + */ + extern int urg_set_communication_data_size(urg_t *urg, + urg_range_data_byte_t data_byte); + + + /*! \~japanese ƒŒ�[ƒU‚ð”­Œõ‚³‚¹‚é */ + extern int urg_laser_on(urg_t *urg); + + + /*! \~japanese ƒŒ�[ƒU‚ð�Á“”‚·‚é */ + extern int urg_laser_off(urg_t *urg); + + + /*! \~japanese ƒZƒ“ƒT‚ð�Ä‹N“®‚·‚é */ + extern int urg_reboot(urg_t *urg); + + + /*! + \~japanese + \brief ƒZƒ“ƒT‚ð’á�Á”ï“d—Í‚Ì�ó‘Ô‚É‘JˆÚ‚³‚¹‚é + + ’á�Á”ï“d—͂̃‚�[ƒh‚Å‚Í�AƒXƒLƒƒƒi‚̉ñ“]‚ª’âŽ~‚µŒv‘ª‚à’†’f‚³‚ê‚Ü‚·�B + + - ’á�Á”ï“d—͂̃‚�[ƒh + - ƒŒ�[ƒU‚ª�Á“”‚µ‚ÄŒv‘ª‚ª’†’f‚³‚ê‚é�B + - ƒXƒLƒƒƒi‚̉ñ“]‚ª’âŽ~‚·‚é�B + + ’á�Á”ï“d—͂̃‚�[ƒh‚©‚甲‚¯‚邽‚ß‚É‚Í \ref urg_wakeup() ŠÖ�”‚ðŒÄ‚Ñ�o‚µ‚ĉº‚³‚¢�B + + \see urg_wakeup() + */ + extern void urg_sleep(urg_t *urg); + + + /*! + \~japanese + \brief ƒZƒ“ƒT‚ð’á�Á”ï“d—͂̃‚�[ƒh‚©‚ç’Ê�í‚Ì�ó‘Ô‚É‘JˆÚ‚³‚¹‚é + + \see urg_sleep() + */ + extern void urg_wakeup(urg_t *urg); + + /*! + \~japanese + \brief ƒZƒ“ƒT‚ªŒv‘ª‚Å‚«‚é�ó‘Ô‚©‚ð•Ô‚· + + \retval 1 ƒZƒ“ƒT‚ªŒv‘ª‚Å‚«‚é�ó‘Ô‚É‚ ‚é + \retval 0 ƒZƒ“ƒT‚ªŒv‘ª‚Å‚«‚é�ó‘ԂɂȂ¢ + + ‹N“®’¼Œã‚ŃXƒLƒƒƒi‚̉ñ“]‚ªˆÀ’肵‚Ä‚¢‚È‚¢�ê�‡‚â�A‰½‚ç‚©‚̃Gƒ‰�[‚ÅŒv‘ª‚Å‚«‚È‚¢�ê�‡�A‚±‚ÌŠÖ�”‚Í 0 ‚ð•Ô‚µ‚Ü‚·�B + */ + extern int urg_is_stable(urg_t *urg); + + + /*! + \~japanese + \brief ƒZƒ“ƒTŒ^Ž®‚ð•¶Žš—ñ‚ŕԂ· + + ƒZƒ“ƒT‚ÌŒ^Ž®‚ð•¶Žš—ñ‚ŕԂ·�B•Ô‚³‚ê‚é•¶Žš—ñ‚̓Zƒ“ƒTˆË‘¶‚ƂȂé�B + + \param[in] urg URG ƒZƒ“ƒTŠÇ—� + + \return ƒZƒ“ƒTŒ^Ž®‚Ì•¶Žš—ñ + */ + extern const char *urg_sensor_product_type(urg_t *urg); + + + /*! + \~japanese + \brief ƒZƒ“ƒT‚̃VƒŠƒAƒ‹ ID •¶Žš—ñ‚ð•Ô‚· + + ƒZƒ“ƒT‚̃VƒŠƒAƒ‹ ID •¶Žš—ñ‚ð•Ô‚·�B•Ô‚³‚ê‚é•¶Žš—ñ‚̓Zƒ“ƒTˆË‘¶‚ƂȂé�B + + \param[in] urg URG ƒZƒ“ƒTŠÇ—� + + \return ƒVƒŠƒAƒ‹ ID •¶Žš—ñ + */ + extern const char *urg_sensor_serial_id(urg_t *urg); + + /*! + \brief returns the vendor name + + \param[in] URG + + \return The vendor name + */ + extern const char *urg_sensor_vendor(urg_t *urg); + + + /*! + \~japanese + \brief ƒZƒ“ƒT‚̃o�[ƒWƒ‡ƒ“•¶Žš—ñ‚ð•Ô‚· + + ƒZƒ“ƒT‚̃\ƒtƒgƒEƒFƒA�Eƒo�[ƒWƒ‡ƒ“•¶Žš—ñ‚ð•Ô‚·�B•Ô‚³‚ê‚é•¶Žš—ñ‚̓Zƒ“ƒTˆË‘¶‚ƂȂé�B + + \param[in] urg URG ƒZƒ“ƒTŠÇ—� + + \return ƒo�[ƒWƒ‡ƒ“•¶Žš—ñ + */ + extern const char *urg_sensor_firmware_version(urg_t *urg); + + extern const char *urg_sensor_firmware_date(urg_t *urg); + + /*! + \brief returns the protocol version + + \param[in] URG + + \return The current protocol version + */ + extern const char *urg_sensor_protocol_version(urg_t *urg); + + /*! + \~japanese + \brief ƒZƒ“ƒT‚̃Xƒe�[ƒ^ƒX•¶Žš—ñ‚ð•Ô‚· + + ƒZƒ“ƒT‚̃Xƒe�[ƒ^ƒX•¶Žš—ñ‚ð•Ô‚·�B•Ô‚³‚ê‚é•¶Žš—ñ‚̓Zƒ“ƒTˆË‘¶‚ƂȂé�B + + \param[in] urg URG ƒZƒ“ƒTŠÇ—� + \return ƒXƒe�[ƒ^ƒX•¶Žš—ñ + */ + extern const char *urg_sensor_status(urg_t *urg); + + + /*! + \~japanese + \brief ƒZƒ“ƒT‚Ì�ó‘Ô‚ð•Ô‚· + + ƒZƒ“ƒT‚̃Xƒe�[ƒ^ƒX•¶Žš—ñ‚ð•Ô‚·�B•Ô‚³‚ê‚é•¶Žš—ñ‚̓Zƒ“ƒTˆË‘¶‚ƂȂé�B + + \param[in] urg URG ƒZƒ“ƒTŠÇ—� + \return �ó‘Ô‚ðŽ¦‚·•¶Žš—ñ + + \attention �ó‘Ԃɂ‚¢‚Ä‚Í SCIP ‚Ì’Ê�MŽd—l�‘‚ðŽQ�Ƃ̂±‚Æ�B + */ + extern const char *urg_sensor_state(urg_t *urg); + + + /*! + \~japanese + \brief Œv‘ª—p‚̃Gƒ‰�[ƒnƒ“ƒhƒ‰‚ð“o˜^‚·‚é + + ƒGƒ‰�[ƒnƒ“ƒhƒ‰‚Í Gx, Mx Œn‚̃Rƒ}ƒ“ƒh‚̉ž“š‚ª "00" ‚© "99" ˆÈŠO‚̂Ƃ«‚ɌĂÑ�o‚³‚ê‚é�B + */ + extern void urg_set_error_handler(urg_t *urg, urg_error_handler handler); + + + /*! + \~japanese + \brief SCIP •¶Žš—ñ‚̃fƒR�[ƒh‚ð�s‚¤ + + \param[in] data SCIP •¶Žš—ñ + \param[in] data ‚Ì byte ƒTƒCƒY + + \retval ƒfƒR�[ƒhŒã‚Ì�”’l + */ + extern long urg_scip_decode(const char data[], int size); + + +#ifdef __cplusplus +} +#endif + +#endif /* !URG_SENSOR_H */ diff --git a/src/urg_c/current/include/urg_c/urg_serial.h b/src/urg_c/current/include/urg_c/urg_serial.h new file mode 100644 index 0000000..3ac5ec7 --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_serial.h @@ -0,0 +1,91 @@ +#ifndef URG_SERIAL_H +#define URG_SERIAL_H + +/*! + \file + \brief ƒVƒŠƒAƒ‹’Ê�M + + \author Satofumi KAMIMURA + + $Id: urg_serial.h,v 1d233c7a2240 2011/02/19 03:08:45 Satofumi $ +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "urg_c/urg_detect_os.h" + +#if defined(URG_WINDOWS_OS) +#include +#elif defined(ANDROID) +#include +#define tcdrain(fd) ioctl(fd, TCSBRK, 1) +#else +#include +#include +#endif +#include "urg_ring_buffer.h" + + +enum { + RING_BUFFER_SIZE_SHIFT = 7, + RING_BUFFER_SIZE = 1 << RING_BUFFER_SIZE_SHIFT, + + ERROR_MESSAGE_SIZE = 256, +}; + + +//! ƒVƒŠƒAƒ‹’Ê�M—p +typedef struct +{ +#if defined(URG_WINDOWS_OS) + HANDLE hCom; /*!< �Ú‘±ƒŠƒ\�[ƒX */ + int current_timeout; /*!< ƒ^ƒCƒ€ƒAƒEƒg‚Ì�ݒ莞ŠÔ [msec] */ +#else + int fd; /*!< ƒtƒ@ƒCƒ‹ƒfƒBƒXƒNƒŠƒvƒ^*/ + struct termios sio; /*!< ’Ê�M�Ý’è */ +#endif + + ring_buffer_t ring; /*!< ƒŠƒ“ƒOƒoƒbƒtƒ@ */ + char buffer[RING_BUFFER_SIZE]; /*!< ƒoƒbƒtƒ@—̈æ */ + char has_last_ch; /*!< �‘‚«–ß‚µ‚½•¶Žš‚ª‚ ‚é‚©‚̃tƒ‰ƒO */ + char last_ch; /*!< �‘‚«–ß‚µ‚½‚P•¶Žš */ +} urg_serial_t; + + +//! �Ú‘±‚ðŠJ‚­ +extern int serial_open(urg_serial_t *serial, const char *device, long baudrate); + + +//! �Ú‘±‚ð•‚¶‚é +extern void serial_close(urg_serial_t *serial); + + +//! ƒ{�[ƒŒ�[ƒg‚ð�Ý’è‚·‚é +extern int serial_set_baudrate(urg_serial_t *serial, long baudrate); + + +//! ƒf�[ƒ^‚ð‘—�M‚·‚é +extern int serial_write(urg_serial_t *serial, const char *data, int size); + + +//! ƒf�[ƒ^‚ðŽó�M‚·‚é +extern int serial_read(urg_serial_t *serial, + char *data, int max_size, int timeout); + + +//! ‰ü�s‚܂ł̃f�[ƒ^‚ðŽó�M‚·‚é +extern int serial_readline(urg_serial_t *serial, + char *data, int max_size, int timeout); + + +//! ƒGƒ‰�[•¶Žš—ñ‚ðŠi”[‚µ‚ĕԂ· +extern int serial_error(urg_serial_t *serial, + char *error_message, int max_size); + +#ifdef __cplusplus +} +#endif + +#endif /* !URG_SERIAL_H */ diff --git a/src/urg_c/current/include/urg_c/urg_serial_utils.h b/src/urg_c/current/include/urg_c/urg_serial_utils.h new file mode 100644 index 0000000..f1650c1 --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_serial_utils.h @@ -0,0 +1,31 @@ +#ifndef URG_SERIAL_UTILS_H +#define URG_SERIAL_UTILS_H + +/*! + \file + \brief ƒVƒŠƒAƒ‹—p‚Ì•â�•ŠÖ�” + + \author Satofumi KAMIMURA + + $Id$ +*/ + + +//! ƒVƒŠƒAƒ‹ƒ|�[ƒg‚ðŒŸ�õ‚·‚é +extern int urg_serial_find_port(void); + + +//! ŒŸ�õ‚µ‚½ƒVƒŠƒAƒ‹ƒ|�[ƒg–¼‚ð•Ô‚· +extern const char *urg_serial_port_name(int index); + + +/*! + \brief ƒ|�[ƒg‚ª URG ‚©‚Ç‚¤‚© + + \retval 1 URG ‚̃|�[ƒg + \retval 0 •s–¾ + \retval <0 ƒGƒ‰�[ +*/ +extern int urg_serial_is_urg_port(int index); + +#endif /* !URG_SERIAL_UTILS_H */ diff --git a/src/urg_c/current/include/urg_c/urg_tcpclient.h b/src/urg_c/current/include/urg_c/urg_tcpclient.h new file mode 100644 index 0000000..8347e40 --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_tcpclient.h @@ -0,0 +1,133 @@ +#ifndef URG_TCPCLIENT_H +#define URG_TCPCLIENT_H + +/*! + \file + \brief TCP/IP read/write functions + + \author Katsumi Kimoto + + $Id: urg_tcpclient.h,v 1d233c7a2240 2011/02/19 03:08:45 Satofumi $ +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "urg_c/urg_ring_buffer.h" +#include "urg_c/urg_detect_os.h" +#include +#if defined(URG_WINDOWS_OS) +#include +#else +#include +#include +#include +#endif + + +// -- NOT INTERFACE, for internal use only -- +// For urg_ringbuffer.h +// The size of buffer must be specified by the power of 2 +// i.e. ring buffer size = two to the RB_BITSHIFT-th power. +enum { + RB_BITSHIFT = 8, + RB_SIZE = 1 << RB_BITSHIFT, + + // caution ! available buffer size is less than the + // size given to the ring buffer(RB_SIZE). + BUFSIZE = RB_SIZE - 1, +}; + + +//! TCP/IP connection +typedef struct { + // socket + struct sockaddr_in server_addr; + int sock_desc; + int sock_addr_size; + + // buffer + ring_buffer_t rb; + char buf[RB_SIZE]; + + // line reading functions + int pushed_back; // for pushded back char + +} urg_tcpclient_t; +// -- end of NON INTERFACE definitions -- + + +// -- belows are MODULE INTERFACES -- +/*! + \brief constructor of tcp client module + + \param[in,out] cli tcp client type variable which must be allocated by a caller. + \param[in] server_ip_str IP address expressed in string, i.e. "192.168.0.1" + \param[in] port_num port number expressed in integer, i.e. port_num = 10200 + + \retval 0 succeeded. + \retval -1 error +*/ +extern int tcpclient_open(urg_tcpclient_t* cli, + const char* server_ip_str, int port_num); + + +/*! + \brief destructor of tcp client module + + \param[in,out] cli : tcp client type variable which must be deallocated by a caller after closing. +*/ +extern void tcpclient_close(urg_tcpclient_t* cli); + + +/*! + \brief read from socket. + + \param[in,out] cli : tcp client type variable which must be deallocated by a caller after closing. + \param[out] userbuf : buffer to store read data which must be allocated by a caller. + \param[in] req_size: data size requested to read in byte. + \param[in] timeout : time out specification which unit is microsecond. + + \return the number of data read, -1 when error. +*/ +extern int tcpclient_read(urg_tcpclient_t* cli, + char* userbuf, int req_size, int timeout); + + +/*! + \brief write to socket. + + \param[in,out] cli : tcp client type variable which must be deallocated by a caller after closing. + \param[in] userbuf : data to write. + \param[in] req_size: data size requested to write in byte. + + \return returns the number of data wrote, -1 when error. +*/ +extern int tcpclient_write(urg_tcpclient_t* cli, + const char* userbuf, int req_size); + + +//! \attention not implemented yet. +extern int tcpclient_error(urg_tcpclient_t* cli, + char* error_message, int max_size); + + +/*! + \brief read one line from socket. + + \param[in,out] cli : tcp client type variable which must be deallocated by a caller after closing. + \param[out] userbuf : buffer to store read data which must be allocated by a caller. + \param[in] buf_size: data size requested to read in byte. + \param[in] timeout : time out specification which unit is microsecond. + + \return the number of data read, -1 when error. +*/ +extern int tcpclient_readline(urg_tcpclient_t* cli, + char* userbuf, int buf_size, int timeout); + +#ifdef __cplusplus +} +#endif + +#endif /* !URG_TCPCLIENT_H */ diff --git a/src/urg_c/current/include/urg_c/urg_time.h b/src/urg_c/current/include/urg_c/urg_time.h new file mode 100644 index 0000000..4503b4c --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_time.h @@ -0,0 +1,58 @@ +/********************************************************************* + * Software License Agreement (BSD License) + * + * Copyright (c) 2010, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + *********************************************************************/ + +#ifndef URG_TIME_H +#define URG_TIME_H + +#ifdef __cplusplus +extern "C" { +#endif + + #include + #include +#ifdef WIN32 + #include +#else + #include +#endif + + #define HAS_CLOCK_GETTIME (_POSIX_C_SOURCE >= 199309L) + + extern void urg_get_walltime(unsigned long long *nsecs); + +#ifdef __cplusplus +} +#endif + +#endif /* !URG_TIME_H */ diff --git a/src/urg_c/current/include/urg_c/urg_utils.h b/src/urg_c/current/include/urg_c/urg_utils.h new file mode 100644 index 0000000..8048421 --- /dev/null +++ b/src/urg_c/current/include/urg_c/urg_utils.h @@ -0,0 +1,192 @@ +#ifndef URG_UTILS_H +#define URG_UTILS_H + +/*! + \file + \~japanese + \brief URG ƒZƒ“ƒT—p‚Ì•â�•ŠÖ�” + + \~english + \brief URG sensor utility + + \~ + \author Satofumi KAMIMURA + + $Id: urg_utils.h,v 630ee326c5ce 2011/02/19 08:06:25 Satofumi $ +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "urg_c/urg_sensor.h" + + + /*! + \~japanese + \brief URG ‚̃Gƒ‰�[‚ðŽ¦‚·•¶Žš—ñ‚ð•Ô‚· + + \param[in] urg URG ƒZƒ“ƒTŠÇ—� + + \retval URG ‚̃Gƒ‰�[‚ðŽ¦‚·•¶Žš—ñ + + \~ + Example + \code + if (!urg_open(&urg, "/dev/ttyACM0", 115200, URG_SERIAL)) { + printf("urg_open: %s\n", urg_error(&urg)); + return -1; + } \endcode + */ + extern const char *urg_error(const urg_t *urg); + + + /*! + \~japanese + \brief ƒZƒ“ƒT‚ª•Ô‚·‹——£‚Ì�Å‘å’l�A�Å�¬’l‚ð•Ô‚· + + ƒZƒ“ƒT‚ª•Ô‚·‹——£‚ð [�Å�¬’l, �Å‘å’l] ‚ŕԂµ‚Ü‚·�B + + \param[in] urg URG ƒZƒ“ƒTŠÇ—� + \param[out] min_distance �Å�¬’l [mm] + \param[out] max_distance �Å‘å’l [mm] + + \~ + Example + \code + long min_distance, max_distance; + urg_distance_min_max(&urg, &min_distance, &max_distance); + + for (int i = 0; i < n; ++i) { + long distance = data[i]; + if ((distance < min_distance) || (distance > max_distance)) { + continue; + } + ... + } \endcode + */ + extern void urg_distance_min_max(const urg_t *urg, + long *min_distance, long *max_distance); + + + /*! + \~japanese + \brief Œv‘ª step ‚Ì�Å‘å’l�A�Å�¬’l‚ð•Ô‚· + + urg_set_scanning_parameter() ‚ÅŽw’è‚Å‚«‚é”͈͂ð [�Å�¬’l, �Å‘å’l] ‚ŕԂ·�B + + \param[in] urg URG ƒZƒ“ƒTŠÇ—� + \param[out] min_step �Å�¬’l + \param[out] max_step �Å‘å’l + + step ‚̓Zƒ“ƒT�³–Ê‚ª 0 ‚Å‚ ‚è�AƒZƒ“ƒT�ã•”‚©‚猩‚½�ê�‡‚Ì”½ŽžŒv‚Ü‚í‚è‚Ì•ûŒü‚ª�³�AŽžŒv‚Ü‚í‚è‚Ì•ûŒü‚ª•‰‚Ì step ’l‚ƂȂé�B + + \image html sensor_step_image.png ƒZƒ“ƒT‚Æ step ‚ÌŠÖŒW + + min_step, max_step ‚Ì’l‚̓Zƒ“ƒT‚É‚æ‚Á‚ĈقȂé�B + + \~ + Example + \code + urg_step_min_max(&urg, &min_step, &max_step); + + printf("range first: %d [deg]\n", urg_step2deg(&urg, min_step)); + printf("range last : %d [deg]\n", urg_step2deg(&urg, max_step)); \endcode + + \see urg_set_scanning_parameter(), urg_step2rad(), urg_step2deg() + */ + extern void urg_step_min_max(const urg_t *urg, int *min_step, int *max_step); + + + /*! \~japanese ‚PƒXƒLƒƒƒ“‚É‚©‚©‚鎞ŠÔ [usec] ‚ð•Ô‚· */ + extern long urg_scan_usec(const urg_t *urg); + + + /*! \~japanese Žæ“¾ƒf�[ƒ^�”‚Ì�Å‘å’l‚ð•Ô‚· */ + extern int urg_max_data_size(const urg_t *urg); + + + /*! + \~japanese + \brief ƒCƒ“ƒfƒbƒNƒX‚ÆŠp“x(radian)‚̕ϊ·‚ð�s‚¤ + + ƒCƒ“ƒfƒbƒN‚Æ‚Í urg_get_distance() ‚Ȃǂ̋——£ƒf�[ƒ^Žæ“¾ŠÖ�”‚ª•Ô‚µ‚½ƒf�[ƒ^”z—ñ‚ɂ‚¢‚Ă̒l‚Å‚ ‚é�B‚±‚ÌŠÖ�”‚Í�A�ÅŒã‚É�s‚Á‚½‹——£ƒf�[ƒ^Žæ“¾ŠÖ�”‚̃f�[ƒ^”z—ñ‚ɂ‚¢‚Ä—LŒø‚ƂȂé�B + + \param[in] urg URG ƒZƒ“ƒTŠÇ—� + \param[in] index ƒCƒ“ƒfƒbƒNƒX + + \return Šp“x [radian] + + index ‚Í�AŽæ“¾‚µ‚½Œv‘ªƒf�[ƒ^‚ɂ‚¢‚Ă̒l‚Å‚ ‚è step ‚âŠp“x‚Ƃ̊֌W‚͎擾�Ý’è‚É‚æ‚èˆÙ‚È‚é�B + + \image html sensor_index_image.png ƒZƒ“ƒT‚ÌŒv‘ª”͈͂ƃCƒ“ƒfƒbƒNƒX‚ÌŠÖŒW + + \~ + Example + \code + int n = urg_get_distance(&urg, data, NULL); + for (int i = 0; i < n; ++i) { + long distance = data[i]; + double radian = urg_index2rad(i); + double x = distance * cos(radian); + double y = distance * sin(radian); + printf("%.1f, %.1f\n", x, y); + } \endcode + + \see urg_index2deg(), urg_rad2index(), urg_deg2index() + */ + extern double urg_index2rad(const urg_t *urg, int index); + + + /*! \~japanese ƒCƒ“ƒfƒbƒNƒX‚ÆŠp“x(degree)‚̕ϊ·‚ð�s‚¤ */ + extern double urg_index2deg(const urg_t *urg, int index); + + + /*! \~japanese Šp“x(radian)‚ƃCƒ“ƒfƒbƒNƒX‚̕ϊ·‚ð�s‚¤ */ + extern int urg_rad2index(const urg_t *urg, double radian); + + + /*! \~japanese Šp“x(degree)‚ƃCƒ“ƒfƒbƒNƒX‚̕ϊ·‚ð�s‚¤ */ + extern int urg_deg2index(const urg_t *urg, double degree); + + + /*! + \~japanese + \brief Šp“x(radian)‚Æ step ‚̕ϊ·‚ð�s‚¤ + + urg_step_min_max() ‚Å’è‹`‚³‚ê‚Ä‚¢‚é step ‚ɂ‚¢‚Ä�AŠp“x(radian)‚Æ step ‚̕ϊ·‚ð�s‚¤�B + + \param[in] urg URG ƒZƒ“ƒTŠÇ—� + \param[in] radian Šp“x [radian] + + \return step + + \image html sensor_angle_image.png ƒZƒ“ƒT‚Ì step ‚ÆŠp“x‚Ƃ̊֌W + + Šp“x‚©‚ç step ‚Ö•ÏŠ·‚µ‚½Œ‹‰Ê‚ª�®�”‚łȂ¢�ê�‡�AŒ‹‰Ê‚Í 0 ‚Ì•ûŒü‚É�Ø‚èŽÌ‚Ä‚ç‚ꂽ’l‚ƂȂé�B + + \~ + \see urg_step_min_max(), urg_deg2step(), urg_step2rad(), urg_step2deg() + */ + extern int urg_rad2step(const urg_t *urg, double radian); + + + /*! \~japanese Šp“x(degree)‚Æ step ‚̕ϊ·‚ð�s‚¤ */ + extern int urg_deg2step(const urg_t *urg, double degree); + + + /*! \~japanese step ‚Æ Šp“x(radian)‚̕ϊ·‚ð�s‚¤ */ + extern double urg_step2rad(const urg_t *urg, int step); + + + /*! \~japanese step ‚Æ Šp“x(degree)‚̕ϊ·‚ð�s‚¤ */ + extern double urg_step2deg(const urg_t *urg, int step); + + /*! \~japanese step ‚ƃCƒ“ƒfƒbƒNƒX‚̕ϊ·‚ð�s‚¤ */ + extern int urg_step2index(const urg_t *urg, int step); + +#ifdef __cplusplus +} +#endif + +#endif /* !URG_UTILS_H */ diff --git a/src/urg_c/current/samples/Makefile b/src/urg_c/current/samples/Makefile new file mode 100644 index 0000000..69d8431 --- /dev/null +++ b/src/urg_c/current/samples/Makefile @@ -0,0 +1,97 @@ +# Makefile for c/urg/samples +# $Id: Makefile,v ef6863dc48c6 2010/12/02 06:08:48 Satofumi $ + +# Compile options +SRCDIR = ../src +INCLUDEDIR = ../include +CC = gcc +CFLAGS = -g -O0 -Wall -Werror -W $(INCLUDES) +INCLUDES = -I$(INCLUDEDIR) +LDFLAGS = +LDLIBS = -lm `/bin/sh ld_wsock.sh` `/bin/sh ld_setupapi.sh` + +# Target +TARGET = \ + get_distance \ + get_distance_intensity \ + get_multiecho \ + get_multiecho_intensity \ + calculate_xy \ + sync_time_stamp \ + sensor_parameter \ + find_port \ + timeout_test \ + reboot_test \ + angle_convert_test \ + +all : $(TARGET) + +clean : + $(RM) *.o $(TARGET) + +depend : + makedepend -Y -- $(INCLUDES) -- $(wildcard *.h *.c) + +.PHONY : all depend clean +###################################################################### +REQUIRE_LIB = $(SRCDIR)/liburg_c.a +$(REQUIRE_LIB) : $(wildcard $(SRCDIR)/*.[ch]) + cd $(@D)/ && $(MAKE) $(@F) + +get_distance get_distance_intensity get_multiecho get_multiecho_intensity calculate_xy sync_time_stamp sensor_parameter timeout_test reboot_test angle_convert_test : open_urg_sensor.o $(REQUIRE_LIB) +find_port : $(REQUIRE_LIB) + +# DO NOT DELETE + +open_urg_sensor.o: ../include/urg_sensor.h ../include/urg_connection.h +open_urg_sensor.o: ../include/urg_serial.h ../include/urg_detect_os.h +open_urg_sensor.o: ../include/urg_ring_buffer.h ../include/urg_tcpclient.h +angle_convert_test.o: ../include/urg_sensor.h ../include/urg_connection.h +angle_convert_test.o: ../include/urg_serial.h ../include/urg_detect_os.h +angle_convert_test.o: ../include/urg_ring_buffer.h ../include/urg_tcpclient.h +angle_convert_test.o: ../include/urg_utils.h open_urg_sensor.h +calculate_xy.o: ../include/urg_sensor.h ../include/urg_connection.h +calculate_xy.o: ../include/urg_serial.h ../include/urg_detect_os.h +calculate_xy.o: ../include/urg_ring_buffer.h ../include/urg_tcpclient.h +calculate_xy.o: ../include/urg_utils.h open_urg_sensor.h +find_port.o: ../include/urg_serial_utils.h +get_distance.o: ../include/urg_sensor.h ../include/urg_connection.h +get_distance.o: ../include/urg_serial.h ../include/urg_detect_os.h +get_distance.o: ../include/urg_ring_buffer.h ../include/urg_tcpclient.h +get_distance.o: ../include/urg_utils.h open_urg_sensor.h +get_distance_intensity.o: ../include/urg_sensor.h ../include/urg_connection.h +get_distance_intensity.o: ../include/urg_serial.h ../include/urg_detect_os.h +get_distance_intensity.o: ../include/urg_ring_buffer.h +get_distance_intensity.o: ../include/urg_tcpclient.h ../include/urg_utils.h +get_distance_intensity.o: open_urg_sensor.h +get_multiecho.o: ../include/urg_sensor.h ../include/urg_connection.h +get_multiecho.o: ../include/urg_serial.h ../include/urg_detect_os.h +get_multiecho.o: ../include/urg_ring_buffer.h ../include/urg_tcpclient.h +get_multiecho.o: ../include/urg_utils.h open_urg_sensor.h +get_multiecho_intensity.o: ../include/urg_sensor.h +get_multiecho_intensity.o: ../include/urg_connection.h +get_multiecho_intensity.o: ../include/urg_serial.h ../include/urg_detect_os.h +get_multiecho_intensity.o: ../include/urg_ring_buffer.h +get_multiecho_intensity.o: ../include/urg_tcpclient.h ../include/urg_utils.h +get_multiecho_intensity.o: open_urg_sensor.h +open_urg_sensor.o: open_urg_sensor.h ../include/urg_sensor.h +open_urg_sensor.o: ../include/urg_connection.h ../include/urg_serial.h +open_urg_sensor.o: ../include/urg_detect_os.h ../include/urg_ring_buffer.h +open_urg_sensor.o: ../include/urg_tcpclient.h ../include/urg_utils.h +reboot_test.o: ../include/urg_sensor.h ../include/urg_connection.h +reboot_test.o: ../include/urg_serial.h ../include/urg_detect_os.h +reboot_test.o: ../include/urg_ring_buffer.h ../include/urg_tcpclient.h +reboot_test.o: ../include/urg_utils.h open_urg_sensor.h +sensor_parameter.o: ../include/urg_sensor.h ../include/urg_connection.h +sensor_parameter.o: ../include/urg_serial.h ../include/urg_detect_os.h +sensor_parameter.o: ../include/urg_ring_buffer.h ../include/urg_tcpclient.h +sensor_parameter.o: ../include/urg_utils.h open_urg_sensor.h +sync_time_stamp.o: ../include/urg_sensor.h ../include/urg_connection.h +sync_time_stamp.o: ../include/urg_serial.h ../include/urg_detect_os.h +sync_time_stamp.o: ../include/urg_ring_buffer.h ../include/urg_tcpclient.h +sync_time_stamp.o: ../include/urg_utils.h open_urg_sensor.h +timeout_test.o: ../include/urg_sensor.h ../include/urg_connection.h +timeout_test.o: ../include/urg_serial.h ../include/urg_detect_os.h +timeout_test.o: ../include/urg_ring_buffer.h ../include/urg_tcpclient.h +timeout_test.o: ../include/urg_utils.h ../include/urg_debug.h +timeout_test.o: open_urg_sensor.h diff --git a/src/urg_c/current/samples/Makefile.release b/src/urg_c/current/samples/Makefile.release new file mode 100644 index 0000000..13cde60 --- /dev/null +++ b/src/urg_c/current/samples/Makefile.release @@ -0,0 +1,18 @@ +TARGET = sensor_parameter get_distance get_distance_intensity get_multiecho get_multiecho_intensity sync_time_stamp calculate_xy find_port + +URG_LIB = ../src/liburg_c.a + +include ../build_rule.mk + +CFLAGS = -O2 $(INCLUDES) -I../include +LDLIBS = -lm `/bin/sh ld_wsock.sh` `/bin/sh ld_setupapi.sh` + +all : $(TARGET) + +clean : + $(RM) *.o $(TARGET) + +$(TARGET) : open_urg_sensor.o $(URG_LIB) + +$(URG_LIB) : + cd $(@D)/ && $(MAKE) $(@F) diff --git a/src/urg_c/current/samples/angle_convert_test.c b/src/urg_c/current/samples/angle_convert_test.c new file mode 100644 index 0000000..010b078 --- /dev/null +++ b/src/urg_c/current/samples/angle_convert_test.c @@ -0,0 +1,35 @@ +/*! + \~japanese + \example angle_convert_test.c 角度変æ�›ã�®çµ�果を表示ã�™ã‚‹ + + \author Satofumi KAMIMURA + + $Id: sync_time_stamp.c,v 799c195d046c 2011/01/14 05:10:38 hokuyo $ +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "open_urg_sensor.h" +#include + + +int main(int argc, char *argv[]) +{ + urg_t urg; + int min_step; + int max_step; + + if (open_urg_sensor(&urg, argc, argv) < 0) { + return 1; + } + + urg_step_min_max(&urg, &min_step, &max_step); + + printf("urg_step2deg(%d): %f\n", min_step, urg_step2deg(&urg, min_step)); + printf("urg_step2deg(%d): %f\n", max_step, urg_step2deg(&urg, max_step)); + + printf("urg_step2rad(%d): %f\n", min_step, urg_step2rad(&urg, min_step)); + printf("urg_step2rad(%d): %f\n", max_step, urg_step2rad(&urg, max_step)); + + return 0; +} diff --git a/src/urg_c/current/samples/calculate_xy.c b/src/urg_c/current/samples/calculate_xy.c new file mode 100644 index 0000000..5cf21e5 --- /dev/null +++ b/src/urg_c/current/samples/calculate_xy.c @@ -0,0 +1,78 @@ +/*! + \~japanese + \example calculate_xy.c X-Y �À•WŒn‚ł̈ʒu‚ðŒvŽZ‚·‚é + + ƒZƒ“ƒT‘O•û‚ª X ޲‚Ì•ûŒü‚Ƃ݂Ȃµ‚½’¼�s�À•W�ã‚Å�A‹——£ƒf�[ƒ^‚ðˆÊ’u‚ð�o—Í‚·‚é�B + + \author Satofumi KAMIMURA + + $Id: calculate_xy.c,v 586c4fa697ef 2011/01/24 08:50:01 Satofumi $ +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "open_urg_sensor.h" +#include +#include +#include + + +int main(int argc, char *argv[]) +{ + urg_t urg; + long *data; + long max_distance; + long min_distance; + long time_stamp; + unsigned long long system_time_stamp; + int i; + int n; + + if (open_urg_sensor(&urg, argc, argv) < 0) { + return 1; + } + + data = (long *)malloc(urg_max_data_size(&urg) * sizeof(data[0])); + if (!data) { + perror("urg_max_index()"); + return 1; + } + + // \~japanese ƒf�[ƒ^Žæ“¾ + urg_start_measurement(&urg, URG_DISTANCE, 1, 0); + n = urg_get_distance(&urg, data, &time_stamp, &system_time_stamp); + if (n < 0) { + printf("urg_get_distance: %s\n", urg_error(&urg)); + urg_close(&urg); + return 1; + } + + // \~japanese X-Y �À•WŒn‚Ì’l‚ð�o—Í + urg_distance_min_max(&urg, &min_distance, &max_distance); + for (i = 0; i < n; ++i) { + long distance = data[i]; + double radian; + long x; + long y; + + if ((distance < min_distance) || (distance > max_distance)) { + continue; + } + + radian = urg_index2rad(&urg, i); + x = (long)(distance * cos(radian)); + y = (long)(distance * sin(radian)); + + printf("%ld, %ld\n", x, y); + } + printf("\n"); + + // \~japanese �Ø’f + free(data); + urg_close(&urg); + +#if defined(URG_MSC) + getchar(); +#endif + return 0; +} diff --git a/src/urg_c/current/samples/find_port.c b/src/urg_c/current/samples/find_port.c new file mode 100644 index 0000000..5039934 --- /dev/null +++ b/src/urg_c/current/samples/find_port.c @@ -0,0 +1,33 @@ +/*! + \~japanese + \example find_port.c ƒ|�[ƒg‚Ì’T�õ + + \author Satofumi KAMIMURA + + $Id$ +*/ + +#include "urg_c/urg_serial_utils.h" +#include + + +int main(void) +{ + int found_port_size = urg_serial_find_port(); + int i; + + if (found_port_size == 0) { + printf("could not found ports.\n"); + return 1; + } + + for (i = 0; i < found_port_size; ++i) { + printf("%s", urg_serial_port_name(i)); + if (urg_serial_is_urg_port(i)) { + printf(" [URG]"); + } + printf("\n"); + } + + return 0; +} diff --git a/src/urg_c/current/samples/get_distance.c b/src/urg_c/current/samples/get_distance.c new file mode 100644 index 0000000..98f2336 --- /dev/null +++ b/src/urg_c/current/samples/get_distance.c @@ -0,0 +1,107 @@ +/*! + \~japanese + \example get_distance.c ‹——£ƒf�[ƒ^‚ðŽæ“¾‚·‚é + + \~ + \author Satofumi KAMIMURA + + $Id: get_distance.c,v 586c4fa697ef 2011/01/24 08:50:01 Satofumi $ +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "open_urg_sensor.h" +#include +#include + + +static void print_data(urg_t *urg, long data[], int data_n, long time_stamp) +{ +#if 1 + int front_index; + + (void)data_n; + + // \~japanese ‘O•û‚̃f�[ƒ^‚݂̂ð•\ަ + front_index = urg_step2index(urg, 0); + printf("%ld [mm], (%ld [msec])\n", data[front_index], time_stamp); + +#else + (void)time_stamp; + + int i; + long min_distance; + long max_distance; + + // \~japanese ‘S‚Ẵf�[ƒ^‚Ì X-Y ‚̈ʒu‚ð•\ަ + urg_distance_min_max(urg, &min_distance, &max_distance); + for (i = 0; i < data_n; ++i) { + long l = data[i]; + double radian; + long x; + long y; + + if ((l <= min_distance) || (l >= max_distance)) { + continue; + } + radian = urg_index2rad(urg, i); + x = (long)(l * cos(radian)); + y = (long)(l * sin(radian)); + printf("(%ld, %ld), ", x, y); + } + printf("\n"); +#endif +} + + +int main(int argc, char *argv[]) +{ + enum { + CAPTURE_TIMES = 10, + }; + urg_t urg; + long *data = NULL; + long time_stamp; + unsigned long long system_time_stamp; + int n; + int i; + + if (open_urg_sensor(&urg, argc, argv) < 0) { + return 1; + } + + data = (long *)malloc(urg_max_data_size(&urg) * sizeof(data[0])); + if (!data) { + perror("urg_max_index()"); + return 1; + } + + // \~japanese ƒf�[ƒ^Žæ“¾ +#if 0 + // \~japanese ƒf�[ƒ^‚̎擾”͈͂ð•Ï�X‚·‚é�ê�‡ + urg_set_scanning_parameter(&urg, + urg_deg2step(&urg, -90), + urg_deg2step(&urg, +90), 0); +#endif + + urg_start_measurement(&urg, URG_DISTANCE, CAPTURE_TIMES, 0); + for (i = 0; i < CAPTURE_TIMES; ++i) { + n = urg_get_distance(&urg, data, &time_stamp, &system_time_stamp); + if (n <= 0) { + printf("urg_get_distance: %s\n", urg_error(&urg)); + free(data); + urg_close(&urg); + return 1; + } + print_data(&urg, data, n, time_stamp); + } + + // \~japanese �Ø’f + free(data); + urg_close(&urg); + +#if defined(URG_MSC) + getchar(); +#endif + return 0; +} diff --git a/src/urg_c/current/samples/get_distance_intensity.c b/src/urg_c/current/samples/get_distance_intensity.c new file mode 100644 index 0000000..0c5acc2 --- /dev/null +++ b/src/urg_c/current/samples/get_distance_intensity.c @@ -0,0 +1,103 @@ +/*! + \~japanese + \example get_distance_intensity.c ‹——£�E‹­“xƒf�[ƒ^‚ðŽæ“¾‚·‚é + + \author Satofumi KAMIMURA + + $Id: get_distance_intensity.c,v 586c4fa697ef 2011/01/24 08:50:01 Satofumi $ +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "open_urg_sensor.h" +#include +#include +#include + + +static void print_data(urg_t *urg, long data[], unsigned short intensity[], + int data_n, long time_stamp) +{ +#if 1 + int front_index; + (void)data_n; + + // \~japanese ‘O•û‚̃f�[ƒ^‚݂̂ð•\ަ + front_index = urg_step2index(urg, 0); + printf("%ld [mm], %d [1], (%ld [msec])\n", + data[front_index], intensity[front_index], time_stamp); + +#else + (void)urg; + + int i; + + // \~japanese ‘S‚Ẵf�[ƒ^‚ð•\ަ + printf("# n = %d, time_stamp = %ld\n", data_n, time_stamp); + for (i = 0; i < data_n; ++i) { + printf("%d, %ld, %d\n", i, data[i], intensity[i]); + } +#endif +} + + +int main(int argc, char *argv[]) +{ + enum { + CAPTURE_TIMES = 10, + }; + urg_t urg; + int max_data_size; + long *data = NULL; + unsigned short *intensity = NULL; + long time_stamp; + unsigned long long system_time_stamp; + int n; + int i; + + if (open_urg_sensor(&urg, argc, argv) < 0) { + return 1; + } + + // Distance Intensity reading only (?) on UXM-30LX + if (!strstr(urg_sensor_product_type(&urg),"UXM-30LX")) { + fprintf(stderr,"Distance Intensity not supported on %s\n", + urg_sensor_product_type(&urg)); + return 1; + } + + max_data_size = urg_max_data_size(&urg); + data = (long *)malloc(max_data_size * sizeof(data[0])); + if (!data) { + perror("urg_max_index()"); + return 1; + } + intensity = malloc(max_data_size * sizeof(intensity[0])); + if (!intensity) { + perror("urg_max_index()"); + return 1; + } + + // \~japanese ƒf�[ƒ^Žæ“¾ + urg_start_measurement(&urg, URG_DISTANCE_INTENSITY, CAPTURE_TIMES, 0); + for (i = 0; i < CAPTURE_TIMES; ++i) { + n = urg_get_distance_intensity(&urg, data, intensity, &time_stamp, &system_time_stamp); + if (n <= 0) { + printf("urg_get_distance_intensity: %s\n", urg_error(&urg)); + free(data); + urg_close(&urg); + return 1; + } + print_data(&urg, data, intensity, n, time_stamp); + } + + // \~japanese �Ø’f + free(intensity); + free(data); + urg_close(&urg); + +#if defined(URG_MSC) + getchar(); +#endif + return 0; +} diff --git a/src/urg_c/current/samples/get_multiecho.c b/src/urg_c/current/samples/get_multiecho.c new file mode 100644 index 0000000..6e3816d --- /dev/null +++ b/src/urg_c/current/samples/get_multiecho.c @@ -0,0 +1,98 @@ + /*! + \~japanese + \example get_multiecho.c ‹——£ƒf�[ƒ^(ƒ}ƒ‹ƒ`ƒGƒR�[)‚ðŽæ“¾‚·‚é + + \author Satofumi KAMIMURA + + $Id$ +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "open_urg_sensor.h" +#include +#include + + +static void print_echo_data(long data[], int index) +{ + int i; + + // [mm] + for (i = 0; i < URG_MAX_ECHO; ++i) { + printf("%ld, ", data[(URG_MAX_ECHO * index) + i]); + } +} + + +static void print_data(urg_t *urg, long data[], int data_n, long time_stamp) +{ +#if 1 + int front_index; + + (void)data_n; + + // \~japanese ‘O•û‚̃f�[ƒ^‚݂̂ð•\ަ + front_index = urg_step2index(urg, 0); + print_echo_data(data, front_index); + printf("%ld\n", time_stamp); + +#else + (void)urg; + + int i; + + // \~japanese ‘S‚Ẵf�[ƒ^‚ð•\ަ + printf("# n = %d, time_stamp = %ld\n", data_n, time_stamp); + for (i = 0; i < data_n; ++i) { + print_echo_data(data, i); + printf("\n"); + } +#endif +} + + +int main(int argc, char *argv[]) +{ + enum { + CAPTURE_TIMES = 10, + }; + urg_t urg; + long *data = NULL; + long time_stamp; + unsigned long long system_time_stamp; + int n; + int i; + + if (open_urg_sensor(&urg, argc, argv) < 0) { + return 1; + } + + data = (long *)malloc(urg_max_data_size(&urg) * 3 * sizeof(data[0])); + if (!data) { + perror("urg_max_index()"); + return 1; + } + + // \~japanese ƒf�[ƒ^Žæ“¾ + urg_start_measurement(&urg, URG_MULTIECHO, CAPTURE_TIMES, 0); + for (i = 0; i < CAPTURE_TIMES; ++i) { + n = urg_get_multiecho(&urg, data, &time_stamp, &system_time_stamp); + if (n <= 0) { + printf("urg_get_multiecho: %s\n", urg_error(&urg)); + free(data); + urg_close(&urg); + return 1; + } + print_data(&urg, data, n, time_stamp); + } + + // \~japanese �Ø’f + free(data); + urg_close(&urg); + +#if defined(URG_MSC) + getchar(); +#endif + return 0; +} diff --git a/src/urg_c/current/samples/get_multiecho_intensity.c b/src/urg_c/current/samples/get_multiecho_intensity.c new file mode 100644 index 0000000..1c1d79c --- /dev/null +++ b/src/urg_c/current/samples/get_multiecho_intensity.c @@ -0,0 +1,113 @@ +/*! + \~japanese + \example get_multiecho_intensity.c ‹——£�E‹­“xƒf�[ƒ^(ƒ}ƒ‹ƒ`ƒGƒR�[)‚ðŽæ“¾‚·‚é + + \author Satofumi KAMIMURA + + $Id$ +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "open_urg_sensor.h" +#include +#include + + +static void print_echo_data(long data[], unsigned short intensity[], + int index) +{ + int i; + + // [mm] + for (i = 0; i < URG_MAX_ECHO; ++i) { + printf("%ld, ", data[(URG_MAX_ECHO * index) + i]); + } + + // [1] + for (i = 0; i < URG_MAX_ECHO; ++i) { + printf("%d, ", intensity[(URG_MAX_ECHO * index) + i]); + } +} + + +// \~japanese ‹——£�A‹­“x‚̃f�[ƒ^‚ð•\ަ‚·‚é +static void print_data(urg_t *urg, long data[], + unsigned short intensity[], int data_n, long time_stamp) +{ +#if 1 + int front_index; + + (void)data_n; + + // \~japanese ‘O•û‚̃f�[ƒ^‚݂̂ð•\ަ + front_index = urg_step2index(urg, 0); + print_echo_data(data, intensity, front_index); + printf("%ld\n", time_stamp); + +#else + (void)urg; + int i; + + // \~japanese ‘S‚Ẵf�[ƒ^‚ð•\ަ + printf("# n = %d, time_stamp = %ld\n", data_n, time_stamp); + for (i = 0; i < data_n; ++i) { + print_echo_data(data, intensity, i); + printf("\n"); + } +#endif +} + + +int main(int argc, char *argv[]) +{ + enum { + CAPTURE_TIMES = 10, + }; + urg_t urg; + int max_data_size; + long *data = NULL; + unsigned short *intensity = NULL; + long time_stamp; + unsigned long long system_time_stamp; + int n; + int i; + + if (open_urg_sensor(&urg, argc, argv) < 0) { + return 1; + } + + max_data_size = urg_max_data_size(&urg); + data = (long *)malloc(max_data_size * 3 * sizeof(data[0])); + intensity = (unsigned short *)malloc(max_data_size * 3 * + sizeof(intensity[0])); + + if (!data) { + perror("urg_max_index()"); + return 1; + } + + // \~japanese ƒf�[ƒ^Žæ“¾ + urg_start_measurement(&urg, URG_MULTIECHO_INTENSITY, CAPTURE_TIMES, 0); + for (i = 0; i < CAPTURE_TIMES; ++i) { + n = urg_get_multiecho_intensity(&urg, data, intensity, &time_stamp, &system_time_stamp); + if (n <= 0) { + printf("urg_get_multiecho_intensity: %s\n", urg_error(&urg)); + free(data); + free(intensity); + urg_close(&urg); + return 1; + } + print_data(&urg, data, intensity, n, time_stamp); + } + + // \~japanese �Ø’f + free(data); + free(intensity); + urg_close(&urg); + +#if defined(URG_MSC) + getchar(); +#endif + return 0; +} diff --git a/src/urg_c/current/samples/ld_setupapi.sh b/src/urg_c/current/samples/ld_setupapi.sh new file mode 100644 index 0000000..5595776 --- /dev/null +++ b/src/urg_c/current/samples/ld_setupapi.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ "${MSYSTEM}" = "MINGW32" ] ; then + echo "-lsetupapi" +fi diff --git a/src/urg_c/current/samples/ld_wsock.sh b/src/urg_c/current/samples/ld_wsock.sh new file mode 100644 index 0000000..52d8fe1 --- /dev/null +++ b/src/urg_c/current/samples/ld_wsock.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +if [ "${MSYSTEM}" = "MINGW32" ] ; then + echo "-lwsock32" +fi diff --git a/src/urg_c/current/samples/open_urg_sensor.c b/src/urg_c/current/samples/open_urg_sensor.c new file mode 100644 index 0000000..5a0a564 --- /dev/null +++ b/src/urg_c/current/samples/open_urg_sensor.c @@ -0,0 +1,51 @@ +/*! + \~japanese + \brief URG ‚Æ‚Ì�Ú‘± + + \~ + \author Satofumi KAMIMURA + + $Id: open_urg_sensor.c,v d00944669fc8 2011/02/16 13:41:09 Satofumi $ +*/ + +#include "open_urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "urg_c/urg_detect_os.h" +#include +#include + + +int open_urg_sensor(urg_t *urg, int argc, char *argv[]) +{ +#if defined(URG_WINDOWS_OS) + const char *device = "COM4"; +#elif defined(URG_LINUX_OS) + const char *device = "/dev/ttyACM0"; + //const char *device = "/dev/ttyUSB0"; +#else + const char *device = "/dev/tty.usbmodemfa131"; +#endif + urg_connection_type_t connection_type = URG_SERIAL; + long baudrate_or_port = 115200; + //const char *ip_address = "localhost"; + const char *ip_address = "192.168.0.10"; + int i; + + // \~japanese �Ú‘±ƒ^ƒCƒv‚Ì�ؑւ¦ + for (i = 1; i < argc; ++i) { + if (!strcmp(argv[i], "-e")) { + connection_type = URG_ETHERNET; + baudrate_or_port = 10940; + device = ip_address; + } + } + + // \~japanese �Ú‘± + if (urg_open(urg, connection_type, device, baudrate_or_port) < 0) { + printf("urg_open: %s, %ld: %s\n", + device, baudrate_or_port, urg_error(urg)); + return -1; + } + + return 0; +} diff --git a/src/urg_c/current/samples/open_urg_sensor.h b/src/urg_c/current/samples/open_urg_sensor.h new file mode 100644 index 0000000..9eb9b7a --- /dev/null +++ b/src/urg_c/current/samples/open_urg_sensor.h @@ -0,0 +1,19 @@ +#ifndef OPEN_URG_SENSOR_H +#define OPEN_URG_SENSOR_H + +/*! + \~japanese + \brief URG ‚Æ‚Ì�Ú‘± + + \~ + \author Satofumi KAMIMURA + + $Id$ +*/ + +#include "urg_c/urg_sensor.h" + + +extern int open_urg_sensor(urg_t *urg, int argc, char *argv[]); + +#endif /* !OPEN_URG_SENSOR_H */ diff --git a/src/urg_c/current/samples/reboot_test.c b/src/urg_c/current/samples/reboot_test.c new file mode 100644 index 0000000..bfbdeec --- /dev/null +++ b/src/urg_c/current/samples/reboot_test.c @@ -0,0 +1,27 @@ +/*! + \example reboot_test.c reboot test + + \author Satofumi KAMIMURA + + $Id$ +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "open_urg_sensor.h" +#include + + +int main(int argc, char *argv[]) +{ + enum { DATA_SIZE = 1081 }; + urg_t urg; + + if (open_urg_sensor(&urg, argc, argv) < 0) { + return 1; + } + + urg_reboot(&urg); + + return 0; +} diff --git a/src/urg_c/current/samples/sensor_parameter.c b/src/urg_c/current/samples/sensor_parameter.c new file mode 100644 index 0000000..c379050 --- /dev/null +++ b/src/urg_c/current/samples/sensor_parameter.c @@ -0,0 +1,49 @@ +/*! + \~japanese + \example sensor_parameter.c ƒZƒ“ƒT�î•ñ‚Ì�o—Í + + \author Satofumi KAMIMURA + + $Id: sensor_parameter.c,v 0caa22c18f6b 2010/12/30 03:36:32 Satofumi $ +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "open_urg_sensor.h" +#include + + +int main(int argc, char *argv[]) +{ + urg_t urg; + int min_step; + int max_step; + long min_distance; + long max_distance; + + if (open_urg_sensor(&urg, argc, argv) < 0) { + return 1; + } + + printf("Sensor product type: %s\n", urg_sensor_product_type(&urg)); + printf("Sensor firmware version: %s\n", urg_sensor_firmware_version(&urg)); + printf("Sensor serial ID: %s\n", urg_sensor_serial_id(&urg)); + printf("Sensor status: %s\n", urg_sensor_status(&urg)); + printf("Sensor state: %s\n", urg_sensor_state(&urg)); + + urg_step_min_max(&urg, &min_step, &max_step); + printf("step: [%d, %d]\n", min_step, max_step); + + urg_distance_min_max(&urg, &min_distance, &max_distance); + printf("distance: [%ld, %ld)\n", min_distance, max_distance); + + printf("scan interval: %ld [usec]\n", urg_scan_usec(&urg)); + printf("sensor data size: %d\n", urg_max_data_size(&urg)); + + urg_close(&urg); + +#if defined(URG_MSC) + getchar(); +#endif + return 0; +} diff --git a/src/urg_c/current/samples/sync_time_stamp.c b/src/urg_c/current/samples/sync_time_stamp.c new file mode 100644 index 0000000..196803d --- /dev/null +++ b/src/urg_c/current/samples/sync_time_stamp.c @@ -0,0 +1,118 @@ +/*! + \~japanese + \example sync_time_stamp.c ƒZƒ“ƒT‚Æ PC ‚̃^ƒCƒ€ƒXƒ^ƒ“ƒv‚𓯊ú‚·‚é + + \author Satofumi KAMIMURA + + $Id: sync_time_stamp.c,v 799c195d046c 2011/01/14 05:10:38 hokuyo $ +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "open_urg_sensor.h" +#include +#if defined(URG_WINDOWS_OS) +#include +#else +#include +#endif + +static int pc_msec_time(void) +{ + static int is_initialized = 0; +#if defined(URG_WINDOWS_OS) + static clock_t first_clock; + clock_t current_clock; +#else + static struct timeval first_time; + struct timeval current_time; +#endif + long msec_time; + +#if defined(URG_WINDOWS_OS) + if (!is_initialized) { + first_clock = clock(); + is_initialized = 1; + } + current_clock = clock(); + msec_time = (current_clock - first_clock) * 1000 / CLOCKS_PER_SEC; +#else + if (!is_initialized) { + gettimeofday(&first_time, NULL); + is_initialized = 1; + } + gettimeofday(¤t_time, NULL); + + msec_time = + ((current_time.tv_sec - first_time.tv_sec) * 1000) + + ((current_time.tv_usec - first_time.tv_usec) / 1000); +#endif + return msec_time; +} + + +/*! + \~japanese + \brief PC ‚̃^ƒCƒ€ƒXƒ^ƒ“ƒv‚É•â�³‚·‚邽‚߂̒l‚ð•Ô‚· +*/ +static long print_time_stamp(urg_t *urg, long time_stamp_offset) +{ + long sensor_time_stamp; + long pc_time_stamp; + long before_pc_time_stamp; + long after_pc_time_stamp; + long delay; + + urg_start_time_stamp_mode(urg); + + before_pc_time_stamp = pc_msec_time(); + sensor_time_stamp = urg_time_stamp(urg); + after_pc_time_stamp = pc_msec_time(); + delay = (after_pc_time_stamp - before_pc_time_stamp) / 2; + + if (sensor_time_stamp < 0) { + printf("urg_time_stamp: %s\n", urg_error(urg)); + return -1; + } + sensor_time_stamp -= time_stamp_offset; + + pc_time_stamp = pc_msec_time(); + urg_stop_time_stamp_mode(urg); + + printf("%ld,\t%ld\n", pc_time_stamp, sensor_time_stamp); + + return sensor_time_stamp - (pc_time_stamp - delay); +} + + +int main(int argc, char *argv[]) +{ + enum { + TIME_STAMP_PRINT_TIMES = 5, + }; + + urg_t urg; + long time_stamp_offset; + int i; + + if (open_urg_sensor(&urg, argc, argv) < 0) { + return 1; + } + + printf("# pc,\tsensor\n"); + + // \~japanese URG ‚̃^ƒCƒ€ƒXƒ^ƒ“ƒv‚Æ PC ‚̃^ƒCƒ€ƒXƒ^ƒ“ƒv‚ð•\ަ + time_stamp_offset = print_time_stamp(&urg, 0); + + // \~japanese URG ‚Ì•â�³Œã‚̃^ƒCƒ€ƒXƒ^ƒ“ƒv‚Æ PC ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv‚ð•\ަ + for (i = 0; i < TIME_STAMP_PRINT_TIMES; ++i) { + print_time_stamp(&urg, time_stamp_offset); + } + + urg_close(&urg); + +#if defined(URG_MSC) + getchar(); +#endif + return 0; +} diff --git a/src/urg_c/current/samples/timeout_test.c b/src/urg_c/current/samples/timeout_test.c new file mode 100644 index 0000000..8abc280 --- /dev/null +++ b/src/urg_c/current/samples/timeout_test.c @@ -0,0 +1,32 @@ +/*! + \example timeout_test.c timeout test + + \author Satofumi KAMIMURA + + $Id$ +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_utils.h" +#include "urg_c/urg_debug.h" +#include "open_urg_sensor.h" +#include + + +int main(int argc, char *argv[]) +{ + enum { TIMEOUT_MSEC = 3000 }; + char buffer; + int n; + urg_t urg; + + if (open_urg_sensor(&urg, argc, argv) < 0) { + return 1; + } + + printf("read\n"); + n = urg_raw_read(&urg, &buffer, 1, TIMEOUT_MSEC); + printf("n = %d\n", n); + + return 0; +} diff --git a/src/urg_c/current/src/Makefile b/src/urg_c/current/src/Makefile new file mode 100644 index 0000000..7faf29b --- /dev/null +++ b/src/urg_c/current/src/Makefile @@ -0,0 +1,67 @@ +# Makefile for libs/c +# $Id: Makefile,v 4537e5141a86 2011/02/17 07:10:04 Satofumi $ + +# Compile options +CC = gcc +#CFLAGS = -O2 -Wall -Werror -W $(INCLUDES) +CFLAGS = -g -O0 -Wall -Werror -W $(INCLUDES) +INCLUDES = -I../include +LDFLAGS = +LDLIBS = + +# Target +URG_C_LIB = liburg_c.a +TARGET = $(URG_C_LIB) + +all : $(TARGET) + +clean : + $(RM) *.o $(TARGET) + +depend : + makedepend -Y -- $(INCLUDES) -- $(wildcard *.h *.c) + +.PHONY : all clean depend +###################################################################### +$(URG_C_LIB) : \ + $(URG_C_LIB)(urg_sensor.o) \ + $(URG_C_LIB)(urg_utils.o) \ + $(URG_C_LIB)(urg_debug.o) \ + $(URG_C_LIB)(urg_connection.o) \ + $(URG_C_LIB)(urg_serial.o) \ + $(URG_C_LIB)(urg_serial_utils.o) \ + $(URG_C_LIB)(urg_tcpclient.o) \ + $(URG_C_LIB)(urg_ring_buffer.o) \ + +urg_serial_utils.o : urg_serial_utils_windows.c urg_serial_utils_linux.c + +# DO NOT DELETE + +urg_connection.o: ../include/urg_connection.h ../include/urg_serial.h +urg_connection.o: ../include/urg_detect_os.h ../include/urg_ring_buffer.h +urg_connection.o: ../include/urg_tcpclient.h +urg_debug.o: ../include/urg_debug.h ../include/urg_sensor.h +urg_debug.o: ../include/urg_connection.h ../include/urg_serial.h +urg_debug.o: ../include/urg_detect_os.h ../include/urg_ring_buffer.h +urg_debug.o: ../include/urg_tcpclient.h +urg_ring_buffer.o: ../include/urg_ring_buffer.h +urg_sensor.o: ../include/urg_sensor.h ../include/urg_connection.h +urg_sensor.o: ../include/urg_serial.h ../include/urg_detect_os.h +urg_sensor.o: ../include/urg_ring_buffer.h ../include/urg_tcpclient.h +urg_sensor.o: ../include/urg_errno.h +urg_serial.o: ../include/urg_serial.h ../include/urg_detect_os.h +urg_serial.o: ../include/urg_ring_buffer.h urg_serial_linux.c +urg_serial_linux.o: ../include/urg_ring_buffer.h +urg_serial_utils.o: ../include/urg_serial_utils.h ../include/urg_detect_os.h +urg_serial_utils.o: urg_serial_utils_linux.c +urg_serial_utils_linux.o: ../include/urg_serial_utils.h +urg_serial_utils_windows.o: ../include/urg_serial_utils.h +urg_serial_utils_windows.o: ../include/urg_detect_os.h +urg_serial_windows.o: ../include/urg_serial.h ../include/urg_detect_os.h +urg_serial_windows.o: ../include/urg_ring_buffer.h +urg_tcpclient.o: ../include/urg_detect_os.h ../include/urg_tcpclient.h +urg_tcpclient.o: ../include/urg_ring_buffer.h +urg_utils.o: ../include/urg_utils.h ../include/urg_sensor.h +urg_utils.o: ../include/urg_connection.h ../include/urg_serial.h +urg_utils.o: ../include/urg_detect_os.h ../include/urg_ring_buffer.h +urg_utils.o: ../include/urg_tcpclient.h ../include/urg_errno.h diff --git a/src/urg_c/current/src/Makefile.release b/src/urg_c/current/src/Makefile.release new file mode 100644 index 0000000..0dc2554 --- /dev/null +++ b/src/urg_c/current/src/Makefile.release @@ -0,0 +1,20 @@ +LIB_URG = liburg_c.a + +include ../build_rule.mk + +CFLAGS = -g -O2 $(INCLUDES) -I../include -fPIC + +all : $(LIB_URG) + +clean : + $(RM) *.o $(LIB_URG) + +$(LIB_URG) : \ + $(LIB_URG)(urg_sensor.o) \ + $(LIB_URG)(urg_utils.o) \ + $(LIB_URG)(urg_debug.o) \ + $(LIB_URG)(urg_connection.o) \ + $(LIB_URG)(urg_ring_buffer.o) \ + $(LIB_URG)(urg_serial.o) \ + $(LIB_URG)(urg_serial_utils.o) \ + $(LIB_URG)(urg_tcpclient.o) \ diff --git a/src/urg_c/current/src/urg_connection.c b/src/urg_c/current/src/urg_connection.c new file mode 100644 index 0000000..c474459 --- /dev/null +++ b/src/urg_c/current/src/urg_connection.c @@ -0,0 +1,108 @@ +/*! + \file + \brief ’Ê�M‚Ì�ˆ—� + + \author Satofumi KAMIMURA + + $Id: urg_connection.c,v 0caa22c18f6b 2010/12/30 03:36:32 Satofumi $ +*/ + +#include "urg_c/urg_connection.h" + + +int connection_open(urg_connection_t *connection, + urg_connection_type_t connection_type, + const char *device, long baudrate_or_port) +{ + connection->type = connection_type; + + switch (connection_type) { + case URG_SERIAL: + return serial_open(&connection->serial, device, baudrate_or_port); + break; + + case URG_ETHERNET: + return tcpclient_open(&connection->tcpclient, + device, baudrate_or_port); + break; + } + return -1; +} + + +void connection_close(urg_connection_t *connection) +{ + switch (connection->type) { + case URG_SERIAL: + serial_close(&connection->serial); + break; + + case URG_ETHERNET: + tcpclient_close(&connection->tcpclient); + break; + } +} + + +int connection_set_baudrate(urg_connection_t *connection, long baudrate) +{ + int ret = -1; + + switch (connection->type) { + case URG_SERIAL: + ret = serial_set_baudrate(&connection->serial, baudrate); + break; + + case URG_ETHERNET: + ret = 0; + break; + } + + return ret; +} + + +int connection_write(urg_connection_t *connection, + const char *data, int size) +{ + switch (connection->type) { + case URG_SERIAL: + return serial_write(&connection->serial, data, size); + break; + case URG_ETHERNET: + return tcpclient_write(&connection->tcpclient, data, size); + break; + } + return -1; +} + + +int connection_read(urg_connection_t *connection, + char *data, int max_size, int timeout) +{ + switch (connection->type) { + case URG_SERIAL: + return serial_read(&connection->serial, data, max_size, timeout); + break; + case URG_ETHERNET: + return tcpclient_read(&connection->tcpclient, data, max_size, timeout); + break; + } + return -1; +} + + +int connection_readline(urg_connection_t *connection, + char *data, int max_size, int timeout) +{ + switch (connection->type) { + case URG_SERIAL: + return serial_readline(&connection->serial, data, max_size, timeout); + break; + case URG_ETHERNET: + return tcpclient_readline(&connection->tcpclient, + data, max_size, timeout); + break; + } + return -1; +} diff --git a/src/urg_c/current/src/urg_debug.c b/src/urg_c/current/src/urg_debug.c new file mode 100644 index 0000000..1d55c3e --- /dev/null +++ b/src/urg_c/current/src/urg_debug.c @@ -0,0 +1,28 @@ +/*! + \~japanese + \brief URG ƒZƒ“ƒT—p‚Ì•â�•ŠÖ�” + + \author Satofumi KAMIMURA + + $Id: urg_utils.c,v da778fd816c2 2011/01/05 20:02:06 Satofumi $ +*/ + +#include "urg_c/urg_debug.h" + + +int urg_raw_write(urg_t *urg, const char *data, int data_size) +{ + return connection_write(&urg->connection, data, data_size); +} + + +int urg_raw_read(urg_t *urg, char *data, int max_data_size, int timeout) +{ + return connection_read(&urg->connection, data, max_data_size, timeout); +} + + +int urg_raw_readline(urg_t *urg, char *data, int max_data_size, int timeout) +{ + return connection_readline(&urg->connection, data, max_data_size, timeout); +} diff --git a/src/urg_c/current/src/urg_ring_buffer.c b/src/urg_c/current/src/urg_ring_buffer.c new file mode 100644 index 0000000..cdbfb2c --- /dev/null +++ b/src/urg_c/current/src/urg_ring_buffer.c @@ -0,0 +1,112 @@ +/*! + \file + \brief ƒŠƒ“ƒOƒoƒbƒtƒ@ + + \author Satofumi KAMIMURA + + $Id$ +*/ + +#include "urg_c/urg_ring_buffer.h" + + +void ring_initialize(ring_buffer_t *ring, char *buffer, const int shift_length) +{ + ring->buffer = buffer; + ring->buffer_size = 1 << shift_length; + ring_clear(ring); +} + + +void ring_clear(ring_buffer_t *ring) +{ + ring->first = 0; + ring->last = 0; +} + + +int ring_size(const ring_buffer_t *ring) +{ + int first = ring->first; + int last = ring->last; + + return (last >= first) ? last - first : ring->buffer_size - (first - last); +} + + +int ring_capacity(const ring_buffer_t *ring) +{ + return ring->buffer_size - 1; +} + + +static void byte_move(char *dest, const char *src, int n) +{ + const char *last_p = dest + n; + while (dest < last_p) { + *dest++ = *src++; + } +} + + +int ring_write(ring_buffer_t *ring, const char *data, int size) +{ + int free_size = ring_capacity(ring) - ring_size(ring); + int push_size = (size > free_size) ? free_size : size; + + // ƒf�[ƒ^”z’u + if (ring->first <= ring->last) { + // last ‚©‚ç buffer_size �I’[‚܂łɔz’u + int left_size = 0; + int to_end = ring->buffer_size - ring->last; + int move_size = (to_end > push_size) ? push_size : to_end; + + byte_move(&ring->buffer[ring->last], data, move_size); + ring->last += move_size; + ring->last &= (ring->buffer_size -1); + + left_size = push_size - move_size; + if (left_size > 0) { + // 0 ‚©‚ç first ‚Ì‘O‚܂łð”z’u + byte_move(ring->buffer, &data[move_size], left_size); + ring->last = left_size; + } + } else { + // last ‚©‚ç first ‚Ì‘O‚܂Ŕz’u + byte_move(&ring->buffer[ring->last], data, size); + ring->last += push_size; + } + return push_size; +} + + +int ring_read(ring_buffer_t *ring, char *buffer, int size) +{ + // ƒf�[ƒ^Žæ“¾ + int now_size = ring_size(ring); + int pop_size = (size > now_size) ? now_size : size; + + if (ring->first <= ring->last) { + byte_move(buffer, &ring->buffer[ring->first], pop_size); + ring->first += pop_size; + + } else { + // first ‚©‚ç buffer_size �I’[‚܂łð”z’u + int left_size = 0; + int to_end = ring->buffer_size - ring->first; + int move_size = (to_end > pop_size) ? pop_size : to_end; + byte_move(buffer, &ring->buffer[ring->first], move_size); + + ring->first += move_size; + ring->first &= (ring->buffer_size -1); + + left_size = pop_size - move_size; + if (left_size > 0) { + // 0 ‚©‚ç last ‚Ì‘O‚܂łð”z’u + byte_move(&buffer[move_size], ring->buffer, left_size); + + ring->first = left_size; + } + } + return pop_size; +} diff --git a/src/urg_c/current/src/urg_sensor.c b/src/urg_c/current/src/urg_sensor.c new file mode 100644 index 0000000..801d366 --- /dev/null +++ b/src/urg_c/current/src/urg_sensor.c @@ -0,0 +1,1378 @@ +/*! + \brief URG ƒZƒ“ƒT�§Œä + + \author Satofumi KAMIMURA + + $Id: urg_sensor.c,v 66816edea765 2011/05/03 06:53:52 satofumi $ + + \todo Mx Œv‘ª’†‚É‘¼‚Ì Mx ƒRƒ}ƒ“ƒh‚ð‘—�M‚µ‚½‚Æ‚«‚É�A“K�؂ɓ®�ì‚·‚邿‚¤‚É‚·‚é +*/ + +#include "urg_c/urg_sensor.h" +#include "urg_c/urg_errno.h" +#include +#include +#include +#include + +#if defined(URG_MSC) +#define snprintf _snprintf +#endif + + +enum { + URG_FALSE = 0, + URG_TRUE = 1, + + BUFFER_SIZE = 64 + 2 + 6, + + EXPECTED_END = -1, + + RECEIVE_DATA_TIMEOUT, + RECEIVE_DATA_COMPLETE, /*!< ƒf�[ƒ^‚ð�³�í‚ÉŽó�M */ + + PP_RESPONSE_LINES = 10, + VV_RESPONSE_LINES = 7, + II_RESPONSE_LINES = 9, + + MAX_TIMEOUT = 140, +}; + + +static const char NOT_CONNECTED_MESSAGE[] = "not connected."; +static const char RECEIVE_ERROR_MESSAGE[] = "receive error."; + + +//! ƒ`ƒFƒbƒNƒTƒ€‚ÌŒvŽZ +static char scip_checksum(const char buffer[], int size) +{ + unsigned char sum = 0x00; + int i; + + for (i = 0; i < size; ++i) { + sum += buffer[i]; + } + + // ŒvŽZ‚̈Ӗ¡‚Í SCIP Žd—l�‘‚ðŽQ�Ƃ̂±‚Æ + return (sum & 0x3f) + 0x30; +} + + +static int set_errno_and_return(urg_t *urg, int urg_errno) +{ + urg->last_errno = urg_errno; + return urg_errno; +} + + +// Žó�M‚µ‚½‰ž“š‚Ì�s�”‚ð•Ô‚· +static int scip_response(urg_t *urg, const char* command, + const int expected_ret[], int timeout, + char *receive_buffer, int receive_buffer_max_size) +{ + char *p = receive_buffer; + char buffer[BUFFER_SIZE]; + int filled_size = 0; + int line_number = 0; + int ret = URG_UNKNOWN_ERROR; + + int write_size = (int)strlen(command); + int n = connection_write(&urg->connection, command, write_size); + + if (n != write_size) { + return set_errno_and_return(urg, URG_SEND_ERROR); + } + + if (p) { + *p = '\0'; + } + + do { + n = connection_readline(&urg->connection, buffer, BUFFER_SIZE, timeout); + if (n < 0) { + return set_errno_and_return(urg, URG_NO_RESPONSE); + + } else if (p && (line_number > 0) + && (n < (receive_buffer_max_size - filled_size))) { + // ƒGƒR�[ƒoƒbƒN‚ÍŠ®‘Sˆê’v‚̃`ƒFƒbƒN‚ð�s‚¤‚½‚ß�AŠi”[‚µ‚È‚¢ + memcpy(p, buffer, n); + p += n; + *p++ = '\0'; + filled_size += n; + } + + if (line_number == 0) { + // ƒGƒR�[ƒoƒbƒN•¶Žš—ñ‚ª�Aˆê’v‚·‚é‚©‚ðŠm”F‚·‚é + if (strncmp(buffer, command, write_size - 1)) { + return set_errno_and_return(urg, URG_INVALID_RESPONSE); + } + } else if (n > 0) { + // ƒGƒR�[ƒoƒbƒNˆÈŠO‚Ì�s‚̃`ƒFƒbƒNƒTƒ€‚ð•]‰¿‚·‚é + char checksum = buffer[n - 1]; + if ((checksum != scip_checksum(buffer, n - 1)) && + (checksum != scip_checksum(buffer, n - 2))) { + return set_errno_and_return(urg, URG_CHECKSUM_ERROR); + } + } + + // ƒXƒe�[ƒ^ƒX‰ž“š‚ð•]‰¿‚µ‚Ä�A–ß‚è’l‚ðŒˆ’è‚·‚é + if (line_number == 1) { + if (n == 1) { + // SCIP 1.1 ‰ž“š‚Ì�ê�‡‚Í�A�³�퉞“š‚Æ‚Ý‚È‚· + ret = 0; + + } else if (n != 3) { + return set_errno_and_return(urg, URG_INVALID_RESPONSE); + + } else { + int i; + int actual_ret = strtol(buffer, NULL, 10); + for (i = 0; expected_ret[i] != EXPECTED_END; ++i) { + if (expected_ret[i] == actual_ret) { + ret = 0; + break; + } + } + } + } + + ++line_number; + } while (n > 0); + + return (ret < 0) ? ret : (line_number - 1); +} + + +static void ignore_receive_data(urg_t *urg, int timeout) +{ + char buffer[BUFFER_SIZE]; + int n; + + if (urg->is_sending == URG_FALSE) { + return; + } + + do { + n = connection_readline(&urg->connection, + buffer, BUFFER_SIZE, timeout); + } while (n >= 0); + + urg->is_sending = URG_FALSE; +} + + +static void ignore_receive_data_with_qt(urg_t *urg, int timeout) +{ + if ((urg->is_sending == URG_FALSE) && (urg->is_laser_on == URG_FALSE)) { + return; + } + + connection_write(&urg->connection, "QT\n", 3); + urg->is_sending = URG_TRUE; + urg->is_laser_on = URG_FALSE; + ignore_receive_data(urg, timeout); +} + + +static int change_sensor_baudrate(urg_t *urg, + long current_baudrate, long next_baudrate) +{ + enum { SS_COMMAND_SIZE = 10 }; + char buffer[SS_COMMAND_SIZE]; + int ss_expected[] = { 0, 3, 4, EXPECTED_END }; + int ret; + + if (current_baudrate == next_baudrate) { + // Œ»�݂̃{�[ƒŒ�[ƒg‚Æ�Ý’è‚·‚éƒ{�[ƒŒ�[ƒg‚ªˆê��‚È‚ç‚Î�A–ß‚é + return set_errno_and_return(urg, URG_NO_ERROR); + } + + // "SS" ƒRƒ}ƒ“ƒh‚Ń{�[ƒŒ�[ƒg‚ð•Ï�X‚·‚é + snprintf(buffer, SS_COMMAND_SIZE, "SS%06ld\n", next_baudrate); + ret = scip_response(urg, buffer, ss_expected, urg->timeout, NULL, 0); + + // 0F ‰ž“š‚̂Ƃ«‚Í Ethernet —p‚̃Zƒ“ƒT‚Ƃ݂Ȃµ�A�³�퉞“š‚ð•Ô‚· + if (ret == -15) { + return set_errno_and_return(urg, URG_NO_ERROR); + } + if (ret <= 0) { + return set_errno_and_return(urg, URG_INVALID_PARAMETER); + } + + // �³�퉞“š‚È‚ç‚Î�AƒzƒXƒg‘¤‚̃{�[ƒŒ�[ƒg‚ð•Ï�X‚·‚é + ret = connection_set_baudrate(&urg->connection, next_baudrate); + + // ƒZƒ“ƒT‘¤‚Ì�ݒ蔽‰f‚ð‘҂‚½‚ß‚É�­‚µ‚¾‚¯‘Ò‹@‚·‚é + ignore_receive_data(urg, MAX_TIMEOUT); + + return set_errno_and_return(urg, ret); +} + + +// ƒ{�[ƒŒ�[ƒg‚ð•Ï�X‚µ‚È‚ª‚ç�Ú‘±‚·‚é +static int connect_urg_device(urg_t *urg, long baudrate) +{ + long try_baudrate[] = { 19200, 38400, 115200 }; + int try_times = sizeof(try_baudrate) / sizeof(try_baudrate[0]); + int i; + + // Žwަ‚³‚ꂽƒ{�[ƒŒ�[ƒg‚©‚ç�Ú‘±‚·‚é + for (i = 0; i < try_times; ++i) { + if (try_baudrate[i] == baudrate) { + try_baudrate[i] = try_baudrate[0]; + try_baudrate[0] = baudrate; + break; + } + } + + for (i = 0; i < try_times; ++i) { + enum { RECEIVE_BUFFER_SIZE = 4 }; + int qt_expected[] = { 0, EXPECTED_END }; + char receive_buffer[RECEIVE_BUFFER_SIZE + 1]; + int ret; + + connection_set_baudrate(&urg->connection, try_baudrate[i]); + + // QT ‚ð‘—�M‚µ�A‰ž“š‚ª•Ô‚³‚ê‚é‚©‚Ń{�[ƒŒ�[ƒg‚ªˆê’v‚µ‚Ä‚¢‚é‚©‚ðŠm”F‚·‚é + ret = scip_response(urg, "QT\n", qt_expected, MAX_TIMEOUT, + receive_buffer, RECEIVE_BUFFER_SIZE); + if (ret > 0) { + if (!strcmp(receive_buffer, "E")) { + int scip20_expected[] = { 0, EXPECTED_END }; + + // QT ‰ž“š‚Ì�ÅŒã‚̉ü�s‚ð“ǂݔò‚΂· + ignore_receive_data(urg, MAX_TIMEOUT); + + // "E" ‚ª•Ô‚³‚ꂽ�ê�‡‚Í�ASCIP 1.1 ‚Ƃ݂Ȃµ "SCIP2.0" ‚ð‘—�M‚·‚é + ret = scip_response(urg, "SCIP2.0\n", scip20_expected, + MAX_TIMEOUT, NULL, 0); + + // SCIP2.0 ‰ž“š‚Ì�ÅŒã‚̉ü�s‚ð“ǂݔò‚΂· + ignore_receive_data(urg, MAX_TIMEOUT); + + // ƒ{�[ƒŒ�[ƒg‚ð•Ï�X‚µ‚Ä–ß‚é + return change_sensor_baudrate(urg, try_baudrate[i], baudrate); + + } else if (!strcmp(receive_buffer, "0Ee")) { + int tm2_expected[] = { 0, EXPECTED_END }; + + // "0Ee" ‚ª•Ô‚³‚ꂽ�ê�‡‚Í�ATM ƒ‚�[ƒh‚Ƃ݂Ȃµ "TM2" ‚ð‘—�M‚·‚é + scip_response(urg, "TM2\n", tm2_expected, + MAX_TIMEOUT, NULL, 0); + + // ƒ{�[ƒŒ�[ƒg‚ð•Ï�X‚µ‚Ä–ß‚é + return change_sensor_baudrate(urg, try_baudrate[i], baudrate); + } + } + + if (ret <= 0) { + if (ret == URG_INVALID_RESPONSE) { + // ˆÙ�í‚ȃGƒR�[ƒoƒbƒN‚̂Ƃ«‚Í�A‹——£ƒf�[ƒ^Žó�M’†‚Ƃ݂Ȃµ‚Ä + // ƒf�[ƒ^‚ð“ǂݔò‚΂· + ignore_receive_data_with_qt(urg, MAX_TIMEOUT); + + // ƒ{�[ƒŒ�[ƒg‚ð•Ï�X‚µ‚Ä–ß‚é + return change_sensor_baudrate(urg, try_baudrate[i], baudrate); + + } else { + // ‰ž“š‚ª‚È‚¢‚Æ‚«‚Í�Aƒ{�[ƒŒ�[ƒg‚ð•Ï�X‚µ‚Ä�A�Ä“x�Ú‘±‚ð�s‚¤ + ignore_receive_data_with_qt(urg, MAX_TIMEOUT); + continue; + } + } else if (!strcmp("00P", receive_buffer)) { + + // ƒZƒ“ƒT‚ƃzƒXƒg‚̃{�[ƒŒ�[ƒg‚ð•Ï�X‚µ‚Ä–ß‚é + return change_sensor_baudrate(urg, try_baudrate[i], baudrate); + } + } + + return set_errno_and_return(urg, URG_NOT_DETECT_BAUDRATE_ERROR); +} + + +// PP ƒRƒ}ƒ“ƒh‚̉ž“š‚ð urg_t ‚ÉŠi”[‚·‚é +static int receive_parameter(urg_t *urg) +{ + enum { RECEIVE_BUFFER_SIZE = BUFFER_SIZE * 9, }; + char receive_buffer[RECEIVE_BUFFER_SIZE]; + int pp_expected[] = { 0, EXPECTED_END }; + unsigned short received_bits = 0x0000; + char *p; + int i; + + int ret = scip_response(urg, "PP\n", pp_expected, MAX_TIMEOUT, + receive_buffer, RECEIVE_BUFFER_SIZE); + if (ret < 0) { + return ret; + } else if (ret < PP_RESPONSE_LINES) { + ignore_receive_data_with_qt(urg, MAX_TIMEOUT); + return set_errno_and_return(urg, URG_INVALID_RESPONSE); + } + + p = receive_buffer; + for (i = 0; i < (ret - 1); ++i) { + + if (!strncmp(p, "DMIN:", 5)) { + urg->min_distance = strtol(p + 5, NULL, 10); + received_bits |= 0x0001; + + } else if (!strncmp(p, "DMAX:", 5)) { + urg->max_distance = strtol(p + 5, NULL, 10); + received_bits |= 0x0002; + + } else if (!strncmp(p, "ARES:", 5)) { + urg->area_resolution = strtol(p + 5, NULL, 10); + received_bits |= 0x0004; + + } else if (!strncmp(p, "AMIN:", 5)) { + urg->first_data_index = strtol(p + 5, NULL, 10); + received_bits |= 0x0008; + + } else if (!strncmp(p, "AMAX:", 5)) { + urg->last_data_index = strtol(p + 5, NULL, 10); + received_bits |= 0x0010; + + } else if (!strncmp(p, "AFRT:", 5)) { + urg->front_data_index = strtol(p + 5, NULL, 10); + received_bits |= 0x0020; + + } else if (!strncmp(p, "SCAN:", 5)) { + int rpm = strtol(p + 5, NULL, 10); + // ƒ^ƒCƒ€ƒAƒEƒgŽžŠÔ‚Í�AŒv‘ªŽüŠú‚Ì 16 ”{’ö“x‚Ì’l‚É‚·‚é + urg->scan_usec = 1000 * 1000 * 60 / rpm; + urg->timeout = urg->scan_usec >> (10 - 4); + received_bits |= 0x0040; + } + p += strlen(p) + 1; + } + + // ‘S‚Ẵpƒ‰ƒ��[ƒ^‚ðŽó�M‚µ‚½‚©Šm”F + if (received_bits != 0x007f) { + return set_errno_and_return(urg, URG_RECEIVE_ERROR); + } + + urg_set_scanning_parameter(urg, + urg->first_data_index - urg->front_data_index, + urg->last_data_index - urg->front_data_index, + 1); + + return set_errno_and_return(urg, URG_NO_ERROR); +} + + +//! SCIP •¶Žš—ñ‚̃fƒR�[ƒh +long urg_scip_decode(const char data[], int size) +{ + const char* p = data; + const char* last_p = p + size; + int value = 0; + + while (p < last_p) { + value <<= 6; + value &= ~0x3f; + value |= *p++ - 0x30; + } + return value; +} + + +static int parse_parameter(const char *parameter, int size) +{ + char buffer[5]; + + memcpy(buffer, parameter, size); + buffer[size] = '\0'; + + return strtol(buffer, NULL, 10); +} + + +static urg_measurement_type_t parse_distance_parameter(urg_t *urg, + const char echoback[]) +{ + urg_measurement_type_t ret_type = URG_UNKNOWN; + + urg->received_range_data_byte = URG_COMMUNICATION_3_BYTE; + if (echoback[1] == 'S') { + urg->received_range_data_byte = URG_COMMUNICATION_2_BYTE; + ret_type = URG_DISTANCE; + + } else if (echoback[1] == 'D') { + if ((echoback[0] == 'G') || (echoback[0] == 'M')) { + ret_type = URG_DISTANCE; + } else if ((echoback[0] == 'H') || (echoback[0] == 'N')) { + ret_type = URG_MULTIECHO; + } + } else if (echoback[1] == 'E') { + if ((echoback[0] == 'G') || (echoback[0] == 'M')) { + ret_type = URG_DISTANCE_INTENSITY; + } else if ((echoback[0] == 'H') || (echoback[0] == 'N')) { + ret_type = URG_MULTIECHO_INTENSITY; + } + } else { + return URG_UNKNOWN; + } + + // ƒpƒ‰ƒ��[ƒ^‚ÌŠi”[ + urg->received_first_index = parse_parameter(&echoback[2], 4); + urg->received_last_index = parse_parameter(&echoback[6], 4); + urg->received_skip_step = parse_parameter(&echoback[10], 2); + + return ret_type; +} + + +static urg_measurement_type_t parse_distance_echoback(urg_t *urg, + const char echoback[]) +{ + size_t line_length; + urg_measurement_type_t ret_type = URG_UNKNOWN; + + if (!strcmp("QT", echoback)) { + return URG_STOP; + } + + line_length = strlen(echoback); + if ((line_length == 12) && + ((echoback[0] == 'G') || (echoback[0] == 'H'))) { + ret_type = parse_distance_parameter(urg, echoback); + + } else if ((line_length == 15) && + ((echoback[0] == 'M') || (echoback[0] == 'N'))) { + ret_type = parse_distance_parameter(urg, echoback); + } + return ret_type; +} + + +static int receive_length_data(urg_t *urg, long length[], + unsigned short intensity[], + urg_measurement_type_t type, char buffer[]) +{ + int n; + int step_filled = 0; + int line_filled = 0; + int multiecho_index = 0; + + int each_size = + (urg->received_range_data_byte == URG_COMMUNICATION_2_BYTE) ? 2 : 3; + int data_size = each_size; + int is_intensity = URG_FALSE; + int is_multiecho = URG_FALSE; + int multiecho_max_size = 1; + + if ((type == URG_DISTANCE_INTENSITY) || (type == URG_MULTIECHO_INTENSITY)) { + data_size *= 2; + is_intensity = URG_TRUE; + } + if ((type == URG_MULTIECHO) || (type == URG_MULTIECHO_INTENSITY)) { + is_multiecho = URG_TRUE; + multiecho_max_size = URG_MAX_ECHO; + } + + do { + char *p = buffer; + char *last_p; + + n = connection_readline(&urg->connection, + &buffer[line_filled], BUFFER_SIZE - line_filled, + urg->timeout); + + if (n > 0) { + // ƒ`ƒFƒbƒNƒTƒ€‚Ì•]‰¿ + if (buffer[line_filled + n - 1] != + scip_checksum(&buffer[line_filled], n - 1)) { + ignore_receive_data_with_qt(urg, urg->timeout); + return set_errno_and_return(urg, URG_CHECKSUM_ERROR); + } + } + + if (n > 0) { + line_filled += n - 1; + } + last_p = p + line_filled; + + while ((last_p - p) >= data_size) { + int index; + + if (*p == '&') { + // �擪•¶Žš‚ª '&' ‚¾‚Á‚½‚Æ‚«‚Í�Aƒ}ƒ‹ƒ`ƒGƒR�[‚̃f�[ƒ^‚Ƃ݂Ȃ· + + if ((last_p - (p + 1)) < data_size) { + // '&' ‚ð�œ‚¢‚Ä�Adata_size •ªƒf�[ƒ^‚ª–³‚¯‚ê‚Δ²‚¯‚é + break; + } + + --step_filled; + ++multiecho_index; + ++p; + --line_filled; + + } else { + // ŽŸ‚̃f�[ƒ^ + multiecho_index = 0; + } + + index = (step_filled * multiecho_max_size) + multiecho_index; + + if (step_filled > + (urg->received_last_index - urg->received_first_index)) { + // ƒf�[ƒ^‚ª‘½‰ß‚¬‚é�ê�‡‚Í�AŽc‚è‚̃f�[ƒ^‚𖳎‹‚µ‚Ä–ß‚é + ignore_receive_data_with_qt(urg, urg->timeout); + return set_errno_and_return(urg, URG_RECEIVE_ERROR); + } + + + if (is_multiecho && (multiecho_index == 0)) { + // ƒ}ƒ‹ƒ`ƒGƒR�[‚̃f�[ƒ^Ši”[�æ‚ðƒ_ƒ~�[ƒf�[ƒ^‚Å–„‚ß‚é + int i; + if (length) { + for (i = 1; i < multiecho_max_size; ++i) { + length[index + i] = 0; + } + } + if (intensity) { + for (i = 1; i < multiecho_max_size; ++i) { + intensity[index + i] = 0; + } + } + } + + // ‹——£ƒf�[ƒ^‚ÌŠi”[ + if (length) { + length[index] = urg_scip_decode(p, 3); + } + p += 3; + + // ‹­“xƒf�[ƒ^‚ÌŠi”[ + if (is_intensity) { + if (intensity) { + intensity[index] = (unsigned short)urg_scip_decode(p, 3); + } + p += 3; + } + + ++step_filled; + line_filled -= data_size; + } + + // ŽŸ‚É�ˆ—�‚·‚é•¶Žš‚ð‘Þ”ð + memmove(buffer, p, line_filled); + } while (n > 0); + + return step_filled; +} + + +//! ‹——£ƒf�[ƒ^‚̎擾 +static int receive_data(urg_t *urg, long data[], unsigned short intensity[], + long *time_stamp, unsigned long long *system_time_stamp) +{ + urg_measurement_type_t type; + char buffer[BUFFER_SIZE]; + int ret = 0; + int n; + int extended_timeout = urg->timeout + + 2 * (urg->scan_usec * (urg->scanning_skip_scan) / 1000); + + // ƒGƒR�[ƒoƒbƒN‚̎擾 + n = connection_readline(&urg->connection, + buffer, BUFFER_SIZE, extended_timeout); + if (n <= 0) { + return set_errno_and_return(urg, URG_NO_RESPONSE); + } + // ƒGƒR�[ƒoƒbƒN‚̉ð�Í + type = parse_distance_echoback(urg, buffer); + + // ‰ž“š‚̎擾 + n = connection_readline(&urg->connection, + buffer, BUFFER_SIZE, urg->timeout); + if (n != 3) { + ignore_receive_data_with_qt(urg, urg->timeout); + return set_errno_and_return(urg, URG_INVALID_RESPONSE); + } + + if (buffer[n - 1] != scip_checksum(buffer, n - 1)) { + // ƒ`ƒFƒbƒNƒTƒ€‚Ì•]‰¿ + ignore_receive_data_with_qt(urg, urg->timeout); + return set_errno_and_return(urg, URG_CHECKSUM_ERROR); + } + + if (type == URG_STOP) { + // QT ‰ž“š‚Ì�ê�‡‚É‚Í�A�ÅŒã‚̉ü�s‚ð“ǂݎ̂Ä�A�³�퉞“š‚Æ‚µ‚Ä�ˆ—�‚·‚é + n = connection_readline(&urg->connection, + buffer, BUFFER_SIZE, urg->timeout); + if (n == 0) { + return 0; + } else { + return set_errno_and_return(urg, URG_INVALID_RESPONSE); + } + } + + if (urg->specified_scan_times != 1) { + if (!strncmp(buffer, "00", 2)) { + // "00" ‰ž“š‚Ì�ê�‡‚Í�AƒGƒR�[ƒoƒbƒN‰ž“š‚Æ‚Ý‚È‚µ�A + // �ÅŒã‚Ì‹ó�s‚ð“ǂݎ̂Ä�AŽŸ‚©‚ç‚̃f�[ƒ^‚ð•Ô‚· + n = connection_readline(&urg->connection, + buffer, BUFFER_SIZE, urg->timeout); + + if (n != 0) { + ignore_receive_data_with_qt(urg, urg->timeout); + return set_errno_and_return(urg, URG_INVALID_RESPONSE); + } else { + return receive_data(urg, data, intensity, time_stamp, system_time_stamp); + } + } + } + + if (((urg->specified_scan_times == 1) && (strncmp(buffer, "00", 2))) || + ((urg->specified_scan_times != 1) && (strncmp(buffer, "99", 2)))) { + if (urg->error_handler) { + type = urg->error_handler(buffer, urg); + } + + if (type == URG_UNKNOWN) { + // Gx, Hx ‚̂Ƃ«‚Í 00P ‚ª•Ô‚³‚ꂽ‚Æ‚«‚ªƒf�[ƒ^ + // Mx, Nx ‚̂Ƃ«‚Í 99b ‚ª•Ô‚³‚ꂽ‚Æ‚«‚ªƒf�[ƒ^ + ignore_receive_data_with_qt(urg, urg->timeout); + return set_errno_and_return(urg, URG_INVALID_RESPONSE); + } + } + + // ƒ^ƒCƒ€ƒXƒ^ƒ“ƒv‚̎擾 + n = connection_readline(&urg->connection, + buffer, BUFFER_SIZE, urg->timeout); + if (n > 0) { + if (time_stamp) { + *time_stamp = urg_scip_decode(buffer, 4); + } + if (system_time_stamp) { + urg_get_walltime(system_time_stamp); + } + } + + // ƒf�[ƒ^‚̎擾 + switch (type) { + case URG_DISTANCE: + case URG_MULTIECHO: + ret = receive_length_data(urg, data, NULL, type, buffer); + break; + + case URG_DISTANCE_INTENSITY: + case URG_MULTIECHO_INTENSITY: + ret = receive_length_data(urg, data, intensity, type, buffer); + break; + + case URG_STOP: + case URG_UNKNOWN: + ret = 0; + break; + } + + // specified_scan_times == 1 ‚̂Ƃ«‚Í Gx ŒnƒRƒ}ƒ“ƒh‚ªŽg‚í‚ê‚邽‚ß + // ƒf�[ƒ^‚𖾎¦“I‚É’âŽ~‚µ‚È‚­‚Ă悢 + if ((urg->specified_scan_times > 1) && (urg->scanning_remain_times > 0)) { + if (--urg->scanning_remain_times <= 0) { + // ƒf�[ƒ^‚Ì’âŽ~‚݂̂ð�s‚¤ + urg_stop_measurement(urg); + } + } + return ret; +} + + +int urg_open(urg_t *urg, urg_connection_type_t connection_type, + const char *device_or_address, long baudrate_or_port) +{ + int ret; + long baudrate = baudrate_or_port; + + urg->is_active = URG_FALSE; + urg->is_sending = URG_TRUE; + urg->last_errno = URG_NOT_CONNECTED; + urg->timeout = MAX_TIMEOUT; + urg->scanning_skip_scan = 0; + urg->error_handler = NULL; + + // ƒfƒoƒCƒX‚Ö‚Ì�Ú‘± + ret = connection_open(&urg->connection, connection_type, + device_or_address, baudrate_or_port); + + if (ret < 0) { + switch (connection_type) { + case URG_SERIAL: + urg->last_errno = URG_SERIAL_OPEN_ERROR; + break; + + case URG_ETHERNET: + urg->last_errno = URG_ETHERNET_OPEN_ERROR; + break; + + default: + urg->last_errno = URG_INVALID_RESPONSE; + break; + } + return urg->last_errno; + } + + // Žw’肵‚½ƒ{�[ƒŒ�[ƒg‚Å URG ‚Æ’Ê�M‚Å‚«‚邿‚¤‚É’²�® + if (connection_type == URG_ETHERNET) { + // Ethernet ‚̂Ƃ«‚͉¼‚Ì’Ê�M‘¬“x‚ðŽw’肵‚Ä‚¨‚­ + baudrate = 115200; + } + + if (connect_urg_device(urg, baudrate) != URG_NO_ERROR) { + return set_errno_and_return(urg, ret); + } + urg->is_sending = URG_FALSE; + + // •Ï�”‚Ì�‰Šú‰» + urg->last_errno = URG_NO_ERROR; + urg->range_data_byte = URG_COMMUNICATION_3_BYTE; + urg->specified_scan_times = 0; + urg->scanning_remain_times = 0; + urg->is_laser_on = URG_FALSE; + + // ƒpƒ‰ƒ��[ƒ^�î•ñ‚ðŽæ“¾ + ret = receive_parameter(urg); + if (ret == URG_NO_ERROR) { + urg->is_active = URG_TRUE; + } + return ret; +} + + +void urg_close(urg_t *urg) +{ + if (urg->is_active) { + ignore_receive_data_with_qt(urg, urg->timeout); + } + connection_close(&urg->connection); + urg->is_active = URG_FALSE; +} + + +void urg_set_timeout_msec(urg_t *urg, int msec) +{ + urg->timeout = msec; +} + + +int urg_start_time_stamp_mode(urg_t *urg) +{ + const int expected[] = { 0, EXPECTED_END }; + int n; + + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + // TM0 ‚ð”­�s‚·‚é + n = scip_response(urg, "TM0\n", expected, urg->timeout, NULL, 0); + if (n <= 0) { + return set_errno_and_return(urg, URG_INVALID_RESPONSE); + } else { + return 0; + } +} + + +long urg_time_stamp(urg_t *urg) +{ + const int expected[] = { 0, EXPECTED_END }; + char buffer[BUFFER_SIZE]; + char *p; + int ret; + + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + ret = scip_response(urg, "TM1\n", expected, + urg->timeout, buffer, BUFFER_SIZE); + if (ret < 0) { + return ret; + } + + // buffer ‚©‚çƒ^ƒCƒ€ƒXƒ^ƒ“ƒv‚ðŽæ“¾‚µ�AƒfƒR�[ƒh‚µ‚ĕԂ· + if (strcmp(buffer, "00P")) { + // �Å�‰‚̉ž“š‚ª "00P" ‚łȂ¯‚ê‚Ζ߂é + return set_errno_and_return(urg, URG_RECEIVE_ERROR); + } + p = buffer + 4; + if (strlen(p) != 5) { + return set_errno_and_return(urg, URG_RECEIVE_ERROR); + } + if (p[5] == scip_checksum(p, 4)) { + return set_errno_and_return(urg, URG_CHECKSUM_ERROR); + } + return urg_scip_decode(p, 4); +} + + +int urg_stop_time_stamp_mode(urg_t *urg) +{ + int expected[] = { 0, EXPECTED_END }; + int n; + + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + // TM2 ‚ð”­�s‚·‚é + n = scip_response(urg, "TM2\n", expected, urg->timeout, NULL, 0); + if (n <= 0) { + return set_errno_and_return(urg, URG_INVALID_RESPONSE); + } else { + return 0; + } +} + + +static int send_distance_command(urg_t *urg, int scan_times, int skip_scan, + char single_scan_ch, char continuous_scan_ch, + char scan_type_ch) +{ + char buffer[BUFFER_SIZE]; + int write_size = 0; + int front_index = urg->front_data_index; + int n; + + urg->specified_scan_times = (scan_times < 0) ? 0 : scan_times; + urg->scanning_remain_times = urg->specified_scan_times; + urg->scanning_skip_scan = (skip_scan < 0) ? 0 : skip_scan; + if (scan_times >= 100) { + // Œv‘ª‰ñ�”‚ª 99 ‚ð‰z‚¦‚é�ê�‡‚Í�A–³ŒÀ‰ñ‚̃XƒLƒƒƒ“‚ð�s‚¤ + urg->specified_scan_times = 0; + } + + if (urg->scanning_remain_times == 1) { + // ƒŒ�[ƒU”­Œõ‚ðŽwަ + urg_laser_on(urg); + + write_size = snprintf(buffer, BUFFER_SIZE, "%c%c%04d%04d%02d\n", + single_scan_ch, scan_type_ch, + urg->scanning_first_step + front_index, + urg->scanning_last_step + front_index, + urg->scanning_skip_step); + } else { + write_size = snprintf(buffer, BUFFER_SIZE, "%c%c%04d%04d%02d%01d%02d\n", + continuous_scan_ch, scan_type_ch, + urg->scanning_first_step + front_index, + urg->scanning_last_step + front_index, + urg->scanning_skip_step, + skip_scan, urg->specified_scan_times); + urg->is_sending = URG_TRUE; + } + + n = connection_write(&urg->connection, buffer, write_size); + if (n != write_size) { + return set_errno_and_return(urg, URG_SEND_ERROR); + } + + return 0; +} + + +int urg_start_measurement(urg_t *urg, urg_measurement_type_t type, + int scan_times, int skip_scan) +{ + char range_byte_ch; + int ret = 0; + + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + if ((skip_scan < 0) || (skip_scan > 9)) { + ignore_receive_data_with_qt(urg, urg->timeout); + return set_errno_and_return(urg, URG_INVALID_PARAMETER); + } + + // !!! Mx Œn, Nx Œn‚ÌŒv‘ª’†‚̂Ƃ«‚Í�AQT ‚ð”­�s‚µ‚Ä‚©‚ç + // !!! Œv‘ªŠJŽnƒRƒ}ƒ“ƒh‚ð‘—�M‚·‚邿‚¤‚É‚·‚é + // !!! ‚½‚¾‚µ�AMD Œv‘ª’†‚É MD ‚ð”­�s‚·‚邿‚¤‚É�A“¯‚¶ƒRƒ}ƒ“ƒh‚Ì�ê�‡‚Í + // !!! Mx Œn, Nx Œn‚ÌŒv‘ª‚Í�ã�‘‚«‚·‚邱‚Æ‚ª‚Å‚«‚邿‚¤‚É‚·‚é + + // Žw’肳‚ꂽƒ^ƒCƒv‚̃pƒPƒbƒg‚ð�¶�¬‚µ�A‘—�M‚·‚é + switch (type) { + case URG_DISTANCE: + range_byte_ch = + (urg->range_data_byte == URG_COMMUNICATION_2_BYTE) ? 'S' : 'D'; + ret = send_distance_command(urg, scan_times, skip_scan, + 'G', 'M', range_byte_ch); + break; + + case URG_DISTANCE_INTENSITY: + ret = send_distance_command(urg, scan_times, skip_scan, + 'G', 'M', 'E'); + break; + + case URG_MULTIECHO: + ret = send_distance_command(urg, scan_times, skip_scan, + 'H', 'N', 'D'); + break; + + case URG_MULTIECHO_INTENSITY: + ret = send_distance_command(urg, scan_times, skip_scan, + 'H', 'N', 'E'); + break; + + case URG_STOP: + case URG_UNKNOWN: + default: + ignore_receive_data_with_qt(urg, urg->timeout); + urg->last_errno = URG_INVALID_PARAMETER; + ret = urg->last_errno; + break; + } + + return ret; +} + + +int urg_get_distance(urg_t *urg, long data[], long *time_stamp, unsigned long long *system_time_stamp) +{ + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + return receive_data(urg, data, NULL, time_stamp, system_time_stamp); +} + + +int urg_get_distance_intensity(urg_t *urg, + long data[], unsigned short intensity[], + long *time_stamp, unsigned long long *system_time_stamp) +{ + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + return receive_data(urg, data, intensity, time_stamp, system_time_stamp); +} + + +int urg_get_multiecho(urg_t *urg, long data_multi[], long *time_stamp, unsigned long long *system_time_stamp) +{ + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + return receive_data(urg, data_multi, NULL, time_stamp, system_time_stamp); +} + + +int urg_get_multiecho_intensity(urg_t *urg, + long data_multi[], + unsigned short intensity_multi[], + long *time_stamp, unsigned long long *system_time_stamp) +{ + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + return receive_data(urg, data_multi, intensity_multi, time_stamp, system_time_stamp); +} + + +int urg_stop_measurement(urg_t *urg) +{ + enum { MAX_READ_TIMES = 3 }; + int ret = URG_INVALID_RESPONSE; + int n; + int i; + + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + // QT ‚ð”­�s‚·‚é + n = connection_write(&urg->connection, "QT\n", 3); + if (n != 3) { + return set_errno_and_return(urg, URG_SEND_ERROR); + } + + for (i = 0; i < MAX_READ_TIMES; ++i) { + // QT ‚̉ž“š‚ª•Ô‚³‚ê‚é‚Ü‚Å�A‹——£ƒf�[ƒ^‚ð“ǂݎ̂Ăé + ret = receive_data(urg, NULL, NULL, NULL, NULL); + if (ret == URG_NO_ERROR) { + // �³�퉞“š + urg->is_laser_on = URG_FALSE; + urg->is_sending = URG_FALSE; + return set_errno_and_return(urg, URG_NO_ERROR); + } + } + return ret; +} + + +int urg_set_scanning_parameter(urg_t *urg, int first_step, int last_step, + int skip_step) +{ + // �Ý’è‚͈̔͊O‚ðŽw’肵‚½‚Æ‚«‚Í�AƒGƒ‰�[‚ð•Ô‚· + if (((skip_step < 0) || (skip_step >= 100)) || + (first_step > last_step) || + (first_step < -urg->front_data_index) || + (last_step > (urg->last_data_index - urg->front_data_index))) { + return set_errno_and_return(urg, URG_SCANNING_PARAMETER_ERROR); + } + + urg->scanning_first_step = first_step; + urg->scanning_last_step = last_step; + urg->scanning_skip_step = skip_step; + + return set_errno_and_return(urg, URG_NO_ERROR); +} + + +int urg_set_connection_data_size(urg_t *urg, + urg_range_data_byte_t data_byte) +{ + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + if ((data_byte != URG_COMMUNICATION_3_BYTE) || + (data_byte != URG_COMMUNICATION_2_BYTE)) { + return set_errno_and_return(urg, URG_DATA_SIZE_PARAMETER_ERROR); + } + + urg->range_data_byte = data_byte; + + return set_errno_and_return(urg, URG_NO_ERROR); +} + + +int urg_laser_on(urg_t *urg) +{ + int expected[] = { 0, 2, EXPECTED_END }; + int ret; + + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + if (urg->is_laser_on != URG_FALSE) { + // Šù‚ɃŒ�[ƒU‚ª”­Œõ‚µ‚Ä‚¢‚邯‚«‚Í�AƒRƒ}ƒ“ƒh‚ð‘—�M‚µ‚È‚¢‚悤‚É‚·‚é + urg->last_errno = 0; + return urg->last_errno; + } + + ret = scip_response(urg, "BM\n", expected, urg->timeout, NULL, 0); + if (ret >= 0) { + urg->is_laser_on = URG_TRUE; + ret = 0; + } + return ret; +} + + +int urg_laser_off(urg_t *urg) +{ + return urg_stop_measurement(urg); +} + + +int urg_reboot(urg_t *urg) +{ + int expected[] = { 0, 1, EXPECTED_END }; + int ret; + int i; + + if (!urg->is_active) { + return set_errno_and_return(urg, URG_NOT_CONNECTED); + } + + // ‚Q‰ñ–Ú‚Ì RB ‘—�MŒã�A�Ú‘±‚ð�Ø’f‚·‚é + for (i = 0; i < 2; ++i) { + ret = scip_response(urg, "RB\n", expected, urg->timeout, NULL, 0); + if (ret < 0) { + return set_errno_and_return(urg, URG_INVALID_RESPONSE); + } + } + urg->is_active = URG_FALSE; + urg_close(urg); + + urg->last_errno = 0; + return urg->last_errno; +} + + +void urg_sleep(urg_t *urg) +{ + enum { RECEIVE_BUFFER_SIZE = 4 }; + int sl_expected[] = { 0, EXPECTED_END }; + char receive_buffer[RECEIVE_BUFFER_SIZE]; + + if (urg_stop_measurement(urg) != URG_NO_ERROR) { + return; + } + + scip_response(urg, "%SL\n", sl_expected, MAX_TIMEOUT, + receive_buffer, RECEIVE_BUFFER_SIZE); +} + + +void urg_wakeup(urg_t *urg) +{ + urg_stop_measurement(urg); +} + + +int urg_is_stable(urg_t *urg) +{ + const char *stat = urg_sensor_status(urg); + return strncmp("Stable", stat, 6) ? 0 : 1; +} + + +static char *copy_token(char *dest, char *receive_buffer, + const char *start_str, const char *end_ch, int lines) +{ + size_t start_str_len = strlen(start_str); + size_t end_ch_len = strlen(end_ch); + int i; + size_t j; + + for (j = 0; j < end_ch_len; ++j) { + const char *p = receive_buffer; + + for (i = 0; i < lines; ++i) { + if (!strncmp(p, start_str, start_str_len)) { + + char *last_p = strchr(p + start_str_len, end_ch[j]); + if (last_p) { + *last_p = '\0'; + memcpy(dest, p + start_str_len, + last_p - (p + start_str_len) + 1); + return dest; + } + } + p += strlen(p) + 1; + } + } + return NULL; +} + + +static const char *receive_command_response(urg_t *urg, + char *buffer, int buffer_size, + const char* command, + int response_lines) +{ + const int vv_expected[] = { 0, EXPECTED_END }; + int ret; + + if (!urg->is_active) { + return NOT_CONNECTED_MESSAGE; + } + + ret = scip_response(urg, command, vv_expected, urg->timeout, + buffer, buffer_size); + if (ret < response_lines) { + return RECEIVE_ERROR_MESSAGE; + } + + return NULL; +} + + +const char *urg_sensor_product_type(urg_t *urg) +{ + enum { + RECEIVE_BUFFER_SIZE = BUFFER_SIZE * VV_RESPONSE_LINES, + }; + char receive_buffer[RECEIVE_BUFFER_SIZE]; + const char *ret; + char *p; + + ret = receive_command_response(urg, receive_buffer, RECEIVE_BUFFER_SIZE, + "VV\n", VV_RESPONSE_LINES); + if (ret) { + return ret; + } + + p = copy_token(urg->return_buffer, + receive_buffer, "PROD:", ";", VV_RESPONSE_LINES); + return (p) ? p : RECEIVE_ERROR_MESSAGE; +} + + +const char *urg_sensor_serial_id(urg_t *urg) +{ + enum { + RECEIVE_BUFFER_SIZE = BUFFER_SIZE * VV_RESPONSE_LINES, + }; + char receive_buffer[RECEIVE_BUFFER_SIZE]; + const char *ret; + char *p; + + ret = receive_command_response(urg, receive_buffer, RECEIVE_BUFFER_SIZE, + "VV\n", VV_RESPONSE_LINES); + if (ret) { + return ret; + } + + p = copy_token(urg->return_buffer, + receive_buffer, "SERI:", ";", VV_RESPONSE_LINES); + return (p) ? p : RECEIVE_ERROR_MESSAGE; +} + +const char *urg_sensor_vendor(urg_t *urg){ + enum { + RECEIVE_BUFFER_SIZE = BUFFER_SIZE * VV_RESPONSE_LINES, + }; + char receive_buffer[RECEIVE_BUFFER_SIZE]; + const char *ret; + char *p; + + if (!urg->is_active) { + return NOT_CONNECTED_MESSAGE; + } + + ret = receive_command_response(urg, receive_buffer, RECEIVE_BUFFER_SIZE, + "VV\n", VV_RESPONSE_LINES); + if (ret) { + return ret; + } + + p = copy_token(urg->return_buffer, + receive_buffer, "VEND:", ";", VV_RESPONSE_LINES); + return (p) ? p : RECEIVE_ERROR_MESSAGE; +} + +const char *urg_sensor_firmware_version(urg_t *urg) +{ + enum { + RECEIVE_BUFFER_SIZE = BUFFER_SIZE * VV_RESPONSE_LINES, + }; + char receive_buffer[RECEIVE_BUFFER_SIZE]; + const char *ret; + char *p; + + if (!urg->is_active) { + return NOT_CONNECTED_MESSAGE; + } + + ret = receive_command_response(urg, receive_buffer, RECEIVE_BUFFER_SIZE, + "VV\n", VV_RESPONSE_LINES); + if (ret) { + return ret; + } + + p = copy_token(urg->return_buffer, + receive_buffer, "FIRM:", "(", VV_RESPONSE_LINES); + return (p) ? p : RECEIVE_ERROR_MESSAGE; +} + +const char *urg_sensor_firmware_date(urg_t *urg) +{ + enum { + RECEIVE_BUFFER_SIZE = BUFFER_SIZE * VV_RESPONSE_LINES, + }; + char receive_buffer[RECEIVE_BUFFER_SIZE]; + const char *ret; + char *p; + + if (!urg->is_active) { + return NOT_CONNECTED_MESSAGE; + } + + // Get the firmware version and append a '(', this will be what's before the date + char firmware_version[50]; + strcpy(firmware_version, urg_sensor_firmware_version(urg)); + strcat(firmware_version, "("); + + ret = receive_command_response(urg, receive_buffer, RECEIVE_BUFFER_SIZE, + "VV\n", VV_RESPONSE_LINES); + if (ret) { + return ret; + } + + // Strip out the actual date from between the '(' and ')' + char *date; + p = copy_token(urg->return_buffer, + receive_buffer, "FIRM:", ";", VV_RESPONSE_LINES); + date = copy_token(urg->return_buffer, p, firmware_version, ")", 1); + return (date) ? date : RECEIVE_ERROR_MESSAGE; +} + +const char *urg_sensor_protocol_version(urg_t *urg) +{ + enum { + RECEIVE_BUFFER_SIZE = BUFFER_SIZE * VV_RESPONSE_LINES, + }; + char receive_buffer[RECEIVE_BUFFER_SIZE]; + const char *ret; + char *p; + + if (!urg->is_active) { + return NOT_CONNECTED_MESSAGE; + } + + ret = receive_command_response(urg, receive_buffer, RECEIVE_BUFFER_SIZE, + "VV\n", VV_RESPONSE_LINES); + if (ret) { + return ret; + } + + p = copy_token(urg->return_buffer, + receive_buffer, "PROT:", ";", VV_RESPONSE_LINES); + return (p) ? p : RECEIVE_ERROR_MESSAGE; +} + + +const char *urg_sensor_status(urg_t *urg) +{ + enum { + RECEIVE_BUFFER_SIZE = BUFFER_SIZE * II_RESPONSE_LINES, + }; + char receive_buffer[RECEIVE_BUFFER_SIZE]; + const char *ret; + char *p; + + if (!urg->is_active) { + return NOT_CONNECTED_MESSAGE; + } + + ret = receive_command_response(urg, receive_buffer, RECEIVE_BUFFER_SIZE, + "II\n", II_RESPONSE_LINES); + if (ret) { + return ret; + } + + p = copy_token(urg->return_buffer, + receive_buffer, "STAT:", ";", II_RESPONSE_LINES); + return (p) ? p : RECEIVE_ERROR_MESSAGE; +} + + +const char *urg_sensor_state(urg_t *urg) +{ + enum { + RECEIVE_BUFFER_SIZE = BUFFER_SIZE * II_RESPONSE_LINES, + }; + char receive_buffer[RECEIVE_BUFFER_SIZE]; + const char *ret; + char *p; + + if (!urg->is_active) { + return NOT_CONNECTED_MESSAGE; + } + + ret = receive_command_response(urg, receive_buffer, RECEIVE_BUFFER_SIZE, + "II\n", II_RESPONSE_LINES); + if (ret) { + return ret; + } + + p = copy_token(urg->return_buffer, + receive_buffer, "MESM:", " (", II_RESPONSE_LINES); + return (p) ? p : RECEIVE_ERROR_MESSAGE; +} + + +void urg_set_error_handler(urg_t *urg, urg_error_handler handler) +{ + urg->error_handler = handler; +} diff --git a/src/urg_c/current/src/urg_serial.c b/src/urg_c/current/src/urg_serial.c new file mode 100644 index 0000000..68a24c3 --- /dev/null +++ b/src/urg_c/current/src/urg_serial.c @@ -0,0 +1,69 @@ +/*! + \file + \brief ƒVƒŠƒAƒ‹’Ê�M + + \author Satofumi KAMIMURA + + $Id: urg_serial.c,v 0caa22c18f6b 2010/12/30 03:36:32 Satofumi $ +*/ + +#include "urg_c/urg_serial.h" + + +enum { + False = 0, + True, +}; + + +#if defined(URG_WINDOWS_OS) +#include "urg_serial_windows.c" +#else +#include "urg_serial_linux.c" +#endif + + +// ‰ü�s‚©‚Ç‚¤‚©‚Ì”»’è +static int is_linefeed(const char ch) +{ + return ((ch == '\r') || (ch == '\n')) ? 1 : 0; +} + + +static void serial_ungetc(urg_serial_t *serial, char ch) +{ + serial->has_last_ch = True; + serial->last_ch = ch; +} + + +int serial_readline(urg_serial_t *serial, char *data, int max_size, int timeout) +{ + /* ‚P•¶Žš‚¸‚“ǂÝ�o‚µ‚Ä•]‰¿‚·‚é */ + int filled = 0; + int is_timeout = 0; + + while (filled < max_size) { + char recv_ch; + int n = serial_read(serial, &recv_ch, 1, timeout); + if (n <= 0) { + is_timeout = 1; + break; + } else if (is_linefeed(recv_ch)) { + break; + } + data[filled++] = recv_ch; + } + if (filled >= max_size) { + --filled; + serial_ungetc(serial, data[filled]); + } + data[filled] = '\0'; + + if ((filled == 0) && is_timeout) { + return -1; + } else { + //fprintf(stderr, "%s\n", data); + return filled; + } +} diff --git a/src/urg_c/current/src/urg_serial_linux.c b/src/urg_c/current/src/urg_serial_linux.c new file mode 100644 index 0000000..ff8e75d --- /dev/null +++ b/src/urg_c/current/src/urg_serial_linux.c @@ -0,0 +1,244 @@ +/*! + \file + \brief ƒVƒŠƒAƒ‹’Ê�M + + \author Satofumi KAMIMURA + + $Id$ +*/ + +#include "urg_c/urg_ring_buffer.h" +#include +#include + + +enum { + INVALID_FD = -1, +}; + + +static void serial_initialize(urg_serial_t *serial) +{ + serial->fd = INVALID_FD; + serial->has_last_ch = False; + + ring_initialize(&serial->ring, serial->buffer, RING_BUFFER_SIZE_SHIFT); +} + + +static void serial_clear(urg_serial_t* serial) +{ + tcdrain(serial->fd); + tcflush(serial->fd, TCIOFLUSH); + ring_clear(&serial->ring); + serial->has_last_ch = False; +} + + +int serial_open(urg_serial_t *serial, const char *device, long baudrate) +{ + int flags = 0; + int ret = 0; + + serial_initialize(serial); + +#ifndef URG_MAC_OS + enum { O_EXLOCK = 0x0 }; /* Linux ‚ł͎g‚¦‚È‚¢‚̂Ń_ƒ~�[‚ð�ì�¬‚µ‚Ä‚¨‚­ */ +#endif + serial->fd = open(device, O_RDWR | O_EXLOCK | O_NONBLOCK | O_NOCTTY); + if (serial->fd < 0) { + /* �Ú‘±‚ÉŽ¸”s */ + //strerror_r(errno, serial->error_string, ERROR_MESSAGE_SIZE); + return -1; + } + + flags = fcntl(serial->fd, F_GETFL, 0); + fcntl(serial->fd, F_SETFL, flags & ~O_NONBLOCK); + + /* ƒVƒŠƒAƒ‹’Ê�M‚Ì�‰Šú‰» */ + tcgetattr(serial->fd, &serial->sio); + serial->sio.c_iflag = 0; + serial->sio.c_oflag = 0; + serial->sio.c_cflag &= ~(CSIZE | PARENB | CSTOPB); + serial->sio.c_cflag |= CS8 | CREAD | CLOCAL; + serial->sio.c_lflag &= ~(ICANON | ECHO | ISIG | IEXTEN); + + serial->sio.c_cc[VMIN] = 0; + serial->sio.c_cc[VTIME] = 0; + + /* ƒ{�[ƒŒ�[ƒg‚Ì•Ï�X */ + ret = serial_set_baudrate(serial, baudrate); + if (ret < 0) { + return ret; + } + + /* ƒVƒŠƒAƒ‹�§Œä�\‘¢‘Ì‚Ì�‰Šú‰» */ + serial->has_last_ch = False; + + return 0; +} + + +void serial_close(urg_serial_t *serial) +{ + if (serial->fd >= 0) { + close(serial->fd); + serial->fd = INVALID_FD; + } +} + + +int serial_set_baudrate(urg_serial_t *serial, long baudrate) +{ + long baudrate_value = -1; + + switch (baudrate) { + case 4800: + baudrate_value = B4800; + break; + + case 9600: + baudrate_value = B9600; + break; + + case 19200: + baudrate_value = B19200; + break; + + case 38400: + baudrate_value = B38400; + break; + + case 57600: + baudrate_value = B57600; + break; + + case 115200: + baudrate_value = B115200; + break; + + default: + return -1; + } + + /* ƒ{�[ƒŒ�[ƒg•Ï�X */ + cfsetospeed(&serial->sio, baudrate_value); + cfsetispeed(&serial->sio, baudrate_value); + tcsetattr(serial->fd, TCSADRAIN, &serial->sio); + serial_clear(serial); + + return 0; +} + + +int serial_write(urg_serial_t *serial, const char *data, int size) +{ + if (serial->fd == INVALID_FD) { + return -1; + } + return write(serial->fd, data, size); +} + + +static int wait_receive(urg_serial_t* serial, int timeout) +{ + fd_set rfds; + struct timeval tv; + + // ƒ^ƒCƒ€ƒAƒEƒg�Ý’è + FD_ZERO(&rfds); + FD_SET(serial->fd, &rfds); + + tv.tv_sec = timeout / 1000; + tv.tv_usec = (timeout % 1000) * 1000; + + if (select(serial->fd + 1, &rfds, NULL, NULL, + (timeout < 0) ? NULL : &tv) <= 0) { + /* ƒ^ƒCƒ€ƒAƒEƒg”­�¶ */ + return 0; + } + return 1; +} + + +static int internal_receive(char data[], int data_size_max, + urg_serial_t* serial, int timeout) +{ + int filled = 0; + + if (data_size_max <= 0) { + return 0; + } + + while (filled < data_size_max) { + int require_n; + int read_n; + + if (! wait_receive(serial, timeout)) { + break; + } + + require_n = data_size_max - filled; + read_n = read(serial->fd, &data[filled], require_n); + if (read_n <= 0) { + /* “Ç‚Ý�o‚µƒGƒ‰�[�BŒ»�݂܂ł̎ó�M“à—e‚Å–ß‚é */ + break; + } + filled += read_n; + } + return filled; +} + + +int serial_read(urg_serial_t *serial, char *data, int max_size, int timeout) +{ + int buffer_size; + int read_n; + int filled = 0; + + if (max_size <= 0) { + return 0; + } + + /* �‘‚«–ß‚µ‚½‚P•¶Žš‚ª‚ ‚ê‚Î�A�‘‚«�o‚· */ + if (serial->has_last_ch != False) { + data[0] = serial->last_ch; + serial->has_last_ch = False; + ++filled; + } + if (serial->fd == INVALID_FD) { + if (filled > 0) { + return filled; + } else { + return -1; + } + } + + buffer_size = ring_size(&serial->ring); + read_n = max_size - filled; + if (buffer_size < read_n) { + // ƒŠƒ“ƒOƒoƒbƒtƒ@“à‚̃f�[ƒ^‚Å‘«‚è‚È‚¯‚ê‚Î�Aƒf�[ƒ^‚ð“ǂݑ«‚· + char buffer[RING_BUFFER_SIZE]; + int n = internal_receive(buffer, + ring_capacity(&serial->ring) - buffer_size, + serial, 0); + if (n > 0) { + ring_write(&serial->ring, buffer, n); + buffer_size += n; + } + } + + // ƒŠƒ“ƒOƒoƒbƒtƒ@“à‚̃f�[ƒ^‚ð•Ô‚· + if (read_n > buffer_size) { + read_n = buffer_size; + } + if (read_n > 0) { + ring_read(&serial->ring, &data[filled], read_n); + filled += read_n; + } + + // ƒf�[ƒ^‚ðƒ^ƒCƒ€ƒAƒEƒg•t‚«‚œǂÝ�o‚· + filled += internal_receive(&data[filled], max_size - filled, + serial, timeout); + return filled; +} diff --git a/src/urg_c/current/src/urg_serial_utils.c b/src/urg_c/current/src/urg_serial_utils.c new file mode 100644 index 0000000..42c534a --- /dev/null +++ b/src/urg_c/current/src/urg_serial_utils.c @@ -0,0 +1,18 @@ +/*! + \file + \brief ƒVƒŠƒAƒ‹—p‚Ì•â�•ŠÖ�” + + \author Satofumi KAMIMURA + + $Id$ +*/ + +#include "urg_c/urg_serial_utils.h" +#include "urg_c/urg_detect_os.h" + + +#if defined(URG_WINDOWS_OS) +#include "urg_serial_utils_windows.c" +#else +#include "urg_serial_utils_linux.c" +#endif diff --git a/src/urg_c/current/src/urg_serial_utils_linux.c b/src/urg_c/current/src/urg_serial_utils_linux.c new file mode 100644 index 0000000..509c069 --- /dev/null +++ b/src/urg_c/current/src/urg_serial_utils_linux.c @@ -0,0 +1,91 @@ +/*! + \file + \brief ƒVƒŠƒAƒ‹—p‚Ì•â�•ŠÖ�” + + \author Satofumi KAMIMURA + + $Id: urg_serial_utils_linux.c,v 0caa22c18f6b 2010/12/30 03:36:32 Satofumi $ +*/ + +#include "urg_c/urg_serial_utils.h" +#include +#include +#include +#include + + +enum { + MAX_PORTS = 16, + DEVICE_NAME_SIZE = 255, +}; + + +static char found_ports[MAX_PORTS][DEVICE_NAME_SIZE]; +static int found_ports_size = 0; + +static const char *search_dir_names[] = { + "/dev", + "/dev/usb", +}; +static const char *search_base_names[] = { + "ttyACM", + "ttyUSB", + "tty.usbmodem", +}; + + +static void check_base_name(const char* dir_name, const char *file_name) +{ + int n = sizeof(search_base_names) / sizeof(search_base_names[0]); + int i; + + for (i = 0; i < n; ++i) { + const char *base_name = search_base_names[i]; + if (!strncmp(base_name, file_name, strlen(base_name))) { + snprintf(found_ports[found_ports_size], DEVICE_NAME_SIZE, + "%s/%s", dir_name, file_name); + ++found_ports_size; + } + } +} + + +int urg_serial_find_port(void) +{ + int n = sizeof(search_dir_names) / sizeof(search_dir_names[0]); + int i; + + found_ports_size = 0; + for (i = 0; i < n; ++i) { + struct dirent* dir; + const char *dir_name = search_dir_names[i]; + DIR *dp = opendir(dir_name); + if (!dp) { + continue; + } + + while ((dir = readdir(dp))) { + check_base_name(dir_name, dir->d_name); + } + } + return found_ports_size; +} + + +const char *urg_serial_port_name(int index) +{ + if ((index < 0) || (index >= found_ports_size)) { + return ""; + } else { + return found_ports[index]; + } +} + + +int urg_serial_is_urg_port(int index) +{ + // Linux ‚Ì�ê�‡�Aƒ|�[ƒg‚ª URG ‚©‚Ç‚¤‚©‚Í’f’è‚Å‚«‚È‚¢ + // !!! —]—Í‚ª‚ ‚ê‚Î�Admesg ‚ȂǂÌ�o—Í‚©‚ç”»’è‚·‚邿‚¤‚É‚µ‚Ä‚à‚æ‚¢ + (void)index; + return 0; +} diff --git a/src/urg_c/current/src/urg_serial_utils_windows.c b/src/urg_c/current/src/urg_serial_utils_windows.c new file mode 100644 index 0000000..fa68e9b --- /dev/null +++ b/src/urg_c/current/src/urg_serial_utils_windows.c @@ -0,0 +1,177 @@ +/*! + \file + \brief ƒVƒŠƒAƒ‹—p‚Ì•â�•ŠÖ�” + + \author Satofumi KAMIMURA + + $Id: urg_serial_utils_windows.c,v faa71b0113fd 2011/01/17 12:00:22 Satofumi $ + + \todo •Ï�”–¼‚ð '_' ‹æ�Ø‚è‚ÌŒ`Ž®‚É•Ï�X‚·‚é + \todo C90 ‘Š“–‚Å“®�ì‚·‚邿‚¤‚É’²�®‚·‚é�B‚½‚¾‚µ�A"//" ƒRƒ�ƒ“ƒg‚ÍŽg‚¤ +*/ + +#include "urg_c/urg_serial_utils.h" +#include "urg_c/urg_detect_os.h" +#include +#include +#include +#include + + +#if defined(URG_MSC) +#define snprintf _snprintf +#endif + + +enum { + MAX_PORTS = 16, + DEVICE_NAME_SIZE = 7, +}; + + +static char found_ports[MAX_PORTS][DEVICE_NAME_SIZE]; +static int is_urg_ports[MAX_PORTS]; +static int found_ports_size = 0; + +static char *search_driver_names[] = { + "URG Series USB Device Driver", + "URG-X002 USB Device Driver", +}; + + +static void swap_item(int from_index, int to_index) +{ + char buffer[DEVICE_NAME_SIZE]; + int is_urg_port; + + if (from_index == to_index) { + return; + } + + strncpy(buffer, found_ports[to_index], DEVICE_NAME_SIZE); + strncpy(found_ports[to_index], found_ports[from_index], DEVICE_NAME_SIZE); + strncpy(found_ports[from_index], buffer, DEVICE_NAME_SIZE); + + is_urg_port = is_urg_ports[to_index]; + is_urg_ports[to_index] = is_urg_ports[from_index]; + is_urg_ports[from_index] = is_urg_port; +} + + +static void sort_ports(void) +{ + int last_index = 0; + int i; + + for (i = 0; i < found_ports_size; ++i) { + if ((is_urg_ports[i] == 1) && (last_index < i)) { + swap_item(i, last_index); + last_index = i + 1; + } + } +} + + +int urg_serial_find_port(void) +{ + // ƒfƒoƒCƒXƒ}ƒl�[ƒWƒƒ‚̈ꗗ‚©‚ç COM ƒfƒoƒCƒX‚ð’T‚· + + //4D36E978-E325-11CE-BFC1-08002BE10318 + GUID GUID_DEVINTERFACE_COM_DEVICE = { + 0x4D36E978L, 0xE325, 0x11CE, + {0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18 } + }; + + HDEVINFO hdi; + SP_DEVINFO_DATA sDevInfo; + int i; + + found_ports_size = 0; + hdi = SetupDiGetClassDevs(&GUID_DEVINTERFACE_COM_DEVICE, 0, 0, + DIGCF_PRESENT | DIGCF_INTERFACEDEVICE); + if (hdi == INVALID_HANDLE_VALUE) { + return 0; + } + + sDevInfo.cbSize = sizeof(SP_DEVINFO_DATA); + for (i = 0; SetupDiEnumDeviceInfo(hdi, i, &sDevInfo); ++i){ + + enum { + BufferSize = 256, + ComNameLengthMax = 7, + }; + char buffer[BufferSize + 1]; + DWORD dwRegType; + DWORD dwSize; + int is_urg_port; + char *p; + int n; + int j; + + // ƒtƒŒƒ“ƒhƒŠ�[ƒl�[ƒ€‚ðŽæ“¾‚µ‚Ä COM ”Ô�†‚ðŽæ‚è�o‚· + SetupDiGetDeviceRegistryPropertyA(hdi, &sDevInfo, SPDRP_FRIENDLYNAME, + &dwRegType, (BYTE*)buffer, BufferSize, + &dwSize); + n = (int)strlen(buffer); + if (n < ComNameLengthMax) { + // COM –¼‚ª’Z‰ß‚¬‚½�ê�‡�A�ˆ—�‚µ‚È‚¢ + // –â‘肪‚ ‚é�ê�‡‚Í�A�C�³‚·‚é + continue; + } + + // (COMx) ‚Ì�ÅŒã‚ÌŠ‡ŒÊ‚̈ʒu‚É '\0' ‚ð‘ã“ü‚·‚é + p = strrchr(buffer, ')'); + if (p) { + *p = '\0'; + } + + // COM ‚Æ”Ô�†‚܂ł̕¶Žš—ñ‚𔲂«�o‚· + p = strstr(&buffer[n - ComNameLengthMax], "COM"); + if (! p) { + continue; + } + + snprintf(found_ports[found_ports_size], DEVICE_NAME_SIZE, "%s", p); + + // ƒfƒoƒCƒX–¼‚ðŽæ“¾‚µ�AURG ƒ|�[ƒg‚©‚Ì”»’è‚É—p‚¢‚é + SetupDiGetDeviceRegistryPropertyA(hdi, &sDevInfo, SPDRP_DEVICEDESC, + &dwRegType, (BYTE*)buffer, BufferSize, + &dwSize); + is_urg_port = 0; + n = sizeof(search_driver_names) / sizeof(search_driver_names[0]); + for (j = 0; j < n; ++j) { + if (! strcmp(search_driver_names[j], buffer)) { + is_urg_port = 1; + break; + } + } + is_urg_ports[found_ports_size] = is_urg_port; + ++found_ports_size; + } + SetupDiDestroyDeviceInfoList(hdi); + + // is_urg_port ‚Ì—v‘f‚ª�擪‚É—ˆ‚邿‚¤‚Ƀ\�[ƒg‚·‚é + sort_ports(); + + return found_ports_size; +} + + +const char *urg_serial_port_name(int index) +{ + if ((index < 0) || (index >= found_ports_size)) { + return ""; + } else { + return found_ports[index]; + } +} + + +int urg_serial_is_urg_port(int index) +{ + if ((index < 0) || (index >= found_ports_size)) { + return -1; + } else { + return is_urg_ports[index]; + } +} diff --git a/src/urg_c/current/src/urg_serial_windows.c b/src/urg_c/current/src/urg_serial_windows.c new file mode 100644 index 0000000..c10a279 --- /dev/null +++ b/src/urg_c/current/src/urg_serial_windows.c @@ -0,0 +1,216 @@ +/*! + \file + \brief ƒVƒŠƒAƒ‹’Ê�M + + \author Satofumi KAMIMURA + + $Id$ +*/ + +#include "urg_c/urg_serial.h" +#include + +#if defined(URG_MSC) +#define False 0 +#endif + + +static void serial_initialize(urg_serial_t *serial) +{ + serial->hCom = INVALID_HANDLE_VALUE; + serial->has_last_ch = False; + + ring_initialize(&serial->ring, serial->buffer, RING_BUFFER_SIZE_SHIFT); +} + + +static void set_timeout(urg_serial_t *serial, int timeout) +{ + COMMTIMEOUTS timeouts; + GetCommTimeouts(serial->hCom, &timeouts); + + timeouts.ReadIntervalTimeout = (timeout == 0) ? MAXDWORD : 0; + timeouts.ReadTotalTimeoutConstant = timeout; + timeouts.ReadTotalTimeoutMultiplier = 0; + + SetCommTimeouts(serial->hCom, &timeouts); +} + + +int serial_open(urg_serial_t *serial, const char *device, long baudrate) +{ + // COM10 ˆÈ�~‚ւ̑Ήž—p + enum { NameLength = 11 }; + char adjusted_device[NameLength]; + + serial_initialize(serial); + + /* COM ƒ|�[ƒg‚ðŠJ‚­ */ + _snprintf(adjusted_device, NameLength, "\\\\.\\%s", device); + serial->hCom = CreateFileA(adjusted_device, GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + + if (serial->hCom == INVALID_HANDLE_VALUE) { + // !!! store error_message buffer + //printf("open failed: %s\n", device); + return -1; + } + + /* ’Ê�MƒTƒCƒY‚Ì�X�V */ + SetupComm(serial->hCom, 4096 * 8, 4096); + + /* ƒ{�[ƒŒ�[ƒg‚Ì•Ï�X */ + serial_set_baudrate(serial, baudrate); + + /* ƒVƒŠƒAƒ‹�§Œä�\‘¢‘Ì‚Ì�‰Šú‰» */ + serial->has_last_ch = False; + + /* ƒ^ƒCƒ€ƒAƒEƒg‚Ì�Ý’è */ + serial->current_timeout = 0; + set_timeout(serial, serial->current_timeout); + + return 0; +} + + +void serial_close(urg_serial_t *serial) +{ + if (serial->hCom != INVALID_HANDLE_VALUE) { + CloseHandle(serial->hCom); + serial->hCom = INVALID_HANDLE_VALUE; + } +} + + +int serial_set_baudrate(urg_serial_t *serial, long baudrate) +{ + long baudrate_value; + DCB dcb; + + switch (baudrate) { + + case 4800: + baudrate_value = CBR_4800; + break; + + case 9600: + baudrate_value = CBR_9600; + break; + + case 19200: + baudrate_value = CBR_19200; + break; + + case 38400: + baudrate_value = CBR_38400; + break; + + case 57600: + baudrate_value = CBR_57600; + break; + + case 115200: + baudrate_value = CBR_115200; + break; + + default: + baudrate_value = baudrate; + } + + GetCommState(serial->hCom, &dcb); + dcb.BaudRate = baudrate_value; + dcb.ByteSize = 8; + dcb.Parity = NOPARITY; + dcb.fParity = FALSE; + dcb.StopBits = ONESTOPBIT; + SetCommState(serial->hCom, &dcb); + + return 0; +} + + +int serial_write(urg_serial_t *serial, const char *data, int size) +{ + DWORD n; + + if (size < 0) { + return 0; + } + + if (serial->hCom == INVALID_HANDLE_VALUE) { + return -1; + } + + WriteFile(serial->hCom, data, (DWORD)size, &n, NULL); + return n; +} + + +static int internal_receive(char data[], int max_size, + urg_serial_t* serial, int timeout) +{ + int filled = 0; + DWORD n; + + if (timeout != serial->current_timeout) { + set_timeout(serial, timeout); + serial->current_timeout = timeout; + } + + ReadFile(serial->hCom, &data[filled], (DWORD)max_size - filled, &n, NULL); + + return filled + n; +} + + +int serial_read(urg_serial_t *serial, char *data, int max_size, int timeout) +{ + int filled = 0; + int buffer_size; + int read_n; + + if (max_size <= 0) { + return 0; + } + + /* �‘‚«–ß‚µ‚½‚P•¶Žš‚ª‚ ‚ê‚Î�A�‘‚«�o‚· */ + if (serial->has_last_ch) { + data[0] = serial->last_ch; + serial->has_last_ch = False; + ++filled; + } + + if (serial->hCom == INVALID_HANDLE_VALUE) { + if (filled > 0) { + return filled; + } + return -1; + } + + buffer_size = ring_size(&serial->ring); + read_n = max_size - filled; + if (buffer_size < read_n) { + // ƒŠƒ“ƒOƒoƒbƒtƒ@“à‚̃f�[ƒ^‚Å‘«‚è‚È‚¯‚ê‚Î�Aƒf�[ƒ^‚ð“ǂݑ«‚· + char buffer[RING_BUFFER_SIZE]; + int n = internal_receive(buffer, + ring_capacity(&serial->ring) - buffer_size, + serial, 0); + ring_write(&serial->ring, buffer, n); + } + buffer_size = ring_size(&serial->ring); + + // ƒŠƒ“ƒOƒoƒbƒtƒ@“à‚̃f�[ƒ^‚ð•Ô‚· + if (read_n > buffer_size) { + read_n = buffer_size; + } + if (read_n > 0) { + ring_read(&serial->ring, &data[filled], read_n); + filled += read_n; + } + + // ƒf�[ƒ^‚ðƒ^ƒCƒ€ƒAƒEƒg•t‚«‚œǂÝ�o‚· + filled += internal_receive(&data[filled], + max_size - filled, serial, timeout); + return filled; +} diff --git a/src/urg_c/current/src/urg_tcpclient.c b/src/urg_c/current/src/urg_tcpclient.c new file mode 100644 index 0000000..3abc934 --- /dev/null +++ b/src/urg_c/current/src/urg_tcpclient.c @@ -0,0 +1,327 @@ +/*! + \file + \brief TCP/IP read/write functions + + \author Katsumi Kimoto + + $Id: urg_tcpclient.c,v d746d6f9127d 2011/05/08 23:10:44 satofumi $ +*/ + +// http://www.ne.jp/asahi/hishidama/home/tech/lang/socket.html + +#include "urg_c/urg_detect_os.h" +#include +#if defined(URG_WINDOWS_OS) +#else +#include +#include +#include +#endif +#include "urg_c/urg_tcpclient.h" + +#include + +enum { + Invalid_desc = -1, +}; + + +static void tcpclient_buffer_init(urg_tcpclient_t* cli) +{ + ring_initialize(&cli->rb, cli->buf, RB_BITSHIFT); +} + + +// get number of data in buffer. +static int tcpclient_buffer_data_num(urg_tcpclient_t* cli) +{ + return ring_size(&cli->rb); +} + + +static int tcpclient_buffer_write(urg_tcpclient_t* cli, + const char* data, int size) +{ + return ring_write(&cli->rb, data, size); +} + + +static int tcpclient_buffer_read(urg_tcpclient_t* cli, char* data, int size) +{ + return ring_read(&cli->rb, data, size); +} + + +static void set_block_mode(urg_tcpclient_t* cli) +{ +#if defined(URG_WINDOWS_OS) + u_long flag = 0; + ioctlsocket(cli->sock_desc, FIONBIO, &flag); +#else + int flag = 0; + fcntl(cli->sock_desc, F_SETFL, flag); +#endif +} + + +int tcpclient_open(urg_tcpclient_t* cli, const char* ip_str, int port_num) +{ + enum { Connect_timeout_second = 2 }; + fd_set rmask, wmask; + struct timeval tv = { Connect_timeout_second, 0 }; +#if defined(URG_WINDOWS_OS) + u_long flag; +#else + int flag; + int sock_optval = -1; + int sock_optval_size = sizeof(sock_optval); +#endif + int ret; + + cli->sock_desc = Invalid_desc; + cli->pushed_back = -1; // no pushed back char. + +#if defined(URG_WINDOWS_OS) + { + static int is_initialized = 0; + WORD wVersionRequested = 0x0202; + WSADATA WSAData; + int err; + if (!is_initialized) { + err = WSAStartup(wVersionRequested, &WSAData); + if (err != 0) { + return -1; + } + is_initialized = 1; + } + } +#endif + + tcpclient_buffer_init(cli); + + cli->sock_addr_size = sizeof (struct sockaddr_in); + if ((cli->sock_desc = (int)socket(AF_INET, SOCK_STREAM, 0)) < 0) { + return -1; + } + + memset((char*)&(cli->server_addr), 0, sizeof(cli->sock_addr_size)); + cli->server_addr.sin_family = AF_INET; + cli->server_addr.sin_port = htons(port_num); + + if (!strcmp(ip_str, "localhost")) { + ip_str = "127.0.0.1"; + } + + /* bind is not required, and port number is dynamic */ + if ((cli->server_addr.sin_addr.s_addr = inet_addr(ip_str)) == INADDR_NONE) { + return -1; + } + +#if defined(URG_WINDOWS_OS) + //ƒmƒ“ƒuƒ�ƒbƒN‚É•Ï�X + flag = 1; + ioctlsocket(cli->sock_desc, FIONBIO, &flag); + + if (connect(cli->sock_desc, (const struct sockaddr *)&(cli->server_addr), + cli->sock_addr_size) == SOCKET_ERROR) { + int error_number = WSAGetLastError(); + if (error_number != WSAEWOULDBLOCK) { + tcpclient_close(cli); + return -1; + } + + FD_ZERO(&rmask); + FD_SET((SOCKET)cli->sock_desc, &rmask); + wmask = rmask; + + ret = select((int)cli->sock_desc + 1, &rmask, &wmask, NULL, &tv); + if (ret == 0) { + // ƒ^ƒCƒ€ƒAƒEƒg + tcpclient_close(cli); + return -2; + } + } + //ƒuƒ�ƒbƒNƒ‚�[ƒh‚É‚·‚é + set_block_mode(cli); + +#else + //ƒmƒ“ƒuƒ�ƒbƒN‚É•Ï�X + flag = fcntl(cli->sock_desc, F_GETFL, 0); + fcntl(cli->sock_desc, F_SETFL, flag | O_NONBLOCK); + + if (connect(cli->sock_desc, (const struct sockaddr *)&(cli->server_addr), + cli->sock_addr_size) < 0) { + if (errno != EINPROGRESS) { + tcpclient_close(cli); + return -1; + } + + // EINPROGRESS:ƒRƒlƒNƒVƒ‡ƒ“—v‹�‚ÍŽn‚Ü‚Á‚½‚ª�A‚Ü‚¾Š®—¹‚µ‚Ä‚¢‚È‚¢ + FD_ZERO(&rmask); + FD_SET(cli->sock_desc, &rmask); + wmask = rmask; + + ret = select(cli->sock_desc + 1, &rmask, &wmask, NULL, &tv); + if (ret <= 0) { + // ƒ^ƒCƒ€ƒAƒEƒg�ˆ—� + tcpclient_close(cli); + return -2; + } + + if (getsockopt(cli->sock_desc, SOL_SOCKET, SO_ERROR, (int*)&sock_optval, + (socklen_t*)&sock_optval_size) != 0) { + // �Ú‘±‚ÉŽ¸”s + tcpclient_close(cli); + return -3; + } + + if (sock_optval != 0) { + // �Ú‘±‚ÉŽ¸”s + tcpclient_close(cli); + return -4; + } + + set_block_mode(cli); + } +#endif + + return 0; +} + + +void tcpclient_close(urg_tcpclient_t* cli) +{ + if (cli->sock_desc != Invalid_desc) { +#if defined(URG_WINDOWS_OS) + closesocket(cli->sock_desc); + //WSACleanup(); +#else + close(cli->sock_desc); +#endif + cli->sock_desc = Invalid_desc; + } +} + + +int tcpclient_read(urg_tcpclient_t* cli, + char* userbuf, int req_size, int timeout) +{ + // number of data in buffer. + int num_in_buf = tcpclient_buffer_data_num(cli); + int sock = cli->sock_desc; + int rem_size = req_size; // remaining size to be sent back. + int n; + + // copy data in buffer to user buffer and return with requested size. + if (num_in_buf > 0) { + n = tcpclient_buffer_read(cli, userbuf, req_size); + rem_size = req_size - n; // lacking size. + if (rem_size <= 0) { + return req_size; + } + + num_in_buf = tcpclient_buffer_data_num(cli); + } + + // data in buffer was not enough, read from socket to fill buffer, + // without blocking, i.e. read from system's buffer. + { + char tmpbuf[BUFSIZE]; + // receive with non-blocking mode. +#if defined(URG_WINDOWS_OS) + int no_timeout = 1; + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&no_timeout, sizeof(struct timeval)); + n = recv(sock, tmpbuf, BUFSIZE - num_in_buf, 0); +#else + n = recv(sock, tmpbuf, BUFSIZE - num_in_buf, MSG_DONTWAIT); +#endif + if (n > 0) { + tcpclient_buffer_write(cli, tmpbuf, n); // copy socket to my buffer + } + + n = tcpclient_buffer_read(cli, &userbuf[req_size-rem_size], rem_size); + // n never be greater than rem_size + rem_size -= n; + if (rem_size <= 0) { + return req_size; + } + } + + // lastly recv with blocking but with time out to read necessary size. + { +#if defined(URG_WINDOWS_OS) + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, + (const char *)&timeout, sizeof(struct timeval)); +#else + struct timeval tv; + tv.tv_sec = timeout / 1000; // millisecond to seccond + tv.tv_usec = (timeout % 1000) * 1000; // millisecond to microsecond + setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval)); +#endif + //4th arg 0:no flag + n = recv(sock, &userbuf[req_size-rem_size], rem_size, 0); + // n never be greater than rem_size + if (n > 0) { + rem_size -= n; + } + } + + return (req_size - rem_size); // last return may be less than req_size; +} + + +int tcpclient_write(urg_tcpclient_t* cli, const char* buf, int size) +{ + // blocking if data size is larger than system's buffer. + return send(cli->sock_desc, buf, size, 0); //4th arg 0: no flag +} + + +int tcpclient_error(urg_tcpclient_t* cli, char* error_message, int max_size) +{ + (void)cli; + (void)error_message; + (void)max_size; + + // not implemented yet. + + return -1; +} + + +int tcpclient_readline(urg_tcpclient_t* cli, + char* userbuf, int buf_size, int timeout) +{ + int n = 0; + int i = 0; + + if (cli->pushed_back > 0) { + userbuf[i] = cli->pushed_back; + i++; + cli->pushed_back = -1; + } + for (; i < buf_size; ++i) { + char ch; + n = tcpclient_read(cli, &ch, 1, timeout); + if (n <= 0) { + break; // error + } + if (ch == '\n' || ch == '\r') { + break; // success + } + userbuf[i] = ch; + } + + if (i >= buf_size) { // No CR or LF found. + --i; + cli->pushed_back = userbuf[buf_size - 1] & 0xff; + userbuf[buf_size - 1] = '\0'; + } + userbuf[i] = '\0'; + + if (i == 0 && n <= 0) { // error + return -1; + } + + return i; // the number of characters filled into user buffer. +} diff --git a/src/urg_c/current/src/urg_time.c b/src/urg_c/current/src/urg_time.c new file mode 100644 index 0000000..68824e1 --- /dev/null +++ b/src/urg_c/current/src/urg_time.c @@ -0,0 +1,89 @@ +/*! + \brief URG Æ’Zƒ“ƒT—p‚Ì•âÂ�•ŠÖÂ�â€� + + \author Satofumi KAMIMURA + + $Id: urg_utils.c,v da778fd816c2 2011/01/05 20:02:06 Satofumi $ +*/ + +#include "urg_c/urg_time.h" + +// Portable time function borrowed from ros::Time +void urg_walltime(unsigned long *sec, unsigned long *nsec) + { +#ifndef WIN32 +#if HAS_CLOCK_GETTIME + struct timespec start; + clock_gettime(CLOCK_REALTIME, &start); + *sec = start.tv_sec; + *nsec = start.tv_nsec; +#else + struct timeval timeofday; + gettimeofday(&timeofday,NULL); + sec = timeofday.tv_sec; + nsec = timeofday.tv_usec * 1000; +#endif +#else + // Win32 implementation + // unless I've missed something obvious, the only way to get high-precision + // time on Windows is via the QueryPerformanceCounter() call. However, + // this is somewhat problematic in Windows XP on some processors, especially + // AMD, because the Windows implementation can freak out when the CPU clocks + // down to save power. Time can jump or even go backwards. Microsoft has + // fixed this bug for most systems now, but it can still show up if you have + // not installed the latest CPU drivers (an oxymoron). They fixed all these + // problems in Windows Vista, and this API is by far the most accurate that + // I know of in Windows, so I'll use it here despite all these caveats + static LARGE_INTEGER cpu_freq, init_cpu_time; + static uint32_t start_sec = 0; + static uint32_t start_nsec = 0; + if ( ( start_sec == 0 ) && ( start_nsec == 0 ) ) + { + QueryPerformanceFrequency(&cpu_freq); + if (cpu_freq.QuadPart == 0) { + throw NoHighPerformanceTimersException(); + } + QueryPerformanceCounter(&init_cpu_time); + // compute an offset from the Epoch using the lower-performance timer API + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + LARGE_INTEGER start_li; + start_li.LowPart = ft.dwLowDateTime; + start_li.HighPart = ft.dwHighDateTime; + // why did they choose 1601 as the time zero, instead of 1970? + // there were no outstanding hard rock bands in 1601. +#ifdef _MSC_VER + start_li.QuadPart -= 116444736000000000Ui64; +#else + start_li.QuadPart -= 116444736000000000ULL; +#endif + start_sec = (uint32_t)(start_li.QuadPart / 10000000); // 100-ns units. odd. + start_nsec = (start_li.LowPart % 10000000) * 100; + } + LARGE_INTEGER cur_time; + QueryPerformanceCounter(&cur_time); + LARGE_INTEGER delta_cpu_time; + delta_cpu_time.QuadPart = cur_time.QuadPart - init_cpu_time.QuadPart; + // todo: how to handle cpu clock drift. not sure it's a big deal for us. + // also, think about clock wraparound. seems extremely unlikey, but possible + double d_delta_cpu_time = delta_cpu_time.QuadPart / (double) cpu_freq.QuadPart; + uint32_t delta_sec = (uint32_t) floor(d_delta_cpu_time); + uint32_t delta_nsec = (uint32_t) boost::math::round((d_delta_cpu_time-delta_sec) * 1e9); + + int64_t sec_sum = (int64_t)start_sec + (int64_t)delta_sec; + int64_t nsec_sum = (int64_t)start_nsec + (int64_t)delta_nsec; + + // Throws an exception if we go out of 32-bit range + normalizeSecNSecUnsigned(sec_sum, nsec_sum); + + sec = sec_sum; + nsec = nsec_sum; +#endif + } + +void urg_get_walltime(unsigned long long *nsecs){ + unsigned long sec; + unsigned long nsec; + urg_walltime(&sec, &nsec); + *nsecs = (unsigned long long)sec*1000000000ll + (unsigned long long)nsec; +} \ No newline at end of file diff --git a/src/urg_c/current/src/urg_utils.c b/src/urg_c/current/src/urg_utils.c new file mode 100644 index 0000000..2a272d1 --- /dev/null +++ b/src/urg_c/current/src/urg_utils.c @@ -0,0 +1,209 @@ +/*! + \brief URG ƒZƒ“ƒT—p‚Ì•â�•ŠÖ�” + + \author Satofumi KAMIMURA + + $Id: urg_utils.c,v da778fd816c2 2011/01/05 20:02:06 Satofumi $ +*/ + +#include "urg_c/urg_utils.h" +#include "urg_c/urg_errno.h" +#define _USE_MATH_DEFINES +#include + +#undef max +#undef min + + +static int max(int a, int b) +{ + return (a > b) ? a : b; +} + + +static int min(int a, int b) +{ + return (a < b) ? a : b; +} + + +const char *urg_error(const urg_t *urg) +{ + typedef struct + { + int no; + const char* message; + } error_messages_t; + + + error_messages_t errors[] = { + { URG_NO_ERROR, "no error." }, + { URG_UNKNOWN_ERROR, "unknown error." }, + { URG_NOT_CONNECTED, "not connected." }, + { URG_NOT_IMPLEMENTED, "not implemented." }, + { URG_INVALID_RESPONSE, "invalid response." }, + { URG_NO_RESPONSE, "no response." }, + + { URG_SEND_ERROR, "send error." }, + { URG_RECEIVE_ERROR, "receive error." }, + { URG_CHECKSUM_ERROR, "checksum error." }, + { URG_INVALID_PARAMETER, "invalid parameter." }, + { URG_MEASUREMENT_TYPE_MISMATCH, "measurement type mismatch." }, + + { URG_SERIAL_OPEN_ERROR, "could not open serial device." }, + { URG_NOT_DETECT_BAUDRATE_ERROR, "could not detect serial baudrate." }, + { URG_ETHERNET_OPEN_ERROR, "could not open ethernet port." }, + { URG_SCANNING_PARAMETER_ERROR, "scanning parameter error." }, + { URG_DATA_SIZE_PARAMETER_ERROR, "data size parameter error." }, + }; + + int n = sizeof(errors) / sizeof(errors[0]); + int i; + + for (i = 0; i < n; ++i) { + if (errors[i].no == urg->last_errno) { + return errors[i].message; + } + } + + return "Unknown error."; +} + + +void urg_distance_min_max(const urg_t *urg, + long *min_distance, long *max_distance) +{ + if (!urg->is_active) { + *min_distance = 1; + *max_distance = 0; + return; + } + + *min_distance = urg->min_distance; + + // urg_set_communication_data_size() ‚𔽉f‚µ‚½‹——£‚ð•Ô‚· + *max_distance = + (urg->range_data_byte == URG_COMMUNICATION_2_BYTE) ? + max(urg->max_distance, 4095) : urg->max_distance; +} + + +void urg_step_min_max(const urg_t *urg, int *min_index, int *max_index) +{ + if (!urg->is_active) { + *min_index = 1; + *max_index = 0; + return; + } + + *min_index = urg->first_data_index - urg->front_data_index; + *max_index = urg->last_data_index - urg->front_data_index; +} + + +long urg_scan_usec(const urg_t *urg) +{ + if (!urg->is_active) { + return URG_NOT_CONNECTED; + } + + return urg->scan_usec; +} + + +int urg_max_data_size(const urg_t *urg) +{ + if (!urg->is_active) { + return URG_NOT_CONNECTED; + } + return urg->last_data_index + 1; +} + + +double urg_index2rad(const urg_t *urg, int index) +{ + int actual_index; + int step; + + if (!urg->is_active) { + return URG_NOT_CONNECTED; + } + + actual_index = min(max(0, index), urg->last_data_index); + step = actual_index - urg->front_data_index + urg->received_first_index; + return urg_step2rad(urg, step); +} + + +double urg_index2deg(const urg_t *urg, int index) +{ + return urg_index2rad(urg, index) * 180.0 / M_PI; +} + + +int urg_rad2index(const urg_t *urg, double radian) +{ + int index; + + if (!urg->is_active) { + return URG_NOT_CONNECTED; + } + + index = + (int)(floor((urg->area_resolution * radian / (2.0 * M_PI) + 0.5))) + + urg->front_data_index; + + return min(max(0, index), urg->last_data_index); +} + + +int urg_deg2index(const urg_t *urg, double degree) +{ + return urg_rad2index(urg, degree * M_PI / 180.0); +} + + +int urg_rad2step(const urg_t *urg, double radian) +{ + if (!urg->is_active) { + return URG_NOT_CONNECTED; + } + + return urg_rad2index(urg, radian) - urg->front_data_index; +} + + +int urg_deg2step(const urg_t *urg, double degree) +{ + return urg_rad2step(urg, degree * M_PI / 180.0); +} + + +double urg_step2rad(const urg_t *urg, int step) +{ + if (!urg->is_active) { + return URG_NOT_CONNECTED; + } + + return (2.0 * M_PI) * step / urg->area_resolution; +} + + +double urg_step2deg(const urg_t *urg, int step) +{ + return urg_step2rad(urg, step) * 180.0 / M_PI; +} + + +int urg_step2index(const urg_t *urg, int step) +{ + int measure_step; + + if (!urg->is_active) { + return URG_NOT_CONNECTED; + } + + measure_step = step - urg->received_first_index; + return min(max(0, measure_step + urg->front_data_index), + urg->last_data_index); +} diff --git a/src/urg_c/current/urg_c-config.in b/src/urg_c/current/urg_c-config.in new file mode 100644 index 0000000..695e676 --- /dev/null +++ b/src/urg_c/current/urg_c-config.in @@ -0,0 +1,33 @@ +#!/bin/sh + +version=VERSION +prefix=PREFIX +includedir=${prefix}/include/urg_c +installlib=${prefix}/lib + +usage="Usage: urg_c-config [--version] [--cflags] [--libs]" + +if test $# -eq 0; then + echo "${usage}" 1>&2 + exit 1 +fi + +while test $# -gt 0; do + + case $1 in + --version) + echo "${version}" + ;; + --cflags) + echo -I${includedir} + ;; + --libs) + echo -lurg_c LIBS + ;; + *) + echo "${usage}" 1>&2 + exit 1 + ;; + esac + shift +done diff --git a/src/urg_c/current/viewers/Makefile b/src/urg_c/current/viewers/Makefile new file mode 100644 index 0000000..ba2a311 --- /dev/null +++ b/src/urg_c/current/viewers/Makefile @@ -0,0 +1,6 @@ +# viewers/ + +all : + +clean : + cd viewer_sdl/ && $(MAKE) clean diff --git a/src/urg_c/current/viewers/viewer_sdl/Makefile b/src/urg_c/current/viewers/viewer_sdl/Makefile new file mode 100644 index 0000000..0bd7e75 --- /dev/null +++ b/src/urg_c/current/viewers/viewer_sdl/Makefile @@ -0,0 +1,39 @@ +# viewers/viewer_sdl/ + +# Compile options +SRCDIR = ../../src +INCLUDEDIR = ../../include +CC = gcc +#CFLAGS = -O2 -Wall -Werror -W $(INCLUDE) `sdl-config --cflags` +CFLAGS = -g -O0 -Wall -Werror -W $(INCLUDE) `sdl-config --cflags` +INCLUDE = -I$(INCLUDEDIR) +LDFLAGS = -L/usr/X11/lib +ifeq ($(OS),Windows_NT) +LDLIBS = `sdl-config --libs` -lopengl32 -lwsock32 +else +LDLIBS = `sdl-config --libs` -lGL +endif + + +TARGET = viewer_sdl + +all : $(TARGET) + +clean : + $(RM) $(TARGET) *.o + +depend : + makedepend -Y -- $(INCLUDES) -- $(wildcard *.h *.c) + +.PHONY : all clean depend +###################################################################### +REQUIRE_LIB = $(SRCDIR)/liburg_c.a +$(REQUIRE_LIB) : $(wildcard $(SRCDIR)/*.[ch]) + cd $(@D)/ && $(MAKE) $(@F) + +viewer_sdl : plotter_sdl.o $(REQUIRE_LIB) + +# DO NOT DELETE + +plotter_sdl.o: plotter_sdl.h +viewer_sdl.o: plotter_sdl.h diff --git a/src/urg_c/current/viewers/viewer_sdl/plotter_sdl.c b/src/urg_c/current/viewers/viewer_sdl/plotter_sdl.c new file mode 100644 index 0000000..03ceaea --- /dev/null +++ b/src/urg_c/current/viewers/viewer_sdl/plotter_sdl.c @@ -0,0 +1,288 @@ +/*! + \file + \brief Plotter (SDL) + + \author Satofumi KAMIMURA + + $Id: plotter_sdl.c,v 540bc11f70c8 2011/05/08 23:04:49 satofumi $ + + \todo glDrawElements() を使ã�†ã‚ˆã�†ã�«ä¿®æ­£ã�™ã‚‹ + \todo MAX_POINTS ã�® 1081 ã�®æ•°ã‚’センサã�‹ã‚‰ã�®æƒ…å ±ã�§åˆ�期化ã�™ã‚‹ +*/ + +//#define USE_GL_2 1 + +#if defined(USE_GL_2) +#define GL_GLEXT_PROTOTYPES 1 +#define GL3_PROTOTYPES 1 +#endif +#include "plotter_sdl.h" +#include +#include + + +enum { + SCREEN_WIDTH = 640, + SCREEN_HEIGHT = 480, +}; + + +typedef struct +{ + GLfloat x; + GLfloat y; +} vector_t; + + +static SDL_Surface *screen_ = NULL; +static vector_t *points_ = NULL; +static size_t max_points_size_ = 0; +static size_t points_size_ = 0; +static double draw_magnify_ = 0.1; + + +static void opengl_initialize(void) +{ + int bpp = SDL_GetVideoInfo()->vfmt->BitsPerPixel; + + // Initialize the display + int rgb_size[3]; + switch (bpp) { + case 8: + rgb_size[0] = 3; + rgb_size[1] = 3; + rgb_size[2] = 2; + break; + + case 15: + case 16: + rgb_size[0] = 5; + rgb_size[1] = 5; + rgb_size[2] = 5; + break; + + default: + rgb_size[0] = 8; + rgb_size[1] = 8; + rgb_size[2] = 8; + break; + } + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, rgb_size[0]); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, rgb_size[1]); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, rgb_size[2]); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + //SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); +} + + +static void opengl_setup(void) +{ + glPushAttrib(GL_ENABLE_BIT); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glViewport(-1, -1, +1, +1); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glOrtho(-1.0, +1.0, -1.0, +1.0, -10.0, +10.0); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); + glShadeModel(GL_SMOOTH); +} + + +static void draw_points(void) +{ + +#if !defined(USE_GL_2) + size_t i; + + glBegin(GL_POINTS); + for (i = 0; i < points_size_; ++i) { + glVertex2i(points_[i].x, points_[i].y); + } + glEnd(); + + points_size_ = 0; + +#else + int memory_size = points_size * sizeof(points[0]); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + + glBindBuffer(GL_ARRAY_BUFFER, buffer_id); + glBufferData(GL_ARRAY_BUFFER, memory_size, points, GL_STATIC_DRAW); + + glInterleavedArrays(GL_V2F, 0, NULL); + glDrawArrays(GL_POINTS, 0, points_size); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + + points_size = 0; +#endif +} + + +static void enter2D(void) +{ + glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + + glOrtho(0.0, SCREEN_WIDTH - 1.0, 0.0, SCREEN_HEIGHT - 1.0, 0.0, 1.0); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); + + glTranslatef(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 0.0); +} + + +bool plotter_initialize(int data_size) +{ + points_ = malloc(data_size * sizeof(vector_t)); + if (!points_) { + return false; + } + max_points_size_ = data_size; + + if (SDL_Init(SDL_INIT_VIDEO) < 0) { + printf("SDL_Init: %s\n", SDL_GetError()); + return false; + } + + // ç”»é�¢ã�®ä½œæˆ� + opengl_initialize(); + screen_ = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_OPENGL); + if (!screen_) { + return false; + } + opengl_setup(); + + // æ��画設定 + glPointSize(2.0); +#if defined(USE_GL_2) + glGenBuffers(1, &buffer_id); +#endif + enter2D(); + + // データã�®ç¢ºä¿� + // !!! + + return true; +} + + +void plotter_terminate(void) +{ + SDL_Quit(); +} + + +void plotter_clear(void) +{ + glClearColor(0x00, 0x00, 0x00, 0xff); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +} + + +void plotter_swap(void) +{ + // 表示を入れæ�›ã�ˆã‚‹ã�¨ã��ã�«ã€�ã�¾ã� æ��ç”»ã�—ã�¦ã�„ã�ªã�„内容をæ��ç”»ã�™ã‚‹ + draw_points(); + + SDL_GL_SwapBuffers(); +} + + +void plotter_set_color(unsigned char r, unsigned g, unsigned b) +{ + // 色を変更ã�™ã‚‹ã�¨ã��ã�«ã€�ã�¾ã�¨ã‚�ã�¦æ��画を行ã�† + draw_points(); + + glColor3f(r / 255.0, g / 255.0, b / 255.0); +} + + +void plotter_plot(float x, float y) +{ + if (points_size_ >= max_points_size_) { + return; + } + + points_[points_size_].x = draw_magnify_ * x; + points_[points_size_].y = draw_magnify_ * y; + ++points_size_; +} + + +bool plotter_is_quit(void) +{ + bool is_quit = false; + int magnify = 0; + + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch (event.type) { + + case SDL_QUIT: + is_quit = true; + break; + + case SDL_KEYDOWN: + if ((event.key.keysym.sym == SDLK_q) || + (event.key.keysym.sym == SDLK_F4)) { + is_quit = true; + } + if (event.key.keysym.sym == SDLK_COMMA) { + --magnify; + } + if (event.key.keysym.sym == SDLK_PERIOD) { + ++magnify; + } + break; + + case SDL_MOUSEBUTTONDOWN: + if (event.button.button == SDL_BUTTON_WHEELUP) { + --magnify; + } else if (event.button.button == SDL_BUTTON_WHEELDOWN) { + ++magnify; + } + break; + } + } + + // æ��ç”»ã�®æ‹¡å¤§çŽ‡ã‚’å¤‰æ›´ã�™ã‚‹ + while (magnify < 0) { + draw_magnify_ *= 0.90; + ++magnify; + } + while (magnify > 0) { + draw_magnify_ *= 1.10; + --magnify; + } + if (draw_magnify_ < 0.001) { + draw_magnify_ = 0.001; + } else if (draw_magnify_ > 10.0) { + draw_magnify_ = 10.0; + } + + return is_quit; +} diff --git a/src/urg_c/current/viewers/viewer_sdl/plotter_sdl.h b/src/urg_c/current/viewers/viewer_sdl/plotter_sdl.h new file mode 100644 index 0000000..684b2e5 --- /dev/null +++ b/src/urg_c/current/viewers/viewer_sdl/plotter_sdl.h @@ -0,0 +1,24 @@ +#ifndef PLOTTER_SDL_H +#define PLOTTER_SDL_H + +/*! + \file + \brief Plotter (SDL) + + \author Satofumi KAMIMURA + + $Id: plotter_sdl.h,v 2a8d923c70f3 2010/08/08 12:22:29 Satofumi $ +*/ + +#include + + +extern bool plotter_initialize(int data_size); +extern void plotter_terminate(void); +extern void plotter_clear(void); +extern void plotter_swap(void); +extern void plotter_set_color(unsigned char r, unsigned g, unsigned b); +extern void plotter_plot(float x, float y); +extern bool plotter_is_quit(void); + +#endif /* !PLOTTER_SDL_H */ diff --git a/src/urg_c/current/viewers/viewer_sdl/viewer_sdl.c b/src/urg_c/current/viewers/viewer_sdl/viewer_sdl.c new file mode 100644 index 0000000..3b40da0 --- /dev/null +++ b/src/urg_c/current/viewers/viewer_sdl/viewer_sdl.c @@ -0,0 +1,241 @@ +/*! + \file + \brief Simple viewer (SDL) + + \author Satofumi KAMIMURA + + $Id: viewer_sdl.c,v d746d6f9127d 2011/05/08 23:10:44 satofumi $ +*/ + +#include "urg_sensor.h" +#include "urg_utils.h" +#include "urg_connection.h" +#include "plotter_sdl.h" +#include +#include + + +#if defined(URG_WINDOWS_OS) +static const char *serial_device = "COM4"; +#else +static const char *serial_device = "/dev/ttyACM0"; +#endif +static const char *ethernet_address = "192.168.0.10"; +//static const char *ethernet_address = "localhost"; + + +typedef struct +{ + urg_connection_type_t connection_type; + const char *device; + long baudrate_or_port; + urg_measurement_type_t measurement_type; + bool is_intensity; + bool is_multiecho; +} scan_mode_t; + + +static void help_exit(const char *program_name) +{ + printf("URG simple data viewer\n" + "usage:\n" + " %s [options]\n" + "\n" + "options:\n" + " -h, --help display this help and exit\n" + " -i, intensity mode\n" + " -m, multiecho mode\n" + "\n", + program_name); +} + + +static void parse_args(scan_mode_t *mode, int argc, char *argv[]) +{ + int i; + + mode->connection_type = URG_SERIAL; + mode->device = serial_device; + mode->baudrate_or_port = 115200; + mode->is_multiecho = false; + mode->is_intensity = false; + + for (i = 1; i < argc; ++i) { + const char *token = argv[i]; + + if (!strcmp(token, "-h") || !strcmp(token, "--help")) { + help_exit(argv[0]); + + } else if (!strcmp(token, "-e")) { + mode->connection_type = URG_ETHERNET; + mode->device = ethernet_address; + mode->baudrate_or_port = 10940; + + } else if (!strcmp(token, "-m")) { + mode->is_multiecho = true; + } else if (!strcmp(token, "-i")) { + mode->is_intensity = true; + } + } + + if (mode->is_multiecho) { + mode->measurement_type = + (mode->is_intensity) ? URG_MULTIECHO_INTENSITY : URG_MULTIECHO; + } else { + mode->measurement_type = + (mode->is_intensity) ? URG_DISTANCE_INTENSITY : URG_DISTANCE; + } +} + + +static void plot_data_point(urg_t *urg, long data[], unsigned short intensity[], + int data_n, bool is_multiecho, int offset) +{ + long min_distance; + long max_distance; + const double radian_offset = M_PI / 2.0; + int step = (is_multiecho) ? 3 : 1; + int i; + + urg_distance_min_max(urg, &min_distance, &max_distance); + + for (i = 0; i < data_n; ++i) { + int index = (step * i) + offset; + long l = (data) ? data[index] : intensity[index]; + double rad; + float x; + float y; + + if ((l <= min_distance) || (l >= max_distance)) { + continue; + } + + rad = urg_index2rad(urg, i) + radian_offset; + x = l * cos(rad); + y = l * sin(rad); + plotter_plot(x, y); + } +} + + +static void plot_data(urg_t *urg, + long data[], unsigned short intensity[], int data_n, + bool is_multiecho) +{ + plotter_clear(); + + // è·�離 + plotter_set_color(0x00, 0xff, 0xff); + plot_data_point(urg, data, NULL, data_n, is_multiecho, 0); + + if (is_multiecho) { + plotter_set_color(0xff, 0x00, 0xff); + plot_data_point(urg, data, NULL, data_n, is_multiecho, 1); + + plotter_set_color(0x00, 0x00, 0xff); + plot_data_point(urg, data, NULL, data_n, is_multiecho, 2); + } + + if (intensity) { + // 強度 + plotter_set_color(0xff, 0xff, 0x00); + plot_data_point(urg, NULL, intensity, data_n, is_multiecho, 0); + + if (is_multiecho) { + plotter_set_color(0xff, 0x00, 0x00); + plot_data_point(urg, NULL, intensity, data_n, is_multiecho, 1); + + plotter_set_color(0x00, 0xff, 0x00); + plot_data_point(urg, NULL, intensity, data_n, is_multiecho, 2); + } + } + + plotter_swap(); +} + + +int main(int argc, char *argv[]) +{ + scan_mode_t mode; + urg_t urg; + long *data = NULL; + unsigned short *intensity = NULL; + //long previous_timestamp = 0; + long timestamp; + int data_size; + + + // 引数ã�®è§£æž� + parse_args(&mode, argc, argv); + + // URG ã�«æŽ¥ç¶š + if (urg_open(&urg, mode.connection_type, + mode.device, mode.baudrate_or_port)) { + printf("urg_open: %s\n", urg_error(&urg)); + return 1; + } + + // データå�–å¾—ã�®æº–å‚™ + data_size = urg_max_data_size(&urg); + if (mode.is_multiecho) { + data_size *= 3; + } + data = malloc(data_size * sizeof(data[0])); + if (mode.is_intensity) { + intensity = malloc(data_size * sizeof(intensity[0])); + } + + // ç”»é�¢ã�®ä½œæˆ� + if (!plotter_initialize(data_size * ((mode.is_intensity) ? 2 : 1))) { + return 1; + } + + // データã�®å�–å¾—ã�¨æ��ç”» + urg_start_measurement(&urg, mode.measurement_type, URG_SCAN_INFINITY, 0); + while (1) { + int n; + //urg_start_measurement(&urg, mode.measurement_type, 1, 0); + switch (mode.measurement_type) { + case URG_DISTANCE: + n = urg_get_distance(&urg, data, ×tamp); + break; + + case URG_DISTANCE_INTENSITY: + n = urg_get_distance_intensity(&urg, data, intensity, ×tamp); + break; + + case URG_MULTIECHO: + n = urg_get_multiecho(&urg, data, ×tamp); + break; + + case URG_MULTIECHO_INTENSITY: + n = urg_get_multiecho_intensity(&urg, data, intensity, ×tamp); + break; + + default: + n = 0; + break; + } + + if (n <= 0) { + printf("urg_get_function: %s\n", urg_error(&urg)); + break; + } + + //fprintf(stderr, "%ld, ", timestamp - previous_timestamp); + //previous_timestamp = timestamp; + + plot_data(&urg, data, intensity, n, mode.is_multiecho); + if (plotter_is_quit()) { + break; + } + } + + // リソースã�®è§£æ”¾ + plotter_terminate(); + free(intensity); + free(data); + urg_close(&urg); + + return 0; +} diff --git a/src/urg_c/current/visual_cpp/calculate_xy/calculate_xy.vcproj b/src/urg_c/current/visual_cpp/calculate_xy/calculate_xy.vcproj new file mode 100644 index 0000000..08803c1 --- /dev/null +++ b/src/urg_c/current/visual_cpp/calculate_xy/calculate_xy.vcproj @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/urg_c/current/visual_cpp/find_port/find_port.vcproj b/src/urg_c/current/visual_cpp/find_port/find_port.vcproj new file mode 100644 index 0000000..5df77eb --- /dev/null +++ b/src/urg_c/current/visual_cpp/find_port/find_port.vcproj @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/urg_c/current/visual_cpp/get_distance/get_distance.vcproj b/src/urg_c/current/visual_cpp/get_distance/get_distance.vcproj new file mode 100644 index 0000000..6d4fe33 --- /dev/null +++ b/src/urg_c/current/visual_cpp/get_distance/get_distance.vcproj @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/urg_c/current/visual_cpp/get_distance_intensity/get_distance_intensity.vcproj b/src/urg_c/current/visual_cpp/get_distance_intensity/get_distance_intensity.vcproj new file mode 100644 index 0000000..3b40d3b --- /dev/null +++ b/src/urg_c/current/visual_cpp/get_distance_intensity/get_distance_intensity.vcproj @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/urg_c/current/visual_cpp/get_multiecho/get_multiecho.vcproj b/src/urg_c/current/visual_cpp/get_multiecho/get_multiecho.vcproj new file mode 100644 index 0000000..705bd23 --- /dev/null +++ b/src/urg_c/current/visual_cpp/get_multiecho/get_multiecho.vcproj @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/urg_c/current/visual_cpp/get_multiecho_intensity/get_multiecho_intensity.vcproj b/src/urg_c/current/visual_cpp/get_multiecho_intensity/get_multiecho_intensity.vcproj new file mode 100644 index 0000000..5dfc6bd --- /dev/null +++ b/src/urg_c/current/visual_cpp/get_multiecho_intensity/get_multiecho_intensity.vcproj @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/urg_c/current/visual_cpp/sensor_parameter/sensor_parameter.vcproj b/src/urg_c/current/visual_cpp/sensor_parameter/sensor_parameter.vcproj new file mode 100644 index 0000000..3b67e00 --- /dev/null +++ b/src/urg_c/current/visual_cpp/sensor_parameter/sensor_parameter.vcproj @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/urg_c/current/visual_cpp/sync_time_stamp/sync_time_stamp.vcproj b/src/urg_c/current/visual_cpp/sync_time_stamp/sync_time_stamp.vcproj new file mode 100644 index 0000000..a6859dd --- /dev/null +++ b/src/urg_c/current/visual_cpp/sync_time_stamp/sync_time_stamp.vcproj @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/urg_c/current/visual_cpp/urg.sln b/src/urg_c/current/visual_cpp/urg.sln new file mode 100644 index 0000000..f853f04 --- /dev/null +++ b/src/urg_c/current/visual_cpp/urg.sln @@ -0,0 +1,92 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "urg", "urg\urg.vcproj", "{269630A6-5F78-484F-A729-5CD301B5CABA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sensor_parameter", "sensor_parameter\sensor_parameter.vcproj", "{3347DEB1-A1EC-4242-8079-233B9E5EB0C3}" + ProjectSection(ProjectDependencies) = postProject + {269630A6-5F78-484F-A729-5CD301B5CABA} = {269630A6-5F78-484F-A729-5CD301B5CABA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "get_distance", "get_distance\get_distance.vcproj", "{8F73522C-18D0-4436-B444-3E17A2A84788}" + ProjectSection(ProjectDependencies) = postProject + {269630A6-5F78-484F-A729-5CD301B5CABA} = {269630A6-5F78-484F-A729-5CD301B5CABA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "get_distance_intensity", "get_distance_intensity\get_distance_intensity.vcproj", "{17A43425-7F91-4D65-A28A-C90B3E22863F}" + ProjectSection(ProjectDependencies) = postProject + {269630A6-5F78-484F-A729-5CD301B5CABA} = {269630A6-5F78-484F-A729-5CD301B5CABA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "get_multiecho", "get_multiecho\get_multiecho.vcproj", "{0C8D756A-E46E-4EA0-8719-5807E6A7A5C0}" + ProjectSection(ProjectDependencies) = postProject + {269630A6-5F78-484F-A729-5CD301B5CABA} = {269630A6-5F78-484F-A729-5CD301B5CABA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "get_multiecho_intensity", "get_multiecho_intensity\get_multiecho_intensity.vcproj", "{AFB48029-6ADD-4F7A-A36C-6F0A67BC0D2C}" + ProjectSection(ProjectDependencies) = postProject + {269630A6-5F78-484F-A729-5CD301B5CABA} = {269630A6-5F78-484F-A729-5CD301B5CABA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "calculate_xy", "calculate_xy\calculate_xy.vcproj", "{64658378-45FE-4BA5-9C28-1A91CDC6C4EB}" + ProjectSection(ProjectDependencies) = postProject + {269630A6-5F78-484F-A729-5CD301B5CABA} = {269630A6-5F78-484F-A729-5CD301B5CABA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sync_time_stamp", "sync_time_stamp\sync_time_stamp.vcproj", "{EF96A9B9-81AE-4B35-81EC-68DB295963DB}" + ProjectSection(ProjectDependencies) = postProject + {269630A6-5F78-484F-A729-5CD301B5CABA} = {269630A6-5F78-484F-A729-5CD301B5CABA} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "find_port", "find_port\find_port.vcproj", "{B1E1DC1F-F6C1-4A11-8A7D-D30E0211A18E}" + ProjectSection(ProjectDependencies) = postProject + {269630A6-5F78-484F-A729-5CD301B5CABA} = {269630A6-5F78-484F-A729-5CD301B5CABA} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {269630A6-5F78-484F-A729-5CD301B5CABA}.Debug|Win32.ActiveCfg = Debug|Win32 + {269630A6-5F78-484F-A729-5CD301B5CABA}.Debug|Win32.Build.0 = Debug|Win32 + {269630A6-5F78-484F-A729-5CD301B5CABA}.Release|Win32.ActiveCfg = Release|Win32 + {269630A6-5F78-484F-A729-5CD301B5CABA}.Release|Win32.Build.0 = Release|Win32 + {3347DEB1-A1EC-4242-8079-233B9E5EB0C3}.Debug|Win32.ActiveCfg = Debug|Win32 + {3347DEB1-A1EC-4242-8079-233B9E5EB0C3}.Debug|Win32.Build.0 = Debug|Win32 + {3347DEB1-A1EC-4242-8079-233B9E5EB0C3}.Release|Win32.ActiveCfg = Release|Win32 + {3347DEB1-A1EC-4242-8079-233B9E5EB0C3}.Release|Win32.Build.0 = Release|Win32 + {8F73522C-18D0-4436-B444-3E17A2A84788}.Debug|Win32.ActiveCfg = Debug|Win32 + {8F73522C-18D0-4436-B444-3E17A2A84788}.Debug|Win32.Build.0 = Debug|Win32 + {8F73522C-18D0-4436-B444-3E17A2A84788}.Release|Win32.ActiveCfg = Release|Win32 + {8F73522C-18D0-4436-B444-3E17A2A84788}.Release|Win32.Build.0 = Release|Win32 + {17A43425-7F91-4D65-A28A-C90B3E22863F}.Debug|Win32.ActiveCfg = Debug|Win32 + {17A43425-7F91-4D65-A28A-C90B3E22863F}.Debug|Win32.Build.0 = Debug|Win32 + {17A43425-7F91-4D65-A28A-C90B3E22863F}.Release|Win32.ActiveCfg = Release|Win32 + {17A43425-7F91-4D65-A28A-C90B3E22863F}.Release|Win32.Build.0 = Release|Win32 + {0C8D756A-E46E-4EA0-8719-5807E6A7A5C0}.Debug|Win32.ActiveCfg = Debug|Win32 + {0C8D756A-E46E-4EA0-8719-5807E6A7A5C0}.Debug|Win32.Build.0 = Debug|Win32 + {0C8D756A-E46E-4EA0-8719-5807E6A7A5C0}.Release|Win32.ActiveCfg = Release|Win32 + {0C8D756A-E46E-4EA0-8719-5807E6A7A5C0}.Release|Win32.Build.0 = Release|Win32 + {AFB48029-6ADD-4F7A-A36C-6F0A67BC0D2C}.Debug|Win32.ActiveCfg = Debug|Win32 + {AFB48029-6ADD-4F7A-A36C-6F0A67BC0D2C}.Debug|Win32.Build.0 = Debug|Win32 + {AFB48029-6ADD-4F7A-A36C-6F0A67BC0D2C}.Release|Win32.ActiveCfg = Release|Win32 + {AFB48029-6ADD-4F7A-A36C-6F0A67BC0D2C}.Release|Win32.Build.0 = Release|Win32 + {64658378-45FE-4BA5-9C28-1A91CDC6C4EB}.Debug|Win32.ActiveCfg = Debug|Win32 + {64658378-45FE-4BA5-9C28-1A91CDC6C4EB}.Debug|Win32.Build.0 = Debug|Win32 + {64658378-45FE-4BA5-9C28-1A91CDC6C4EB}.Release|Win32.ActiveCfg = Release|Win32 + {64658378-45FE-4BA5-9C28-1A91CDC6C4EB}.Release|Win32.Build.0 = Release|Win32 + {EF96A9B9-81AE-4B35-81EC-68DB295963DB}.Debug|Win32.ActiveCfg = Debug|Win32 + {EF96A9B9-81AE-4B35-81EC-68DB295963DB}.Debug|Win32.Build.0 = Debug|Win32 + {EF96A9B9-81AE-4B35-81EC-68DB295963DB}.Release|Win32.ActiveCfg = Release|Win32 + {EF96A9B9-81AE-4B35-81EC-68DB295963DB}.Release|Win32.Build.0 = Release|Win32 + {B1E1DC1F-F6C1-4A11-8A7D-D30E0211A18E}.Debug|Win32.ActiveCfg = Debug|Win32 + {B1E1DC1F-F6C1-4A11-8A7D-D30E0211A18E}.Debug|Win32.Build.0 = Debug|Win32 + {B1E1DC1F-F6C1-4A11-8A7D-D30E0211A18E}.Release|Win32.ActiveCfg = Release|Win32 + {B1E1DC1F-F6C1-4A11-8A7D-D30E0211A18E}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/urg_c/current/visual_cpp/urg/urg.vcproj b/src/urg_c/current/visual_cpp/urg/urg.vcproj new file mode 100644 index 0000000..e28e6a3 --- /dev/null +++ b/src/urg_c/current/visual_cpp/urg/urg.vcproj @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/urg_c/current/windowsexe/cleanobj.bat b/src/urg_c/current/windowsexe/cleanobj.bat new file mode 100644 index 0000000..01743cf --- /dev/null +++ b/src/urg_c/current/windowsexe/cleanobj.bat @@ -0,0 +1,3 @@ +REM Cleaning obj, exe, and manifest files + +del *.obj *.exe *.manifest diff --git a/src/urg_c/current/windowsexe/compile.bat b/src/urg_c/current/windowsexe/compile.bat new file mode 100644 index 0000000..647a149 --- /dev/null +++ b/src/urg_c/current/windowsexe/compile.bat @@ -0,0 +1,32 @@ +REM Compile URG library + +cl.exe -c -MD -I../include ../src/urg_sensor.c +cl.exe -c -MD -I../include ../src/urg_utils.c +cl.exe -c -MD -I../include ../src/urg_connection.c +cl.exe -c -MD -I../include ../src/urg_serial.c +cl.exe -c -MD -I../include ../src/urg_serial_utils.c +cl.exe -c -MD -I../include ../src/urg_tcpclient.c +cl.exe -c -MD -I../include ../src/urg_ring_buffer.c + +REM Compile sample utility + +cl.exe -c -MD -I../include ../samples/open_urg_sensor.c + +REM Compile samples linking with ws2_32.lib setupapi.lib with /MD option. + +cl.exe /MD -I../include ../samples/sensor_parameter.c open_urg_sensor.obj urg_sensor.obj urg_utils.obj urg_connection.obj urg_serial.obj urg_serial_utils.obj urg_tcpclient.obj urg_ring_buffer.obj ws2_32.lib setupapi.lib + +cl.exe /MD -I../include ../samples/calculate_xy.c open_urg_sensor.obj urg_sensor.obj urg_utils.obj urg_connection.obj urg_serial.obj urg_serial_utils.obj urg_tcpclient.obj urg_ring_buffer.obj ws2_32.lib setupapi.lib + +cl.exe /MD -I../include ../samples/get_multiecho_intensity.c open_urg_sensor.obj urg_sensor.obj urg_utils.obj urg_connection.obj urg_serial.obj urg_serial_utils.obj urg_tcpclient.obj urg_ring_buffer.obj ws2_32.lib setupapi.lib + +cl.exe /MD -I../include ../samples/find_port.c open_urg_sensor.obj urg_sensor.obj urg_utils.obj urg_connection.obj urg_serial.obj urg_serial_utils.obj urg_tcpclient.obj urg_ring_buffer.obj ws2_32.lib setupapi.lib + +cl.exe /MD -I../include ../samples/get_distance.c open_urg_sensor.obj urg_sensor.obj urg_utils.obj urg_connection.obj urg_serial.obj urg_serial_utils.obj urg_tcpclient.obj urg_ring_buffer.obj ws2_32.lib setupapi.lib + +cl.exe /MD -I../include ../samples/get_distance_intensity.c open_urg_sensor.obj urg_sensor.obj urg_utils.obj urg_connection.obj urg_serial.obj urg_serial_utils.obj urg_tcpclient.obj urg_ring_buffer.obj ws2_32.lib setupapi.lib + +cl.exe /MD -I../include ../samples/sync_time_stamp.c open_urg_sensor.obj urg_sensor.obj urg_utils.obj urg_connection.obj urg_serial.obj urg_serial_utils.obj urg_tcpclient.obj urg_ring_buffer.obj ws2_32.lib setupapi.lib + +cl.exe /MD -I../include ../samples/get_multiecho.c open_urg_sensor.obj urg_sensor.obj urg_utils.obj urg_connection.obj urg_serial.obj urg_serial_utils.obj urg_tcpclient.obj urg_ring_buffer.obj ws2_32.lib setupapi.lib + diff --git a/src/urg_c/package.xml b/src/urg_c/package.xml new file mode 100644 index 0000000..1bbb718 --- /dev/null +++ b/src/urg_c/package.xml @@ -0,0 +1,24 @@ + + + urg_c + 1.0.405 + The urg_c package + + Chad Rockey + Tony Baltovski + + BSD + + http://sourceforge.net/projects/urgwidget/ + https://github.com/ros-drivers/urg_c/issues + https://github.com/ros-drivers/urg_c + + Satofumi Kamimura + Katsumi Kimoto + Adrian Boeing + + catkin + + + + diff --git a/src/urg_c/split_comment.rb b/src/urg_c/split_comment.rb new file mode 100644 index 0000000..daa2f99 --- /dev/null +++ b/src/urg_c/split_comment.rb @@ -0,0 +1,144 @@ +#!/usr/bin/env ruby +# -*- coding: cp932 -*- + +# Doxygen ƒRƒ�ƒ“ƒg‚É�]‚Á‚Ä‘Î�Ûƒtƒ@ƒCƒ‹‚ðƒRƒs�[‚·‚邯‚«‚̃Rƒ�ƒ“ƒg�o—Í‚ð’²�®‚·‚é + +#$KCODE = "SJIS" + + +if ARGV.empty? + print "usage: \n" + + " " + __FILE__ + " [options] \n" + + "\n" + + "[options]\n" + + " -e output english comment.\n" + + " -j output Japanese comment.\n" + + "\n" + exit(1) +end + + +# �ÅŒã‚̈ø�”‚ªƒfƒBƒŒƒNƒgƒŠ‚łȂ¯‚ê‚Î�AƒGƒ‰�[ƒ�ƒbƒZ�[ƒW‚ð•Ô‚· +output_directory = ARGV.pop +output_mode = ARGV.shift +if not FileTest::directory?(output_directory) + print "No such directory: " + output_directory + "\n" + exit(1) +end +target_files = ARGV + + +def split_single_line(line, mode, output_mode) + + # Œ»�݂̃‚�[ƒh‚É�]‚Á‚½ƒRƒ�ƒ“ƒg‚݂̂ð�o—Í‚·‚é + if output_mode == "-e" then + if line =~ /\\\~japanese .+ ([\*\\])/ + line = $` + $1 + $' + end + if line =~ /\\\~english / + line = $` + $' + end + end + + if output_mode == "-j" + if line =~ /\\\~english .+ ([\*\\])/ + line = $` + $1 + $' + end + if line =~ /\\\~japanese / + line = $` + $' + end + end + + return line +end + + +def remove_matched_word(line) + + if line.strip == "" + line = "" + end + line +end + + +# Doxygen ƒRƒ�ƒ“ƒg‚É�]‚Á‚Ä‘Î�Ûƒtƒ@ƒCƒ‹‚ðƒRƒs�[‚·‚邯‚«‚̃Rƒ�ƒ“ƒg�o—Í‚ð’²�®‚·‚é +def split_comment(file_name, output_mode) + lines = "" + mode = "both" + is_comment = false + + p file_name + File.open(file_name) { |fd| + fd.each { |line| + line.force_encoding("cp932") + + if is_comment + # ƒRƒ�ƒ“ƒg’† + case line + when /\\\~japanese/ + mode = "japanese" + line = $` + $' + if line.strip == "" + line = "" + end + when /\\\~english/ + mode = "japanese" + line = $` + $' + if line.strip == "" + line = "" + end + when /\\\~/ + mode = "both" + line = remove_matched_word($` + $') + end + if line =~ /\*\// + is_comment = false + lines += line + else + # ƒ‚�[ƒh‚É�]‚Á‚ăRƒ�ƒ“ƒg‚ð�o—Í‚·‚é + if mode == "japanese" and output_mode == "-j" + lines += line + elsif mode == "english" and output_mode == "-e" + lines += line + elsif mode == "both" + lines += line + end + end + else + # ƒ\�[ƒXƒR�[ƒh’† + if line =~ /\/\*/ + if line =~ /\*\// + is_comment = false + line = split_single_line(line, mode, output_mode) + else + is_comment = true + mode = "both" + end + else + # // ƒRƒ�ƒ“ƒg‚Ì�ê�‡‚Ì�ˆ—� + case line + when /~japanese/ + line = split_single_line(line, mode, output_mode) + when /~english/ + line = split_single_line(line, mode, output_mode) + end + end + lines += line + end + } + } + + lines +end + + +# ‘Î�ۂ̃tƒ@ƒCƒ‹‚ð�ˆ—�‚µ‚‚Â�AŽw’肳‚ꂽƒfƒBƒŒƒNƒgƒŠ‚ɃRƒs�[‚·‚é +target_files.each { |file_name| + converted_lines = split_comment(file_name, output_mode) + converted_file_name = output_directory + "/" + File.basename(file_name) + + File.open(converted_file_name, "w") { |fd| + fd.print converted_lines + } +} diff --git a/src/urg_node/.travis.yml b/src/urg_node/.travis.yml new file mode 100644 index 0000000..34dbc3d --- /dev/null +++ b/src/urg_node/.travis.yml @@ -0,0 +1,32 @@ +# This config uses industrial_ci (https://github.com/ros-industrial/industrial_ci.git). +# For troubleshooting, see readme (https://github.com/ros-industrial/industrial_ci/blob/master/README.rst) + +language: generic # optional, just removes the language badge + +services: + - docker + +# include the following block if the C/C++ build artifacts should get cached by Travis, +# CCACHE_DIR needs to get set as well to actually fill the cache +cache: + directories: + - $HOME/.ccache + +git: + quiet: true # optional, silences the cloning of the target repository + +# configure the build environment(s) +# https://github.com/ros-industrial/industrial_ci/blob/master/doc/index.rst#variables-you-can-configure +env: + global: # global settings for all jobs + - ROS_REPO=ros + - CCACHE_DIR=$HOME/.ccache # enables C/C++ caching in industrial_ci + matrix: # each line is a job + - ROS_DISTRO="kinetic" + - ROS_DISTRO="melodic" + +# clone and run industrial_ci +install: + - git clone --quiet --depth 1 https://github.com/ros-industrial/industrial_ci.git .industrial_ci -b master +script: + - .industrial_ci/travis.sh diff --git a/src/urg_node/CHANGELOG.rst b/src/urg_node/CHANGELOG.rst new file mode 100644 index 0000000..0b7fc76 --- /dev/null +++ b/src/urg_node/CHANGELOG.rst @@ -0,0 +1,159 @@ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Changelog for package urg_node +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +0.1.15 (2020-10-27) +------------------- +* Function setSkip() set as void + This function as no return type causing undefined behavior. This function + has been declared as void. +* Contributors: bostoncleek + +0.1.14 (2020-06-04) +------------------- +* Bumped CMake version. +* Removed trailing whitespace. +* Contributors: Tony Baltovski + +0.1.13 (2020-03-27) +------------------- +* Revert "fix(updateStatus): Update status on diagnostics update" +* Contributors: Tony Baltovski + +0.1.12 (2020-03-14) +------------------- +* Updated roslint to only check files in this repo. +* Updated TravisCI config. +* fix(updateStatus): Update status on diagnostics update + Otherwise the diagnostics information does not really reflect the device + status. +* synchronize_time: reset when clock is warped + If either the hardware clock or system clock warp, reset the EMA to + prevent incorrect clock values from being used. Detect the warp by + putting a limit on the absolute error between the synchronized clock + and the system clock. When a warp is detected, reset the EMA to force + the clocks to resynchronize. Use the system clock until the EMA has + stabalized again. +* synchronize system clock to hardware time + Remove jitter from the system clock by synchronizing it to the change + in hardware time stamps. This does not synchrnoize it in an absolute + sense (i.e., doesn't remove system latench). However, coupled with + calibrating system latency, this results in a stable, accurate clock. +* Add Travis config. +* Fixed linter errors. +* Contributors: C. Andy Martin, Rein Appeldoorn, Tony Baltovski + +0.1.11 (2017-10-17) +------------------- +* Add support for URG-04LX in SCIP 1.1 mode + The urg_node does not support SCIP 1.1. The Hokuyo URG-04LX supports both + SCIP 1.1 and SCIP 2.0, but needs to be switched to SCIP 2.0 at every startup + in its default configuration. For this purpose the function + URGCWrapper::setToSCIP2() was added. + A URG-04LX in SCIP 1.1 mode used to lead to an exception being thrown in + URGCwrapper::initialize. Now, before throwing the exception an attempt to + switch the sensor to SCIP 2.0 is made. +* Fixed comments in launch file and added roslaunch. +* Add flag to prevent updating of detailed status. + If using a model that does not support AR00 command, hide it + behind a rosparam. +* Add safety stop heading and distance values (`#28 `_) + Added to the laser status field the last report of a safety + stop of distance and angle reported. If this fails or is unavailable + it will just report 0. +* Updating depend and roslint. + Fixing some roslint error after moving a header name. + Additionally fixing the gencfg to be on the lib and not the node. +* Adding missing std_srvs depend. + Adding missing std_srvs depend to package.xml and CMakelists.txt +* Move urg_node to be a library. + Moving urg_node to urg_node_driver as a library. + This allows for other nodes to include this as an object instead + of spawning another separate process. +* Add getAR00 status command. + Added ability to pull the status of the lidar AR00 status command. + This then publishes a latched topic with the current status of the + lidar's error code and lockout status. +* Update urg_node to be a self contained class + Updating urg node to be a self contained class. This allows + for it to be imported in other nodes. +* Roslint +* Contributors: Benjamin Scholz, Mike O'Driscoll, Tony Baltovski + +0.1.10 (2017-03-21) +------------------- +* Updated maintainer. +* Error handling for connection failures +* Created urg_lidar.launch +* Installed getID +* Contributors: Eric Tappan, Jeff Schmidt, Kei Okada, Tony Baltovski + +0.1.9 (2014-08-13) +------------------ +* Merge pull request `#7 `_ from mikeferguson/indigo-devel + add a script to set the IP address of an URG laser +* Updated diagnostics to support configurable parameters. +* add a script to set the IP address of an URG laser +* Contributors: Chad Rockey, Michael Ferguson + +0.1.8 (2014-06-16) +------------------ +* Merge pull request `#6 `_ from mikeferguson/indigo-devel + Add default device status on UST-20LX +* Add default device status on UST-20LX +* Contributors: Chad Rockey, Michael Ferguson + +0.1.7 (2014-04-21) +------------------ +* Added more robust plug/unplug reconnect behavior. +* Added more robustness and the ability to continually reloop and reconnect until node is shutdown. +* Fix initialization crash. +* Install fix for Android. +* Missed a willowgarage email. +* Contributors: Chad Rockey + +0.1.6 (2013-10-24) +------------------ +* Added getID executable for udev users. + +0.1.5 (2013-08-22) +------------------ +* Missing diagnostic_updater depend + +0.1.4 (2013-08-22) +------------------ +* Merge pull request `#2 `_ from mitll-ros-pkg/diagnostics + Added diagnostics to the URG Node. +* Added diagnostics to the URG Node. + +0.1.3 (2013-08-21) +------------------ +* No more Willow Garage email. + +0.1.2 (2013-03-14) +------------------ +* Be more tolerant of connection dropouts and try to reconnect. +* Fixed poor initilization causing uncertain output. +* Updated consts + +0.1.1 (2013-03-04) +------------------ +* Only advertise for single or multiecho, not both. +* Generalized multi echo grab function +* Updated to use laser_proc to automatically publish compatibility messages. +* Optimize the fill multi echo laserscan message to use reserve instead of resize wherever possible. + +0.1.0 (2013-03-03) +------------------ +* Added install rules. +* Renamed package to urg_node. +* Updated to use better timestamping. +* Updated to use urg_c name for library. +* Added information functions for future diagnostics. +* Added experimental timestamp synchronization. Fixed segfault for multiecho intensity. +* Fixed skip being cluster. Added skip functionallity. +* Connected dynamic reconfigure, including angle limit requests. +* Added ability to publish both single and multi echo scans. +* Added dynamic reconfigure; can update reconfigure limits +* Initial commit. Connecting to both ethernet and serial devices. +* Initial commit diff --git a/src/urg_node/CMakeLists.txt b/src/urg_node/CMakeLists.txt new file mode 100644 index 0000000..887f72b --- /dev/null +++ b/src/urg_node/CMakeLists.txt @@ -0,0 +1,91 @@ +cmake_minimum_required(VERSION 3.0.2) +project(urg_node) + +find_package(catkin REQUIRED COMPONENTS + diagnostic_updater dynamic_reconfigure laser_proc message_generation + nodelet rosconsole roscpp sensor_msgs std_msgs std_srvs tf urg_c +) +set_directory_properties(PROPERTIES COMPILE_OPTIONS "-std=c++11") + +# Dynamic reconfigure support +generate_dynamic_reconfigure_options(cfg/URG.cfg) + +add_message_files(FILES + Status.msg +) + +generate_messages( + DEPENDENCIES std_msgs +) + +catkin_package( + INCLUDE_DIRS include + LIBRARIES urg_c_wrapper urg_node_driver + CATKIN_DEPENDS dynamic_reconfigure laser_proc message_runtime nodelet rosconsole + roscpp sensor_msgs std_msgs std_srvs urg_c + DEPENDS +) + + +include_directories(include ${catkin_INCLUDE_DIRS}) + +## Declare a cpp library +add_library(urg_c_wrapper src/urg_c_wrapper.cpp) +target_link_libraries(urg_c_wrapper ${catkin_LIBRARIES}) + +# Declare the cpp as a lib also +add_library(urg_node_driver src/urg_node_driver.cpp) +add_dependencies(urg_node_driver ${PROJECT_NAME}_gencfg ${PROJECT_NAME}_gencpp) +target_link_libraries(urg_node_driver urg_c_wrapper ${catkin_LIBRARIES}) + +## Declare a cpp executable +add_executable(urg_node src/urg_node.cpp) +target_link_libraries(urg_node urg_node_driver ${catkin_LIBRARIES}) + +## Declare getID tool +add_executable(getID src/getID.cpp) +target_link_libraries(getID urg_c_wrapper ${catkin_LIBRARIES}) + +## Mark executables and/or libraries for installation +install(TARGETS urg_c_wrapper urg_node urg_node_driver getID + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +install( + DIRECTORY include/${PROJECT_NAME}/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} +) + +## Mark cpp header files for installation +install(DIRECTORY include/${PROJECT_NAME}/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING PATTERN "*.h" + PATTERN ".svn" EXCLUDE +) + +## Install script to set IP addresses +install(PROGRAMS + scripts/set_urg_ip.py + DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +if(CATKIN_ENABLE_TESTING) + find_package(roslint) + # Ignore long -> int32_t warning, urg_c driver uses + # long, etc. Wrapper must also use these + set(ROSLINT_CPP_OPTS "--filter=-runtime/references,-runtime/int") + roslint_cpp( + include/urg_node/urg_c_wrapper.h + include/urg_node/urg_node_driver.h + src/getID.cpp + src/urg_c_wrapper.cpp + src/urg_node_driver.cpp + src/urg_node.cpp + ) + roslint_add_test() + + find_package(roslaunch REQUIRED) + roslaunch_add_file_check(launch/urg_lidar.launch) +endif() diff --git a/src/urg_node/README.md b/src/urg_node/README.md new file mode 100644 index 0000000..6d254ec --- /dev/null +++ b/src/urg_node/README.md @@ -0,0 +1,4 @@ +urg_node +=================== + +ROS wrapper for the Hokuyo urg_c library. \ No newline at end of file diff --git a/src/urg_node/cfg/URG.cfg b/src/urg_node/cfg/URG.cfg new file mode 100644 index 0000000..f67efa9 --- /dev/null +++ b/src/urg_node/cfg/URG.cfg @@ -0,0 +1,19 @@ +#! /usr/bin/env python + +PACKAGE='urg_node' + +from dynamic_reconfigure.parameter_generator_catkin import * + +from math import pi + +gen = ParameterGenerator() +# Name Type Reconfiguration level Description Default Min Max +gen.add("tf_prefix", str_t, 0, "tf_prefix for this node's output.", "") +gen.add("frame_id", str_t, 0, "Output frame_id for the laserscan.", "laser") +gen.add("time_offset", double_t, 0, "A manually calibrated offset (in seconds) to add to the timestamp before publication of a message.", 0.0, -10.0, 10.0) +gen.add("angle_min", double_t, 1, "Controls the angle of the first range measurement in radians.", -pi, -pi, pi) +gen.add("angle_max", double_t, 1, "Controls the angle of the last range measurement in radians.", pi, -pi, pi) +gen.add("cluster", int_t, 1, "The number of adjacent range measurements to cluster into a single reading.", 1, 1, 99) +gen.add("skip", int_t, 1, "The number of input messages to skip between each output message.", 0, 0, 9) + +exit(gen.generate(PACKAGE, "urg_node", "URG")) \ No newline at end of file diff --git a/src/urg_node/include/urg_node/urg_c_wrapper.h b/src/urg_node/include/urg_node/urg_c_wrapper.h new file mode 100644 index 0000000..ae3bf06 --- /dev/null +++ b/src/urg_node/include/urg_node/urg_c_wrapper.h @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey + */ + +#ifndef URG_NODE_URG_C_WRAPPER_H +#define URG_NODE_URG_C_WRAPPER_H + +#include +#include +#include +#include + +#include +#include + +#include +#include + +namespace urg_node +{ + +class URGStatus +{ +public: + URGStatus() + { + status = 0; + operating_mode = 0; + area_number = 0; + error_status = false; + error_code = 0; + lockout_status = false; + } + + uint16_t status; + uint16_t operating_mode; + uint16_t area_number; + bool error_status; + uint16_t error_code; + bool lockout_status; +}; + +class UrgDetectionReport +{ +public: + UrgDetectionReport() + { + status = 0; + area = 0; + distance = 0; + angle = 0; + } + + uint16_t status; + uint16_t area; + uint16_t distance; + float angle; +}; + +class URGCWrapper +{ +public: + URGCWrapper(const std::string& ip_address, const int ip_port, + bool& using_intensity, bool& using_multiecho, bool synchronize_time); + + URGCWrapper(const int serial_baud, const std::string& serial_port, + bool& using_intensity, bool& using_multiecho, bool synchronize_time); + + ~URGCWrapper(); + + void start(); + + void stop(); + + bool isStarted() const; + + double getRangeMin() const; + + double getRangeMax() const; + + double getAngleMin() const; + + double getAngleMax() const; + + double getAngleMinLimit() const; + + double getAngleMaxLimit() const; + + double getAngleIncrement() const; + + double getScanPeriod() const; + + double getTimeIncrement() const; + + std::string getIPAddress() const; + + int getIPPort() const; + + std::string getSerialPort() const; + + int getSerialBaud() const; + + std::string getVendorName(); + + std::string getProductName(); + + std::string getFirmwareVersion(); + + std::string getFirmwareDate(); + + std::string getProtocolVersion(); + + std::string getDeviceID(); + + ros::Duration getComputedLatency() const; + + ros::Duration getUserTimeOffset() const; + + std::string getSensorStatus(); + + std::string getSensorState(); + + void setFrameId(const std::string& frame_id); + + void setUserLatency(const double latency); + + bool setAngleLimitsAndCluster(double& angle_min, double& angle_max, int cluster); + + void setSkip(int skip); + + ros::Duration computeLatency(size_t num_measurements); + + bool grabScan(const sensor_msgs::LaserScanPtr& msg); + + bool grabScan(const sensor_msgs::MultiEchoLaserScanPtr& msg); + + bool getAR00Status(URGStatus& status); + + bool getDL00Status(UrgDetectionReport& report); + +private: + void initialize(bool& using_intensity, bool& using_multiecho, bool synchronize_time); + + bool isIntensitySupported(); + + bool isMultiEchoSupported(); + + ros::Duration getAngularTimeOffset() const; + + ros::Duration getNativeClockOffset(size_t num_measurements); + + ros::Duration getTimeStampOffset(size_t num_measurements); + + /** + * @brief Get synchronized time stamp using hardware clock + * @param time_stamp The current hardware time stamp. + * @param system_time_stamp The current system time stamp. + * @returns ros::Time stamp representing synchronized time + */ + ros::Time getSynchronizedTime(long time_stamp, long long system_time_stamp); + + /** + * @brief Set the Hokuyo URG-04LX from SCIP 1.1 mode to SCIP 2.0 mode. + * @returns True if successful and false if not. + */ + bool setToSCIP2(); + + /** + * @brief calculate the crc of a given set of bytes. + * @param bytes The bytes array to be processed. + * @param size The size of the bytes array. + * @return the calculated CRC of the bytes. + */ + uint16_t checkCRC(const char* bytes, const uint32_t size); + + /** + * @brief Send an arbitrary serial command to the lidar. These commands + * can also be sent via the ethernet socket. + * @param cmd The arbitrary command fully formatted to be sent as provided + * @returns The textual response of the Lidar, empty if, but may return lidar's own error string. + */ + std::string sendCommand(std::string cmd); + + std::string frame_id_; ///< Output frame_id for each laserscan. + + urg_t urg_; + bool started_; + + std::vector data_; + std::vector intensity_; + + bool use_intensity_; + bool use_multiecho_; + urg_measurement_type_t measurement_type_; + int first_step_; + int last_step_; + int cluster_; + int skip_; + + ros::Duration system_latency_; + ros::Duration user_latency_; + + // used for clock synchronziation + bool synchronize_time_; + double hardware_clock_; + long last_hardware_time_stamp_; + double hardware_clock_adj_; + const double adj_alpha_ = .01; + uint64_t adj_count_; + + std::string ip_address_; + int ip_port_; + std::string serial_port_; + int serial_baud_; +}; +} // namespace urg_node + +#endif // URG_NODE_URG_C_WRAPPER_H diff --git a/src/urg_node/include/urg_node/urg_node_driver.h b/src/urg_node/include/urg_node/urg_node_driver.h new file mode 100644 index 0000000..db97103 --- /dev/null +++ b/src/urg_node/include/urg_node/urg_node_driver.h @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * Copyright (c) 2017, Clearpath Robotics, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Mike O'Driscoll + */ + +#ifndef URG_NODE_URG_NODE_DRIVER_H +#define URG_NODE_URG_NODE_DRIVER_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "urg_node/urg_c_wrapper.h" + +namespace urg_node +{ +class UrgNode +{ +public: + UrgNode(); + UrgNode(ros::NodeHandle nh, ros::NodeHandle private_nh); + ~UrgNode(); + + /** + * @brief Start's the nodes threads to run the lidar. + */ + void run(); + + /** + * @brief Trigger an update of the lidar's status + * publish the latest known information about the lidar on latched topic. + * @return True on update successful, false otherwise. + */ + bool updateStatus(); + +private: + void initSetup(); + bool connect(); + bool reconfigure_callback(urg_node::URGConfig& config, int level); + void update_reconfigure_limits(); + void calibrate_time_offset(); + void updateDiagnostics(); + void populateDiagnosticsStatus(diagnostic_updater::DiagnosticStatusWrapper &stat); + void scanThread(); + + bool statusCallback(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res); + + ros::NodeHandle nh_; + ros::NodeHandle pnh_; + + boost::thread diagnostics_thread_; + boost::thread scan_thread_; + + boost::shared_ptr urg_; + boost::shared_ptr > srv_; ///< Dynamic reconfigure server + boost::shared_ptr diagnostic_updater_; + boost::shared_ptr laser_freq_; + boost::shared_ptr echoes_freq_; + + boost::mutex lidar_mutex_; + + /* Non-const device properties. If you poll the driver for these + * while scanning is running, then the scan will probably fail. + */ + std::string device_status_; + std::string vendor_name_; + std::string product_name_; + std::string firmware_version_; + std::string firmware_date_; + std::string protocol_version_; + std::string device_id_; + uint16_t error_code_; + bool lockout_status_; + + int error_count_; + double freq_min_; + bool close_diagnostics_; + bool close_scan_; + + int ip_port_; + std::string ip_address_; + std::string serial_port_; + int serial_baud_; + bool calibrate_time_; + bool synchronize_time_; + bool publish_intensity_; + bool publish_multiecho_; + int error_limit_; + double diagnostics_tolerance_; + double diagnostics_window_time_; + bool detailed_status_; + + volatile bool service_yield_; + + ros::Publisher laser_pub_; + laser_proc::LaserPublisher echoes_pub_; + ros::Publisher status_pub_; + + ros::ServiceServer status_service_; +}; + +} // namespace urg_node + +#endif // URG_NODE_URG_NODE_DRIVER_H diff --git a/src/urg_node/launch/urg_lidar.launch b/src/urg_node/launch/urg_lidar.launch new file mode 100644 index 0000000..e729ac2 --- /dev/null +++ b/src/urg_node/launch/urg_lidar.launch @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/urg_node/msg/Status.msg b/src/urg_node/msg/Status.msg new file mode 100644 index 0000000..9810526 --- /dev/null +++ b/src/urg_node/msg/Status.msg @@ -0,0 +1,17 @@ +# Normal vs setting in the UAM manual. +uint16 NORMAL=0 +uint16 SETTING=1 +uint16 operating_mode + +# The configured area number the stop occurred in. +uint16 area_number +# If the laser is reporting an error or not. +bool error_status +# The error code the laser is reporting. +uint16 error_code +# Does the laser report that it is locked out. +bool lockout_status +# Distance in mm the stop was reported at. +uint16 distance +# The reported angle of the stop in deg. +float32 angle diff --git a/src/urg_node/package.xml b/src/urg_node/package.xml new file mode 100644 index 0000000..ab90267 --- /dev/null +++ b/src/urg_node/package.xml @@ -0,0 +1,40 @@ + + + urg_node + 0.1.15 + urg_node + + Tony Baltovski + + BSD + + http://ros.org/wiki/urg_node + https://github.com/ros-drivers/urg_node/issues + https://github.com/ros-drivers/urg_node + + Chad Rockey + Mike O'Driscoll + + catkin + + diagnostic_updater + dynamic_reconfigure + laser_proc + message_generation + nodelet + rosconsole + roscpp + sensor_msgs + std_msgs + std_srvs + tf + urg_c + + message_runtime + + roslint + roslaunch + + + + diff --git a/src/urg_node/scripts/set_urg_ip.py b/src/urg_node/scripts/set_urg_ip.py new file mode 100644 index 0000000..926450b --- /dev/null +++ b/src/urg_node/scripts/set_urg_ip.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python + +# Copyright (c) 2014 Unbounded Robotics Inc. +# All right 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 Unbounded Robotics Inc. 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 UNBOUNDED ROBOTICS INC. 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. + +""" +Change the IP address of a Hokuyo URG Laser +""" + +import argparse +import socket + +def parse_and_validate_ipv4(argument, name): + """ + Each address must have 4 + """ + if len(argument.split(".")) != 4: + print("Invalid %s, must be of the form xxx.yyy.zzz.www" % name) + exit(-1) + parsed = "" + for x in argument.split("."): + if len(x) > 3: + print("Invalid %s, must be of the form xxx.yyy.zzz.www" % name) + exit(-1) + while len(x) < 3: + x = "0" + x + parsed += x + return parsed + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('new_ip', help='The desired IP address for the laser') + parser.add_argument('new_gw', help='The desired gateway for the laser') + parser.add_argument('--nm', help='The desired netmask for the laser', default="255.255.255.0") + parser.add_argument('--ip', help='The current IP address of the laser', default="192.168.0.10") + args = parser.parse_args() + + # Packet starts with $IP, ends with \x0a, contains: + # 12 character IP + # 12 character netmask + # 12 character gateway + ip = parse_and_validate_ipv4(args.new_ip, "IP address") + gw = parse_and_validate_ipv4(args.new_gw, "gateway address") + nm = parse_and_validate_ipv4(args.nm, "netmask") + msg = "$IP" + ip + nm + gw + "\x0a" + + print("Connecting to %s" % args.ip) + sock = socket.socket() + sock.connect((args.ip, 10940)) + + print("Updating settings") + sock.send(msg) + try: + sock.settimeout(5) + returned = sock.recv(40) + except socket.timeout: + print("Laser did not return any packet, is probably not updated.") + exit(-1) + if msg != returned: + print("Laser does not appear to have updated") + exit(-1) + print("Done updating, cycle power on laser") diff --git a/src/urg_node/src/getID.cpp b/src/urg_node/src/getID.cpp new file mode 100644 index 0000000..194a637 --- /dev/null +++ b/src/urg_node/src/getID.cpp @@ -0,0 +1,189 @@ +/********************************************************************* +* Software License Agreement (BSD License) +* +* Copyright (c) 2009, Willow Garage, Inc. +* 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 Willow Garage 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 OWNER 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. +*********************************************************************/ + +#include +#include +#include + +#include +#include +#include +/* gcc defined unix */ +#ifdef unix +#include +#endif +#ifdef WIN32 +#include +#define pipe(X) _pipe(X, 4096, O_BINARY) +#define fileno _fileno +#define dup2 _dup2 +#define read _read +#endif + +std::vector &split(const std::string &s, char delim, std::vector &elems) +{ + std::stringstream ss(s); + std::string item; + while (std::getline(ss, item, delim)) + { + elems.push_back(item); + } + return elems; +} + + +std::vector split(const std::string &s, char delim) +{ + std::vector elems; + split(s, delim, elems); + return elems; +} + +int +main(int argc, char** argv) +{ + ros::Time::init(); + + if (argc < 2 || argc > 3) + { + fprintf(stderr, + "usage: getID /dev/ttyACM? [quiet]\nOutputs the device ID of a hokuyo at /dev/ttyACM? or IP address" + " (specified as 192.168.1.6:10940). Add a second argument for script friendly output.\n"); + return 1; + } + + bool verbose = (argc == 2); + + int save_stdout = dup(STDOUT_FILENO); + + if (!verbose) // Block urg's prints + { + int fds[2]; + int res; + char buf[256]; + int so; + + res = pipe(fds); + assert(res == 0); + + so = fileno(stdout); + // close stdout handle and make the writable part of fds the new stdout. + res = dup2(fds[1], so); + assert(res != -1); + } + + + bool publish_intensity = false; + bool publish_multiecho = false; + bool synchronize_time = false; + int serial_baud = 115200; + int ip_port = 10940; + std::string ip_address = ""; + std::string serial_port = ""; + + std::vector ip_split = split(argv[1], ':'); + if (ip_split.size() < 2) // Not an IP address + { + serial_port = argv[1]; + } + else if (ip_split.size() == 2) // IP address formatted as IP:PORT + { + ip_address = ip_split[0]; + ip_port = atoi(ip_split[1].c_str()); + } + else // Invalid + { + if (verbose) + { + printf("getID failed due to invalid specifier.\n"); + return 1; + } + } + + boost::shared_ptr urg_; + + for (int retries = 10; retries; retries--) + { + // Set up the urgwidget + try + { + if (ip_address != "") + { + urg_.reset(new urg_node::URGCWrapper(ip_address, ip_port, + publish_intensity, publish_multiecho, synchronize_time)); + } + else + { + urg_.reset(new urg_node::URGCWrapper(serial_baud, serial_port, + publish_intensity, publish_multiecho, synchronize_time)); + } + std::string device_id = urg_->getDeviceID(); + if (verbose) + { + if (ip_address != "") + { + printf("Device at %s:%i has ID ", ip_address.c_str(), ip_port); + } + else + { + printf("Device at %s has ID ", serial_port.c_str()); + } + } + // Print this in either mode + fflush(NULL); // Clear whatever we aren't printing + dup2(save_stdout, STDOUT_FILENO); // Restore std::out + printf("%s\n", device_id.c_str()); + return 0; + } + catch (std::runtime_error& e) + { + printf("getID failed: %s\n", e.what()); + } + ros::Duration(1.0).sleep(); + } + + if (verbose) + { + printf("getID failed for 10 seconds. Giving up.\n"); + if (ip_address != "") + { + printf("Device at %s:%i\n", ip_address.c_str(), ip_port); + } + else + { + printf("Device at %s\n", serial_port.c_str()); + } + } + return 1; +} diff --git a/src/urg_node/src/urg_c_wrapper.cpp b/src/urg_node/src/urg_c_wrapper.cpp new file mode 100644 index 0000000..775a262 --- /dev/null +++ b/src/urg_node/src/urg_c_wrapper.cpp @@ -0,0 +1,1095 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey, Mike O'Driscoll + */ + +#include "ros/ros.h" +#include +#include +#include +#include +#include + +namespace urg_node +{ + +URGCWrapper::URGCWrapper(const std::string& ip_address, const int ip_port, + bool& using_intensity, bool& using_multiecho, bool synchronize_time) +{ + // Store for comprehensive diagnostics + ip_address_ = ip_address; + ip_port_ = ip_port; + serial_port_ = ""; + serial_baud_ = 0; + + + long baudrate_or_port = (long)ip_port; + const char *device = ip_address.c_str(); + + int result = urg_open(&urg_, URG_ETHERNET, device, baudrate_or_port); + if (result < 0) + { + std::stringstream ss; + ss << "Could not open network Hokuyo:\n"; + ss << ip_address << ":" << ip_port << "\n"; + ss << urg_error(&urg_); + throw std::runtime_error(ss.str()); + } + + initialize(using_intensity, using_multiecho, synchronize_time); +} + +URGCWrapper::URGCWrapper(const int serial_baud, const std::string& serial_port, + bool& using_intensity, bool& using_multiecho, bool synchronize_time) +{ + // Store for comprehensive diagnostics + serial_baud_ = serial_baud; + serial_port_ = serial_port; + ip_address_ = ""; + ip_port_ = 0; + + long baudrate_or_port = (long)serial_baud; + const char *device = serial_port.c_str(); + + int result = urg_open(&urg_, URG_SERIAL, device, baudrate_or_port); + if (result < 0) + { + std::stringstream ss; + ss << "Could not open serial Hokuyo:\n"; + ss << serial_port << " @ " << serial_baud << "\n"; + ss << urg_error(&urg_); + stop(); + urg_close(&urg_); + throw std::runtime_error(ss.str()); + } + + initialize(using_intensity, using_multiecho, synchronize_time); +} + +void URGCWrapper::initialize(bool& using_intensity, bool& using_multiecho, bool synchronize_time) +{ + int urg_data_size = urg_max_data_size(&urg_); + // urg_max_data_size can return a negative, error code value. Resizing based on this value will fail. + if (urg_data_size < 0) + { + // This error can be caused by a URG-04LX in SCIP 1.1 mode, so we try to set SCIP 2.0 mode. + if (setToSCIP2() && urg_max_data_size(&urg_) >= 0) + { + // If setting SCIP 2.0 was successful, we set urg_data_size to the correct value. + urg_data_size = urg_max_data_size(&urg_); + } + else + { + urg_.last_errno = urg_data_size; + std::stringstream ss; + ss << "Could not initialize Hokuyo:\n"; + ss << urg_error(&urg_); + stop(); + urg_close(&urg_); + throw std::runtime_error(ss.str()); + } + } + // Ocassionally urg_max_data_size returns a string pointer, make sure we don't allocate too much space, + // the current known max is 1440 steps + if (urg_data_size > 5000) + { + urg_data_size = 5000; + } + data_.resize(urg_data_size * URG_MAX_ECHO); + intensity_.resize(urg_data_size * URG_MAX_ECHO); + + started_ = false; + frame_id_ = ""; + first_step_ = 0; + last_step_ = 0; + cluster_ = 1; + skip_ = 0; + + synchronize_time_ = synchronize_time; + hardware_clock_ = 0.0; + last_hardware_time_stamp_ = 0; + hardware_clock_adj_ = 0.0; + adj_count_ = 0; + + if (using_intensity) + { + using_intensity = isIntensitySupported(); + } + + if (using_multiecho) + { + using_multiecho = isMultiEchoSupported(); + } + + use_intensity_ = using_intensity; + use_multiecho_ = using_multiecho; + + measurement_type_ = URG_DISTANCE; + if (use_intensity_ && use_multiecho_) + { + measurement_type_ = URG_MULTIECHO_INTENSITY; + } + else if (use_intensity_) + { + measurement_type_ = URG_DISTANCE_INTENSITY; + } + else if (use_multiecho_) + { + measurement_type_ = URG_MULTIECHO; + } +} + +void URGCWrapper::start() +{ + if (!started_) + { + int result = urg_start_measurement(&urg_, measurement_type_, 0, skip_); + if (result < 0) + { + std::stringstream ss; + ss << "Could not start Hokuyo measurement:\n"; + if (use_intensity_) + { + ss << "With Intensity" << "\n"; + } + if (use_multiecho_) + { + ss << "With MultiEcho" << "\n"; + } + ss << urg_error(&urg_); + throw std::runtime_error(ss.str()); + } + } + started_ = true; +} + +void URGCWrapper::stop() +{ + urg_stop_measurement(&urg_); + started_ = false; +} + +URGCWrapper::~URGCWrapper() +{ + stop(); + urg_close(&urg_); +} + +bool URGCWrapper::grabScan(const sensor_msgs::LaserScanPtr& msg) +{ + msg->header.frame_id = frame_id_; + msg->angle_min = getAngleMin(); + msg->angle_max = getAngleMax(); + msg->angle_increment = getAngleIncrement(); + msg->scan_time = getScanPeriod(); + msg->time_increment = getTimeIncrement(); + msg->range_min = getRangeMin(); + msg->range_max = getRangeMax(); + + // Grab scan + int num_beams = 0; + long time_stamp = 0; + unsigned long long system_time_stamp = 0; + + if (use_intensity_) + { + num_beams = urg_get_distance_intensity(&urg_, &data_[0], &intensity_[0], &time_stamp, &system_time_stamp); + } + else + { + num_beams = urg_get_distance(&urg_, &data_[0], &time_stamp, &system_time_stamp); + } + if (num_beams <= 0) + { + return false; + } + + // Fill scan + if (synchronize_time_) + { + msg->header.stamp = getSynchronizedTime(time_stamp, system_time_stamp); + } + else + { + msg->header.stamp.fromNSec((uint64_t)system_time_stamp); + } + msg->header.stamp = msg->header.stamp + system_latency_ + user_latency_ + getAngularTimeOffset(); + msg->ranges.resize(num_beams); + if (use_intensity_) + { + msg->intensities.resize(num_beams); + } + + for (int i = 0; i < num_beams; i++) + { + if (data_[(i) + 0] != 0) + { + msg->ranges[i] = static_cast(data_[i]) / 1000.0; + if (use_intensity_) + { + msg->intensities[i] = intensity_[i]; + } + } + else + { + msg->ranges[i] = std::numeric_limits::quiet_NaN(); + continue; + } + } + return true; +} + +bool URGCWrapper::grabScan(const sensor_msgs::MultiEchoLaserScanPtr& msg) +{ + msg->header.frame_id = frame_id_; + msg->angle_min = getAngleMin(); + msg->angle_max = getAngleMax(); + msg->angle_increment = getAngleIncrement(); + msg->scan_time = getScanPeriod(); + msg->time_increment = getTimeIncrement(); + msg->range_min = getRangeMin(); + msg->range_max = getRangeMax(); + + // Grab scan + int num_beams = 0; + long time_stamp = 0; + unsigned long long system_time_stamp; + + if (use_intensity_) + { + num_beams = urg_get_multiecho_intensity(&urg_, &data_[0], &intensity_[0], &time_stamp, &system_time_stamp); + } + else + { + num_beams = urg_get_multiecho(&urg_, &data_[0], &time_stamp, &system_time_stamp); + } + if (num_beams <= 0) + { + return false; + } + + // Fill scan (uses vector.reserve wherever possible to avoid initalization and unecessary memory expansion) + msg->header.stamp.fromNSec((uint64_t)system_time_stamp); + msg->header.stamp = msg->header.stamp + system_latency_ + user_latency_ + getAngularTimeOffset(); + msg->ranges.reserve(num_beams); + if (use_intensity_) + { + msg->intensities.reserve(num_beams); + } + + for (size_t i = 0; i < num_beams; i++) + { + sensor_msgs::LaserEcho range_echo; + range_echo.echoes.reserve(URG_MAX_ECHO); + sensor_msgs::LaserEcho intensity_echo; + if (use_intensity_) + { + intensity_echo.echoes.reserve(URG_MAX_ECHO); + } + for (size_t j = 0; j < URG_MAX_ECHO; j++) + { + if (data_[(URG_MAX_ECHO * i) + j] != 0) + { + range_echo.echoes.push_back(static_cast(data_[(URG_MAX_ECHO * i) + j]) / 1000.0f); + if (use_intensity_) + { + intensity_echo.echoes.push_back(intensity_[(URG_MAX_ECHO * i) + j]); + } + } + else + { + break; + } + } + msg->ranges.push_back(range_echo); + if (use_intensity_) + { + msg->intensities.push_back(intensity_echo); + } + } + + return true; +} + +bool URGCWrapper::getAR00Status(URGStatus& status) +{ + // Construct and write AR00 command. + std::string str_cmd; + str_cmd += 0x02; // STX + str_cmd.append("000EAR00A012"); // AR00 cmd with length and checksum. + str_cmd += 0x03; // ETX + + // Get the response + std::string response = sendCommand(str_cmd); + + ROS_DEBUG_STREAM("Full response: " << response); + + // Strip STX and ETX before calculating the CRC. + response.erase(0, 1); + response.erase(response.size() - 1, 1); + + // Get the CRC, it's the last 4 chars. + std::stringstream ss; + ss << response.substr(response.size() - 4, 4); + uint16_t crc; + ss >> std::hex >> crc; + + // Remove the CRC from the check. + std::string msg = response.substr(0, response.size() - 4); + // Check the checksum. + uint16_t checksum_result = checkCRC(msg.data(), msg.size()); + + if (checksum_result != crc) + { + ROS_WARN("Received bad frame, incorrect checksum"); + return false; + } + + // Debug output reponse up to scan data. + ROS_DEBUG_STREAM("Response: " << response.substr(0, 41)); + // Decode the result if crc checks out. + // Grab the status + ss.clear(); + ROS_DEBUG_STREAM("Status " << response.substr(8, 2)); + ss << response.substr(8, 2); // Status is 8th position 2 chars. + ss >> std::hex >> status.status; + + if (status.status != 0) + { + ROS_WARN("Received bad status"); + return false; + } + + // Grab the operating mode + ss.clear(); + ROS_DEBUG_STREAM("Operating mode " << response.substr(10, 1);); + ss << response.substr(10, 1); + ss >> std::hex >> status.operating_mode; + + // Grab the area number + ss.clear(); + ss << response.substr(11, 2); + ROS_DEBUG_STREAM("Area Number " << response.substr(11, 2)); + ss >> std::hex >> status.area_number; + // Per documentation add 1 to offset area number + status.area_number++; + + // Grab the Error Status + ss.clear(); + ss << response.substr(13, 1); + ROS_DEBUG_STREAM("Error status " << response.substr(13, 1)); + ss >> std::hex >> status.error_status; + + + // Grab the error code + ss.clear(); + ss << response.substr(14, 2); + ROS_DEBUG_STREAM("Error code " << std::hex << response.substr(14, 2)); + ss >> std::hex >> status.error_code; + // Offset by 0x40 is non-zero as per documentation + if (status.error_code != 0) + { + status.error_code += 0x40; + } + + // Get the lockout status + ss.clear(); + ss << response.substr(16, 1); + ROS_DEBUG_STREAM("Lockout " << response.substr(16, 1)); + ss >> std::hex >> status.lockout_status; + + return true; +} + +bool URGCWrapper::getDL00Status(UrgDetectionReport& report) +{ + // Construct and write DL00 command. + std::string str_cmd; + str_cmd += 0x02; // STX + str_cmd.append("000EDL005BCB"); // DL00 cmd with length and checksum. + str_cmd += 0x03; // ETX + + // Get the response + std::string response = sendCommand(str_cmd); + + ROS_DEBUG_STREAM("Full response: " << response); + + // Strip STX and ETX before calculating the CRC. + response.erase(0, 1); + response.erase(response.size() - 1, 1); + + // Get the CRC, it's the last 4 chars. + std::stringstream ss; + ss << response.substr(response.size() - 4, 4); + uint16_t crc; + ss >> std::hex >> crc; + + // Remove the CRC from the check. + std::string msg = response.substr(0, response.size() - 4); + // Check the checksum. + uint16_t checksum_result = checkCRC(msg.data(), msg.size()); + + if (checksum_result != crc) + { + ROS_WARN("Received bad frame, incorrect checksum"); + return false; + } + + // Decode the result if crc checks out. + // Grab the status + uint16_t status = 0; + ss.clear(); + ROS_DEBUG_STREAM("Status " << response.substr(8, 2)); + ss << response.substr(8, 2); // Status is 8th position 2 chars. + ss >> std::hex >> status; + + if (status != 0) + { + ROS_WARN("Received bad status"); + return false; + } + + std::vector reports; + msg = msg.substr(10); // remove the header. + // Process the message, there are 29 reports. + // The 30th report is a circular buff marker of area with 0xFF + // denoting the "last" report being the previous one. + for (int i = 0; i < 30; i++) + { + uint16_t area = 0; + uint16_t distance = 0; + uint16_t step = 0; + ss.clear(); + + // Each msg is 64 chars long, offset which + // report is being read in. + uint16_t offset_pos = i * 64; + ss << msg.substr(offset_pos, 2); // Area is 2 chars long + ss >> std::hex >> area; + + + ss.clear(); + ss << msg.substr(offset_pos + 4, 4); // Distance is offset 4 from beginning, 4 chars long. + ss >> std::hex >> distance; + + ss.clear(); + ss << msg.substr(offset_pos + 8, 4); // "Step" is offset 8 from beginning 4 chars long. + ss >> std::hex >> step; + ROS_DEBUG_STREAM(i << " Area: " << area << " Distance: " << distance << " Step: " << step); + + UrgDetectionReport r; + r.area = area; + r.distance = distance; + // From read value to angle of report is a value/8. + r.angle = static_cast(step) / 8.0; + + reports.push_back(r); + } + + for (auto iter = reports.begin(); iter != reports.end(); ++iter) + { + // Check if value retrieved for area is FF. + // if it is this is the last element lasers circular buffer. + if (iter->area == 0xFF) + { + // Try and read the previous item. + // if it's the beginning, then all reports + // are empty. + if (iter - 1 == reports.begin()) + { + ROS_WARN("All reports are empty, no detections available."); + report.status = status; + return false; + } + if (iter - 1 != reports.begin()) + { + report = *(iter-1); + report.area += 1; // Final area is offset by 1. + report.status = status; + break; + } + } + } + + return true; +} + +bool URGCWrapper::setToSCIP2() +{ + if (urg_.connection.type == URG_ETHERNET) + return false; + + char buffer[sizeof("SCIP2.0\n")]; + int n; + + do + { + n = serial_readline(&(urg_.connection.serial), buffer, sizeof(buffer), 1000); + } + while (n >= 0); + + serial_write(&(urg_.connection.serial), "SCIP2.0\n", sizeof(buffer)); + n = serial_readline(&(urg_.connection.serial), buffer, sizeof(buffer), 1000); + + // Check if switching was successful. + if (n > 0 && strcmp(buffer, "SCIP2.0") == 0 + && urg_open(&urg_, URG_SERIAL, serial_port_.c_str(), (long)serial_baud_) >= 0) + { + ROS_DEBUG_STREAM("Set sensor to SCIP 2.0."); + return true; + } + return false; +} + +uint16_t URGCWrapper::checkCRC(const char* bytes, const uint32_t size) +{ + boost::crc_optimal<16, 0x1021, 0, 0, true, true> crc_kermit_type; + crc_kermit_type.process_bytes(bytes, size); + return crc_kermit_type.checksum(); +} + +std::string URGCWrapper::sendCommand(std::string cmd) +{ + std::string result; + bool restart = false; + + if (isStarted()) + { + restart = true; + // Scan must stop before sending a command + stop(); + } + + // Get the socket reference and send + int sock = urg_.connection.tcpclient.sock_desc; + write(sock, cmd.c_str(), cmd.size()); + + // All serial command structures start with STX + LEN as + // the first 5 bytes, read those in. + size_t total_read_len = 0; + size_t read_len = 0; + // Read in the header, make sure we get all 5 bytes expcted + char recvb[5] = {0}; + ssize_t expected_read = 5; + while (total_read_len < expected_read) + { + read_len = read(sock, recvb + total_read_len, expected_read - total_read_len); // READ STX + total_read_len += read_len; + if (read_len <= 0) + { + ROS_ERROR("Read socket failed: %s", strerror(errno)); + result.clear(); + return result; + } + } + + std::string recv_header(recvb, read_len); + // Convert the read len from hex chars to int. + std::stringstream ss; + ss << recv_header.substr(1, 4); + ss >> std::hex >> expected_read; + ROS_DEBUG_STREAM("Read len " << expected_read); + + // Already read len of 5, take that out. + uint32_t arr_size = expected_read - 5; + // Bounds check the size, we really shouldn't exceed 8703 bytes + // based on the currently known messages on the hokuyo documentations + if (arr_size > 10000) + { + ROS_ERROR("Buffer creation bounds exceeded, shouldn't allocate: %u bytes", arr_size); + result.clear(); + return result; + } + + ROS_DEBUG_STREAM("Creating buffer read of arr_Size: " << arr_size); + // Create buffer space for read. + boost::shared_array data; + data.reset(new char[arr_size]); + + // Read the remaining command + total_read_len = 0; + read_len = 0; + expected_read = arr_size; + + ROS_DEBUG_STREAM("Expected body size: " << expected_read); + while (total_read_len < expected_read) + { + read_len = read(sock, data.get()+total_read_len, expected_read - total_read_len); + total_read_len += read_len; + ROS_DEBUG_STREAM("Read in after header " << read_len); + if (read_len <= 0) + { + ROS_ERROR("Read socket failed: %s", strerror(errno)); + result.clear(); + return result; + } + } + + // Combine the read portions to return for processing. + result += recv_header; + result += std::string(data.get(), expected_read); + + // Resume scan after sending. + if (restart) + { + start(); + } + + return result; +} + +bool URGCWrapper::isStarted() const +{ + return started_; +} + +double URGCWrapper::getRangeMin() const +{ + long minr; + long maxr; + urg_distance_min_max(&urg_, &minr, &maxr); + return static_cast(minr) / 1000.0; +} + +double URGCWrapper::getRangeMax() const +{ + long minr; + long maxr; + urg_distance_min_max(&urg_, &minr, &maxr); + return static_cast(maxr) / 1000.0; +} + +double URGCWrapper::getAngleMin() const +{ + return urg_step2rad(&urg_, first_step_); +} + +double URGCWrapper::getAngleMax() const +{ + return urg_step2rad(&urg_, last_step_); +} + +double URGCWrapper::getAngleMinLimit() const +{ + int min_step; + int max_step; + urg_step_min_max(&urg_, &min_step, &max_step); + return urg_step2rad(&urg_, min_step); +} + +double URGCWrapper::getAngleMaxLimit() const +{ + int min_step; + int max_step; + urg_step_min_max(&urg_, &min_step, &max_step); + return urg_step2rad(&urg_, max_step); +} + +double URGCWrapper::getAngleIncrement() const +{ + double angle_min = getAngleMin(); + double angle_max = getAngleMax(); + return cluster_ * (angle_max - angle_min) / static_cast(last_step_ - first_step_); +} + +double URGCWrapper::getScanPeriod() const +{ + long scan_usec = urg_scan_usec(&urg_); + return 1.e-6 * static_cast(scan_usec); +} + +double URGCWrapper::getTimeIncrement() const +{ + int min_step; + int max_step; + urg_step_min_max(&urg_, &min_step, &max_step); + double scan_period = getScanPeriod(); + double circle_fraction = (getAngleMaxLimit() - getAngleMinLimit()) / (2.0 * 3.141592); + return cluster_ * circle_fraction * scan_period / static_cast(max_step - min_step); +} + + +std::string URGCWrapper::getIPAddress() const +{ + return ip_address_; +} + +int URGCWrapper::getIPPort() const +{ + return ip_port_; +} + +std::string URGCWrapper::getSerialPort() const +{ + return serial_port_; +} + +int URGCWrapper::getSerialBaud() const +{ + return serial_baud_; +} + +std::string URGCWrapper::getVendorName() +{ + return std::string(urg_sensor_vendor(&urg_)); +} + +std::string URGCWrapper::getProductName() +{ + return std::string(urg_sensor_product_type(&urg_)); +} + +std::string URGCWrapper::getFirmwareVersion() +{ + return std::string(urg_sensor_firmware_version(&urg_)); +} + +std::string URGCWrapper::getFirmwareDate() +{ + return std::string(urg_sensor_firmware_date(&urg_)); +} + +std::string URGCWrapper::getProtocolVersion() +{ + return std::string(urg_sensor_protocol_version(&urg_)); +} + +std::string URGCWrapper::getDeviceID() +{ + return std::string(urg_sensor_serial_id(&urg_)); +} + +ros::Duration URGCWrapper::getComputedLatency() const +{ + return system_latency_; +} + +ros::Duration URGCWrapper::getUserTimeOffset() const +{ + return user_latency_; +} + +std::string URGCWrapper::getSensorStatus() +{ + return std::string(urg_sensor_status(&urg_)); +} + +std::string URGCWrapper::getSensorState() +{ + return std::string(urg_sensor_state(&urg_)); +} + +void URGCWrapper::setFrameId(const std::string& frame_id) +{ + frame_id_ = frame_id; +} + +void URGCWrapper::setUserLatency(const double latency) +{ + user_latency_.fromSec(latency); +} + +// Must be called before urg_start +bool URGCWrapper::setAngleLimitsAndCluster(double& angle_min, double& angle_max, int cluster) +{ + if (started_) + { + return false; // Must not be streaming + } + + // Set step limits + first_step_ = urg_rad2step(&urg_, angle_min); + last_step_ = urg_rad2step(&urg_, angle_max); + cluster_ = cluster; + + // Make sure step limits are not the same + if (first_step_ == last_step_) + { + // Make sure we're not at a limit + int min_step; + int max_step; + urg_step_min_max(&urg_, &min_step, &max_step); + if (first_step_ == min_step) // At beginning of range + { + last_step_ = first_step_ + 1; + } + else // At end of range (or all other cases) + { + first_step_ = last_step_ - 1; + } + } + + // Make sure angle_max is greater than angle_min (should check this after end limits) + if (last_step_ < first_step_) + { + double temp = first_step_; + first_step_ = last_step_; + last_step_ = temp; + } + + angle_min = urg_step2rad(&urg_, first_step_); + angle_max = urg_step2rad(&urg_, last_step_); + int result = urg_set_scanning_parameter(&urg_, first_step_, last_step_, cluster); + if (result < 0) + { + return false; + } + return true; +} + +void URGCWrapper::setSkip(int skip) +{ + skip_ = skip; +} + +bool URGCWrapper::isIntensitySupported() +{ + if (started_) + { + return false; // Must not be streaming + } + + urg_start_measurement(&urg_, URG_DISTANCE_INTENSITY, 0, 0); + int ret = urg_get_distance_intensity(&urg_, &data_[0], &intensity_[0], NULL, NULL); + if (ret <= 0) + { + return false; // Failed to start measurement with intensity: must not support it + } + urg_stop_measurement(&urg_); + return true; +} + +bool URGCWrapper::isMultiEchoSupported() +{ + if (started_) + { + return false; // Must not be streaming + } + + urg_start_measurement(&urg_, URG_MULTIECHO, 0, 0); + int ret = urg_get_multiecho(&urg_, &data_[0], NULL, NULL); + if (ret <= 0) + { + return false; // Failed to start measurement with multiecho: must not support it + } + urg_stop_measurement(&urg_); + return true; +} + +ros::Duration URGCWrapper::getAngularTimeOffset() const +{ + // Adjust value for Hokuyo's timestamps + // Hokuyo's timestamps start from the rear center of the device (at Pi according to ROS standards) + double circle_fraction = 0.0; + if (first_step_ == 0 && last_step_ == 0) + { + circle_fraction = (getAngleMinLimit() + 3.141592) / (2.0 * 3.141592); + } + else + { + circle_fraction = (getAngleMin() + 3.141592) / (2.0 * 3.141592); + } + return ros::Duration(circle_fraction * getScanPeriod()); +} + +ros::Duration URGCWrapper::computeLatency(size_t num_measurements) +{ + system_latency_.fromNSec(0); + + ros::Duration start_offset = getNativeClockOffset(1); + ros::Duration previous_offset; + + std::vector time_offsets(num_measurements); + for (size_t i = 0; i < num_measurements; i++) + { + ros::Duration scan_offset = getTimeStampOffset(1); + ros::Duration post_offset = getNativeClockOffset(1); + ros::Duration adjusted_scan_offset = scan_offset - start_offset; + ros::Duration adjusted_post_offset = post_offset - start_offset; + ros::Duration average_offset; + average_offset.fromSec((adjusted_post_offset.toSec() + previous_offset.toSec()) / 2.0); + + time_offsets[i] = adjusted_scan_offset - average_offset; + + previous_offset = adjusted_post_offset; + } + + // Get median value + // Sort vector using nth_element (partially sorts up to the median index) + std::nth_element(time_offsets.begin(), time_offsets.begin() + time_offsets.size() / 2, time_offsets.end()); + system_latency_ = time_offsets[time_offsets.size() / 2]; + // Angular time offset makes the output comparable to that of hokuyo_node + return system_latency_ + getAngularTimeOffset(); +} + +ros::Duration URGCWrapper::getNativeClockOffset(size_t num_measurements) +{ + if (started_) + { + std::stringstream ss; + ss << "Cannot get native clock offset while started."; + throw std::runtime_error(ss.str()); + } + + if (urg_start_time_stamp_mode(&urg_) < 0) + { + std::stringstream ss; + ss << "Cannot start time stamp mode."; + throw std::runtime_error(ss.str()); + } + + std::vector time_offsets(num_measurements); + for (size_t i = 0; i < num_measurements; i++) + { + ros::Time request_time = ros::Time::now(); + ros::Time laser_time; + laser_time.fromNSec(1e6 * (uint64_t)urg_time_stamp(&urg_)); // 1e6 * milliseconds = nanoseconds + ros::Time response_time = ros::Time::now(); + ros::Time average_time; + average_time.fromSec((response_time.toSec() + request_time.toSec()) / 2.0); + time_offsets[i] = laser_time - average_time; + } + + if (urg_stop_time_stamp_mode(&urg_) < 0) + { + std::stringstream ss; + ss << "Cannot stop time stamp mode."; + throw std::runtime_error(ss.str()); + }; + + // Return median value + // Sort vector using nth_element (partially sorts up to the median index) + std::nth_element(time_offsets.begin(), time_offsets.begin() + time_offsets.size() / 2, time_offsets.end()); + return time_offsets[time_offsets.size() / 2]; +} + +ros::Duration URGCWrapper::getTimeStampOffset(size_t num_measurements) +{ + if (started_) + { + std::stringstream ss; + ss << "Cannot get time stamp offset while started."; + throw std::runtime_error(ss.str()); + } + + start(); + + std::vector time_offsets(num_measurements); + for (size_t i = 0; i < num_measurements; i++) + { + long time_stamp; + unsigned long long system_time_stamp; + int ret = 0; + + if (measurement_type_ == URG_DISTANCE) + { + ret = urg_get_distance(&urg_, &data_[0], &time_stamp, &system_time_stamp); + } + else if (measurement_type_ == URG_DISTANCE_INTENSITY) + { + ret = urg_get_distance_intensity(&urg_, &data_[0], &intensity_[0], &time_stamp, &system_time_stamp); + } + else if (measurement_type_ == URG_MULTIECHO) + { + ret = urg_get_multiecho(&urg_, &data_[0], &time_stamp, &system_time_stamp); + } + else if (measurement_type_ == URG_MULTIECHO_INTENSITY) + { + ret = urg_get_multiecho_intensity(&urg_, &data_[0], &intensity_[0], &time_stamp, &system_time_stamp); + } + + if (ret <= 0) + { + std::stringstream ss; + ss << "Cannot get scan to measure time stamp offset."; + throw std::runtime_error(ss.str()); + } + + ros::Time laser_timestamp; + laser_timestamp.fromNSec(1e6 * (uint64_t)time_stamp); + ros::Time system_time; + system_time.fromNSec((uint64_t)system_time_stamp); + + time_offsets[i] = laser_timestamp - system_time; + } + + stop(); + + // Return median value + // Sort vector using nth_element (partially sorts up to the median index) + std::nth_element(time_offsets.begin(), time_offsets.begin() + time_offsets.size() / 2, time_offsets.end()); + return time_offsets[time_offsets.size() / 2]; +} + +ros::Time URGCWrapper::getSynchronizedTime(long time_stamp, long long system_time_stamp) +{ + ros::Time stamp, system_time; + system_time.fromNSec((uint64_t)system_time_stamp); + stamp = system_time; + + const uint32_t t1 = static_cast(time_stamp); + const uint32_t t0 = static_cast(last_hardware_time_stamp_); + // hokuyo uses a 24-bit counter, so mask out irrelevant bits + const uint32_t mask = 0x00ffffff; + double delta = static_cast(mask&(t1-t0))/1000.0; + hardware_clock_ += delta; + double cur_adj = stamp.toSec() - hardware_clock_; + if (adj_count_ > 0) + { + hardware_clock_adj_ = adj_alpha_*cur_adj+(1.0-adj_alpha_)*hardware_clock_adj_; + } + else + { + // Initialize the EMA + hardware_clock_adj_ = cur_adj; + } + adj_count_++; + last_hardware_time_stamp_ = time_stamp; + + // Once hardware clock is synchronized, use it. Otherwise just return the + // input system_time_stamp as ros::Time. + if (adj_count_ > 100) + { + stamp.fromSec(hardware_clock_+hardware_clock_adj_); + // If the time error is large a clock warp has occurred. + // Reset the EMA and use the system time. + if (fabs((stamp-system_time).toSec()) > 0.1) + { + adj_count_ = 0; + hardware_clock_ = 0.0; + last_hardware_time_stamp_ = 0; + stamp = system_time; + ROS_INFO("%s: detected clock warp, reset EMA", __func__); + } + } + return stamp; +} +} // namespace urg_node diff --git a/src/urg_node/src/urg_node.cpp b/src/urg_node/src/urg_node.cpp new file mode 100644 index 0000000..3836f02 --- /dev/null +++ b/src/urg_node/src/urg_node.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey, Michael Carroll, Mike O'Driscoll + */ + +#include "urg_node/urg_node_driver.h" + +int main(int argc, char **argv) +{ + // Initialize node and nodehandles + ros::init(argc, argv, "urg_node"); + + urg_node::UrgNode node; + node.run(); + + ros::spin(); + + return 0; +} diff --git a/src/urg_node/src/urg_node_driver.cpp b/src/urg_node/src/urg_node_driver.cpp new file mode 100644 index 0000000..64b20d3 --- /dev/null +++ b/src/urg_node/src/urg_node_driver.cpp @@ -0,0 +1,600 @@ +/* + * Copyright (c) 2013, Willow Garage, Inc. + * 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 Willow Garage, Inc. 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 OWNER 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. + */ + +/* + * Author: Chad Rockey, Michael Carroll, Mike O'Driscoll + */ + +#include "urg_node/urg_node_driver.h" + +#include // tf header for resolving tf prefix +#include +#include +#include + +namespace urg_node +{ + +// Useful typedefs +typedef diagnostic_updater::FrequencyStatusParam FrequencyStatusParam; + +UrgNode::UrgNode(ros::NodeHandle nh, ros::NodeHandle private_nh) : + nh_(nh), + pnh_(private_nh) +{ + initSetup(); +} + +UrgNode::UrgNode(): + nh_(), + pnh_("~") +{ + initSetup(); +} + +void UrgNode::initSetup() +{ + close_diagnostics_ = true; + close_scan_ = true; + service_yield_ = false; + + error_code_ = 0; + lockout_status_ = false; + // Initialize node and nodehandles + + // Get parameters so we can change these later. + pnh_.param("ip_address", ip_address_, ""); + pnh_.param("ip_port", ip_port_, 10940); + pnh_.param("serial_port", serial_port_, "/dev/ttyACM0"); + pnh_.param("serial_baud", serial_baud_, 115200); + pnh_.param("calibrate_time", calibrate_time_, false); + pnh_.param("synchronize_time", synchronize_time_, false); + pnh_.param("publish_intensity", publish_intensity_, true); + pnh_.param("publish_multiecho", publish_multiecho_, false); + pnh_.param("error_limit", error_limit_, 4); + pnh_.param("diagnostics_tolerance", diagnostics_tolerance_, 0.05); + pnh_.param("diagnostics_window_time", diagnostics_window_time_, 5.0); + pnh_.param("get_detailed_status", detailed_status_, false); + + // Set up publishers and diagnostics updaters, we only need one + if (publish_multiecho_) + { + echoes_pub_ = laser_proc::LaserTransport::advertiseLaser(nh_, 20); + } + else + { + laser_pub_ = nh_.advertise("scan", 20); + } + + status_service_ = nh_.advertiseService("update_laser_status", &UrgNode::statusCallback, this); + status_pub_ = nh_.advertise("laser_status", 1, true); + + diagnostic_updater_.reset(new diagnostic_updater::Updater); + diagnostic_updater_->add("Hardware Status", this, &UrgNode::populateDiagnosticsStatus); +} + +UrgNode::~UrgNode() +{ + if (diagnostics_thread_.joinable()) + { + // Clean up our diagnostics thread. + close_diagnostics_ = true; + diagnostics_thread_.join(); + } + if (scan_thread_.joinable()) + { + close_scan_ = true; + scan_thread_.join(); + } +} + +bool UrgNode::updateStatus() +{ + bool result = false; + service_yield_ = true; + boost::mutex::scoped_lock lock(lidar_mutex_); + + if (urg_) + { + device_status_ = urg_->getSensorStatus(); + + if (detailed_status_) + { + URGStatus status; + if (urg_->getAR00Status(status)) + { + urg_node::Status msg; + msg.operating_mode = status.operating_mode; + msg.error_status = status.error_status; + msg.error_code = status.error_code; + msg.lockout_status = status.lockout_status; + + lockout_status_ = status.lockout_status; + error_code_ = status.error_code; + + UrgDetectionReport report; + if (urg_->getDL00Status(report)) + { + msg.area_number = report.area; + msg.distance = report.distance; + msg.angle = report.angle; + } + else + { + ROS_WARN("Failed to get detection report."); + } + + // Publish the status on the latched topic for inspection. + status_pub_.publish(msg); + result = true; + } + else + { + ROS_WARN("Failed to retrieve status"); + + urg_node::Status msg; + status_pub_.publish(msg); + } + } + } + return result; +} + +bool UrgNode::statusCallback(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res) +{ + ROS_INFO("Got update lidar status callback"); + res.success = false; + res.message = "Laser not ready"; + + if (updateStatus()) + { + res.message = "Status retrieved"; + res.success = true; + } + else + { + res.message = "Failed to update status"; + res.success = false; + } + + return true; +} + +bool UrgNode::reconfigure_callback(urg_node::URGConfig& config, int level) +{ + if (!urg_) + { + ROS_ERROR("Reconfigure failed, not ready"); + return false; + } + + if (level < 0) // First call, initialize, laser not yet started + { + urg_->setAngleLimitsAndCluster(config.angle_min, config.angle_max, config.cluster); + urg_->setSkip(config.skip); + } + else if (level > 0) // Must stop + { + urg_->stop(); + ROS_INFO("Stopped data due to reconfigure."); + + // Change values that required stopping + urg_->setAngleLimitsAndCluster(config.angle_min, config.angle_max, config.cluster); + urg_->setSkip(config.skip); + + try + { + urg_->start(); + ROS_INFO("Streaming data after reconfigure."); + } + catch (std::runtime_error& e) + { + ROS_FATAL("%s", e.what()); + ros::Duration(1.0).sleep(); + ros::shutdown(); + return false; + } + } + + // The publish frequency changes based on the number of skipped scans. + // Update accordingly here. + freq_min_ = 1.0 / (urg_->getScanPeriod() * (config.skip + 1)); + + std::string frame_id = tf::resolve(config.tf_prefix, config.frame_id); + urg_->setFrameId(frame_id); + urg_->setUserLatency(config.time_offset); + + return true; +} + +void UrgNode::update_reconfigure_limits() +{ + if (!urg_ || !srv_) + { + ROS_DEBUG_THROTTLE(10, "Unable to update reconfigure limits. Not Ready."); + return; + } + + urg_node::URGConfig min, max; + srv_->getConfigMin(min); + srv_->getConfigMax(max); + + min.angle_min = urg_->getAngleMinLimit(); + min.angle_max = min.angle_min; + max.angle_max = urg_->getAngleMaxLimit(); + max.angle_min = max.angle_max; + + srv_->setConfigMin(min); + srv_->setConfigMax(max); +} + +void UrgNode::calibrate_time_offset() +{ + boost::mutex::scoped_lock lock(lidar_mutex_); + if (!urg_) + { + ROS_DEBUG_THROTTLE(10, "Unable to calibrate time offset. Not Ready."); + return; + } + try + { + // Don't let outside interruption effect lidar offset. + ROS_INFO("Starting calibration. This will take a few seconds."); + ROS_WARN("Time calibration is still experimental."); + ros::Duration latency = urg_->computeLatency(10); + ROS_INFO("Calibration finished. Latency is: %.4f.", latency.toSec()); + } + catch (std::runtime_error& e) + { + ROS_FATAL("Could not calibrate time offset: %s", e.what()); + ros::Duration(1.0).sleep(); + ros::shutdown(); + } +} + + +// Diagnostics update task to be run in a thread. +void UrgNode::updateDiagnostics() +{ + while (!close_diagnostics_) + { + diagnostic_updater_->update(); + boost::this_thread::sleep_for(boost::chrono::milliseconds(10)); + } +} + +// Populate a diagnostics status message. +void UrgNode::populateDiagnosticsStatus(diagnostic_updater::DiagnosticStatusWrapper &stat) +{ + if (!urg_) + { + stat.summary(diagnostic_msgs::DiagnosticStatus::ERROR, + "Not Connected"); + return; + } + + if (!urg_->getIPAddress().empty()) + { + stat.add("IP Address", urg_->getIPAddress()); + stat.add("IP Port", urg_->getIPPort()); + } + else + { + stat.add("Serial Port", urg_->getSerialPort()); + stat.add("Serial Baud", urg_->getSerialBaud()); + } + + if (!urg_->isStarted()) + { + stat.summary(diagnostic_msgs::DiagnosticStatus::ERROR, + "Not Connected: " + device_status_); + } + else if (device_status_ != std::string("Sensor works well.") && + device_status_ != std::string("Stable 000 no error.") && + device_status_ != std::string("sensor is working normally")) + { + stat.summary(diagnostic_msgs::DiagnosticStatus::ERROR, + "Abnormal status: " + device_status_); + } + else if (error_code_ != 0) + { + stat.summaryf(diagnostic_msgs::DiagnosticStatus::ERROR, + "Lidar reporting error code: %X", + error_code_); + } + else if (lockout_status_) + { + stat.summary(diagnostic_msgs::DiagnosticStatus::ERROR, + "Lidar locked out."); + } + else + { + stat.summary(diagnostic_msgs::DiagnosticStatus::OK, + "Streaming"); + } + + stat.add("Vendor Name", vendor_name_); + stat.add("Product Name", product_name_); + stat.add("Firmware Version", firmware_version_); + stat.add("Firmware Date", firmware_date_); + stat.add("Protocol Version", protocol_version_); + stat.add("Device ID", device_id_); + stat.add("Computed Latency", urg_->getComputedLatency()); + stat.add("User Time Offset", urg_->getUserTimeOffset()); + + // Things not explicitly required by REP-0138, but still interesting. + stat.add("Device Status", device_status_); + stat.add("Scan Retrieve Error Count", error_count_); + + stat.add("Lidar Error Code", error_code_); + stat.add("Locked out", lockout_status_); +} + +bool UrgNode::connect() +{ + // Don't let external access to retrieve + // status during the connection process. + boost::mutex::scoped_lock lock(lidar_mutex_); + + try + { + urg_.reset(); // Clear any previous connections(); + if (!ip_address_.empty()) + { + urg_.reset(new urg_node::URGCWrapper(ip_address_, ip_port_, + publish_intensity_, publish_multiecho_, synchronize_time_)); + } + else + { + urg_.reset(new urg_node::URGCWrapper(serial_baud_, serial_port_, + publish_intensity_, publish_multiecho_, synchronize_time_)); + } + + std::stringstream ss; + ss << "Connected to"; + if (publish_multiecho_) + { + ss << " multiecho"; + } + if (!ip_address_.empty()) + { + ss << " network"; + } + else + { + ss << " serial"; + } + ss << " device with"; + if (publish_intensity_) + { + ss << " intensity and"; + } + ss << " ID: " << urg_->getDeviceID(); + ROS_INFO_STREAM(ss.str()); + + device_status_ = urg_->getSensorStatus(); + vendor_name_ = urg_->getVendorName(); + product_name_ = urg_->getProductName(); + firmware_version_ = urg_->getFirmwareVersion(); + firmware_date_ = urg_->getFirmwareDate(); + protocol_version_ = urg_->getProtocolVersion(); + device_id_ = urg_->getDeviceID(); + + if (diagnostic_updater_ && urg_) + { + diagnostic_updater_->setHardwareID(urg_->getDeviceID()); + } + + return true; + } + catch (std::runtime_error& e) + { + ROS_ERROR_THROTTLE(10.0, "Error connecting to Hokuyo: %s", e.what()); + urg_.reset(); + return false; + } + catch (std::exception& e) + { + ROS_ERROR_THROTTLE(10.0, "Unknown error connecting to Hokuyo: %s", e.what()); + urg_.reset(); + return false; + } + + return false; +} + +void UrgNode::scanThread() +{ + while (!close_scan_) + { + if (!urg_) + { + if (!connect()) + { + boost::this_thread::sleep(boost::posix_time::milliseconds(500)); + continue; // Connect failed, sleep, try again. + } + } + + // Configure limits (Must do this after creating the urgwidget) + update_reconfigure_limits(); + + if (calibrate_time_) + { + calibrate_time_offset(); + } + + // Clear the dynamic reconfigure server + srv_.reset(); + // Spin once to de-register it's services before making a new + // service next. + ros::spinOnce(); + + if (!urg_ || !ros::ok) + { + continue; + } + else + { + // Set up dynamic reconfigure + srv_.reset(new dynamic_reconfigure::Server(pnh_)); + // Configure limits (Must do this after creating the urgwidget) + update_reconfigure_limits(); + srv_->setCallback(boost::bind(&UrgNode::reconfigure_callback, this, _1, _2)); + } + + // Before starting, update the status + updateStatus(); + + // Start the urgwidget + try + { + // If the connection failed, don't try and connect + // pointer is invalid. + if (!urg_) + { + continue; // Return to top of main loop, not connected. + } + device_status_ = urg_->getSensorStatus(); + urg_->start(); + ROS_INFO("Streaming data."); + // Clear the error count. + error_count_ = 0; + } + catch (std::runtime_error& e) + { + ROS_ERROR_THROTTLE(10.0, "Error starting Hokuyo: %s", e.what()); + urg_.reset(); + ros::Duration(1.0).sleep(); + continue; // Return to top of main loop + } + catch (...) + { + ROS_ERROR_THROTTLE(10.0, "Unknown error starting Hokuyo"); + urg_.reset(); + ros::Duration(1.0).sleep(); + continue; // Return to top of main loop + } + + while (!close_scan_) + { + // Don't allow external access during grabbing the scan. + try + { + boost::mutex::scoped_lock lock(lidar_mutex_); + if (publish_multiecho_) + { + const sensor_msgs::MultiEchoLaserScanPtr msg(new sensor_msgs::MultiEchoLaserScan()); + if (urg_->grabScan(msg)) + { + echoes_pub_.publish(msg); + echoes_freq_->tick(); + } + else + { + ROS_WARN_THROTTLE(10.0, "Could not grab multi echo scan."); + device_status_ = urg_->getSensorStatus(); + error_count_++; + } + } + else + { + const sensor_msgs::LaserScanPtr msg(new sensor_msgs::LaserScan()); + if (urg_->grabScan(msg)) + { + laser_pub_.publish(msg); + laser_freq_->tick(); + } + else + { + ROS_WARN_THROTTLE(10.0, "Could not grab single echo scan."); + device_status_ = urg_->getSensorStatus(); + error_count_++; + } + } + } + catch (...) + { + ROS_ERROR_THROTTLE(10.0, "Unknown error grabbing Hokuyo scan."); + error_count_++; + } + + if (service_yield_) + { + boost::this_thread::sleep_for(boost::chrono::milliseconds(10)); + service_yield_ = false; + } + + // Reestablish conneciton if things seem to have gone wrong. + if (error_count_ > error_limit_) + { + ROS_ERROR_THROTTLE(10.0, "Error count exceeded limit, reconnecting."); + urg_.reset(); + ros::Duration(2.0).sleep(); + + break; // Return to top of main loop + } + } + } +} + +void UrgNode::run() +{ + // Setup initial connection + connect(); + + // Stop diagnostics + if (!close_diagnostics_) + { + close_diagnostics_ = true; + diagnostics_thread_.join(); + } + + if (publish_multiecho_) + { + echoes_freq_.reset(new diagnostic_updater::HeaderlessTopicDiagnostic("Laser Echoes", + *diagnostic_updater_, + FrequencyStatusParam(&freq_min_, &freq_min_, diagnostics_tolerance_, diagnostics_window_time_))); + } + else + { + laser_freq_.reset(new diagnostic_updater::HeaderlessTopicDiagnostic("Laser Scan", + *diagnostic_updater_, + FrequencyStatusParam(&freq_min_, &freq_min_, diagnostics_tolerance_, diagnostics_window_time_))); + } + + // Now that we are setup, kick off diagnostics. + close_diagnostics_ = false; + diagnostics_thread_ = boost::thread(boost::bind(&UrgNode::updateDiagnostics, this)); + + // Start scanning now that everything is configured. + close_scan_ = false; + scan_thread_ = boost::thread(boost::bind(&UrgNode::scanThread, this)); +} +} // namespace urg_node diff --git a/src/waypoints b/src/waypoints new file mode 160000 index 0000000..115553c --- /dev/null +++ b/src/waypoints @@ -0,0 +1 @@ +Subproject commit 115553cfa8c2ace122414ac5a9b235cd2e225693