Skip to content
Snippets Groups Projects
Commit 48f6dabe authored by Guillem Alenyà's avatar Guillem Alenyà
Browse files

trunk/tags/branches creation

parents
No related branches found
No related tags found
No related merge requests found
# Pre-requisites about cmake itself
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0005 NEW)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
# The project name and the type of project
PROJECT(dynamixel_motor_cont)
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)
SET(CMAKE_INSTALL_PREFIX /usr/local)
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DEBUG")
ENDIF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_C_FLAGS_DEBUG "-g -Wall -D_REENTRANT")
SET(CMAKE_C_FLAGS_RELEASE "-O3 -D_REENTRANT")
ADD_SUBDIRECTORY(src)
FIND_PACKAGE(Doxygen)
FIND_PATH(IRI_DOC_DIR doxygen.conf ${CMAKE_SOURCE_DIR}/doc/iri_doc/)
IF (IRI_DOC_DIR)
ADD_CUSTOM_TARGET (doc ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/iri_doc/doxygen.conf)
ELSE (IRI_DOC_DIR)
ADD_CUSTOM_TARGET (doc ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/doc/doxygen.conf)
ENDIF (IRI_DOC_DIR)
ADD_CUSTOM_TARGET (distclean @echo cleaning cmake files)
IF (UNIX)
ADD_CUSTOM_COMMAND(
COMMENT "distribution clean"
COMMAND make ARGS clean
COMMAND rm ARGS -rf ${CMAKE_SOURCE_DIR}/build/*
TARGET distclean
)
ELSE(UNIX)
ADD_CUSTOM_COMMAND(
COMMENT "distclean only implemented in unix"
TARGET distclean
)
ENDIF(UNIX)
ADD_CUSTOM_TARGET (uninstall @echo uninstall package)
IF (UNIX)
ADD_CUSTOM_COMMAND(
COMMENT "uninstall package"
COMMAND xargs ARGS rm < install_manifest.txt
TARGET uninstall
)
ELSE(UNIX)
ADD_CUSTOM_COMMAND(
COMMENT "uninstall only implemented in unix"
TARGET uninstall
)
ENDIF(UNIX)
IF (UNIX)
SET(CPACK_PACKAGE_FILE_NAME "iri-${PROJECT_NAME}-dev-${CPACK_PACKAGE_VERSION}${DISTRIB}${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
SET(CPACK_PACKAGE_NAME "iri-${PROJECT_NAME}-dev")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Part of IRI-laboratory libraries. More information at http://wikiri.upc.es/index.php/Robotics_Lab")
SET(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "labrobotica@iri.upc.edu")
SET(CPACK_SET_DESTDIR "ON") # Necessary because of the absolute install paths
INCLUDE(CPack)
ELSE(UNIX)
ADD_CUSTOM_COMMAND(
COMMENT "packaging only implemented in unix"
TARGET uninstall
)
ENDIF(UNIX)
#edit the following line to add the librarie's header files
FIND_PATH(dynamixel_motor_cont_INCLUDE_DIR dynamixel.h /usr/include/iridrivers /usr/local/include/iridrivers)
FIND_LIBRARY(dynamixel_motor_cont_LIBRARY
NAMES dynamixel_motor_cont
PATHS /usr/lib /usr/local/lib /usr/local/lib/iridrivers)
IF (dynamixel_motor_cont_INCLUDE_DIR AND dynamixel_motor_cont_LIBRARY)
SET(dynamixel_motor_cont_FOUND TRUE)
ENDIF (dynamixel_motor_cont_INCLUDE_DIR AND dynamixel_motor_cont_LIBRARY)
IF (dynamixel_motor_cont_FOUND)
IF (NOT dynamixel_motor_cont_FIND_QUIETLY)
MESSAGE(STATUS "Found dynamixel_motor_cont: ${dynamixel_motor_cont_LIBRARY}")
ENDIF (NOT dynamixel_motor_cont_FIND_QUIETLY)
ELSE (dynamixel_motor_cont_FOUND)
IF (dynamixel_motor_cont_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find dynamixel_motor_cont")
ENDIF (dynamixel_motor_cont_FIND_REQUIRED)
ENDIF (dynamixel_motor_cont_FOUND)
Copyright (C) 2009-2010 Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
Author shernand (shernand@iri.upc.edu)
All rights reserved.
This file is part of Dynamixel motor controller library
Dynamixel motor controller library 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/>
# Doxyfile 1.5.5
@INCLUDE_PATH = ../doc/
@INCLUDE = doxygen_project_name.conf
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NUMBER =
OUTPUT_DIRECTORY = ../doc
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = NO
ABBREVIATE_BRIEF =
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
QT_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = YES
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
OPTIMIZE_OUTPUT_VHDL = NO
BUILTIN_STL_SUPPORT = NO
CPP_CLI_SUPPORT = NO
SIP_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
TYPEDEF_HIDES_STRUCT = NO
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
EXTRACT_ANON_NSPACES = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
SORT_GROUP_NAMES = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = YES
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = ../src \
../doc/main.dox
INPUT_ENCODING = UTF-8
FILE_PATTERNS = *.c \
*.h \
*.cpp
RECURSIVE = YES
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = *.tab.c \
*.tab.h \
lex* \
*glr.h \
*llr.h \
*glr.c \
*llr.c \
*general.h
EXCLUDE_SYMBOLS =
EXAMPLE_PATH = ../src/examples
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
IMAGE_PATH = ../doc/images
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = YES
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = YES
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
GENERATE_DOCSET = NO
DOCSET_FEEDNAME = "Doxygen generated docs"
DOCSET_BUNDLE_ID = org.doxygen.Project
HTML_DYNAMIC_SECTIONS = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = NO
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = YES
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = NO
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED = _USE_MPI=1
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE =
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
MSCGEN_PATH =
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = YES
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = NO
INCLUDED_BY_GRAPH = NO
CALL_GRAPH = YES
CALLER_GRAPH = YES
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = NO
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_GRAPH_MAX_NODES = 50
MAX_DOT_GRAPH_DEPTH = 2
DOT_TRANSPARENT = YES
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
PROJECT_NAME = "Dynamixel motor controller"
/*! \mainpage Dynamixel motor controller
\section Introduction
\subsection Pre-Requisites
This package requires of the following libraries and packages
- <A href="http://www.cmake.org">cmake</A>, a cross-platform build system.
- <A href="http://www.doxygen.org">doxygen</a> and
<A href="http://www.graphviz.org">graphviz</a> to generate the documentation.
- stdc++,
.
Under linux all of these utilities are available in ready-to-use packages.
Under MacOS most of the packages are available via <a href="http://www.finkproject.org/">fink</a>. <br>
\subsection Compilation
Just download this package, uncompress it, and execute
- cd build
- cmake ..
.
to generate the makefile and then
- make
.
to obtain the shared library (in this case called <em>iriutils.so</em>) and
also all the example programs.
The <em>cmake</em> only need to be executed once (make will automatically call
<em>cmake</em> if you modify one of the <em>CMakeList.txt</em> files).
To generate this documentation type
- make doc
.
The files in the <em>build</em> directory are genetated by <em>cmake</em>
and <em>make</em> and can be safely removed.
After doing so you will need to call cmake manually again.
\subsection Configuration
The default build mode is DEBUG. That is, objects and executables
include debug information.
The RELEASE build mode optimizes for speed. To build in this mode
execute
- cmake .. -DCMAKE_BUILD_TYPE=RELEASE
.
The release mode will be kept until next time cmake is executed.
\subsection Installation
In order to be able to use the library, it it necessary to copy it into the system.
To do that, execute
- make install
.
as root and the shared libraries will be copied to <em>/usr/local/lib/iriutils</em> directory
and the header files will be copied to <em>/usr/local/include/iriutils</em> dierctory. At
this point, the library may be used by any user.
To remove the library from the system, exceute
- make uninstall
.
as root, and all the associated files will be removed from the system.
\section Customization
To build a new application using these library, first it is necessary to locate if the library
has been installed or not using the following command
- FIND_PACKAGE(dynamixel_motor_cont REQUIRED)
In the case that the package is present, it is necessary to add the header files directory to
the include directory path by using
- INCLUDE_DIRECTORIES(${dynamixel_motor_cont_INCLUDE_DIR})
Finally, it is also nevessary to link with the desired libraries by using the following command
- TARGET_LINK_LIBRARIES(<executable name> ${dynamixel_motor_cont_LIBRARY})
.
\section License
This package is licensed under a
<a href="http://www.gnu.org/licenses/lgpl.html">
LGPL 3.0 License</a>.
\section Disclaimer
This 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/>.
*/
# edit the following line to add all the source code files of the library
SET(sources dynamixel_motor.cpp)
# edit the following line to add all the header files of the library
SET(headers dynamixel_motor.h)
FIND_PACKAGE(comm REQUIRED)
FIND_PACKAGE(dynamixel REQUIRED)
FIND_PACKAGE(motor_control REQUIRED)
# edit the following line to add the necessary include directories
INCLUDE_DIRECTORIES(${comm_INCLUDE_DIR} ${dynamixel_INCLUDE_DIR} ${motor_control_INCLUDE_DIR} .)
ADD_LIBRARY(dynamixel_motor_cont SHARED ${sources})
#edit the following line to add the necessary system libraries (if any)
TARGET_LINK_LIBRARIES(dynamixel_motor_cont ${comm_LIBRARY} ${dynamixel_LIBRARY} ${motor_control_LIBRARY})
INSTALL(TARGETS dynamixel_motor_cont
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib/iridrivers
ARCHIVE DESTINATION lib/iridrivers
)
INSTALL(FILES ${headers} DESTINATION include/iridrivers)
INSTALL(FILES ../Finddynamixel_motor_cont.cmake DESTINATION ${CMAKE_ROOT}/Modules/)
ADD_SUBDIRECTORY(examples)
This diff is collapsed.
#ifndef _DYNAMIXEL_MOTOR_H
#define _DYNAMIXEL_MOTOR_H
#include "dynamixelserver.h"
#include "motor_control.h"
#include "eventserver.h"
#include "ftdimodule.h"
#include "mutex.h"
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
typedef enum {
model_number=0x00,
firmware_version=0x02,
id=0x03,
baudrate=0x04,
return_delay_time=0x05,
cw_angle_limit=0x06,
ccw_angle_limit=0x08,
temp_limit=0x0B,
low_voltage_limit=0x0C,
high_voltage_limit=0x0D,
max_torque=0x0E,
return_level=0x10,
alarm_led=0x11,
alarm_shtdwn=0x12,
down_cal=0x14,
up_cal=0x16,
torque_en=0x18,
led=0x19,
cw_comp_margin=0x1A,
ccw_comp_margin=0x1B,
cw_comp_slope=0x1C,
ccw_comp_slope=0x1D,
goal_pos=0x1E,
goal_speed=0x20,
torque_limit=0x22,
current_pos=0x24,
current_speed=0x26,
current_load=0x28,
current_voltage=0x2A,
current_temp=0x2B,
reg_inst=0x2C,
moving=0x2E,
lock=0x2F,
punch=0x30
} reg_id;
typedef enum {
input_voltage_error=0x01,
angle_limit_error=0x02,
overheating_error=0x04,
range_error=0x08,
checksum_error=0x10,
overload_error=0x20,
instruction_error=0x40
}dyn_alarm;
typedef struct
{
std::string model;
unsigned char firmware_ver;
}TDynamixel_info;
typedef struct
{
unsigned char cw_compliance_margin;
unsigned char ccw_compliance_margin;
unsigned char cw_compliance_slope;
unsigned char ccw_compliance_slope;
unsigned char punch;
}TDynamixel_control;
/**
* \brief
*
*/
class CDynamixelMotor : public CMotorControl
{
private:
CDynamixelServer *dyn_server;
/**
* \brief
*
*/
CDynamixel *dynamixel_dev;
/**
* \brief
*
*/
TDynamixel_control control;
/**
* \brief
*
*/
TDynamixel_info info;
/**
* \brief
*
*/
unsigned char alarms;
/**
* \brief
*
*/
bool torque_control;
protected:
/**
* \brief
*
*/
virtual void angles_to_controller(short int motors,std::vector<float>& angles,std::vector<long int>& counts);
/**
* \brief
*
*/
virtual void speeds_to_controller(short int motors,std::vector<float>& angles,std::vector<long int>& counts);
/**
* \brief
*
*/
virtual void accels_to_controller(short int motors,std::vector<float>& angles,std::vector<long int>& counts);
/**
* \brief
*
*/
virtual void controller_to_angles(short int motors,std::vector<long int>& counts,std::vector<float>& angles);
/**
* \brief
*
*/
virtual void controller_to_speeds(short int motors,std::vector<long int>& counts,std::vector<float>& angles);
/**
* \brief
*
*/
virtual void controller_to_accels(short int motors,std::vector<long int>& counts,std::vector<float>& angles);
/**
* \brief
*
*/
virtual void cont_set_accel_range(short int motors,std::vector<long int>& min, std::vector<long int>& max);
/**
* \brief
*
*/
virtual void cont_set_velocity_range(short int motors,std::vector<long int>& min, std::vector<long int>& max);
/**
* \brief
*
*/
virtual void cont_set_position_range(short int motors,std::vector<long int>& min, std::vector<long int>& max);
/**
* \brief
*
*/
virtual void cont_set_encoder_resolution(short int motors,std::vector<int>& enc_res);
/**
* \brief
*
*/
virtual void cont_set_gear_factor(short int motors,std::vector<float>& gear);
/**
* \brief
*
*/
virtual void cont_set_current_limit(short int motors,std::vector<float>& current);
/**
* \brief
*
*/
virtual void cont_get_accel_range(short int motors,std::vector<long int>& min, std::vector<long int>& max);
/**
* \brief
*
*/
virtual void cont_get_velocity_range(short int motors,std::vector<long int>& min, std::vector<long int>& max);
/**
* \brief
*
*/
virtual void cont_get_position_range(short int motors,std::vector<long int>& min, std::vector<long int>& max);
/**
* \brief
*
*/
virtual void cont_get_encoder_resolution(short int motors,std::vector<int>& enc_res);
/**
* \brief
*
*/
virtual void cont_get_gear_factor(short int motors,std::vector<float>& gear);
/**
* \brief
*
*/
virtual void cont_get_current_limit(short int motors,std::vector<float>& current);
/**
* \brief
*
*/
virtual void cont_set_absolute_motion(short int motors);
/**
* \brief
*
*/
virtual void cont_set_relative_motion(short int motors);
/**
* \brief
*
*/
virtual void cont_enable_position_feedback(short int motors,std::vector<float>& sample_rate);
/**
* \brief
*
*/
virtual void cont_enable_velocity_feedback(short int motors,std::vector<float>& sample_rate);
/**
* \brief
*
*/
virtual void cont_enable_acceleration_feedback(short int motors,std::vector<float>& sample_rate);
/**
* \brief
*
*/
virtual void cont_enable_current_feedback(short int motors,std::vector<float>& sample_rate);
/**
* \brief
*
*/
virtual void cont_enable_limits_feedback(short int motors,std::vector<float>& sample_rate);
/**
* \brief
*
*/
virtual void cont_disable_position_feedback(short int motors);
/**
* \brief
*
*/
virtual void cont_disable_velocity_feedback(short int motors);
/**
* \brief
*
*/
virtual void cont_disable_acceleration_feedback(short int motors);
/**
* \brief
*
*/
virtual void cont_disable_current_feedback(short int motors);
/**
* \brief
*
*/
virtual void cont_disable_limits_feedback(short int motors);
/**
* \brief
*
*/
virtual void cont_get_position(short int motors,std::vector<long int>& position);
/**
* \brief
*
*/
virtual void cont_get_velocity(short int motors,std::vector<long int>& velocity);
/**
* \brief
*
*/
virtual void cont_get_acceleration(short int motors,std::vector<long int>& accel);
/**
* \brief
*
*/
virtual void cont_get_current(short int motors,std::vector<float>& current);
/**
* \brief
*
*/
virtual void cont_get_limits(short int motors,std::vector<short int>& limits);
/**
* \brief
*
*/
virtual void cont_wait_for_events(std::vector<short int>& events);
/**
* \brief
*
*/
virtual void cont_set_gpio(int gpio_id,gpio_type type);
/**
* \brief
*
*/
virtual void cont_write_gpio(int gpio_id,bool value);
/**
* \brief
*
*/
virtual void cont_write_gpio(int gpio_id,float value);
/**
* \brief
*
*/
virtual float cont_read_gpio(int gpio_id);
/**
* \brief
*
*/
virtual void cont_flush_hardware_queue(short int motors);
/**
* \brief
*
*/
virtual void cont_config(void *config);
/**
* \brief
*
*/
virtual void cont_save_config(std::string& filename);
/**
* \brief
*
*/
virtual void cont_load_config(std::string& filename);
/**
* \brief
*
*/
virtual void cont_enable(short int motors);
/**
* \brief
*
*/
virtual void cont_disable(short int motors);
/**
* \brief
*
*/
virtual void cont_home(short int motors);
/**
* \brief
*
*/
virtual void cont_load(short int motors,std::vector<long int>& position, std::vector<long int>& velocity, std::vector<long int>& accel);
/**
* \brief
*
*/
virtual void cont_load(short int motors,std::vector<long int>& velocity, std::vector<long int>& accel);
/**
* \brief
*
*/
virtual void cont_move(short int motors);
/**
* \brief
*
*/
virtual void cont_reset(void);
/**
* \brief
*
*/
virtual void cont_stop(short int motors);
/**
* \brief
*
*/
virtual void cont_close(void);
/**
* \brief
*
*/
void reset_motor(void);
public:
/**
* \brief
*
*/
CDynamixelMotor(std::string& cont_id,unsigned char bus_id,unsigned char dev_id);
/**
* \brief
*
*/
int get_baudrate(void);
/**
* \brief
*
*/
unsigned char get_node_address(void);
/**
* \brief
*
*/
std::string get_model(void);
/**
* \brief
*
*/
unsigned char get_firmware_version(void);
/**
* \brief
*
*/
int get_temperature_limit(void);
/**
* \brief
*
*/
void set_temperature_limit(int limit);
/**
* \brief
*
*/
int get_current_temperature(void);
/**
* \brief
*
*/
void get_voltage_limits(float *min, float *max);
/**
* \brief
*
*/
void set_voltage_limits(float min, float max);
/**
* \brief
*
*/
float get_current_voltage(void);
/**
* \brief
*
*/
unsigned char get_led_alarms(void);
/**
* \brief
*
*/
void set_led_alarms(unsigned char alarms);
/**
* \brief
*
*/
unsigned char get_turn_off_alarms(void);
/**
* \brief
*
*/
void set_turn_off_alarms(unsigned char alarms);
/**
* \brief
*
*/
void turn_led_on(void);
/**
* \brief
*
*/
void turn_led_off(void);
/**
* \brief
*
*/
void get_compliance_margin(unsigned char *cw_margin, unsigned char *ccw_margin);
/**
* \brief
*
*/
void set_compliance_margin(unsigned char cw_margin, unsigned char ccw_margin);
/**
* \brief
*
*/
void get_compliance_slope(unsigned char *cw_slope, unsigned char *ccw_margin);
/**
* \brief
*
*/
void set_compliance_slope(unsigned char cw_slope, unsigned char ccw_slope);
/**
* \brief
*
*/
short int get_punch(void);
/**
* \brief
*
*/
void set_punch(short int punch_value);
/**
* \brief
*
*/
bool is_locked(void);
/**
* \brief
*
*/
void lock(void);
/**
* \brief
*
*/
void enable_torque_control(void);
/**
* \brief
*
*/
void disable_torque_control(void);
/**
* \brief
*
*/
bool is_torque_control_enabled(void);
/**
* \brief
*
*/
void set_torque(float torque_ratio);
/**
* \brief
*
*/
float get_torque(void);
/**
* \brief
*
*/
virtual ~CDynamixelMotor();
};
#endif
# edit the following line to add the source code for the example and the name of the executable
ADD_EXECUTABLE(test_dynamixel_motor test_dynamixel_motor.cpp)
# edit the following line to add the necessary libraries
TARGET_LINK_LIBRARIES(test_dynamixel_motor dynamixel_motor_cont ${comm_LIBRARY} ${motor_control_LIBRARY})
#include "dynamixelexceptions.h"
#include "dynamixelserver.h"
#include "eventserver.h"
#include "exceptions.h"
#include "dynamixel_motor.h"
#include <iostream>
std::string cont1_name="AX-12+_1";
std::string cont2_name="AX-12+_2";
int main(int argc, char *argv[])
{
CDynamixelServer *dyn_server=CDynamixelServer::instance();
CEventServer *event_server=CEventServer::instance();
std::vector<std::string> motion_done_1;
std::vector<int> ids;
std::list<std::string> events;
CDynamixelMotor *cont1;
std::vector<float> pos1,vel1,acc1;
std::vector<float> pos2,max,min;
std::vector<float> position;
std::vector<float> current;
short int motors=0x0001;
int i=0;
/*
try{
if(dyn_server->get_num_buses()>0)
{
events.push_back(dyn_server->get_scan_done_event_id());
dyn_server->start_scan(0);
event_server->wait_first(events);
std::cout << "Found " << dyn_server->get_num_devices() << " devices" << std::endl;
ids=dyn_server->get_device_ids();
for(i=0;i<dyn_server->get_num_devices();i++)
std::cout << "Device " << i << " -> id: " << ids[i] << std::endl;
cont1=new CDynamixelMotor(cont1_name,0,ids[0]);
cont1->enable(motors);
cont1->get_position_range(motors,min,max);
std::cout << min[0] << "," << max[0] << std::endl;
min[0]=0.0;
max[0]=300.0;
cont1->set_position_range(motors,min,max);
cont1->get_position(motors,position);
std::cout << "Current position of device " << ids[0] << ": " << position[0] << std::endl;
cont1->get_blend_complete_event(motors,motion_done_1);
events.clear();
events.push_back(motion_done_1[0]);
pos1.push_back(position[0]+50.0);
pos2.push_back(position[0]-50.0);
vel1.push_back(10.0);
acc1.push_back(10.0);
for(i=0;i<10;i++)
{
event_server->wait_all(events);
std::cout << "moving left ..." << std::endl;
cont1->load(motors,pos1,vel1,acc1);
cont1->move(motors);
event_server->wait_all(events);
std::cout << "moving right..." << std::endl;
cont1->load(motors,pos2,vel1,acc1);
cont1->move(motors);
}
}
}catch(CException &e){
std::cout << e.what() << std::endl;
}
return 0;
*/
try{
if(dyn_server->get_num_buses()>0)
{
events.push_back(dyn_server->get_scan_done_event_id());
dyn_server->start_scan(0);
event_server->wait_first(events);
std::cout << "Found " << dyn_server->get_num_devices() << " devices" << std::endl;
ids=dyn_server->get_device_ids();
for(i=0;i<dyn_server->get_num_devices();i++)
std::cout << "Device " << i << " -> id: " << ids[i] << std::endl;
cont1=new CDynamixelMotor(cont1_name,0,ids[0]);
cont1->enable(motors);
cont1->enable_torque_control();
cont1->get_position(motors,position);
std::cout << "Current position of device " << ids[0] << ": " << position[0] << std::endl;
cont1->set_torque(100.0);
sleep(2);
cont1->set_torque(-100.0);
sleep(2);
cont1->set_torque(0.0);
}
}catch(CException &e){
std::cout << e.what() << std::endl;
}
return 0;
}
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