10 namespace moteus = vulp::actuation::moteus;
12 using palimpsest::Dictionary;
17 const std::map<int, std::string>& servo_joint_map,
18 const std::vector<moteus::ServoReply>& servo_replies) {
19 for (
const auto& reply : servo_replies) {
20 const int servo_id = reply.id;
21 auto it = servo_joint_map.find(servo_id);
22 if (it == servo_joint_map.end()) {
23 spdlog::error(
"Unknown servo ID {} in CAN reply", servo_id);
26 const auto& joint = it->second;
31 double position_rev = reply.result.position;
32 double velocity_rev_s = reply.result.velocity;
33 double position_rad = (2.0 * M_PI) * position_rev;
34 double velocity_rad_s = (2.0 * M_PI) * velocity_rev_s;
36 auto& servo = observation(
"servo")(joint);
37 servo(
"d_current") = reply.result.d_current;
38 servo(
"fault") = reply.result.fault;
39 servo(
"mode") =
static_cast<unsigned>(reply.result.mode);
40 servo(
"position") = position_rad;
41 servo(
"q_current") = reply.result.q_current;
42 servo(
"temperature") = reply.result.temperature;
43 servo(
"torque") = reply.result.torque;
44 servo(
"velocity") = velocity_rad_s;
45 servo(
"voltage") = reply.result.voltage;
void observe_servos(Dictionary &observation, const std::map< int, std::string > &servo_joint_map, const std::vector< moteus::ServoReply > &servo_replies)