Skip to content
Snippets Groups Projects
Commit 6ab3a858 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
cmake_minimum_required(VERSION 2.8.3)
project(iri_adc_car_lights)
## Find catkin macros and libraries
find_package(catkin REQUIRED)
# ********************************************************************
# Add catkin additional components here
# ********************************************************************
find_package(catkin REQUIRED COMPONENTS iri_base_driver)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
# ********************************************************************
# Add system and labrobotica dependencies here
# ********************************************************************
# find_package(<dependency> REQUIRED)
find_package(iriutils REQUIRED)
find_package(comm REQUIRED)
find_package(dynamixel REQUIRED)
find_package(rgb_leds_driver REQUIRED)
# ********************************************************************
# Add topic, service and action definition here
# ********************************************************************
## 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, services and actions with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# std_msgs # Or other packages containing msgs
# )
# ********************************************************************
# Add the dynamic reconfigure file
# ********************************************************************
generate_dynamic_reconfigure_options(cfg/AdcCarLights.cfg)
# ********************************************************************
# Add run time dependencies here
# ********************************************************************
catkin_package(
# INCLUDE_DIRS
# LIBRARIES
# ********************************************************************
# Add ROS and IRI ROS run time dependencies
# ********************************************************************
CATKIN_DEPENDS iri_base_driver
# ********************************************************************
# Add system and labrobotica run time dependencies here
# ********************************************************************
# DEPENDS
)
###########
## Build ##
###########
# ********************************************************************
# Add the include directories
# ********************************************************************
include_directories(include)
include_directories(${catkin_INCLUDE_DIRS})
include_directories(${iriutils_INCLUDE_DIRS})
include_directories(${comm_INCLUDE_DIRS})
include_directories(${dynamixel_INCLUDE_DIRS})
include_directories(${rgb_leds_driver_INCLUDE_DIRS})
# include_directories(${<dependency>_INCLUDE_DIRS})
## Declare a cpp library
# add_library(${PROJECT_NAME} <list of source files>)
## Declare a cpp executable
add_executable(${PROJECT_NAME} src/adc_car_lights_driver.cpp src/adc_car_lights_driver_node.cpp)
# ********************************************************************
# Add the libraries
# ********************************************************************
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${iriutils_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${comm_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${dynamixel_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${rgb_leds_driver_LIBRARIES})
# target_link_libraries(${PROJECT_NAME} ${<dependency>_LIBRARIES})
# ********************************************************************
# Add message headers dependencies
# ********************************************************************
# add_dependencies(${PROJECT_NAME} <msg_package_name>_generate_messages_cpp)
add_dependencies(${PROJECT_NAME} iri_base_driver_generate_messages_cpp)
add_dependencies(${PROJECT_NAME}_gencfg iri_base_driver_generate_messages_py)
# ********************************************************************
# Add dynamic reconfigure dependencies
# ********************************************************************
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS})
LICENSE 0 → 100644
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
## Description
The iri_adc_car_lights project description
# ROS Interface
### Parameters
- ~**rate** (Double; default: 10.0; min: 0.1; max: 1000) The main node thread loop rate in Hz.
## Installation
Move to the active workspace:
```bash
roscd && cd ../src
```
Clone the repository:
```bash
git clone <url>
```
Install ROS dependencies:
```
roscd
cd ..
rosdep install -i -r --from-paths src
```
Compile the workspace:
```
catkin_make
```
## How to use it
- Standalone test
`roslaunch iri_adc_car_lights test.launch`
## Disclaimer
Copyright (C) Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
Mantainer IRI labrobotics (labrobotica@iri.upc.edu)
This package is distributed in the hope that it will be useful, but without any warranty. It is provided "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program is with you. should the program prove defective, the GMR group does not assume the cost of any necessary servicing, repair or correction.
In no event unless required by applicable law the author will be liable to you for damages, including any general, special, incidental or consequential damages arising out of the use or inability to use the program (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the program to operate with any other programs), even if the author has been advised of the possibility of such damages.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>
#! /usr/bin/env python
#* 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:
PACKAGE='iri_adc_car_lights'
from iri_base_driver.msg import SensorLevels
from dynamic_reconfigure.parameter_generator_catkin import *
gen = ParameterGenerator()
standard = gen.add_group("standard")
brake = gen.add_group("brake")
turn = gen.add_group("turn")
parked = gen.add_group("parked")
emergency = gen.add_group("emergency")
health = gen.add_group("health")
charge = gen.add_group("charge")
# Name Type Reconf.level Description standard Min Max
gen.add("rate", double_t, SensorLevels.RECONFIGURE_STOP, "Main loop rate (Hz)", 10.0, 0.1, 1000.0)
gen.add("serial_port", str_t, SensorLevels.RECONFIGURE_STOP, "Serial port Linux device", "/dev/ttyACM0")
gen.add("baudrate", int_t, SensorLevels.RECONFIGURE_STOP, "Serial port baudrate", 56700, 9600, 1000000)
gen.add("device_id", int_t, SensorLevels.RECONFIGURE_STOP, "car_lights device ID", 1, 1, 254)
gen.add("num_rows", int_t, SensorLevels.RECONFIGURE_STOP, "Number of rows of the LED array", 6, 1, 200)
gen.add("num_cols", int_t, SensorLevels.RECONFIGURE_STOP, "Number of columns of the LED array",8, 1, 200)
gen.add("front_left_start_row",int_t,SensorLevels.RECONFIGURE_STOP, "Start row of the front left lights",0, 0, 200)
gen.add("front_left_num_rows",int_t,SensorLevels.RECONFIGURE_STOP, "Start row of the front left lights",1, 1, 200)
gen.add("front_left_start_col",int_t,SensorLevels.RECONFIGURE_STOP, "Start column of the front left lights",0, 0, 200)
gen.add("front_left_num_cols",int_t,SensorLevels.RECONFIGURE_STOP, "Start column of the front left lights",8, 1, 200)
gen.add("front_right_start_row",int_t,SensorLevels.RECONFIGURE_STOP, "Start row of the front right lights",1, 0, 200)
gen.add("front_right_num_rows",int_t,SensorLevels.RECONFIGURE_STOP, "Start row of the front right lights",1, 1, 200)
gen.add("front_right_start_col",int_t,SensorLevels.RECONFIGURE_STOP, "Start column of the front right lights",0, 0, 200)
gen.add("front_right_num_cols",int_t,SensorLevels.RECONFIGURE_STOP, "Start column of the front right lights",8, 1, 200)
gen.add("rear_left_start_row",int_t,SensorLevels.RECONFIGURE_STOP, "Start row of the rear left lights",4, 0, 200)
gen.add("rear_left_num_rows",int_t,SensorLevels.RECONFIGURE_STOP, "Start row of the rear left lights",1, 1, 200)
gen.add("rear_left_start_col",int_t,SensorLevels.RECONFIGURE_STOP, "Start column of the rear left lights",0, 0, 200)
gen.add("rear_left_num_cols",int_t,SensorLevels.RECONFIGURE_STOP, "Start column of the rear left lights",8, 1, 200)
gen.add("rear_right_start_row",int_t,SensorLevels.RECONFIGURE_STOP, "Start row of the rear right lights",5, 0, 200)
gen.add("rear_right_num_rows",int_t,SensorLevels.RECONFIGURE_STOP, "Start row of the rear right lights",1, 1, 200)
gen.add("rear_right_start_col",int_t,SensorLevels.RECONFIGURE_STOP, "Start column of the rear right lights",0, 0, 200)
gen.add("rear_right_num_cols",int_t,SensorLevels.RECONFIGURE_STOP, "Start column of the rear right lights",8, 1, 200)
gen.add("clear_all", bool_t, SensorLevels.RECONFIGURE_RUNNING, "Turn off the led array", False)
standard.add("standard_front_R", int_t,SensorLevels.RECONFIGURE_RUNNING, "RED component for the front standard configuration", 32, 0, 255)
standard.add("standard_front_G", int_t,SensorLevels.RECONFIGURE_RUNNING, "GREEN component for the front standard configuration", 32, 0, 255)
standard.add("standard_front_B", int_t,SensorLevels.RECONFIGURE_RUNNING, "BLUE component for the front standard configuration", 32, 0, 255)
standard.add("standard_rear_R", int_t,SensorLevels.RECONFIGURE_RUNNING, "RED component for the rear standard configuration", 32, 0, 255)
standard.add("standard_rear_G", int_t,SensorLevels.RECONFIGURE_RUNNING, "GREEN component for the rear standard configuration", 0, 0, 255)
standard.add("standard_rear_B", int_t,SensorLevels.RECONFIGURE_RUNNING, "BLUE component for the rear standard configuration", 0, 0, 255)
standard.add("standard_active",bool_t,SensorLevels.RECONFIGURE_RUNNING, "Set the standard lights configuration", False)
brake.add("brake_rear_R", int_t,SensorLevels.RECONFIGURE_RUNNING, "RED component for the rear brake configuration", 64, 0, 255)
brake.add("brake_rear_G", int_t,SensorLevels.RECONFIGURE_RUNNING, "GREEN component for the rear brake configuration", 0, 0, 255)
brake.add("brake_rear_B", int_t,SensorLevels.RECONFIGURE_RUNNING, "BLUE component for the rear brake configuration", 0, 0, 255)
brake.add("brake_active",bool_t,SensorLevels.RECONFIGURE_RUNNING, "Set the brake lights configuration", False)
turn.add("turn_R", int_t, SensorLevels.RECONFIGURE_RUNNING, "RED component for the turn configuration", 32, 0, 255)
turn.add("turn_G", int_t, SensorLevels.RECONFIGURE_RUNNING, "GREEN component for the turn configuration", 8, 0, 255)
turn.add("turn_B", int_t, SensorLevels.RECONFIGURE_RUNNING, "BLUE component for the turn configuration", 0, 0, 255)
turn.add("turn_period",double_t,SensorLevels.RECONFIGURE_RUNNING, "turn configuration blinking period", 1.0, 0.5, 5.0)
turn.add("turn_left_active",bool_t, SensorLevels.RECONFIGURE_RUNNING, "Set the turn left configuration", False)
turn.add("turn_right_active",bool_t, SensorLevels.RECONFIGURE_RUNNING, "Set the turn right configuration", False)
parked.add("parked_R", int_t,SensorLevels.RECONFIGURE_RUNNING, "RED component for the parked configuration", 0, 0, 255)
parked.add("parked_G", int_t,SensorLevels.RECONFIGURE_RUNNING, "GREEN component for the parked configuration", 0, 0, 255)
parked.add("parked_B", int_t,SensorLevels.RECONFIGURE_RUNNING, "BLUE component for the parked configuration", 32, 0, 255)
parked.add("parked_active",bool_t,SensorLevels.RECONFIGURE_RUNNING, "Set the parked lights configuration", False)
emergency.add("emergency_R", int_t, SensorLevels.RECONFIGURE_RUNNING, "RED component for the emergency configuration", 32, 0, 255)
emergency.add("emergency_G", int_t, SensorLevels.RECONFIGURE_RUNNING, "GREEN component for the emergency configuration", 8, 0, 255)
emergency.add("emergency_B", int_t, SensorLevels.RECONFIGURE_RUNNING, "BLUE component for the emergency configuration", 0, 0, 255)
emergency.add("emergency_period",double_t,SensorLevels.RECONFIGURE_RUNNING, "emergency configuration blinking period", 1.0, 0.5, 5.0)
emergency.add("emergency_active",bool_t, SensorLevels.RECONFIGURE_RUNNING, "Set the emergency configuration", False)
health.add("health_color1_R", int_t,SensorLevels.RECONFIGURE_RUNNING, "RED component for the health configuration", 0, 0, 255)
health.add("health_color1_G", int_t,SensorLevels.RECONFIGURE_RUNNING, "GREEN component for the health configuration", 0, 0, 255)
health.add("health_color1_B", int_t,SensorLevels.RECONFIGURE_RUNNING, "BLUE component for the health configuration", 32, 0, 255)
health.add("health_color2_R", int_t,SensorLevels.RECONFIGURE_RUNNING, "RED component for the health configuration", 32, 0, 255)
health.add("health_color2_G", int_t,SensorLevels.RECONFIGURE_RUNNING, "GREEN component for the health configuration", 0, 0, 255)
health.add("health_color2_B", int_t,SensorLevels.RECONFIGURE_RUNNING, "BLUE component for the health configuration", 0, 0, 255)
health.add("health_period",double_t,SensorLevels.RECONFIGURE_RUNNING, "health configuration blinking period", 1.0, 0.5, 5.0)
health.add("health_active",bool_t,SensorLevels.RECONFIGURE_RUNNING, "Set the health lights configuration", False)
charge.add("charge_R", int_t, SensorLevels.RECONFIGURE_RUNNING, "RED component for the charge configuration", 0, 0, 255)
charge.add("charge_G", int_t, SensorLevels.RECONFIGURE_RUNNING, "GREEN component for the charge configuration", 0, 0, 255)
charge.add("charge_B", int_t, SensorLevels.RECONFIGURE_RUNNING, "BLUE component for the charge configuration", 64, 0, 255)
charge.add("charge_period",double_t,SensorLevels.RECONFIGURE_RUNNING, "charge configuration blinking period", 1.0, 0.5, 5.0)
charge.add("charge_active",bool_t, SensorLevels.RECONFIGURE_RUNNING, "Set the charge configuration", False)
exit(gen.generate(PACKAGE, "AdcCarLightsDriver", "AdcCarLights"))
rate: 10
serial_port: "/dev/ttyACM0"
baudrate: 57600
device_id: 1
num_rows: 6
num_cols: 8
green_R: 0
green_G: 32
green_B: 0
green_active: false
red_R: 32
red_G: 0
red_B: 0
red_active: false
orange_R: 32
orange_G: 8
orange_B: 0
orange_period: 1.0
orange_active: false
// Copyright (C) 2010-2011 Institut de Robotica i Informatica Industrial, CSIC-UPC.
// Author
// All rights reserved.
//
// This file is part of iri-ros-pkg
// iri-ros-pkg is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// IMPORTANT NOTE: This code has been generated through a script from the
// iri_ros_scripts. Please do NOT delete any comments to guarantee the correctness
// of the scripts. ROS topics can be easly add by using those scripts. Please
// refer to the IRI wiki page for more information:
// http://wikiri.upc.es/index.php/Robotics_Lab
#ifndef _adc_car_lights_driver_h_
#define _adc_car_lights_driver_h_
#include <iri_base_driver/iri_base_driver.h>
#include <iri_adc_car_lights/AdcCarLightsConfig.h>
//include adc_car_lights_driver main library
#include "rgb_leds_frame_buffer_driver.h"
#include "rgb_leds_driver.h"
/**
* \brief IRI ROS Specific Driver Class
*
* This class inherits from the IRI Base class IriBaseDriver, which provides the
* guidelines to implement any specific driver. The IriBaseDriver class offers an
* easy framework to integrate functional drivers implemented in C++ with the
* ROS driver structure. ROS driver_base state transitions are already managed
* by IriBaseDriver.
*
* The AdcCarLightsDriver class must implement all specific driver requirements to
* safetely open, close, run and stop the driver at any time. It also must
* guarantee an accessible interface for all driver's parameters.
*
* The AdcCarLightsConfig.cfg needs to be filled up with those parameters suitable
* to be changed dynamically by the ROS dyanmic reconfigure application. The
* implementation of the CIriNode class will manage those parameters through
* methods like postNodeOpenHook() and reconfigureNodeHook().
*
*/
class AdcCarLightsDriver : public iri_base_driver::IriBaseDriver
{
private:
// private attributes and methods
CRGBLedsFrameBufferDriver *frame_buffer;
CRGBLedsDriver *leds;
public:
/**
* \brief define config type
*
* Define a Config type with the AdcCarLightsConfig. All driver implementations
* will then use the same variable type Config.
*/
typedef iri_adc_car_lights::AdcCarLightsConfig Config;
/**
* \brief config variable
*
* This variable has all the driver parameters defined in the cfg config file.
* Is updated everytime function config_update() is called.
*/
Config config_;
/**
* \brief constructor
*
* In this constructor parameters related to the specific driver can be
* initalized. Those parameters can be also set in the openDriver() function.
* Attributes from the main node driver class IriBaseDriver such as loop_rate,
* may be also overload here.
*/
AdcCarLightsDriver(void);
/**
* \brief open driver
*
* In this function, the driver must be openned. Openning errors must be
* taken into account. This function is automatically called by
* IriBaseDriver::doOpen(), an state transition is performed if return value
* equals true.
*
* \return bool successful
*/
bool openDriver(void);
/**
* \brief close driver
*
* In this function, the driver must be closed. Variables related to the
* driver state must also be taken into account. This function is automatically
* called by IriBaseDriver::doClose(), an state transition is performed if
* return value equals true.
*
* \return bool successful
*/
bool closeDriver(void);
/**
* \brief start driver
*
* After this function, the driver and its thread will be started. The driver
* and related variables should be properly setup. This function is
* automatically called by IriBaseDriver::doStart(), an state transition is
* performed if return value equals true.
*
* \return bool successful
*/
bool startDriver(void);
/**
* \brief stop driver
*
* After this function, the driver's thread will stop its execution. The driver
* and related variables should be properly setup. This function is
* automatically called by IriBaseDriver::doStop(), an state transition is
* performed if return value equals true.
*
* \return bool successful
*/
bool stopDriver(void);
/**
* \brief config update
*
* In this function the driver parameters must be updated with the input
* config variable. Then the new configuration state will be stored in the
* Config attribute.
*
* \param new_cfg the new driver configuration state
*
* \param level level in which the update is taken place
*/
void config_update(Config& new_cfg, uint32_t level=0);
// here define all adc_car_lights_driver interface methods to retrieve and set
// the driver parameters
void clear_all(void);
void set_standard(void);
void set_brake(void);
void set_turn_left(void);
void set_turn_right(void);
void set_parked(void);
void set_emergency(void);
void set_health(void);
void set_charge(void);
/**
* \brief Destructor
*
* This destructor is called when the object is about to be destroyed.
*
*/
~AdcCarLightsDriver(void);
};
#endif
// Copyright (C) 2010-2011 Institut de Robotica i Informatica Industrial, CSIC-UPC.
// Author
// All rights reserved.
//
// This file is part of iri-ros-pkg
// iri-ros-pkg is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// IMPORTANT NOTE: This code has been generated through a script from the
// iri_ros_scripts. Please do NOT delete any comments to guarantee the correctness
// of the scripts. ROS topics can be easly add by using those scripts. Please
// refer to the IRI wiki page for more information:
// http://wikiri.upc.es/index.php/Robotics_Lab
#ifndef _adc_car_lights_driver_node_h_
#define _adc_car_lights_driver_node_h_
#include <iri_base_driver/iri_base_driver_node.h>
#include "adc_car_lights_driver.h"
// [publisher subscriber headers]
// [service client headers]
// [action server client headers]
/**
* \brief IRI ROS Specific Driver Class
*
* This class inherits from the IRI Core class IriBaseNodeDriver<IriBaseDriver>,
* to provide an execution thread to the driver object. A complete framework
* with utilites to test the node functionallity or to add diagnostics to
* specific situations is also given. The inherit template design form allows
* complete access to any IriBaseDriver object implementation.
*
* As mentioned, tests in the different driver states can be performed through
* class methods such as addNodeOpenedTests() or addNodeRunningTests(). Tests
* common to all nodes may be also executed in the pattern class IriBaseNodeDriver.
* Similarly to the tests, diagnostics can easyly be added. See ROS Wiki for
* more details:
* http://www.ros.org/wiki/diagnostics/ (Tutorials: Creating a Diagnostic Analyzer)
* http://www.ros.org/wiki/self_test/ (Example: Self Test)
*/
class AdcCarLightsDriverNode : public iri_base_driver::IriBaseNodeDriver<AdcCarLightsDriver>
{
private:
// [publisher attributes]
// [subscriber attributes]
// [service attributes]
// [client attributes]
// [action server attributes]
// [action client attributes]
/**
* \brief post open hook
*
* This function is called by IriBaseNodeDriver::postOpenHook(). In this function
* specific parameters from the driver must be added so the ROS dynamic
* reconfigure application can update them.
*/
void postNodeOpenHook(void);
void preNodeCloseHook(void);
public:
/**
* \brief constructor
*
* This constructor mainly creates and initializes the AdcCarLightsDriverNode topics
* through the given public_node_handle object. IriBaseNodeDriver attributes
* may be also modified to suit node specifications.
*
* All kind of ROS topics (publishers, subscribers, servers or clients) can
* be easyly generated with the scripts in the iri_ros_scripts package. Refer
* to ROS and IRI Wiki pages for more details:
*
* http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber(c++)
* http://www.ros.org/wiki/ROS/Tutorials/WritingServiceClient(c++)
* http://wikiri.upc.es/index.php/Robotics_Lab
*
* \param nh a reference to the node handle object to manage all ROS topics.
*/
AdcCarLightsDriverNode(ros::NodeHandle& nh);
/**
* \brief config variable
*
* This variable has all the driver parameters defined in the cfg config file.
* Is updated everytime function config_update() is called.
*/
Config config_;
/**
* \brief Destructor
*
* This destructor is called when the object is about to be destroyed.
*
*/
~AdcCarLightsDriverNode(void);
protected:
/**
* \brief main node thread
*
* This is the main thread node function. Code written here will be executed
* in every node loop while the driver is on running state. Loop frequency
* can be tuned by modifying loop_rate attribute.
*
* Here data related to the process loop or to ROS topics (mainly data structs
* related to the MSG and SRV files) must be updated. ROS publisher objects
* must publish their data in this process. ROS client servers may also
* request data to the corresponding server topics.
*/
void mainNodeThread(void);
// [diagnostic functions]
/**
* \brief node add diagnostics
*
* In this function ROS diagnostics applied to this specific node may be
* added. Common use diagnostics for all nodes are already called from
* IriBaseNodeDriver::addDiagnostics(), which also calls this function. Information
* of how ROS diagnostics work can be readen here:
* http://www.ros.org/wiki/diagnostics/
* http://www.ros.org/doc/api/diagnostic_updater/html/example_8cpp-source.html
*/
void addNodeDiagnostics(void);
// [driver test functions]
/**
* \brief specific node dynamic reconfigure
*
* This function is called reconfigureHook()
*
* \param level integer
*/
void node_config_update(Config& new_cfg, uint32_t level);
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<launch>
<arg name="node_name" default="iri_adc_car_lights"/>
<arg name="output" default="screen"/>
<arg name="launch_prefix" default=""/>
<arg name="config_file" default="$(find iri_adc_car_lights)/config/params.yaml"/>
<!-- <arg name="topic_name" default="new_topic_name"/> -->
<node name="$(arg node_name)"
pkg ="iri_adc_car_lights"
type="iri_adc_car_lights"
output="$(arg output)"
launch-prefix="$(arg launch_prefix)">
<rosparam file="$(arg config_file)" command="load"/>
<!--<remap from="~/topic" to="$(arg topic_name)"/>-->
</node>
</launch>
<?xml version="1.0" encoding="UTF-8"?>
<launch>
<arg name="output" default="screen"/>
<arg name="launch_prefix" default=""/>
<arg name="dr" default="true"/>
<include file="$(find iri_adc_car_lights)/launch/node.launch">
<arg name="node_name" value="iri_adc_car_lights"/>
<arg name="output" value="$(arg output)"/>
<arg name="launch_prefix" value="$(arg launch_prefix)"/>
</include>
<node name="rqt_reconfigure_iri_adc_car_lights"
pkg ="rqt_reconfigure"
type="rqt_reconfigure"
if ="$(arg dr)"
args="iri_adc_car_lights">
</node>
</launch>
<?xml version="1.0"?>
<package format="2">
<name>iri_adc_car_lights</name>
<version>0.0.0</version>
<description>The iri_adc_car_lights package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="shernand@iri.upc.edu">shernand</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>LGPL</license>
<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/iri_adc_car_lights</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>iri_base_driver</build_depend>
<build_export_depend>iri_base_driver</build_export_depend>
<exec_depend>iri_base_driver</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
This diff is collapsed.
#include "adc_car_lights_driver_node.h"
#include "exceptions.h"
AdcCarLightsDriverNode::AdcCarLightsDriverNode(ros::NodeHandle &nh) :
iri_base_driver::IriBaseNodeDriver<AdcCarLightsDriver>(nh)
{
//init class attributes if necessary
if(!this->private_node_handle_.getParam("rate", this->config_.rate))
{
ROS_WARN("AdcCarLightsDriverNode::AdcCarLightsDriverNode: param 'rate' not found");
}
else
this->setRate(this->config_.rate);
// [init publishers]
// [init subscribers]
// [init services]
// [init clients]
// [init action servers]
// [init action clients]
}
void AdcCarLightsDriverNode::mainNodeThread(void)
{
//lock access to driver if necessary
this->driver_.lock();
ROS_DEBUG("AdcCarLightsDriverNode::mainNodeThread");
// [fill msg Header if necessary]
// [fill msg structures]
// [fill srv structure and make request to the server]
// [fill action structure and make request to the action server]
// [publish messages]
//unlock access to driver if previously blocked
this->driver_.unlock();
}
/* [subscriber callbacks] */
/* [service callbacks] */
/* [action callbacks] */
/* [action requests] */
void AdcCarLightsDriverNode::postNodeOpenHook(void)
{
}
void AdcCarLightsDriverNode::preNodeCloseHook(void)
{
}
void AdcCarLightsDriverNode::addNodeDiagnostics(void)
{
}
void AdcCarLightsDriverNode::node_config_update(Config& new_cfg, uint32_t level)
{
this->driver_.lock();
try{
if(new_cfg.rate!=this->getRate())
this->setRate(new_cfg.rate);
if(new_cfg.clear_all)
{
this->driver_.clear_all();
new_cfg.clear_all=false;
}
else if(new_cfg.standard_active)
{
this->driver_.set_standard();
new_cfg.standard_active=false;
}
else if(new_cfg.brake_active)
{
this->driver_.set_brake();
new_cfg.brake_active=false;
}
else if(new_cfg.turn_left_active)
{
this->driver_.set_turn_left();
new_cfg.turn_left_active=false;
}
else if(new_cfg.turn_right_active)
{
this->driver_.set_turn_right();
new_cfg.turn_right_active=false;
}
else if(new_cfg.parked_active)
{
this->driver_.set_parked();
new_cfg.parked_active=false;
}
else if(new_cfg.emergency_active)
{
this->driver_.set_emergency();
new_cfg.emergency_active=false;
}
else if(new_cfg.health_active)
{
this->driver_.set_health();
new_cfg.health_active=false;
}
else if(new_cfg.charge_active)
{
this->driver_.set_charge();
new_cfg.charge_active=false;
}
this->config_=new_cfg;
}catch(CException &e){
ROS_WARN_STREAM(e.what());
}
this->driver_.unlock();
}
AdcCarLightsDriverNode::~AdcCarLightsDriverNode(void)
{
// [free dynamic memory]
}
/* main function */
int main(int argc,char *argv[])
{
return iri_base_driver::main<AdcCarLightsDriverNode>(argc, argv, "adc_car_lights_driver_node");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment