Bioscara
DALSA's DIY SCARA Robot Arm.
Loading...
Searching...
No Matches
mMockJoint.h
Go to the documentation of this file.
1
12#ifndef MMOCKJOINT_H
13#define MMOCKJOINT_H
14
15#include <iostream>
17#include <chrono>
18
20{
28 class MockJoint : public BaseJoint
29 {
30 public:
31 MockJoint(const std::string name);
32
33 err_type_t enable(u_int8_t driveCurrent, u_int8_t holdCurrent) override;
34
35 err_type_t disable(void) override;
36
37 err_type_t getPosition(float &pos) override;
38
39 err_type_t setPosition(float pos) override;
40
41 err_type_t getVelocity(float &vel) override;
42
43 err_type_t setVelocity(float vel) override;
44
45 err_type_t checkOrientation(float angle = 2.0) override;
46
47 err_type_t stop(void) override;
48
49 err_type_t getFlags(void) override;
50
51 bool isHomed(void) override;
52
53 protected:
54 err_type_t _home(float velocity, u_int8_t sensitivity, u_int8_t current);
55
56 private:
57 float q = 0.0;
58 float qd = 0.0;
59
60 std::chrono::_V2::system_clock::time_point last_set_position = std::chrono::high_resolution_clock::now();
61 std::chrono::_V2::system_clock::time_point last_set_velocity = last_set_position;
62 std::chrono::_V2::system_clock::time_point async_start_time = last_set_position;
63
71 float getDeltaT(std::chrono::_V2::system_clock::time_point &last_call, bool update = true);
72
74 };
75}
76#endif
Generic base class to control a single joint.
Definition mBaseJoint.h:27
std::string name
Joint name for logging.
Definition mBaseJoint.h:352
stp_reg_t
register and command definitions
Definition mBaseJoint.h:39
@ NONE
Used for signalling purposes.
Definition mBaseJoint.h:40
Representing a single joint mocking the hardware joint.
Definition mMockJoint.h:29
err_type_t setPosition(float pos) override
get the current joint position in radians or m for cylindrical and prismatic joints respectively.
Definition mMockJoint.cpp:44
float q
position
Definition mMockJoint.h:57
float getDeltaT(std::chrono::_V2::system_clock::time_point &last_call, bool update=true)
Compute the time since the given time point.
Definition mMockJoint.cpp:109
std::chrono::_V2::system_clock::time_point async_start_time
Definition mMockJoint.h:62
err_type_t enable(u_int8_t driveCurrent, u_int8_t holdCurrent) override
Engages the joint.
Definition mMockJoint.cpp:10
err_type_t _home(float velocity, u_int8_t sensitivity, u_int8_t current)
Call to start the homing sequence of a joint.
Definition mMockJoint.cpp:82
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 mMockJoint.cpp:54
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 mMockJoint.cpp:60
err_type_t getPosition(float &pos) override
get the current joint position in radians or m for cylindrical and prismatic joints respectively.
Definition mMockJoint.cpp:24
bool isHomed(void) override
Checks the state if the motor is homed.
Definition mMockJoint.cpp:95
std::chrono::_V2::system_clock::time_point last_set_position
Definition mMockJoint.h:60
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 mMockJoint.cpp:70
float qd
velocity
Definition mMockJoint.h:58
stp_reg_t op_mode
Definition mMockJoint.h:73
err_type_t disable(void) override
disenganges the joint
Definition mMockJoint.cpp:17
err_type_t stop(void) override
Stops the motor.
Definition mMockJoint.cpp:76
err_type_t getFlags(void) override
Overload of getFlags(u_int8_t &flags)
Definition mMockJoint.cpp:90
std::chrono::_V2::system_clock::time_point last_set_velocity
Definition mMockJoint.h:61
File including the BaseJoint class.
Definition mBaseJoint.h:19
err_type_t
Enum defining common error types.
Definition uErr.h:23