Bioscara
DALSA's DIY SCARA Robot Arm.
Loading...
Searching...
No Matches
mJoint.h
Go to the documentation of this file.
1
12#ifndef MJOINT_H
13#define MJOINT_H
14
15#include <iostream>
18
20{
25 class Joint : public BaseJoint
26 {
27 public:
60 Joint(const std::string name, const int address, const float reduction, const float min, const float max);
61
67 ~Joint(void);
68
78 err_type_t init(void) override;
79
87 err_type_t deinit(void) override;
88
89 err_type_t enable(u_int8_t driveCurrent, u_int8_t holdCurrent) override;
90
99 err_type_t postHoming(void) override;
100
101 err_type_t getPosition(float &pos) override;
102
103 err_type_t setPosition(float pos) override;
104
105 err_type_t moveSteps(int32_t steps) override;
106
107 err_type_t getVelocity(float &vel) override;
108
109 err_type_t setVelocity(float vel) override;
110
111 err_type_t checkOrientation(float angle = 2.0) override;
112
113 err_type_t stop(void) override;
114
115 err_type_t disableCL(void) override;
116
117 err_type_t setDriveCurrent(u_int8_t current) override;
118
119 err_type_t setHoldCurrent(u_int8_t current) override;
120
121 err_type_t setBrakeMode(u_int8_t mode) override;
122
123 err_type_t setMaxAcceleration(float maxAccel) override;
124
125 err_type_t setMaxVelocity(float maxVel) override;
126
127 err_type_t enableStallguard(u_int8_t sensitivity) override;
128
129 err_type_t getFlags(void) override;
130
131 protected:
132
141
149 err_type_t setHomingOffset(const float offset);
150
151 err_type_t _home(float velocity, u_int8_t sensitivity, u_int8_t current) override;
152
160 err_type_t checkCom(void);
161
162 float reduction = 1;
163 float offset = 0;
164 float min = 0;
165 float max = 0;
166
167 private:
168 template <typename T>
169 int read(const stp_reg_t reg, T &data, u_int8_t &flags);
170
171 template <typename T>
172 int write(const stp_reg_t reg, T data, u_int8_t &flags);
173
175 int handle = -1;
176 };
177}
179
180#endif
Generic base class to control a single joint.
Definition mBaseJoint.h:27
u_int8_t flags
State flags transmitted with every I2C transaction.
Definition mBaseJoint.h:394
std::string name
Joint name for logging.
Definition mBaseJoint.h:352
stp_reg_t
register and command definitions
Definition mBaseJoint.h:39
Representing a single hardware joint connected via I2C.
Definition mJoint.h:26
err_type_t postHoming(void) override
perform tasks after a non-blocking homing
Definition mJoint.cpp:68
err_type_t getVelocity(float &vel) override
get the current joint velocity in radians/s or m/s for cylindrical and prismatic joints respectively.
Definition mJoint.cpp:152
err_type_t enableStallguard(u_int8_t sensitivity) override
Enable encoder stall detection of the joint.
Definition mJoint.cpp:246
float reduction
Joint to actuator reduction ratio.
Definition mJoint.h:162
err_type_t setHoldCurrent(u_int8_t current) override
Set the Hold Current.
Definition mJoint.cpp:212
err_type_t setHomingOffset(const float offset)
Stores the homing position on the joint.
Definition mJoint.cpp:287
float max
Joint upper limit.
Definition mJoint.h:165
err_type_t setBrakeMode(u_int8_t mode) override
Set Brake Mode.
Definition mJoint.cpp:220
err_type_t setMaxAcceleration(float maxAccel) override
Set the maximum permitted joint acceleration (and deceleration) in rad/s^2 or m/s^2 for cylindrical a...
Definition mJoint.cpp:228
float min
Joint lower limit.
Definition mJoint.h:164
err_type_t enable(u_int8_t driveCurrent, u_int8_t holdCurrent) override
Engages the joint.
Definition mJoint.cpp:53
err_type_t checkOrientation(float angle=2.0) override
Calls the checkOrientation method of the motor. Checks in which direction the motor is turning.
Definition mJoint.cpp:174
err_type_t setVelocity(float vel) override
Set the current joint velocity in radians/s or m/s for cylindrical and prismatic joints respectively.
Definition mJoint.cpp:162
int write(const stp_reg_t reg, T data, u_int8_t &flags)
Wrapper function to send command to the I2C slave.
Definition mJoint.hpp:62
err_type_t _home(float velocity, u_int8_t sensitivity, u_int8_t current) override
Call to start the homing sequence of a joint.
Definition mJoint.cpp:78
err_type_t stop(void) override
Stops the motor.
Definition mJoint.cpp:187
err_type_t getFlags(void) override
Overload of getFlags(u_int8_t &flags)
Definition mJoint.cpp:267
int read(const stp_reg_t reg, T &data, u_int8_t &flags)
Wrapper function to request data from the I2C slave.
Definition mJoint.hpp:32
err_type_t deinit(void) override
Disconnects from a joint.
Definition mJoint.cpp:46
err_type_t setPosition(float pos) override
get the current joint position in radians or m for cylindrical and prismatic joints respectively.
Definition mJoint.cpp:126
int handle
I2C bus handle.
Definition mJoint.h:175
err_type_t setMaxVelocity(float maxVel) override
Set the maximum permitted joint velocity in rad/s or m/s for cylindrical and prismatic joints respect...
Definition mJoint.cpp:237
err_type_t disableCL(void) override
Definition mJoint.cpp:195
err_type_t checkCom(void)
Check if communication to the joint is established.
Definition mJoint.cpp:254
err_type_t getPosition(float &pos) override
get the current joint position in radians or m for cylindrical and prismatic joints respectively.
Definition mJoint.cpp:113
int address
I2C adress.
Definition mJoint.h:174
err_type_t setDriveCurrent(u_int8_t current) override
Set the Drive Current.
Definition mJoint.cpp:204
err_type_t getHomingOffset(float &offset)
Retrieves the homing position from the last homing.
Definition mJoint.cpp:275
err_type_t init(void) override
Initialize connection to a joint via I2C.
Definition mJoint.cpp:25
~Joint(void)
Destroy the Joint object.
Definition mJoint.cpp:19
err_type_t moveSteps(int32_t steps) override
Move full steps.
Definition mJoint.cpp:142
float offset
Joint position offset.
Definition mJoint.h:163
File including the BaseJoint class.
Templated functions for the Joint class.
Definition mBaseJoint.h:19
err_type_t
Enum defining common error types.
Definition uErr.h:23