|
Hormodular 1.0
Locomotion gait discovery by using digital hormones on modular robots
|
00001 //------------------------------------------------------------------------------ 00002 //-- SerialModularRobotInterface 00003 //------------------------------------------------------------------------------ 00004 //-- 00005 //-- Interface to the modular robot via serial port 00006 //-- 00007 //------------------------------------------------------------------------------ 00008 //-- 00009 //-- This file belongs to the Hormodular project 00010 //-- (https://github.com/David-Estevez/hormodular.git) 00011 //-- 00012 //------------------------------------------------------------------------------ 00013 //-- Author: David Estevez-Fernandez 00014 //-- 00015 //-- Released under the GPL license (more info on LICENSE.txt file) 00016 //------------------------------------------------------------------------------ 00017 00025 #ifndef SERIAL_MODULAR_ROBOT_INTERFACE_H 00026 #define SERIAL_MODULAR_ROBOT_INTERFACE_H 00027 00028 #include "ModularRobotInterface.hpp" 00029 #include "ConfigParser.h" 00030 #include <string> 00031 #include <vector> 00032 #include <iostream> 00033 #include <SerialStream.h> 00034 00035 namespace hormodular { 00036 00041 class SerialModularRobotInterface : public ModularRobotInterface 00042 { 00043 public: 00044 SerialModularRobotInterface(ConfigParser configParser); 00045 00046 00051 virtual bool start(); 00052 00057 virtual bool stop(); 00058 00064 virtual bool destroy(); 00065 00071 virtual bool reset(); 00072 00073 00074 00083 virtual bool setProperty(std::string property, std::string value); 00084 00085 00086 00095 virtual float getTravelledDistance(); 00096 00098 virtual bool sendJointValues(std::vector<float> joint_values, float step_ms=0); 00099 00106 virtual std::vector<float> getJointValues(); 00107 00108 private: 00109 std::string port_name; 00110 SerialPort* serialPort; 00111 00112 int step_ms; 00113 00114 int num_modules; 00115 std::vector<float> joint_values; 00116 00117 //-- Serial port related functions: 00119 bool initSerialPort(); 00120 00122 bool checkConnection(); 00123 00125 bool toggleLED(); 00126 00128 bool sendJointValuesSerial(std::vector<float> joint_values); 00129 }; 00130 00131 } 00132 00133 #endif //-- SERIAL_MODULAR_ROBOT_INTERFACE_H
1.7.4