WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
MechanismLigament2d.hpp
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <memory>
8#include <string_view>
9
13#include "wpi/units/angle.hpp"
15
16namespace wpi {
17
18/**
19 * Ligament node on a Mechanism2d.
20 *
21 * A ligament can have its length changed (like an elevator) or angle changed,
22 * like an arm.
23 *
24 * @see Mechanism2d
25 */
27 public:
28 MechanismLigament2d(std::string_view name, double length,
29 wpi::units::degree_t angle, double lineWidth = 6,
30 const wpi::util::Color8Bit& color = {235, 137, 52});
31
32 /**
33 * Set the ligament color.
34 *
35 * @param color the color of the line
36 */
38
39 /**
40 * Get the ligament color.
41 *
42 * @return the color of the line
43 */
45
46 /**
47 * Set the ligament's length.
48 *
49 * @param length the line length
50 */
51 void SetLength(double length);
52
53 /**
54 * Get the ligament length.
55 *
56 * @return the line length
57 */
58 double GetLength();
59
60 /**
61 * Set the ligament's angle relative to its parent.
62 *
63 * @param angle the angle
64 */
65 void SetAngle(wpi::units::degree_t angle);
66
67 /**
68 * Get the ligament's angle relative to its parent.
69 *
70 * @return the angle
71 */
72 double GetAngle();
73
74 /**
75 * Set the line thickness.
76 *
77 * @param lineWidth the line thickness
78 */
79 void SetLineWeight(double lineWidth);
80
81 /**
82 * Get the line thickness.
83 *
84 * @return the line thickness
85 */
86 double GetLineWeight();
87
88 protected:
89 void UpdateEntries(std::shared_ptr<wpi::nt::NetworkTable> table) override;
90
91 private:
93 double m_length;
94 wpi::nt::DoubleEntry m_lengthEntry;
95 double m_angle;
96 wpi::nt::DoubleEntry m_angleEntry;
97 double m_weight;
98 wpi::nt::DoubleEntry m_weightEntry;
99 char m_color[10];
100 wpi::nt::StringEntry m_colorEntry;
101};
102} // namespace wpi
@ name
Definition base.h:690
double GetLength()
Get the ligament length.
wpi::util::Color8Bit GetColor()
Get the ligament color.
void SetAngle(wpi::units::degree_t angle)
Set the ligament's angle relative to its parent.
void UpdateEntries(std::shared_ptr< wpi::nt::NetworkTable > table) override
Update all entries with new ones from a new table.
void SetColor(const wpi::util::Color8Bit &color)
Set the ligament color.
void SetLength(double length)
Set the ligament's length.
MechanismLigament2d(std::string_view name, double length, wpi::units::degree_t angle, double lineWidth=6, const wpi::util::Color8Bit &color={235, 137, 52})
double GetLineWeight()
Get the line thickness.
double GetAngle()
Get the ligament's angle relative to its parent.
void SetLineWeight(double lineWidth)
Set the line thickness.
MechanismObject2d(std::string_view name)
NetworkTables Double entry.
Definition DoubleTopic.hpp:180
NetworkTables String entry.
Definition StringTopic.hpp:240
NetworkTables String publisher.
Definition StringTopic.hpp:184
Represents colors that can be used with Addressable LEDs.
Definition Color8Bit.hpp:23
color
Definition color.h:16
Definition CvSource.hpp:15