Skip to content

Commit

Permalink
using a smaller buffer and small reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrichard committed Jan 21, 2012
1 parent 8833a38 commit 0be74f3
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 97 deletions.
1 change: 0 additions & 1 deletion ros/uc_arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ INCLUDE_DIRECTORIES(/opt/ros/electric/stacks/rosserial/rosserial_arduino/librari

ADD_ROBOT_ARM_EXECUTABLE(RobotArm_ROS
RobotArm_ROS.cpp
time.cpp
)

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/RobotArm_ROS.hex DESTINATION ${CMAKE_INSTALL_PREFIX}/share/robotloader/examples/ros)
Expand Down
63 changes: 59 additions & 4 deletions ros/uc_arm/RobotArm_ROS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,36 @@
// http://www.ros.org/wiki/rosserial_arduino/Tutorials
// Richard Ulrich <richi@paraeasy.ch>
// GPL v3


#include "ArexxArmHardware.h"
// robot arm lib
#include "RobotArmBaseLib.h"
#include <RobotArmBaseLib.h>
// ros
#include "ros_arexx.h"
#include <ros/node_handle.h>
#include <std_msgs/Int16.h>
#include <std_msgs/UInt8.h>
// std lib
#include <ctype.h>
#include <ctype.h>

/*****************************************************************************/
namespace ros
{
/*
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega168__)
// downsize our buffers
typedef NodeHandle_<ArexxArmHardware, 6, 6, 150, 150> NodeHandle;
#elif defined(__AVR_ATmega328P__)
*/
typedef NodeHandle_<ArexxArmHardware, 25, 25, 280, 280> NodeHandle;
/*
#else
typedef NodeHandle_<ArexxArmHardware> NodeHandle;
#endif
*/
}
/*****************************************************************************/
// callback functions
template<uint8_t servonum>
Expand Down Expand Up @@ -91,6 +112,40 @@ int main(void)
return 0;
}
/*****************************************************************************/
namespace ros
{
void normalizeSecNSec(unsigned long& sec, unsigned long& nsec){
unsigned long nsec_part= nsec % 1000000000UL;
unsigned long sec_part = nsec / 1000000000UL;
sec += sec_part;
nsec = nsec_part;
}

Time& Time::fromNSec(long t)
{
sec = t / 1000000000;
nsec = t % 1000000000;
normalizeSecNSec(sec, nsec);
return *this;
}

Time& Time::operator +=(const Duration &rhs)
{
sec += rhs.sec;
nsec += rhs.nsec;
normalizeSecNSec(sec, nsec);
return *this;
}

Time& Time::operator -=(const Duration &rhs){
sec += -rhs.sec;
nsec += -rhs.nsec;
normalizeSecNSec(sec, nsec);
return *this;
}

}
/*****************************************************************************/
/// http://stackoverflow.com/questions/920500/what-is-the-purpose-of-cxa-pure-virtual
extern "C" void __cxa_pure_virtual() { while (1); }
/*****************************************************************************/
Expand Down
22 changes: 0 additions & 22 deletions ros/uc_arm/ros_arexx.h

This file was deleted.

70 changes: 0 additions & 70 deletions ros/uc_arm/time.cpp

This file was deleted.

0 comments on commit 0be74f3

Please sign in to comment.