Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roboclawx2 Class #2

Open
daftpwner opened this issue Nov 14, 2018 · 6 comments
Open

Roboclawx2 Class #2

daftpwner opened this issue Nov 14, 2018 · 6 comments

Comments

@daftpwner
Copy link
Contributor

Implement the Roboclawx2 class for accessing a Roboclawx2 motor controller via serial. This class inherits from the MotorInterface ABC, adding the needed code for interfacing with a Roboclaw with a specific serial device ID and serial port.

@daftpwner
Copy link
Contributor Author

eps32_robot_driver-page-2

@daftpwner
Copy link
Contributor Author

Here is a link to the datasheet. You'll want to implement the Packet Serial method.
http://downloads.basicmicro.com/docs/roboclaw_user_manual.pdf

@daftpwner
Copy link
Contributor Author

For the CRC checksum, that can be implemented as a private class method. That way, it can be reused for the RoboclawX1 in #3.

@Dylanfg123 Dylanfg123 self-assigned this Nov 22, 2018
@Andrewhbyers17
Copy link

Here is just sorta skeleton of the class, is this kind of what you had in mind?

@Andrewhbyers17
Copy link

`#include <Arduino.h>
#include <RoboClaw.h>
#include <BMSerial.h>

class MotorInterface
{
public:
virtual int Update() = 0;

protected:
bool Pos_Ctrl;
}

class roboclawx2 : public MotorInterface
{
public:
roboclawx2()
{

}

int update() override
{
  return 0;
}

int setPos(double setpoint , int idx = 0)
{

}

int setVel(double setpoint, int idx = 00)
{

}

int getPos(double* setpoint, int idx = 0)
{

}

int getVel(double* setpoint, int idx = 0)
{

}

int setPosLimits(double lower = -1e7, double upper = 1e7, int idx = 0)
{
  if (lower > upper) return 1;
  if (lower > -1e7) pos_lower_limit = lower;
  if (upper < 1e7) pos_upper_limit = upper;

}

int setVelLimits(double lower = -1e7, double upper = 1e7, int idx = 0)
{
  if (lower > upper) return 1;
  if (lower > -1e7) vel_lower_limit = lower;
  if (upper < 1e7) vel_upper_limit = upper;
}

int getPosLimits(double* lower, double* upper, int idx = 0)
{
  if (lower != NULL) *lower = pos_lower_limit;
  if (upper != NULL) *upper = pos_upper_limit;
}

int getVelLimits(double* lower, double* upper, int idx = 0)
{
  if (lower != NULL) *lower = vel_lower_limit;
  if (upper != NULL) *upper = vel_upper_limit;
}

}
void setup() {
// put your setup code here, to run once:
}

void loop() {
// put your main code here, to run repeatedly:
}`

@Andrewhbyers17
Copy link

I am not sure what to put into each function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants