6 #include "RbClassFactory.h"
8 #include "RbConstraintRelaxation.h"
9 #include "RbConstraintFriction.h"
10 #include "RbMovableItem.h"
13 #include "RbMotorizedJoint.h"
14 #include "RbRigidBody.h"
16 #include "RbCylinder.h"
30 #include "RbAttachment.h"
35 #include "RbLinearHillMuscle.h"
36 #include "RbLinearHillStretchReceptor.h"
42 #include "RbSimulator.h"
43 #include "RbMaterialType.h"
45 #include "RbLANWirelessInterface.h"
46 #include "RbDynamixelUSB.h"
47 #include "RbDynamixelUSBServo.h"
49 #include "RbFirmataController.h"
50 #include "RbFirmataPart.h"
51 #include "RbFirmataAnalogInput.h"
52 #include "RbFirmataAnalogOutput.h"
53 #include "RbFirmataDigitalInput.h"
54 #include "RbFirmataDigitalOutput.h"
55 #include "RbFirmataHingeServo.h"
56 #include "RbFirmataPrismaticServo.h"
57 #include "RbFirmataPWMOutput.h"
59 #include "RbFirmataDynamixelServo.h"
60 #include "RbXBeeCommander.h"
61 #include "RbAnimatSerial.h"
64 extern "C" __declspec(dllexport)
IStdClassFactory* __cdecl GetStdClassFactory()
74 extern "C" __declspec(dllexport) int __cdecl BootstrapRunLibrary(
int argc, const
char **argv)
76 extern "C" int BootstrapRunLibrary(
int argc,
const char **argv)
79 Simulator *lpSim = NULL;
83 Simulator *lpSim = Simulator::CreateSimulator(argc, argv);
86 lpSim->Initialize(argc, argv);
87 lpSim->VisualSelectionMode(SIMULATION_SELECTION_MODE);
89 lpSim->StartSimulation();
92 if(lpSim)
delete lpSim;
96 catch(CStdErrorInfo oError)
98 if(lpSim)
delete lpSim;
99 printf(
"Error occurred: %s\n", oError.m_strError.c_str()) ;
100 return (
int) oError.m_lError;
104 if(lpSim)
delete lpSim;
105 printf(
"An Unknown Error occurred.\n") ;
119 RbClassFactory::RbClassFactory()
124 RbClassFactory::~RbClassFactory()
131 RigidBody *RbClassFactory::CreateRigidBody(std::string strType,
bool bThrowError)
133 RigidBody *lpPart=NULL;
141 else if(strType ==
"BOXCONTACTSENSOR")
146 else if(strType ==
"CYLINDER")
148 else if(strType ==
"CYLINDERCONTACTSENSOR")
153 else if(strType ==
"CONE")
155 else if(strType ==
"SPHERE")
157 else if(strType ==
"ATTACHMENT")
159 else if(strType ==
"LINEARHILLMUSCLE")
161 else if(strType ==
"LINEARHILLSTRETCHRECEPTOR")
163 else if(strType ==
"SPRING")
165 else if(strType ==
"TORUS")
167 else if(strType ==
"ELLIPSOID")
169 else if(strType ==
"MOUTH")
171 else if(strType ==
"ODORSENSOR")
173 else if(strType ==
"MESH")
175 else if(strType ==
"STOMACH")
176 lpPart =
new Stomach;
181 THROW_PARAM_ERROR(Al_Err_lInvalidPartType, Al_Err_strInvalidPartType,
"PartType", strType);
186 catch(CStdErrorInfo oError)
188 if(lpPart)
delete lpPart;
194 if(lpPart)
delete lpPart;
195 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
205 Joint *RbClassFactory::CreateJoint(std::string strType,
bool bThrowError)
213 if(strType ==
"HINGE")
215 else if(strType ==
"PRISMATIC")
217 else if(strType ==
"BALLSOCKET")
219 else if(strType ==
"RPRO")
221 else if(strType ==
"STATIC")
223 else if(strType ==
"UNIVERSAL")
225 else if(strType ==
"FREEJOINT")
231 THROW_PARAM_ERROR(Al_Err_lInvalidJointType, Al_Err_strInvalidJointType,
"JointType", strType);
236 catch(CStdErrorInfo oError)
238 if(lpJoint)
delete lpJoint;
244 if(lpJoint)
delete lpJoint;
245 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
254 Structure *RbClassFactory::CreateStructure(std::string strType,
bool bThrowError)
256 Structure *lpStructure=NULL;
262 if(strType ==
"BASIC")
264 else if(strType ==
"ORGANISM")
266 else if(strType ==
"STRUCTURE")
272 THROW_PARAM_ERROR(Al_Err_lInvalidOrganismType, Al_Err_strInvalidOrganismType,
"OrganismType", strType);
277 catch(CStdErrorInfo oError)
279 if(lpStructure)
delete lpStructure;
285 if(lpStructure)
delete lpStructure;
286 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
296 Simulator *RbClassFactory::CreateSimulator(std::string strType,
bool bThrowError)
298 Simulator *lpSimulator=NULL;
304 if(strType ==
"ROBOTICSSIMULATOR")
306 else if(strType ==
"")
312 THROW_PARAM_ERROR(Al_Err_lInvalidSimulatorType, Al_Err_strInvalidSimulatorType,
"SimulatorType", strType);
317 catch(CStdErrorInfo oError)
319 if(lpSimulator)
delete lpSimulator;
325 if(lpSimulator)
delete lpSimulator;
326 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
336 KeyFrame *RbClassFactory::CreateKeyFrame(std::string strType,
bool bThrowError)
338 KeyFrame *lpFrame=NULL;
357 catch(CStdErrorInfo oError)
359 if(lpFrame)
delete lpFrame;
365 if(lpFrame)
delete lpFrame;
366 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
376 DataChart *RbClassFactory::CreateDataChart(std::string strType,
bool bThrowError)
378 DataChart *lpChart=NULL;
384 if(strType ==
"TABFILE")
385 lpChart =
new FileChart;
386 else if(strType ==
"FILECHART")
387 lpChart =
new FileChart;
388 else if(strType ==
"MEMORYCHART")
389 lpChart =
new MemoryChart;
390 else if(strType ==
"ARRAYCHART")
391 lpChart =
new ArrayChart;
396 THROW_PARAM_ERROR(Al_Err_lInvalidDataChartType, Al_Err_strInvalidDataChartType,
"DataChartType", strType);
401 catch(CStdErrorInfo oError)
403 if(lpChart)
delete lpChart;
409 if(lpChart)
delete lpChart;
410 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
419 DataColumn *RbClassFactory::CreateDataColumn(std::string strType,
bool bThrowError)
421 DataColumn *lpColumn=NULL;
427 if(strType ==
"DATACOLUMN")
428 lpColumn =
new DataColumn;
433 THROW_PARAM_ERROR(Al_Err_lInvalidDataColumnType, Al_Err_strInvalidDataColumnType,
"DataColumnType", strType);
438 catch(CStdErrorInfo oError)
440 if(lpColumn)
delete lpColumn;
446 if(lpColumn)
delete lpColumn;
447 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
457 Adapter *RbClassFactory::CreateAdapter(std::string strType,
bool bThrowError)
459 Adapter *lpAdapter=NULL;
465 if(strType ==
"NODETONODE")
466 lpAdapter =
new Adapter;
467 else if(strType ==
"NODETOPHYSICAL")
468 lpAdapter =
new Adapter;
469 else if(strType ==
"PHYSICALTONODE")
470 lpAdapter =
new Adapter;
471 else if(strType ==
"CONTACT")
472 lpAdapter =
new ContactAdapter;
473 else if(strType ==
"PROPERTYCONTROLADAPTER")
474 lpAdapter =
new PropertyControlAdapter;
479 THROW_PARAM_ERROR(Al_Err_lInvalidAdapterType, Al_Err_strInvalidAdapterType,
"AdapterType", strType);
484 catch(CStdErrorInfo oError)
486 if(lpAdapter)
delete lpAdapter;
492 if(lpAdapter)
delete lpAdapter;
493 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
503 Gain *RbClassFactory::CreateGain(std::string strType,
bool bThrowError)
511 if(strType ==
"BELL")
512 lpGain =
new BellGain;
513 else if(strType ==
"EQUATION")
514 lpGain =
new EquationGain;
515 else if(strType ==
"POLYNOMIAL")
516 lpGain =
new PolynomialGain;
517 else if(strType ==
"SIGMOID")
518 lpGain =
new SigmoidGain;
523 THROW_PARAM_ERROR(Al_Err_lInvalidGainType, Al_Err_strInvalidGainType,
"GainType", strType);
528 catch(CStdErrorInfo oError)
530 if(lpGain)
delete lpGain;
536 if(lpGain)
delete lpGain;
537 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
547 ExternalStimulus *RbClassFactory::CreateExternalStimulus(std::string strType,
bool bThrowError)
555 if(strType ==
"MOTORVELOCITY" || strType ==
"MOTORPOSITION")
557 else if(strType ==
"FORCEINPUT")
559 else if(strType ==
"NODEINPUT")
560 lpStimulus =
new ExternalInputStimulus;
561 else if(strType ==
"RIGIDBODYINPUT")
562 lpStimulus =
new ExternalInputStimulus;
563 else if(strType ==
"JOINTINPUT")
564 lpStimulus =
new ExternalInputStimulus;
565 else if(strType ==
"ENABLERINPUT")
566 lpStimulus =
new EnablerStimulus;
567 else if(strType ==
"INVERSEMUSCLECURRENT")
568 lpStimulus =
new InverseMuscleCurrent;
569 else if(strType ==
"CURRENT")
571 else if(strType ==
"VOLTAGECLAMP")
573 else if(strType ==
"PROPERTYCONTROLSTIMULUS")
579 THROW_PARAM_ERROR(Al_Err_lInvalidExternalStimulusType, Al_Err_strInvalidExternalStimulusType,
"ExternalStimulusType", strType);
584 catch(CStdErrorInfo oError)
586 if(lpStimulus)
delete lpStimulus;
592 if(lpStimulus)
delete lpStimulus;
593 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
603 HudItem *RbClassFactory::CreateHudItem(std::string strType,
bool bThrowError)
605 HudItem *lpItem=NULL;
613 THROW_PARAM_ERROR(Rb_Err_lInvalidHudItemType, Rb_Err_strInvalidHudItemType,
"HudItem", strType);
617 catch(CStdErrorInfo oError)
619 if(lpItem)
delete lpItem;
625 if(lpItem)
delete lpItem;
626 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
635 Hud *RbClassFactory::CreateHud(std::string strType,
bool bThrowError)
645 THROW_PARAM_ERROR(Rb_Err_lInvalidHudItemType, Rb_Err_strInvalidHudItemType,
"Hud", strType);
649 catch(CStdErrorInfo oError)
651 if(lpHud)
delete lpHud;
657 if(lpHud)
delete lpHud;
658 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
667 MaterialType *RbClassFactory::CreateMaterialItem(std::string strType,
bool bThrowError)
669 MaterialType *lpItem=NULL;
675 if(strType ==
"BASIC" || strType ==
"DEFAULT" || strType ==
"BULLET")
681 THROW_PARAM_ERROR(Rb_Err_lInvalidMaterialItemType, Rb_Err_strInvalidMaterialItemType,
"Material Pair", strType);
686 catch(CStdErrorInfo oError)
688 if(lpItem)
delete lpItem;
694 if(lpItem)
delete lpItem;
695 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
704 SimulationWindow *RbClassFactory::CreateWindowItem(std::string strType,
bool bThrowError)
706 SimulationWindow *lpItem=NULL;
714 THROW_PARAM_ERROR(Rb_Err_lInvalidSimWindowType, Rb_Err_strInvalidSimWindowType,
"Simulation Window", strType);
718 catch(CStdErrorInfo oError)
720 if(lpItem)
delete lpItem;
726 if(lpItem)
delete lpItem;
727 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
736 Light *RbClassFactory::CreateLight(std::string strType,
bool bThrowError)
746 THROW_PARAM_ERROR(Rb_Err_lInvalidLightType, Rb_Err_strInvalidLightType,
"Light Type", strType);
750 catch(CStdErrorInfo oError)
752 if(lpItem)
delete lpItem;
758 if(lpItem)
delete lpItem;
759 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
768 NeuralModule *RbClassFactory::CreateNeuralModule(std::string strType,
bool bThrowError)
770 NeuralModule *lpModule=NULL;
776 if(strType ==
"PHYSICSNEURALMODULE")
785 THROW_PARAM_ERROR(Al_Err_lInvalidNeuralModuleType, Al_Err_strInvalidNeuralModuleType,
"NeuralModule", strType);
790 catch(CStdErrorInfo oError)
792 if(lpModule)
delete lpModule;
798 if(lpModule)
delete lpModule;
799 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
809 ConstraintRelaxation *RbClassFactory::CreateConstraintRelaxation(std::string strType,
bool bThrowError)
811 ConstraintRelaxation *lpRelax=NULL;
817 if(strType ==
"CONSTRAINTRELAXATION" || strType ==
"DEFAULT")
825 THROW_PARAM_ERROR(Al_Err_lInvalidRelaxationType, Al_Err_strInvalidRelaxationType,
"Relaxation", strType);
830 catch(CStdErrorInfo oError)
832 if(lpRelax)
delete lpRelax;
838 if(lpRelax)
delete lpRelax;
839 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
849 ConstraintFriction *RbClassFactory::CreateConstraintFriction(std::string strType,
bool bThrowError)
851 ConstraintFriction *lpFriction=NULL;
857 if(strType ==
"CONSTRAINTRELAXATION" || strType ==
"DEFAULT")
865 THROW_PARAM_ERROR(Al_Err_lInvalidFrictionType, Al_Err_strInvalidFrictionType,
"Friction", strType);
870 catch(CStdErrorInfo oError)
872 if(lpFriction)
delete lpFriction;
878 if(lpFriction)
delete lpFriction;
879 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
890 RobotInterface *RbClassFactory::CreateRobotInterface(std::string strType,
bool bThrowError)
892 RobotInterface *lpInterface=NULL;
898 if(strType ==
"STANDARDINTERFACE" || strType ==
"DEFAULT")
902 else if(strType ==
"LANWIRELESSINTERFACE")
910 THROW_PARAM_ERROR(Al_Err_lInvalidRobotInterfaceType, Al_Err_strInvalidRobotInterfaceType,
"RobotInterface", strType);
915 catch(CStdErrorInfo oError)
917 if(lpInterface)
delete lpInterface;
923 if(lpInterface)
delete lpInterface;
924 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
935 RobotIOControl *RbClassFactory::CreateRobotIOControl(std::string strType,
bool bThrowError)
937 RobotIOControl *lpControl=NULL;
943 if(strType ==
"DYNAMIXELUSB")
947 else if(strType ==
"FIRMATACONTROLLER")
951 else if(strType ==
"XBEECOMMANDER")
955 else if(strType ==
"ANIMATSERIAL")
963 THROW_PARAM_ERROR(Al_Err_lInvalidRobotIOControlType, Al_Err_strInvalidRobotIOControlType,
"RobotartIOControl", strType);
968 catch(CStdErrorInfo oError)
970 if(lpControl)
delete lpControl;
976 if(lpControl)
delete lpControl;
977 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
988 RobotPartInterface *RbClassFactory::CreateRobotPartInterface(std::string strType,
bool bThrowError)
990 RobotPartInterface *lpInterface=NULL;
996 if(strType ==
"DYNAMIXELUSBHINGE")
1000 else if(strType ==
"DYNAMIXELUSBPRISMATIC")
1004 else if(strType ==
"FIRMATAANALOGINPUT")
1008 else if(strType ==
"FIRMATAANALOGOUTPUT")
1012 else if(strType ==
"FIRMATADIGITALINPUT")
1016 else if(strType ==
"FIRMATADIGITALOUTPUT")
1020 else if(strType ==
"FIRMATAHINGESERVO")
1024 else if(strType ==
"FIRMATAPRISMATICSERVO")
1028 else if(strType ==
"FIRMATAPWMOUTPUT")
1032 else if(strType ==
"FIRMATADYNAMIXELHINGESERVO")
1036 else if(strType ==
"FIRMATADYNAMIXELPRISMATICSERVO")
1044 THROW_PARAM_ERROR(Al_Err_lInvalidRobotPartInterfaceType, Al_Err_strInvalidRobotPartInterfaceType,
"RobotartInterface", strType);
1049 catch(CStdErrorInfo oError)
1051 if(lpInterface)
delete lpInterface;
1052 RELAY_ERROR(oError);
1057 if(lpInterface)
delete lpInterface;
1058 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
1068 RemoteControlLinkage *RbClassFactory::CreateRemoteControlLinkage(std::string strType,
bool bThrowError)
1070 RemoteControlLinkage *lpLink=NULL;
1076 if(strType ==
"PASSTHROUGHLINKAGE")
1078 lpLink =
new PassThroughLinkage;
1080 else if(strType ==
"PULSEDLINKAGE")
1082 lpLink =
new PulsedLinkage;
1088 THROW_PARAM_ERROR(Al_Err_lInvalidFrictionType, Al_Err_strInvalidFrictionType,
"Friction", strType);
1093 catch(CStdErrorInfo oError)
1095 if(lpLink)
delete lpLink;
1096 RELAY_ERROR(oError);
1101 if(lpLink)
delete lpLink;
1102 THROW_ERROR(Std_Err_lUnspecifiedError, Std_Err_strUnspecifiedError);
1115 CStdSerialize *RbClassFactory::CreateObject(std::string strClassType, std::string strObjectType,
bool bThrowError)
1121 if(strClassType ==
"RIGIDBODY")
1122 lpObject = CreateRigidBody(strObjectType, bThrowError);
1123 else if(strClassType ==
"JOINT")
1124 lpObject = CreateJoint(strObjectType, bThrowError);
1125 else if(strClassType ==
"ORGANISM")
1126 lpObject = CreateStructure(strObjectType, bThrowError);
1127 else if(strClassType ==
"STRUCTURE")
1128 lpObject = CreateStructure(strObjectType, bThrowError);
1129 else if(strClassType ==
"SIMULATOR")
1130 lpObject = CreateSimulator(strObjectType, bThrowError);
1131 else if(strClassType ==
"KEYFRAME")
1132 lpObject = CreateKeyFrame(strObjectType, bThrowError);
1133 else if(strClassType ==
"DATACHART")
1134 lpObject = CreateDataChart(strObjectType, bThrowError);
1135 else if(strClassType ==
"DATACOLUMN")
1136 lpObject = CreateDataColumn(strObjectType, bThrowError);
1137 else if(strClassType ==
"EXTERNALSTIMULUS")
1138 lpObject = CreateExternalStimulus(strObjectType, bThrowError);
1139 else if(strClassType ==
"ADAPTER")
1140 lpObject = CreateAdapter(strObjectType, bThrowError);
1141 else if(strClassType ==
"GAIN")
1142 lpObject = CreateGain(strObjectType, bThrowError);
1143 else if(strClassType ==
"HUDITEM")
1144 lpObject = CreateHudItem(strObjectType, bThrowError);
1145 else if(strClassType ==
"HUD")
1146 lpObject = CreateHud(strObjectType, bThrowError);
1147 else if(strClassType ==
"MATERIAL")
1148 lpObject = CreateMaterialItem(strObjectType, bThrowError);
1149 else if(strClassType ==
"SIMULATIONWINDOW")
1150 lpObject = CreateWindowItem(strObjectType, bThrowError);
1151 else if(strClassType ==
"LIGHT")
1152 lpObject = CreateLight(strObjectType, bThrowError);
1153 else if(strClassType ==
"NEURALMODULE")
1154 lpObject = CreateNeuralModule(strObjectType, bThrowError);
1155 else if(strClassType ==
"CONSTRAINTRELAXATION")
1156 lpObject = CreateConstraintRelaxation(strObjectType, bThrowError);
1157 else if(strClassType ==
"CONSTRAINTFRICTION")
1158 lpObject = CreateConstraintFriction(strObjectType, bThrowError);
1159 else if(strClassType ==
"ROBOTINTERFACE")
1160 lpObject = CreateRobotInterface(strObjectType, bThrowError);
1161 else if(strClassType ==
"ROBOTIOCONTROL")
1162 lpObject = CreateRobotIOControl(strObjectType, bThrowError);
1163 else if(strClassType ==
"ROBOTPARTINTERFACE")
1164 lpObject = CreateRobotPartInterface(strObjectType, bThrowError);
1165 else if(strClassType ==
"REMOTECONTROLLINKAGE")
1166 lpObject = CreateRemoteControlLinkage(strObjectType, bThrowError);
1171 THROW_PARAM_ERROR(Std_Err_lInvalidClassType, Std_Err_strInvalidClassType,
"ClassType", strClassType);
1179 void ROBOTICS_PORT RunBootstrap(
int argc,
const char **argv)
1181 BootstrapRunLibrary(argc, argv);
Declares the vs universal class.
virtual IStdClassFactory * ClassFactory()
Gets the class factory.
Declares the vortex Torus class.
Declares the vortex ellipsoid class.
Vortex ball-and-socket joint class.
Vortex physical structure implementation.
Vortex Organism implementation.
Vortex relative position, relative orientation joint class.
Declares the vortex relative position, relative orientation class.
Declares the vortex mouth class.
std::string Std_Trim(std::string strVal)
Trims a string.
Declares the vortex structure class.
Declares the vortex hinge class.
Declares the vortex ball socket class.
Declares the vs prismatic class.
Declares the vortex odor sensor class.
Current stimulus for neural items.
This stimulus enables or disables a joint or body part for a specified period of time.
virtual bool IsContactSensor()
Query if this object is contact sensor.
Vortex hinge joint class.
Declares the vs universal class.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
Declares the vortex organism class.
The Robotics interface configures a simulation to run on a microcontroller board. ...