⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pmdinterface.h

📁 一个机器人的源代码.软件设计得超级好!是商业级代码.
💻 H
字号:
/*--------------------------------------------------*
 * PMDInterface.h:									*
 * DML interface for PMD chipset-based robot		*
 * (uses PMD's C-Motion library)					*
 *--------------------------------------------------*

#pragma once

#define PMD_SERIAL_INTERFACE
#include "C-Motion.h"
#include "PMDTypes.h"

#include "dml.h"
#include "dmlchanref.h"
#include "RobotMath.h"
#include <string>

class PMD_Axis
{
public:
	// constructors (call during DML channel creation):	
	PMD_Axis(PMDAxis AxisNumber, string AxisName, bool fIOBoardPresent);
	~PMD_Axis();  // destructor (call during DML channel destruction)

	bool Connect(int ComPortNumber);  // returns true if able to initialize PMD chip on specified COM port
	bool Connect(PMD_Axis *pParentAxis);	// connect secondary axis using PMD multidrop serial protocol
	void Reset();							// reset this axis (will cause motion to stop)

	void SetAcceleration(int SetPoint);		// in mm/second^2
	void SetDeceleration(int SetPoint);		// in mm/second^2
	void SetVelocity(int SetPoint);			// in mm/second
	void SetCurrentPosition(int SetPoint);	// in mm
	void SetMoveDistance(int SetPoint);		// in mm, trapezoidal or S-curve moves only
	void SetJerk(int SetPoint);				// in mm/second^3, S-curve moves only
	void SetPowerLevel(int SetPoint);		// 0% to 100% power
	void SetTrapezoidalProfile();			// change motion profile to Trapezoidal
	void SetSCurveProfile();				// change motion profile to S-Curve
	void SetVelocityContouringProfile();	// change motion profile to Velocity Contouring
	void PerformSmoothStop();				// immediately decelerate normally to 0 velocity
	void PerformAbruptStop();				// abruptly stop (immediate velocity change to 0)

	void CommitMotionChanges();  // calls PMDUpdate() to commit new motion control settings

	void PollEventStatus();
	void ResetEventStatus(PMDuint16 PMDEventMask);
	void PollActivityStatus();
	void PollCurrentPosition();
	void PollAnalogInputs();

	// publicly available DML channels for reading back data from the PMD chip:
	DML_ChannelRef *m_pEventStatus;				// readback (axis event status register)
	DML_ChannelRef *m_pfMotionComplete;			// readback (motion complete bit from event status register)
	DML_ChannelRef *m_pActivityStatus;			// readback (axis activity status register)
	DML_ChannelRef *m_pReadCurrentPosition;		// readback (axis current calculated position in microsteps)
	DML_ChannelRef *m_pAnalogInputs[ciNumAnalogInputs];  // readback (analog input values)
	DML_ChannelRef *m_pSetDestinationPosition;	// control (commanded destination position, trapezoidal/S-curve only)

	// Publicly available variables:
	bool m_fConnected;  // serial connection established

private:
	// PMD data structures for this axis:
	PMDAxis				m_AxisNumber;
	PMDAxisHandle		m_hAxis;	// structure to hold PMD data
	PMDAxisInterface	m_pAxis;	// pointer to m_hAxis
	bool				m_fIOBoardPresent;
	
	// Underlying DML representation of each PMD axis:
	DML_ChannelRef *m_pAcceleration;			// control (commanded acceleration in microsteps/cycle^2)
	DML_ChannelRef *m_pDeceleration;			// control (commanded deceleration in microsteps/cycle^2)
	DML_ChannelRef *m_pVelocity;				// control (commanded maximum velocity in microsteps/cycle)
	DML_ChannelRef *m_pJerk;					// control (commanded jerk in microsteps/cycle^3, used for S-curve motion)
	DML_ChannelRef *m_pPowerLevel;				// control (commanded motor power level, 0 to 32767)
	DML_ChannelRef *m_pProfileMode;				// control (trapezoidal, S-curve, or velocity contouring)
	DML_ChannelRef *m_pStopMode;				// control (command an immediate smooth or abrupt stop)
	DML_ChannelRef *m_pSetCurrentPosition;		// control (set axis current actual position in microsteps)
};

// Debug function -- monitor a PMD function call to see if it generates an error.  Log an error message with file and line
// number if the PMD result indicates an error.
void WatchPMDresultExpanded(PMDresult PMDr, char *pszFile, int Line);
#define WatchPMD(PMDr) WatchPMDresultExpanded(PMDr, __FILE__, __LINE__)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -