AnimatLab  2
Test
RbFirmataPrismaticServo.cpp
1 // RbFirmataPrismaticServo.cpp: implementation of the RbFirmataPrismaticServo class.
2 //
4 
5 #include "StdAfx.h"
6 #include <stdarg.h>
7 #include "RbMovableItem.h"
8 #include "RbBody.h"
9 #include "RbJoint.h"
10 #include "RbMotorizedJoint.h"
11 #include "RbHingeLimit.h"
12 #include "RbHinge.h"
13 #include "RbRigidBody.h"
14 #include "RbStructure.h"
15 #include "RbFirmataPart.h"
16 #include "RbFirmataPrismaticServo.h"
17 
18 namespace RoboticsAnimatSim
19 {
20  namespace Robotics
21  {
22  namespace RobotIOControls
23  {
24  namespace Firmata
25  {
26 
28 // Construction/Destruction
30 
31 RbFirmataPrismaticServo::RbFirmataPrismaticServo()
32 {
33  m_lpHinge = NULL;
34 }
35 
36 RbFirmataPrismaticServo::~RbFirmataPrismaticServo()
37 {
38  try
39  {
40  //Do not delete because we do not own it.
41  m_lpHinge = NULL;
42  }
43  catch(...)
44  {Std_TraceMsg(0, "Caught Error in desctructor of RbFirmataHingeServo\r\n", "", -1, false, true);}
45 }
46 
48 {
49 }
50 
52 {
53 }
54 
56 {
57  RobotPartInterface::Initialize();
58 
59  m_lpHinge = dynamic_cast<RbHinge *>(m_lpPart);
60 
61  //if(!m_lpSim->InSimulation())
62  // InitMotorData();
63 }
64 
66 {
67  RobotPartInterface::StepSimulation();
68 
69  //if(m_lpHinge)
70  //{
71  // //Here we need to get the set velocity for this motor that is coming from the neural controller, and then make the real motor go that speed.
72  // if(m_lpThisMotorJoint->MotorType() == eJointMotorType::PositionControl || m_lpThisMotorJoint->MotorType() == eJointMotorType::PositionVelocityControl)
73  // {
74  // float fltSetVelocity = m_lpHinge->SetVelocity();
75  // SetGoalVelocity(fltSetVelocity);
76 
77  // if(fltSetVelocity > 0)
78  // SetGoalPosition_FP(m_iMaxPos);
79  // else
80  // SetGoalPosition_FP(m_iMinPos);
81  // }
82  // else
83  // {
84  // float fltSetPosition = m_lpHinge->SetVelocity();
85  // SetGoalPosition(fltSetPosition);
86  // SetMaximumVelocity();
87  // }
88 
89  // float fltActualPosition = GetActualPosition();
90  // float fltActualVelocity = GetActualVelocity();
91  // //float fltTemperature = GetActualTemperatureCelcius();
92  // //float fltVoltage = GetActualVoltage();
93  // //float fltLoad = GetActualLoad();
94 
95  // m_lpHinge->JointPosition(fltActualPosition);
96  // m_lpHinge->JointVelocity(fltActualVelocity);
97  // //m_lpHinge->Temperature(fltTemperature);
98  // //m_lpHinge->Voltage(fltVoltage);
99  // //m_lpHinge->MotorTorqueToAMagnitude(fltLoad);
100  // //m_lpHinge->MotorTorqueToBMagnitude(fltLoad);
101  //}
102 }
103 
104  } //Firmata
105  } //RobotIOControls
106  } // Robotics
107 } //RoboticsAnimatSim
108 
virtual void StepIO(int iPartIdx)
This method is used to send/recieve the actual IO. This will often be in a seperate thread than the S...
Declares the vortex structure class.
Declares the vortex hinge class.
void Std_TraceMsg(const int iLevel, std::string strMessage, std::string strSourceFile, int iSourceLine, bool bLogToFile, bool bPrintHeader)
Traces a message to the debugger window.
virtual void SetupIO()
This method is called after all connections to whatever control board have been made. It is meant to be used to setup connection information specific to this part. For example, We connect to a Firmata microcontroller like an Arduino, and then do a setup that could take some time. We should not attempt to setup any of the pins until after the board itself has been setup. After that we need to loop through and setup all the parts. That is what this method is for.
Classes for implementing the cm-labs vortex physics engine for AnimatLab.