Skip to content

Commit

Permalink
Update README to reflect latest changes. (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
aentinger authored Dec 13, 2022
1 parent ab42904 commit a23f623
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ sudo useradd $USER dialout
```C++
#include <cstdlib>
#include <iostream>
#include <dynamixel++/Dynamixel++.h>
#include <dynamixel++/dynamixel++.h>

using namespace dynamixelplusplus;

static uint16_t const MX28_ControlTable_Torque_Enable = 64;
static uint16_t const MX28_ControlTable_GoalPosition = 116;
static uint16_t const MX28_ControlTable_PresentPosition = 132;

int main(int argc, char **argv)
int main(int argc, char **argv) try
{
Dynamixel dynamixel_ctrl("/dev/serial/by-id/usb-FTDI_USB__-__Serial_Converter_FT4NNZ55-if00-port0",
Dynamixel::Protocol::V2_0,
Expand All @@ -52,16 +52,21 @@ int main(int argc, char **argv)
dynamixel_ctrl.syncWrite(MX28_ControlTable_Torque_Enable, goal_position_data_map);

/* Read current position. */
std::map<Dynamixel::Id, uint32_t> position_map;
auto err_read = dynamixel_ctrl.syncRead(MX28_ControlTable_PresentPosition, id_vect, position_map);
if (err_read != Dynamixel::Error::None) {
std::cerr << "'syncRead' failed with error code " << static_cast<int>(err_read) << std::endl;
return EXIT_FAILURE;
}

std::map<Dynamixel::Id, uint32_t> const position_map = dynamixel_ctrl.syncRead<uint32_t>(MX28_ControlTable_PresentPosition, id_vect);

for (auto [id, position_raw] : position_map)
std::cout << "Dynamixel MX28 servo #" << static_cast<int>(id) << ": " << position_raw << std::endl;

return EXIT_SUCCESS;
}
catch (dynamixelplusplus::CommunicationError const & e)
{
std::cerr << "CommunicationError caught: " << e.what() << std::endl;
return EXIT_FAILURE;
}
catch (dynamixelplusplus::StatusError const & e)
{
std::cerr << "StatusError caught: " << e.what() << std::endl;
return EXIT_FAILURE;
}
```

0 comments on commit a23f623

Please sign in to comment.