Skip to content

Commit

Permalink
Quad RGB LEDs (RGB ring) added
Browse files Browse the repository at this point in the history
  • Loading branch information
musalman709 committed Nov 10, 2020
1 parent 78b4d3c commit 487b995
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/plugins/robots/e-puck/Interface.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(ARGOS3_HEADERS_PLUGINS_ROBOTS_EPUCK_CONTROLINTERFACE
control_interface/ci_epuck_base_leds_actuator.h
control_interface/ci_epuck_ground_leds_actuator.h
control_interface/ci_epuck_rgb_leds_actuator.h
control_interface/ci_epuck_quad_rgb_leds_actuator.h
control_interface/ci_epuck_range_and_bearing_actuator.h
control_interface/ci_epuck_wheels_actuator.h
control_interface/ci_epuck_ircom_actuator.h
Expand All @@ -45,6 +46,7 @@ set(ARGOS3_SOURCES_PLUGINS_ROBOTS_EPUCK
control_interface/ci_epuck_base_leds_actuator.cpp
control_interface/ci_epuck_ground_leds_actuator.cpp
control_interface/ci_epuck_rgb_leds_actuator.cpp
control_interface/ci_epuck_quad_rgb_leds_actuator.cpp
control_interface/ci_epuck_range_and_bearing_actuator.cpp
control_interface/ci_epuck_wheels_actuator.cpp
control_interface/ci_epuck_ircom_actuator.cpp
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/robots/e-puck/RealLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(ARGOS3_HEADERS_PLUGINS_ROBOTS_EPUCK_REALROBOT
real_robot/real_epuck_base_leds_actuator.h
real_robot/real_epuck_ground_leds_actuator.h
real_robot/real_epuck_rgb_leds_actuator.h
real_robot/real_epuck_quad_rgb_leds_actuator.h
real_robot/real_epuck_range_and_bearing_actuator.h
real_robot/real_epuck_ircom_actuator.h
real_robot/real_epuck_virtual_camrab_actuator.h)
Expand Down Expand Up @@ -75,6 +76,7 @@ set(ARGOS3_SOURCES_PLUGINS_ROBOTS_EPUCK
real_robot/real_epuck_base_leds_actuator.cpp
real_robot/real_epuck_ground_leds_actuator.cpp
real_robot/real_epuck_rgb_leds_actuator.cpp
real_robot/real_epuck_quad_rgb_leds_actuator.cpp
real_robot/real_epuck_range_and_bearing_actuator.cpp
real_robot/real_epuck_ircom_actuator.cpp
real_robot/real_epuck_virtual_camrab_actuator.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* @file <argos3/plugins/robots/e-puck/control_interface/ci_epuck_Quad_RGB_leds_actuator.h
*
* @author Muhammad Salman- <>
* @author Lorenzo Garattoni - <[email protected]>
*/

#include "ci_epuck_quad_rgb_leds_actuator.h"

namespace argos {

/****************************************/
/****************************************/

CCI_EPuckQuadRGBLEDsActuator::CCI_EPuckQuadRGBLEDsActuator() :
m_tLEDSettings(4) {}

/****************************************/
/****************************************/

void CCI_EPuckQuadRGBLEDsActuator::SetColor(size_t un_led_number,
const CColor& c_color) {
m_tLEDSettings[un_led_number] = c_color;
}

/****************************************/
/****************************************/

void CCI_EPuckQuadRGBLEDsActuator::SetColors(const CColor& c_color) {
SetColor(0, c_color);
SetColor(1, c_color);
SetColor(2, c_color);
SetColor(3, c_color);
}

/****************************************/
/****************************************/

void CCI_EPuckQuadRGBLEDsActuator::SetColors(const TLEDSettings& t_colors) {
SetColor(0, t_colors[0]);
SetColor(1, t_colors[1]);
SetColor(2, t_colors[2]);
SetColor(2, t_colors[3]);
}

/****************************************/
/****************************************/

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* @file <argos3/plugins/robots/e-puck/control_interface/ci_epuck_quad_RGB_leds_actuator.h
*
* This file provides the definition of the e-puck Quad_RGB LEDs actuator.
*
* The user can switch on the 4 RGB LEDs on ----
* of the e-puck, specifying the RGB color.
*
* The LEDs are distributed as follows: (View from the top)
*
* front
* r
* l 0 1 i
* e g
* f h
* t 3 2 t
* back
*
* @author Muhammad Salman- <>
* @author Lorenzo Garattoni- <[email protected]>
*/

#ifndef CCI_EPUCK_QUAD_RGB_LEDS_ACTUATOR_H
#define CCI_EPUCK_QUAD_RGB_LEDS_ACTUATOR_H

#include <argos3/core/utility/logging/argos_log.h>

namespace argos {
class CCI_EPuckQuadRGBLEDsActuator;
}

#include <argos3/core/utility/datatypes/color.h>
#include <argos3/core/control_interface/ci_actuator.h>

namespace argos {

class CCI_EPuckQuadRGBLEDsActuator : public CCI_Actuator {

public:

/**
* RGB LED settings data type
*/
typedef std::vector<CColor> TLEDSettings;

public:

CCI_EPuckQuadRGBLEDsActuator();

virtual ~CCI_EPuckQuadRGBLEDsActuator() {}

/**
* Sets the color of a single LED.
* @param un_led_number The number of the LED [0-2]
* @param c_color The wanted color.
*/
virtual void SetColor(size_t un_led_number,
const CColor& c_color);

/**
* Sets the same color for all LEDs.
* @param c_color The wanted color.
*/
virtual void SetColors(const CColor& c_color);

/**
* Sets the colors of all LEDs individually.
*/
virtual void SetColors(const TLEDSettings& c_colors);

// #ifdef ARGOS_WITH_LUA
// /**
// *
// * @param pt_lua_state
// */
// virtual void CreateLuaState(lua_State* pt_lua_state);
// #endif

protected:

/**
* RGB LEDs settings
*/
TLEDSettings m_tLEDSettings;
};

}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* @file <argos3/plugins/robot/e-puck/real_robot/real_epuck_rgb_leds_actuator.h>
*
* @author Lorenzo Garattoni - <[email protected]>
*/

#include "real_epuck_quad_rgb_leds_actuator.h"
#include <argos3/core/utility/logging/argos_log.h>

namespace argos {

/****************************************/
enum GLEDsRegisters {
// REGISTER ADDRESSES
MODE1 0x00 /**< Mode Register 1 */
MODE2 0x01 /**< Mode Register 2 */
//LED0
LED0_ON_L 0x06 /**< LED0 on tick, low byte*/
LED0_ON_H 0x07 /**< LED0 on tick, high byte*/
LED0_OFF_L 0x08 /**< LED0 off tick, low byte */
LED0_OFF_H 0x09 /**< LED0 off tick, high byte */
// etc all 16: LED15_OFF_H 0x45
ALLLED_ON_L 0xFA /**< load all the LEDn_ON registers, low */
ALLLED_ON_H 0xFB /**< load all the LEDn_ON registers, high */
ALLLED_OFF_L 0xFC /**< load all the LEDn_OFF registers, low */
ALLLED_OFF_H 0xFD /**< load all the LEDn_OFF registers,high */
PRESCALE 0xFE /**< Prescaler for PWM output frequency */
TESTMODE 0xFF /**< defines the test mode to be entered */

// MODE1 bits
MODE1_ALLCAL 0x01 /**< respond to LED All Call I2C-bus address */
MODE1_SUB3 0x02 /**< respond to I2C-bus subaddress 3 */
MODE1_SUB2 0x04 /**< respond to I2C-bus subaddress 2 */
MODE1_SUB1 0x08 /**< respond to I2C-bus subaddress 1 */
MODE1_SLEEP 0x10 /**< Low power mode. Oscillator off */
MODE1_AI 0x20 /**< Auto-Increment enabled */
MODE1_EXTCLK 0x40 /**< Use EXTCLK pin clock */
MODE1_RESTART 0x80 /**< Restart enabled */
// MODE2 bits
MODE2_OUTNE_0 0x01 /**< Active LOW output enable input */
MODE2_OUTNE_1 0x02 /**< Active LOW output enable input - high impedience */
MODE2_OUTDRV 0x04 /**< totem pole structure vs open-drain */
MODE2_OCH 0x08 /**< Outputs change on ACK vs STOP */
MODE2_INVRT 0x10 /**< Output logic state inverted */

I2C_ADDRESS 0x40 /**< Default PCA9685 I2C Slave Address */
FREQUENCY_OSCILLATOR 25000000 /**< Int. osc. frequency in datasheet */

PRESCALE_MIN 3 /**< minimum prescale value */
PRESCALE_MAX 255 /**< maximum prescale value */

};

/*******************
*********************/

CRealEPuckQuadRGBLEDsActuator::CRealEPuckQuadRGBLEDsActuator() {

m_tDeviceStream = OpenDevice(I2C_ADDRESS);

}

/****************************************/
/****************************************/

CRealEPuckQuadRGBLEDsActuator::~CRealEPuckQuadRGBLEDsActuator() {

SetColors(CColor::BLACK);
SendData();
CloseDevice(m_tDeviceStream);

}

/****************************************/
/****************************************/

void CRealEPuckQuadRGBLEDsActuator::SendData() {

SInt8 nData[9];
nData[0] = m_tLEDSettings[2].GetRed();
nData[1] = m_tLEDSettings[2].GetGreen();
nData[2] = m_tLEDSettings[2].GetBlue();
nData[3] = m_tLEDSettings[1].GetRed();
nData[4] = m_tLEDSettings[1].GetGreen();
nData[5] = m_tLEDSettings[1].GetBlue();
nData[6] = m_tLEDSettings[0].GetRed();
nData[7] = m_tLEDSettings[0].GetGreen();
nData[8] = m_tLEDSettings[0].GetBlue();
WriteData(m_tDeviceStream, nData, 9);

}

/****************************************/
/****************************************/

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @file <argos3/plugins/robot/e-puck/real_robot/real_epuck_rgb_leds_actuator.h>
*
* @author Lorenzo Garattoni - <[email protected]>
*/

#ifndef REAL_EPUCK_QUAD_RGB_LEDS_ACTUATOR_H
#define REAL_EPUCK_QUAD_RGB_LEDS_ACTUATOR_H

namespace argos {
class CRealEPuckQuadRGBLEDsActuator;
}

#include <argos3/plugins/robots/e-puck/control_interface/ci_epuck_quad_rgb_leds_actuator.h>
#include <argos3/plugins/robots/e-puck/real_robot/real_epuck_i2c_actuator.h>

namespace argos {

class CRealEPuckQuadRGBLEDsActuator : virtual public CCI_EPuckQuadRGBLEDsActuator,
virtual public CRealEPuckI2CActuator {

public:

CRealEPuckQuadRGBLEDsActuator();
virtual ~CRealEPuckQuadRGBLEDsActuator();

virtual void SendData();

private:

TI2CDeviceStream m_tDeviceStream;

};
}
#endif

0 comments on commit 487b995

Please sign in to comment.