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

Add support for X series #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## May, 16th 2018

- [New model] Add (almost complete) support for the servo-motors in the X series

## March, 26th 2018

- [Improvement] Add support to MX series using protocol 2
Expand Down
24 changes: 21 additions & 3 deletions src/dynamixel/auto_detect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,41 @@ namespace dynamixel {
return std::make_shared<servos::Mx64P2>(id);
case servos::Mx106P2::ct_t::model_number_value:
return std::make_shared<servos::Mx106P2>(id);
case servos::Xm430W210::ct_t::model_number_value:
return std::make_shared<servos::Xm430W210>(id);
case servos::Xm430W250::ct_t::model_number_value:
return std::make_shared<servos::Xm430W250>(id);
case servos::Xm430W350::ct_t::model_number_value:
return std::make_shared<servos::Xm430W350>(id);
case servos::Xm540W150::ct_t::model_number_value:
return std::make_shared<servos::Xm540W150>(id);
case servos::Xm540W270::ct_t::model_number_value:
return std::make_shared<servos::Xm540W270>(id);
case servos::Xh430W210::ct_t::model_number_value:
return std::make_shared<servos::Xh430W210>(id);
case servos::Xh430W350::ct_t::model_number_value:
return std::make_shared<servos::Xh430W350>(id);
case servos::Xh430V210::ct_t::model_number_value:
return std::make_shared<servos::Xh430V210>(id);
case servos::Xh430V350::ct_t::model_number_value:
return std::make_shared<servos::Xh430V350>(id);
default:
throw errors::Error("Unrecognized model number");
}
}

/** Send a ping to an ID. If it is answered, read the actuator model and
instanciate a class of the correct type.
instantiate a class of the correct type.

@param id value, from 1 to 254 identifiying an actuator
@param id value, from 1 to 254 identifying an actuator

@return std::shared_ptr to a servo object if we got an answer
**/
template <typename Protocol, typename Controller>
inline std::shared_ptr<servos::BaseServo<Protocol>>
find_servo(const Controller& controller, typename Protocol::id_t id)
{
// Dummy variable used only to differenciate between the two version of
// Dummy variable used only to differentiate between the two version of
// get_servo (protocol 1 or 2)
typename Protocol::address_t selected_protocol = 0;

Expand Down
9 changes: 9 additions & 0 deletions src/dynamixel/servos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
#include "servos/mx106.hpp"
#include "servos/mx106_p2.hpp"
#include "servos/xl320.hpp"
#include "servos/xm430_w210.hpp"
#include "servos/xm430_w250.hpp"
#include "servos/xm430_w350.hpp"
#include "servos/xm540_w150.hpp"
#include "servos/xm540_w270.hpp"
#include "servos/xh430_w210.hpp"
#include "servos/xh430_w350.hpp"
#include "servos/xh430_v210.hpp"
#include "servos/xh430_v350.hpp"
#include "servos/pro_h54_200_s500.hpp"
#include "servos/pro_h54_100_s500.hpp"
#include "servos/pro_h42_20_s300.hpp"
Expand Down
181 changes: 181 additions & 0 deletions src/dynamixel/servos/xh430_v210.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
#ifndef DYNAMIXEL_SERVOS_XH430V210_HPP_
#define DYNAMIXEL_SERVOS_XH430V210_HPP_

#include <stdint.h>

#include "servo.hpp"
#include "../protocols/protocol2.hpp"

namespace dynamixel {
namespace servos {
class Xh430V210;

template <>
struct ModelTraits<Xh430V210> {
typedef protocols::Protocol2 protocol_t;

struct CT {
static const protocol_t::address_t model_number = 0;
typedef uint16_t model_number_t;
static const model_number_t model_number_value = 1050;
static const protocol_t::address_t model_info = 2;
typedef uint32_t model_info_t;
static const protocol_t::address_t firmware_version = 6;
typedef uint8_t firmware_version_t;
static const protocol_t::address_t id = 7;
typedef protocol_t::id_t id_t;
static const protocol_t::address_t baudrate = 8;
typedef uint8_t baudrate_t;
static const protocol_t::address_t return_delay_time = 9;
typedef uint8_t return_delay_time_t;
static const protocol_t::address_t drive_mode = 10;
typedef uint8_t drive_mode_t;
static const protocol_t::address_t operating_mode = 11;
typedef uint8_t operating_mode_t;
static const protocol_t::address_t secondary_id = 12;
typedef uint8_t secondary_id_t;
static const protocol_t::address_t protocol_version = 13;
typedef uint8_t protocol_version_t;
static const protocol_t::address_t homing_offset = 20;
typedef uint32_t homing_offset_t;
static const protocol_t::address_t moving_threshold = 24;
typedef uint32_t moving_threshold_t;
static const protocol_t::address_t highest_temperature_limit = 31;
typedef uint8_t highest_temperature_limit_t;
static const protocol_t::address_t highest_voltage_limit = 32;
typedef uint16_t highest_voltage_limit_t;
static const protocol_t::address_t lowest_voltage_limit = 34;
typedef uint16_t lowest_voltage_limit_t;
static const protocol_t::address_t pwm_limit = 36;
typedef uint16_t pwm_limit_t;
static const protocol_t::address_t current_limit = 38;
typedef uint16_t current_limit_t;
static const protocol_t::address_t acceleration_limit = 40;
typedef uint32_t acceleration_limit_t;
static const protocol_t::address_t speed_limit = 44;
typedef uint32_t speed_limit_t;
static const protocol_t::address_t max_position_limit = 48;
typedef int32_t max_position_limit_t;
static const protocol_t::address_t min_position_limit = 52;
typedef int32_t min_position_limit_t;
static const protocol_t::address_t alarm_shutdown = 63;
typedef uint8_t alarm_shutdown_t;
static const protocol_t::address_t torque_enable = 64;
typedef uint8_t torque_enable_t;
static const protocol_t::address_t led = 65;
typedef uint8_t led_t;
static const protocol_t::address_t status_return_level = 68;
typedef uint8_t status_return_level_t;
static const protocol_t::address_t registered = 69;
typedef uint8_t registered_t;
static const protocol_t::address_t hardware_error_status = 70;
typedef uint8_t hardware_error_status_t;
static const protocol_t::address_t velocity_i_gain = 76;
typedef uint16_t velocity_i_gain_t;
static const protocol_t::address_t velocity_p_gain = 78;
typedef uint16_t velocity_p_gain_t;
static const protocol_t::address_t position_d_gain = 80;
typedef uint16_t position_d_gain_t;
static const protocol_t::address_t position_i_gain = 82;
typedef uint16_t position_i_gain_t;
static const protocol_t::address_t position_p_gain = 84;
typedef uint16_t position_p_gain_t;
static const protocol_t::address_t feedforward_2nd_gain = 88;
typedef uint16_t feedforward_2nd_gain_t;
static const protocol_t::address_t feedforward_1st_gain = 90;
typedef uint16_t feedforward_1st_gain_t;
static const protocol_t::address_t bus_watchdog = 98;
typedef uint8_t bus_watchdog_t;
static const protocol_t::address_t goal_pwm = 100;
typedef uint16_t goal_pwm_t;
static const protocol_t::address_t goal_current = 102;
typedef uint16_t goal_current_t;
static const protocol_t::address_t moving_speed = 104;
typedef uint32_t moving_speed_t;
static const moving_speed_t min_goal_speed = INT32_MIN;
static const moving_speed_t max_goal_speed = INT32_MAX;
static constexpr double rpm_per_tick = 0.229;
static const bool speed_sign_bit = false;
static const protocol_t::address_t profile_acceleration = 108;
typedef uint32_t profile_acceleration_t;
static const protocol_t::address_t profile_speed = 112;
typedef uint32_t profile_speed_t;
static const protocol_t::address_t goal_position = 116;
typedef int32_t goal_position_t;
static const goal_position_t min_goal_position = 0;
static const goal_position_t max_goal_position = 4095;
static const uint32_t min_goal_angle_deg = 0;
static const uint32_t max_goal_angle_deg = 360;
static const protocol_t::address_t realtime_tick = 120;
typedef uint16_t realtime_tick_t;
static const protocol_t::address_t moving = 122;
typedef uint8_t moving_t;
static const protocol_t::address_t moving_status = 123;
typedef uint8_t moving_status_t;
static const protocol_t::address_t present_pwm = 124;
typedef uint16_t present_pwm_t;
static const protocol_t::address_t current = 126;
typedef uint16_t current_t;
static const protocol_t::address_t present_speed = 128;
typedef int32_t present_speed_t;
static const protocol_t::address_t present_position = 132;
typedef int32_t present_position_t;
static const protocol_t::address_t speed_trajectory = 136;
typedef int32_t speed_trajectory_t;
static const protocol_t::address_t position_trajectory = 140;
typedef int32_t position_trajectory_t;
static const protocol_t::address_t present_voltage = 144;
typedef uint16_t present_voltage_t;
static const protocol_t::address_t present_temperature = 146;
typedef uint8_t present_temperature_t;
};
};

class Xh430V210 : public Servo<Xh430V210> {
public:
typedef Xh430V210 Model;

Xh430V210(typename protocol_t::id_t id) : Servo<Xh430V210>(id){};

MODEL_NAME(Xh430V210);

// Here we add the fields that are not common to all dynamixels
READ_FIELD(model_info);
READ_WRITE_FIELD(drive_mode);
READ_WRITE_FIELD(operating_mode);
READ_WRITE_FIELD(secondary_id);
READ_WRITE_FIELD(protocol_version);
READ_WRITE_FIELD(homing_offset);
READ_WRITE_FIELD(moving_threshold);
READ_WRITE_FIELD(pwm_limit);
READ_WRITE_FIELD(current_limit);
READ_WRITE_FIELD(acceleration_limit);
READ_WRITE_FIELD(speed_limit);
READ_WRITE_FIELD(max_position_limit);
READ_WRITE_FIELD(min_position_limit);
READ_WRITE_FIELD(led);
READ_FIELD(registered);
READ_FIELD(hardware_error_status);
READ_WRITE_FIELD(velocity_i_gain);
READ_WRITE_FIELD(velocity_p_gain);
READ_WRITE_FIELD(position_d_gain);
READ_WRITE_FIELD(position_i_gain);
READ_WRITE_FIELD(position_p_gain);
READ_WRITE_FIELD(feedforward_2nd_gain);
READ_WRITE_FIELD(feedforward_1st_gain);
READ_WRITE_FIELD(bus_watchdog);
READ_WRITE_FIELD(goal_pwm);
READ_WRITE_FIELD(goal_current);
READ_WRITE_FIELD(profile_acceleration);
READ_WRITE_FIELD(profile_speed);
READ_FIELD(realtime_tick);
READ_FIELD(moving_status);
READ_FIELD(present_pwm);
// READ_FIELD(current);
READ_FIELD(speed_trajectory);
READ_FIELD(position_trajectory);
};
}
}

#endif
Loading